2018-07-10 03:35:04

by Daniel Rosenberg

[permalink] [raw]
Subject: [PATCH] f2fs: Keep alloc_valid_block_count in sync

If we attempt to request more blocks than we have room for, we try to
instead request as much as we can, however, alloc_valid_block_count
is not decremented to match the new value, allowing it to drift higher
until the next checkpoint. This always decrements it when the requested
amount cannot be fulfilled.

Signed-off-by: Daniel Rosenberg <[email protected]>
---
fs/f2fs/f2fs.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 4d8b1de83143..5af955a8736e 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1680,18 +1680,20 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,
sbi->total_valid_block_count -= diff;
if (!*count) {
spin_unlock(&sbi->stat_lock);
- percpu_counter_sub(&sbi->alloc_valid_block_count, diff);
goto enospc;
}
}
spin_unlock(&sbi->stat_lock);

- if (unlikely(release))
+ if (unlikely(release)) {
+ percpu_counter_sub(&sbi->alloc_valid_block_count, release);
dquot_release_reservation_block(inode, release);
+ }
f2fs_i_blocks_write(inode, *count, true, true);
return 0;

enospc:
+ percpu_counter_sub(&sbi->alloc_valid_block_count, release);
dquot_release_reservation_block(inode, release);
return -ENOSPC;
}
--
2.18.0.203.gfac676dfb9-goog



2018-07-10 06:20:24

by Chao Yu

[permalink] [raw]
Subject: Re: [PATCH] f2fs: Keep alloc_valid_block_count in sync

On 2018/7/10 11:32, Daniel Rosenberg wrote:
> If we attempt to request more blocks than we have room for, we try to
> instead request as much as we can, however, alloc_valid_block_count
> is not decremented to match the new value, allowing it to drift higher
> until the next checkpoint. This always decrements it when the requested
> amount cannot be fulfilled.
>
> Signed-off-by: Daniel Rosenberg <[email protected]>

Good catch, thanks for the fixing. :)

Reviewed-by: Chao Yu <[email protected]>

Thanks,