Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

f2fs: fix to use per-inode maxbytes and cleanup

This is a supplement to commit 6d1451bf7f84 ("f2fs: fix to use per-inode maxbytes")
for some missed cases, also cleanup redundant code in f2fs_llseek.

Cc: Chengguang Xu <cgxu519@mykernel.net>
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

authored by

Zhiguo Niu and committed by
Jaegeuk Kim
d33ebd57 f97a11c8

+7 -9
+2 -2
fs/f2fs/data.c
··· 1938 1938 1939 1939 inode_lock_shared(inode); 1940 1940 1941 - maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS; 1941 + maxbytes = F2FS_BLK_TO_BYTES(max_file_blocks(inode)); 1942 1942 if (start > maxbytes) { 1943 1943 ret = -EFBIG; 1944 1944 goto out; ··· 2063 2063 static inline loff_t f2fs_readpage_limit(struct inode *inode) 2064 2064 { 2065 2065 if (IS_ENABLED(CONFIG_FS_VERITY) && IS_VERITY(inode)) 2066 - return inode->i_sb->s_maxbytes; 2066 + return F2FS_BLK_TO_BYTES(max_file_blocks(inode)); 2067 2067 2068 2068 return i_size_read(inode); 2069 2069 }
+2 -5
fs/f2fs/file.c
··· 432 432 static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence) 433 433 { 434 434 struct inode *inode = file->f_mapping->host; 435 - loff_t maxbytes = inode->i_sb->s_maxbytes; 435 + loff_t maxbytes = F2FS_BLK_TO_BYTES(max_file_blocks(inode)); 436 436 struct dnode_of_data dn; 437 437 pgoff_t pgofs, end_offset; 438 438 loff_t data_ofs = offset; ··· 514 514 static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence) 515 515 { 516 516 struct inode *inode = file->f_mapping->host; 517 - loff_t maxbytes = inode->i_sb->s_maxbytes; 518 - 519 - if (f2fs_compressed_file(inode)) 520 - maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS; 517 + loff_t maxbytes = F2FS_BLK_TO_BYTES(max_file_blocks(inode)); 521 518 522 519 switch (whence) { 523 520 case SEEK_SET:
+3 -2
fs/f2fs/verity.c
··· 74 74 struct address_space *mapping = inode->i_mapping; 75 75 const struct address_space_operations *aops = mapping->a_ops; 76 76 77 - if (pos + count > inode->i_sb->s_maxbytes) 77 + if (pos + count > F2FS_BLK_TO_BYTES(max_file_blocks(inode))) 78 78 return -EFBIG; 79 79 80 80 while (count) { ··· 237 237 pos = le64_to_cpu(dloc.pos); 238 238 239 239 /* Get the descriptor */ 240 - if (pos + size < pos || pos + size > inode->i_sb->s_maxbytes || 240 + if (pos + size < pos || 241 + pos + size > F2FS_BLK_TO_BYTES(max_file_blocks(inode)) || 241 242 pos < f2fs_verity_metadata_pos(inode) || size > INT_MAX) { 242 243 f2fs_warn(F2FS_I_SB(inode), "invalid verity xattr"); 243 244 f2fs_handle_error(F2FS_I_SB(inode),