Bug 1665990 - df reports negative IUsed value for prjquota set directories.
Summary: df reports negative IUsed value for prjquota set directories.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: kernel
Version: 7.6
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Bill O'Donnell
QA Contact: Zorro Lang
URL:
Whiteboard:
Depends On: 1665968
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-01-14 15:53 UTC by Achilles Gaikwad
Modified: 2019-08-06 12:25 UTC (History)
3 users (show)

Fixed In Version: kernel-3.10.0-1015.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1665968
Environment:
Last Closed: 2019-08-06 12:25:30 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 4009611 None None None 2019-06-29 11:44:46 UTC
Red Hat Product Errata RHSA-2019:2029 None None None 2019-08-06 12:25:50 UTC

Description Achilles Gaikwad 2019-01-14 15:53:48 UTC
+++ This bug was initially created as a clone of Bug #1665968 +++

Description of problem:

df will report negative IUsed for a directory which has project quotas enabled.

df for the prjquota dir:
Filesystem     Inodes   IUsed  IFree IUse% Mounted on
/dev/loop7         53 -524229 524282     - /mnt

Version-Release number of selected component (if applicable):
4.18.0-32.el8.x86_64

How reproducible:
Always

Steps to Reproduce:

1. Create a repro.sh file with following contents and make it executable. 

#!/bin/bash
truncate -s1G foo.img 
mkfs.xfs -K -f foo.img > /dev/null 
mount foo.img /mnt/ -o prjquota 
mkdir -p /mnt/test 
xfs_quota -x -c 'project -s -p /mnt/test 42' /mnt
echo df before setting up limits
echo df for mnt
df -i /mnt/
echo df for prjquota dir
df -i /mnt/test
xfs_quota -x -c 'limit -p isoft=53 test-bug' /mnt
echo inode soft limits set for /mnt/test
xfs_quota -x -c report /mnt
echo df after setup for mnt: 
     df -i /mnt
echo df for the prjquota dir: 
     df -i /mnt/test/

echo unmounting
umount /mnt/

2. Execute the script. DF will show negative value

Filesystem     Inodes   IUsed  IFree IUse% Mounted on
/dev/loop7         53 -524229 524282     - /mnt
unmounting

Actual results:

Filesystem     Inodes   IUsed  IFree IUse% Mounted on
/dev/loop7         53 -524229 524282     - /mnt

Expected results:

Filesystem     Inodes   IUsed  IFree IUse% Mounted on
/dev/loop7         53     0      53     - /mnt


Additional info:

This bug has been fixed in commit the following commit 

$ git show de7243057e7cefa923fa5f467c0f1ec24eef41d2
commit de7243057e7cefa923fa5f467c0f1ec24eef41d2
Author: Ye Yin <dbyin@tencent.com>
Date:   Fri Nov 23 09:55:18 2018 -0800

    fs/xfs: fix f_ffree value for statfs when project quota is set
    
    When project is set, we should use inode limit minus the used count
    
    Signed-off-by: Ye Yin <dbyin@tencent.com>
    Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

diff --git a/fs/xfs/xfs_qm_bhv.c b/fs/xfs/xfs_qm_bhv.c
index 73a1d77ec187..3091e4bc04ef 100644
--- a/fs/xfs/xfs_qm_bhv.c
+++ b/fs/xfs/xfs_qm_bhv.c
@@ -40,7 +40,7 @@ xfs_fill_statvfs_from_dquot(
                statp->f_files = limit;
                statp->f_ffree =
                        (statp->f_files > dqp->q_res_icount) ?
-                        (statp->f_ffree - dqp->q_res_icount) : 0;
+                        (statp->f_files - dqp->q_res_icount) : 0;
        }
 }
 

After applying the patch, I am not able to reproduce the issue.

Comment 5 Bruno Meneguele 2019-03-07 20:21:06 UTC
Patch(es) committed on kernel-3.10.0-1015.el7

Comment 10 errata-xmlrpc 2019-08-06 12:25:30 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2019:2029


Note You need to log in before you can comment on or make changes to this bug.