diff options
| author | Baokun Li <libaokun1@huawei.com> | 2025-11-21 17:06:32 +0800 |
|---|---|---|
| committer | Theodore Ts'o <tytso@mit.edu> | 2025-11-28 22:35:26 -0500 |
| commit | b73f45a32420a8393e92fb2dec3b7d109e565127 (patch) | |
| tree | 685e744341c739883a405311ce66b950acfc1fbb /fs/ext4/inode.c | |
| parent | 5835b1339e33549d9e7342fae56243b4fcd758c9 (diff) | |
ext4: remove page offset calculation in ext4_block_truncate_page()
For bs <= ps scenarios, calculating the offset within the block is
sufficient. For bs > ps, an initial page offset calculation can lead to
incorrect behavior. Thus this redundant calculation has been removed.
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Message-ID: <20251121090654.631996-3-libaokun@huaweicloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/inode.c')
| -rw-r--r-- | fs/ext4/inode.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 4afe227fd03f..d232154cc14d 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4193,7 +4193,6 @@ static int ext4_block_zero_page_range(handle_t *handle, static int ext4_block_truncate_page(handle_t *handle, struct address_space *mapping, loff_t from) { - unsigned offset = from & (PAGE_SIZE-1); unsigned length; unsigned blocksize; struct inode *inode = mapping->host; @@ -4202,8 +4201,8 @@ static int ext4_block_truncate_page(handle_t *handle, if (IS_ENCRYPTED(inode) && !fscrypt_has_encryption_key(inode)) return 0; - blocksize = inode->i_sb->s_blocksize; - length = blocksize - (offset & (blocksize - 1)); + blocksize = i_blocksize(inode); + length = blocksize - (from & (blocksize - 1)); return ext4_block_zero_page_range(handle, mapping, from, length); } |