forked from Minki/linux
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 <drosen@google.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
20ee438232
commit
36b877af79
@ -1686,18 +1686,20 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,
|
|||||||
sbi->total_valid_block_count -= diff;
|
sbi->total_valid_block_count -= diff;
|
||||||
if (!*count) {
|
if (!*count) {
|
||||||
spin_unlock(&sbi->stat_lock);
|
spin_unlock(&sbi->stat_lock);
|
||||||
percpu_counter_sub(&sbi->alloc_valid_block_count, diff);
|
|
||||||
goto enospc;
|
goto enospc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spin_unlock(&sbi->stat_lock);
|
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);
|
dquot_release_reservation_block(inode, release);
|
||||||
|
}
|
||||||
f2fs_i_blocks_write(inode, *count, true, true);
|
f2fs_i_blocks_write(inode, *count, true, true);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
enospc:
|
enospc:
|
||||||
|
percpu_counter_sub(&sbi->alloc_valid_block_count, release);
|
||||||
dquot_release_reservation_block(inode, release);
|
dquot_release_reservation_block(inode, release);
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user