Skip to content

Commit c2332d0

Browse files
author
CKI KWF Bot
committed
Merge: ext4: don't over-report free space or inodes in statvfs
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7601 Backport upstream fix for RHEL-125357 on CentOS 9.8. JIRA: https://issues.redhat.com/browse/RHEL-125357 Signed-off-by: Ravi Singh <ravising@redhat.com> Approved-by: Pavel Reichl <preichl@redhat.com> Approved-by: Carlos Maiolino <cmaiolino@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 4c90e46 + 579baf3 commit c2332d0

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)