Skip to content

Commit 579baf3

Browse files
author
Ravi Singh
committed
ext4: don't over-report free space or inodes in statvfs
JIRA: https://issues.redhat.com/browse/RHEL-125357 This fixes an analogus bug that was fixed in xfs in commit 4b8d867 ("xfs: don't over-report free space or inodes in statvfs") where statfs can report misleading / incorrect information where project quota is enabled, and the free space is less than the remaining quota. This commit will resolve a test failure in generic/762 which tests for this bug. Cc: stable@kernel.org Fixes: 689c958 ("ext4: add project quota support") Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> (cherry picked from commit f87d3af) Signed-off-by: Ravi Singh <ravising@redhat.com>
1 parent f07b929 commit 579baf3

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

fs/ext4/super.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6808,22 +6808,29 @@ static int ext4_statfs_project(struct super_block *sb,
68086808
dquot->dq_dqb.dqb_bhardlimit);
68096809
limit >>= sb->s_blocksize_bits;
68106810

6811-
if (limit && buf->f_blocks > limit) {
6811+
if (limit) {
6812+
uint64_t remaining = 0;
6813+
68126814
curblock = (dquot->dq_dqb.dqb_curspace +
68136815
dquot->dq_dqb.dqb_rsvspace) >> sb->s_blocksize_bits;
6814-
buf->f_blocks = limit;
6815-
buf->f_bfree = buf->f_bavail =
6816-
(buf->f_blocks > curblock) ?
6817-
(buf->f_blocks - curblock) : 0;
6816+
if (limit > curblock)
6817+
remaining = limit - curblock;
6818+
6819+
buf->f_blocks = min(buf->f_blocks, limit);
6820+
buf->f_bfree = min(buf->f_bfree, remaining);
6821+
buf->f_bavail = min(buf->f_bavail, remaining);
68186822
}
68196823

68206824
limit = min_not_zero(dquot->dq_dqb.dqb_isoftlimit,
68216825
dquot->dq_dqb.dqb_ihardlimit);
6822-
if (limit && buf->f_files > limit) {
6823-
buf->f_files = limit;
6824-
buf->f_ffree =
6825-
(buf->f_files > dquot->dq_dqb.dqb_curinodes) ?
6826-
(buf->f_files - dquot->dq_dqb.dqb_curinodes) : 0;
6826+
if (limit) {
6827+
uint64_t remaining = 0;
6828+
6829+
if (limit > dquot->dq_dqb.dqb_curinodes)
6830+
remaining = limit - dquot->dq_dqb.dqb_curinodes;
6831+
6832+
buf->f_files = min(buf->f_files, limit);
6833+
buf->f_ffree = min(buf->f_ffree, remaining);
68276834
}
68286835

68296836
spin_unlock(&dquot->dq_dqb_lock);

0 commit comments

Comments
 (0)