summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Rosenberg2019-05-30 02:49:04 +0200
committerJaegeuk Kim2019-06-03 22:27:47 +0200
commit9a9aecaad92d4fba0e2682ca6897d3a5aeabf123 (patch)
treec0a391203640e804b34f369aa3d653eecb5eef9d
parentf2fs: Lower threshold for disable_cp_again (diff)
downloadkernel-qcow2-linux-9a9aecaad92d4fba0e2682ca6897d3a5aeabf123.tar.gz
kernel-qcow2-linux-9a9aecaad92d4fba0e2682ca6897d3a5aeabf123.tar.xz
kernel-qcow2-linux-9a9aecaad92d4fba0e2682ca6897d3a5aeabf123.zip
f2fs: Fix root reserved on remount
On a remount, you can currently set root reserved if it was not previously set. This can cause an underflow if reserved has been set to a very high value, since then root reserved + current reserved could be greater than user_block_count. inc_valid_block_count later subtracts out these values from user_block_count, causing an underflow. Signed-off-by: Daniel Rosenberg <drosen@google.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/super.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 1dc02101e5e5..4b547024571f 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -213,7 +213,8 @@ void f2fs_msg(struct super_block *sb, const char *level, const char *fmt, ...)
static inline void limit_reserve_root(struct f2fs_sb_info *sbi)
{
- block_t limit = (sbi->user_block_count << 1) / 1000;
+ block_t limit = min((sbi->user_block_count << 1) / 1000,
+ sbi->user_block_count - sbi->reserved_blocks);
/* limit is 0.2% */
if (test_opt(sbi, RESERVE_ROOT) &&