f2fs: extend stat_lock to avoid potential race in statfs
authorNiels Dossche <dossche.niels@gmail.com>
Fri, 22 Apr 2022 18:05:04 +0000 (20:05 +0200)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 6 May 2022 17:18:11 +0000 (10:18 -0700)
commit4de851459ea65ac8cf4313af648ec9cf16b72562
tree4aaf71fd474dc807b387323f78ebf95e012cdbe8
parenta7b8618aa2f0f926ce85f2486ac835a85c753ca7
f2fs: extend stat_lock to avoid potential race in statfs

There are multiple calculations and reads of fields of sbi that should
be protected by stat_lock. As stat_lock is not used to read these
values in statfs, this can lead to inconsistent results.
Extend the locking to prevent this issue.
Commit c9c8ed50d94c ("f2fs: fix to avoid potential race on
sbi->unusable_block_count access/update")
already added the use of sbi->stat_lock in statfs in
order to make the calculation of multiple, different fields atomic so
that results are consistent. This is similar to that patch regarding the
change in statfs.

Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/super.c