RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1663502 - xfs_quota project check results in "project inheritance flag is not set" error
Summary: xfs_quota project check results in "project inheritance flag is not set" error
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: xfsprogs
Version: 7.7
Hardware: All
OS: Linux
unspecified
low
Target Milestone: rc
: ---
Assignee: Eric Sandeen
QA Contact: Zorro Lang
URL:
Whiteboard:
Depends On:
Blocks: 1664105
TreeView+ depends on / blocked
 
Reported: 2019-01-04 15:44 UTC by sgardner
Modified: 2019-08-06 13:06 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1664105 (view as bug list)
Environment:
Last Closed: 2019-08-06 13:06:18 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 1663502 0 None None None 2019-01-07 17:15:23 UTC
Red Hat Product Errata RHBA-2019:2216 0 None None None 2019-08-06 13:06:26 UTC

Description sgardner 2019-01-04 15:44:05 UTC
Description of problem:
When running xfs_quota project check command (xfs_quota -xc 'project -c <projid>' <projectDIR>. All files within quota directory will result in "project inheritance flag is not set" error in the output.



Version-Release number of selected component (if applicable):
Does not exist in RHEL7.0-z (3.10.0-123.20.1)
First noticed in RHEL7.1-ga (3.10.0-229)
 


How reproducible:
EASILY



Steps to Reproduce:
1. Make xfs filesystem.
    # mkfs.xfs /dev/vdb

2. Mount
    # mount -o pquota /dev/vdb /mnt

3. Verify project quota is enabled on mount
    # mount | grep vdb
      /dev/vdb on /mnt/test2 type xfs (rw,relatime,seclabel,attr2,inode64,prjquota)

4. Create/Edit /etc/projects to contain the project map.
    # cat /etc/projects
      1:/mnt/p1

5. Create/Edit /etc/projid to contain the Project ID.
    # cat /etc/projid
    p1:1
6. Make the project directory
    # mkdir /mnt/p1

7. Setup the project quota
    # xfs_quota -xc 'project -s p1' /mnt
      Setting up project p1 (path /mnt/p1)...
      Processed 1 (/etc/projects and cmdline) paths for project p1 with recursion depth infinite (-1).

8. Set limits on the project.
    # xfs_quota -xc 'limit -p bsoft=1m bhard=2m p1' /mnt

9. Touch a random file in the project quota dir.
    # touch /mnt/p1/testfile

10. Check the project
    # xfs_quota -xc 'project -c p1' /mnt
      Checking project p1 (path /mnt/p1)...
      /mnt/p1/testfile - project inheritance flag is not set
      Processed 1 (/etc/projects and cmdline) paths for project p1 with recursion depth infinite (-1).

11. Verify that the quota is working.. Quota is working OK.
    # dd if=/dev/urandom of=/mnt/p1/testdd bs=1M
      dd: error writing ‘/mnt/test2/p2_multi1/testdd’: No space left on device
      3+0 records in
      2+0 records out
      2097152 bytes (2.1 MB) copied, 0.0311358 s, 67.4 MB/s

NOTE- New directories do not result in this error.  ALL new files will result in this error.



Actual results:
/mnt/p1/testfile - project inheritance flag is not set



Expected results:
No "project inheritance flag is not set" error for any files.



Additional info:
I discovered that the change in behavior is in the kernel when new files are created within a quota directory.  (haven't found the commit that changed the behavior)  It does not matter which kernel you are booted into when running the quota setup or check.  It only matters which kernel you are booted into when creating a new file.  This means that the change is related to files inheriting the "FS_XFLAG_PROJINHERIT" xflag.

*** But I believe that the files should never inherit this xflag.  This should ONLY be inherited by directories.

Define "FS_XFLAG_PROJINHERIT" - child created in this directory has parents project ID by default.

Because of this, I don't think the change in the kernel behavior is actually the issue, this just exposed the actual bug which is in the xfs_quota check command itself.  It's checking both files and directories for xflag "FS_XFLAG_PROJINHERIT"


Here is the code section that creates this error. (project.c in the xfsprogs) 
------------------------------------------------------------------------------------------------------------------
     94 check_project(
     95 	const char		*path,
     96 	const struct stat	*stat,
     97 	int			flag,
     98 	struct FTW		*data)
     99 {
    100 	struct fsxattr		fsx;
    101 	int			fd;
<snip>
    125 		if (fsx.fsx_projid != prid)
    126 			printf(_("%s - project identifier is not set"
    127 				 " (inode=%u, tree=%u)\n"),
    128 				path, fsx.fsx_projid, (unsigned int)prid);
    129 		if (!(fsx.fsx_xflags & FS_XFLAG_PROJINHERIT))
    130 			printf(_("%s - project inheritance flag is not set\n"),
    131 				path);
------------------------------------------------------------------------------------------------------------------

There is no logic in the code to ignore files in the 'FS_XFLAG_PROJINHERIT" section.

Comment 2 Eric Sandeen 2019-01-04 16:04:17 UTC
This behavior was probably changed in the kernel by:

commit 9336e3a765b68d4a7fdd8256f393ebce95ecb0a7
Author: Dave Chinner <dchinner>
Date:   Thu Oct 2 09:18:40 2014 +1000

    xfs: project id inheritance is a directory only flag
    
    xfs_set_diflags() allows it to be set on non-directory inodes, and
    this flags errors in xfs_repair. Further, inode allocation allows
    the same directory-only flag to be inherited to non-directories.
    Make sure directory inode flags don't appear on other types of
    inodes.
    
    This fixes several xfstests scratch fileystem corruption reports
    (e.g. xfs/050) now that xfstests checks scratch filesystems after
    test completion.
    
    Signed-off-by: Dave Chinner <dchinner>
    Reviewed-by: Brian Foster <bfoster>
    Signed-off-by: Dave Chinner <david>


which is present in v3.18 upstream, and was added to kernel-3.10.0-194.el7 in RHEL7.

Can you confirm which kernel you tested that did not lead to the problem?

I agree that this is inconsistent and that the check should not (no longer) be made in userspace for regular files.

Comment 3 sgardner 2019-01-04 16:22:29 UTC
> 
> Can you confirm which kernel you tested that did not lead to the problem?
> 

- Files created in RHEL7.0-z (3.10.0-123.20.1) and below, do NOT result in this behavior.

- Files created in RHEL7.1-ga (3.10.0-229)and higher, DO result in this behavior.


That definitely looks like the commit that caused the change.

Comment 4 Eric Sandeen 2019-01-04 16:26:20 UTC
Ok, I think we should mark this as a regression then, even though it wasn't exactly xfsprogs that regressed, the overall behavior did.

Comment 6 Murphy Zhou 2019-01-05 01:52:54 UTC
Ack as it's a regression issue.

Comment 7 Achilles Gaikwad 2019-01-05 10:31:29 UTC
proposed a patch here, sent to upstream 

https://marc.info/?l=linux-xfs&m=154668397419031&w=2

TL;DR: Just added a check to see if the file is REG or DIR. 

Snip : 

---
 quota/project.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/quota/project.c b/quota/project.c
index e4e7a012..8c9be08b 100644
--- a/quota/project.c
+++ b/quota/project.c
@@ -99,6 +99,7 @@ check_project(
 {
        struct fsxattr          fsx;
        int                     fd;
+       int                     isdir;

        if (recurse_depth >= 0 && data->level > recurse_depth)
                return -1;
@@ -126,7 +127,8 @@ check_project(
                        printf(_("%s - project identifier is not set"
                                 " (inode=%u, tree=%u)\n"),
                                path, fsx.fsx_projid, (unsigned int)prid);
-               if (!(fsx.fsx_xflags & FS_XFLAG_PROJINHERIT))
+               isdir = S_ISDIR(stat->st_mode);
+               if (!(fsx.fsx_xflags & FS_XFLAG_PROJINHERIT) && isdir)
                        printf(_("%s - project inheritance flag is not set\n"),
                                path);
        }
-- 
2.20.1

Comment 8 Eric Sandeen 2019-02-05 16:57:59 UTC
Upstream:

commit b136f48b19a5b8e788aceb4b80e97d6ae9edd0ea
Author: Achilles Gaikwad <agaikwad>
Date:   Mon Jan 28 13:03:08 2019 -0600

    xfs_quota: fix false error reporting of project inheritance flag is not set
    
    After kernel commit:
    
    9336e3a7 "xfs: project id inheritance is a directory only flag"
    
    xfs stopped setting the project inheritance flag on regular files, but
    userspace quota code still checks for it and will now issue the error:
    
    "project inheritance flag is not set"
    
    for every regular file during quotacheck.  Fix this by only checking
    for the flag on directories.
    
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1663502
    Reported-by: Steven Gardner <sgardner>
    Signed-off-by: Achilles Gaikwad <agaikwad>
    Reviewed-by: Darrick J. Wong <darrick.wong>
    Signed-off-by: Eric Sandeen <sandeen>

Comment 9 Eric Sandeen 2019-02-11 20:34:24 UTC
built in xfsprogs-4.5.0-20.el7

Comment 11 Zorro Lang 2019-06-19 10:18:59 UTC
Reproduced this bug on xfsprogs-4.5.0-19.el7:
# ./check xfs/507
FSTYP         -- xfs (non-debug)
PLATFORM      -- Linux/x86_64 ibm-x3550m3-05 3.10.0-1053.el7.x86_64
MKFS_OPTIONS  -- -f -bsize=4096 /dev/sdb2
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdb2 /mnt/scratch

xfs/507 2s ... - output mismatch (see /root/git/xfstests-zlang/results//xfs/507.out.bad)
    --- tests/xfs/507.out       2019-06-19 05:38:42.821559996 -0400
    +++ /root/git/xfstests-zlang/results//xfs/507.out.bad       2019-06-19 06:16:30.416770093 -0400
    @@ -1,6 +1,8 @@
     QA output created by 507
     == The parent directory has Project inheritance bit by default ==
     Checking project test (path [SCR_MNT]/dir)...
    +[SCR_MNT]/dir/foo - project inheritance flag is not set
    +[SCR_MNT]/dir/dir_inherit/foo - project inheritance flag is not set
     Processed 1 ([PROJECTS_FILE] and cmdline) paths for project test with recursion depth infinite (-1).
     
    ...
    (Run 'diff -u /root/git/xfstests-zlang/tests/xfs/507.out /root/git/xfstests-zlang/results//xfs/507.out.bad'  to see the entire diff)
Ran: xfs/507
Failures: xfs/507
Failed 1 of 1 tests

Test passed on xfsprogs-4.5.0-20.el7
# ./check xfs/507                                                                                                                                         
FSTYP         -- xfs (non-debug)
PLATFORM      -- Linux/x86_64 ibm-x3550m3-05 3.10.0-1053.el7.x86_64
MKFS_OPTIONS  -- -f -bsize=4096 /dev/sdb2
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdb2 /mnt/scratch

xfs/507 2s ...  2s
Ran: xfs/507
Passed all 1 tests

Note: the test case is still reviewing on upstream fstests@, it hasn't been merged.

Comment 13 errata-xmlrpc 2019-08-06 13:06:18 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/RHBA-2019:2216


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