mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hungyu Lin <dennylin0707@gmail.com>
To: tytso@mit.edu
Cc: Andreas Dilger <adilger.kernel@dilger.ca>,
	Baokun Li <libaokun@linux.alibaba.com>, Jan Kara <jack@suse.cz>,
	Ojaswin Mujoo <ojaswin@linux.ibm.com>,
	Ritesh Harjani <ritesh.list@gmail.com>,
	Zhang Yi <yi.zhang@huawei.com>,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
	Hungyu Lin <dennylin0707@gmail.com>
Subject: [PATCH] ext4: report sub-block project quotas in statfs
Date: Sun,  1 Nov 2026 12:58:47 +0000	[thread overview]
Message-ID: <20261101125847.54531-1-dennylin0707@gmail.com> (raw)

ext4_statfs_project() converts the selected space limit from bytes to
filesystem blocks before checking whether it is nonzero. A nonzero quota
smaller than one block therefore skips the project space adjustments.

For example, a valid 1 KiB hard limit on a 4 KiB-block filesystem leaves
statvfs() and df reporting the underlying filesystem's space, even when
unprivileged data allocation fails with EDQUOT.

Test the byte limit before converting it to filesystem blocks. The
resulting zero block limit then clamps the project space statistics to
zero. Keep the existing rounding and the rule that a zero byte limit
means no quota.

Fixes: 689c958cbe6b ("ext4: add project quota support")
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
 fs/ext4/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 9cae52471dee..91c1a54730f6 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -7001,11 +7001,11 @@ static int ext4_statfs_project(struct super_block *sb,
 
 	limit = min_not_zero(dquot->dq_dqb.dqb_bsoftlimit,
 			     dquot->dq_dqb.dqb_bhardlimit);
-	limit >>= sb->s_blocksize_bits;
 
 	if (limit) {
 		uint64_t	remaining = 0;
 
+		limit >>= sb->s_blocksize_bits;
 		curblock = (dquot->dq_dqb.dqb_curspace +
 			    dquot->dq_dqb.dqb_rsvspace) >> sb->s_blocksize_bits;
 		if (limit > curblock)
-- 
2.43.0


                 reply	other threads:[~2026-11-01 12:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261101125847.54531-1-dennylin0707@gmail.com \
    --to=dennylin0707@gmail.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=jack@suse.cz \
    --cc=libaokun@linux.alibaba.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    --cc=tytso@mit.edu \
    --cc=yi.zhang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®