Skip to content

Commit 85f5ab7

Browse files
author
CKI Backport Bot
committed
ext4: don't over-report free space or inodes in statvfs
JIRA: https://issues.redhat.com/browse/RHEL-89589 commit f87d3af Author: Theodore Ts'o <tytso@mit.edu> Date: Fri Mar 14 00:38:42 2025 -0400 ext4: don't over-report free space or inodes in statvfs 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> Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com>
1 parent 1a90383 commit 85f5ab7

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
@@ -6780,22 +6780,29 @@ static int ext4_statfs_project(struct super_block *sb,
67806780
dquot->dq_dqb.dqb_bhardlimit);
67816781
limit >>= sb->s_blocksize_bits;
67826782

6783-
if (limit && buf->f_blocks > limit) {
6783+
if (limit) {
6784+
uint64_t remaining = 0;
6785+
67846786
curblock = (dquot->dq_dqb.dqb_curspace +
67856787
dquot->dq_dqb.dqb_rsvspace) >> sb->s_blocksize_bits;
6786-
buf->f_blocks = limit;
6787-
buf->f_bfree = buf->f_bavail =
6788-
(buf->f_blocks > curblock) ?
6789-
(buf->f_blocks - curblock) : 0;
6788+
if (limit > curblock)
6789+
remaining = limit - curblock;
6790+
6791+
buf->f_blocks = min(buf->f_blocks, limit);
6792+
buf->f_bfree = min(buf->f_bfree, remaining);
6793+
buf->f_bavail = min(buf->f_bavail, remaining);
67906794
}
67916795

67926796
limit = min_not_zero(dquot->dq_dqb.dqb_isoftlimit,
67936797
dquot->dq_dqb.dqb_ihardlimit);
6794-
if (limit && buf->f_files > limit) {
6795-
buf->f_files = limit;
6796-
buf->f_ffree =
6797-
(buf->f_files > dquot->dq_dqb.dqb_curinodes) ?
6798-
(buf->f_files - dquot->dq_dqb.dqb_curinodes) : 0;
6798+
if (limit) {
6799+
uint64_t remaining = 0;
6800+
6801+
if (limit > dquot->dq_dqb.dqb_curinodes)
6802+
remaining = limit - dquot->dq_dqb.dqb_curinodes;
6803+
6804+
buf->f_files = min(buf->f_files, limit);
6805+
buf->f_ffree = min(buf->f_ffree, remaining);
67996806
}
68006807

68016808
spin_unlock(&dquot->dq_dqb_lock);

0 commit comments

Comments
 (0)