summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/super.c
diff options
context:
space:
mode:
authorChengguang Xu <cgxu519@mykernel.net>2021-01-13 13:21:54 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2021-01-27 15:20:06 -0800
commit6d1451bf7f84ea45035553ae566b3c91661d902b (patch)
treefba90e899514861853587a3d5d3d25ff41cc0a2e /fs/f2fs/super.c
parent3afae09ffea5e08f523823be99a784675995d6bb (diff)
downloadlinux-6d1451bf7f84ea45035553ae566b3c91661d902b.tar.bz2
f2fs: fix to use per-inode maxbytes
F2FS inode may have different max size, e.g. compressed file have less blkaddr entries in all its direct-node blocks, result in being with less max filesize. So change to use per-inode maxbytes. Suggested-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Chengguang Xu <cgxu519@mykernel.net> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/super.c')
-rw-r--r--fs/f2fs/super.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index c8be27a9eed6..9749c9ad374f 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2739,10 +2739,10 @@ static const struct export_operations f2fs_export_ops = {
.get_parent = f2fs_get_parent,
};
-static loff_t max_file_blocks(void)
+loff_t max_file_blocks(struct inode *inode)
{
loff_t result = 0;
- loff_t leaf_count = DEF_ADDRS_PER_BLOCK;
+ loff_t leaf_count;
/*
* note: previously, result is equal to (DEF_ADDRS_PER_INODE -
@@ -2751,6 +2751,11 @@ static loff_t max_file_blocks(void)
* result as zero.
*/
+ if (inode && f2fs_compressed_file(inode))
+ leaf_count = ADDRS_PER_BLOCK(inode);
+ else
+ leaf_count = DEF_ADDRS_PER_BLOCK;
+
/* two direct node blocks */
result += (leaf_count * 2);
@@ -3634,8 +3639,7 @@ try_onemore:
if (err)
goto free_options;
- sbi->max_file_blocks = max_file_blocks();
- sb->s_maxbytes = sbi->max_file_blocks <<
+ sb->s_maxbytes = max_file_blocks(NULL) <<
le32_to_cpu(raw_super->log_blocksize);
sb->s_max_links = F2FS_LINK_MAX;