Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d38f8be1 authored by Daniel Rosenberg's avatar Daniel Rosenberg Committed by Jaegeuk Kim
Browse files

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: default avatarDaniel Rosenberg <drosen@google.com>
Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 3ac4020f
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -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)
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% */
	/* limit is 0.2% */
	if (test_opt(sbi, RESERVE_ROOT) &&
	if (test_opt(sbi, RESERVE_ROOT) &&