[PATCH] Ext4: df: fix df to report reserved bytes in quota

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Without quota, df takes both on-disk allocated blocks and dirty reserved
blocks as used, while with quota, df only takes on-disk allocated blocks
by reading quota's information.

To avoid confusing users, this fixes df to read quota's reservd bytes
also.

Signed-off-by: Qixuan Wu <qixuan.wu@xxxxxxxxxxxxxxxxx>
Signed-off-by: Liu Bo <bo.liu@xxxxxxxxxxxxxxxxx>
---
 fs/ext4/super.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index eb104e8476f0..a49d3709c928 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5240,7 +5240,7 @@ static int ext4_statfs_project(struct super_block *sb,
 	struct kqid qid;
 	struct dquot *dquot;
 	u64 limit;
-	u64 curblock;
+	u64 curblock, rsvblock;
 
 	qid = make_kqid_projid(projid);
 	dquot = dqget(sb, qid);
@@ -5253,10 +5253,11 @@ static int ext4_statfs_project(struct super_block *sb,
 		 dquot->dq_dqb.dqb_bhardlimit) >> sb->s_blocksize_bits;
 	if (limit && buf->f_blocks > limit) {
 		curblock = dquot->dq_dqb.dqb_curspace >> sb->s_blocksize_bits;
+		rsvblock = dquot->dq_dqb.dqb_rsvspace >> sb->s_blocksize_bits;
 		buf->f_blocks = limit;
 		buf->f_bfree = buf->f_bavail =
-			(buf->f_blocks > curblock) ?
-			 (buf->f_blocks - curblock) : 0;
+			(buf->f_blocks > (curblock + rsvblock)) ?
+			 (buf->f_blocks - (curblock + rsvblock)) : 0;
 	}
 
 	limit = dquot->dq_dqb.dqb_isoftlimit ?
-- 
1.8.3.1




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux