Skip to contentSkip to conversation

ext4: report sub-block project quotas in statfs

PATCH In review Hungyu Lin 3 participants 3 messages Nov 1 – Nov 2 ext4 file system

lore
Share & tools
lore

Hungyu Lin

author
#0 lore raw

PATCH 1/1 ext4: report sub-block project quotas in statfs

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")
---
 fs/ext4/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/super.c +1 -1
index 9cae52471dee..91c1a54730f6 100644
@@ -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)
Signature · 1 line
2.43.0
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines

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.

Quoted 7 lines

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")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Hungyu Lin
Quoted 8 lines · Hungyu Lin

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.

Quoted 7 lines

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")

Looks good. Feel free to add:

Honza

Quoted 24 lines
---
 fs/ext4/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/super.c +1 -1
index 9cae52471dee..91c1a54730f6 100644
@@ -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)
Signature · 1 line
2.43.0
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR