Bug 1304258

Summary: quotaon -p prints quota off state for an XFS mount point mount with usrquota,grpquota mount options
Product: Red Hat Enterprise Linux 6 Reporter: Zorro Lang <zlang>
Component: quotaAssignee: Petr Pisar <ppisar>
Status: CLOSED WONTFIX QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: low    
Version: 6.10CC: eguan, jorton, xzhou, zlang
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-06 10:39:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1494503    
Attachments:
Description Flags
FIx ported to 3.17, first part
none
Fix ported to 3.17, second part none

Description Zorro Lang 2016-02-03 08:07:56 UTC
Description of problem:
I find this bug when I ran xfstests generic/082 on XFS. generic/082 failed as:
  group quota on SCRATCH_MNT (SCRATCH_DEV) is off
  user quota on SCRATCH_MNT (SCRATCH_DEV) is off

But the SCRATCH_MNT is mount with usrquota,grpquota.

For skip some useless steps in generic/082, I just run:
1. mkfs.xfs /dev/sda2

2. mount /dev/sda2 /mnt/xfstests/mnt1 -o usrquota,grpquota

3. mount -l|grep /dev/sda2
/dev/sda2 on /mnt/xfstests/mnt1 type xfs (rw,usrquota,grpquota)

4. cat /proc/mounts|grep /dev/sda2
/dev/sda2 /mnt/xfstests/mnt1 xfs rw,seclabel,relatime,attr2,delaylog,usrquota,grpquota 0 0

5. quotacheck -ug /mnt/xfstests/mnt1
quotacheck: Cannot find filesystem to check or filesystem not mounted with quota option.

6. quotaon /mnt/xfstests/mnt1
quotaon: Enforcing group quota already on /dev/sda2
quotaon: Enforcing user quota already on /dev/sda2

7. quotaon -p /mnt/xfstests/mnt1
group quota on /mnt/xfstests/mnt1 (/dev/sda2) is off
user quota on /mnt/xfstests/mnt1 (/dev/sda2) is off

8. xfs_quota -x -c "state -ug" /mnt/xfstests/mnt1
User quota state on /mnt/xfstests/mnt1 (/dev/sda2)
  Accounting: ON
  Enforcement: ON
  Inode: #131 (1 blocks, 1 extents)
Group quota state on /mnt/xfstests/mnt1 (/dev/sda2)
  Accounting: ON
  Enforcement: ON
  Inode: #132 (1 blocks, 1 extents)
Blocks grace time: [7 days 00:00:30]
Inodes grace time: [7 days 00:00:30]
Realtime Blocks grace time: [7 days 00:00:30]


So 
step#3 and step#4 show I really mount with quota option
step#5 and step#7 show quota-tools report quota is off
step#8 xfs_quota shows quota is on.

By the way, this failure can't be found on ext3/4.

Actual results:
quotaon -p show quota off if mount xfs with usrquota,grpquota

Expected results:
quotaon -p show quota on if mount xfs with usrquota,grpquota

Additional info:
I try to strace quotaon -p $mnt:
on RHEL-6.8, the quotactl() system call shows as:
---
[root@sgi-uv30-01 ~]# strace -e quotactl quotaon -p /mnt/xfstests/mnt1
quotactl(Q_GETFMT|GRPQUOTA, "/dev/sda2", 0, 0x7ffdc57e848c) = -1 ESRCH (No such process)
group quota on /mnt/xfstests/mnt1 (/dev/sda2) is off
quotactl(Q_GETFMT|USRQUOTA, "/dev/sda2", 0, 0x7ffdc57e848c) = -1 ESRCH (No such process)
user quota on /mnt/xfstests/mnt1 (/dev/sda2) is off
+++ exited with 0 +++
---

on RHEL-7, no this bug. quotaon -p can report quota on. its strace output as:
---
[root@ibm-x3650m4-10 ~]# strace -e quotactl quotaon -p /mnt/xfstests/mnt1                                              
quotactl(Q_XGETQSTAT|GRPQUOTA, "/dev/mapper/rhel_ibm--x3650m4--10-xfscratch", 0, {version=1, ...}) = 0
group quota on /mnt/xfstests/mnt1 (/dev/mapper/rhel_ibm--x3650m4--10-xfscratch) is on
quotactl(Q_XGETQSTAT|USRQUOTA, "/dev/mapper/rhel_ibm--x3650m4--10-xfscratch", 0, {version=1, ...}) = 0
user quota on /mnt/xfstests/mnt1 (/dev/mapper/rhel_ibm--x3650m4--10-xfscratch) is on
+++ exited with 2 +++
---

on RHEL-6.8, strace xfs_quota -x -c "state -ug" show as:
---
quotactl(Q_XGETQSTAT|USRQUOTA, "/dev/sda2", 0, {version=1, ...}) = 0
User quota state on /mnt/xfstests/mnt1 (/dev/sda2)
  Accounting: ON
  Enforcement: ON
  Inode: #131 (1 blocks, 1 extents)
Group quota state on /mnt/xfstests/mnt1 (/dev/sda2)
  Accounting: ON
  Enforcement: ON
  Inode: #132 (1 blocks, 1 extents)
Blocks grace time: [7 days 00:00:30]
Inodes grace time: [7 days 00:00:30]
Realtime Blocks grace time: [7 days 00:00:30]
+++ exited with 0 +++
---

Both RHEL-7 quotaon and xfs_quota use Q_XGETQSTAT, but RHEL-6 quotaon use Q_GETFMT. That's the difference.

BTW, I can reproduce this bug on upstream linux 4.5.0-rc2 on RHEL-6.8. So I think it's not a RHEL-6 kernel bug.

Comment 1 Eryu Guan 2016-02-03 11:02:57 UTC
Upstream quota tools doesn't have this problem. I think that's because upstream commit 40e09a3

commit 40e09a3b49827699d770f8144f973d4928f248b2
Author: Jan Kara <jack>
Date:   Thu Nov 17 00:02:59 2011 +0100

    Add support for quotas on ext4 in system files

changed the order of quota type detection. After this commit, kern_quota_on() detects for XFS first, on the other hand prior to this commit it detects for kernel_iface first (and that was IFACE_GENERIC, then quotactl(Q_GETFMT...) was called and failed).

Comment 2 Petr Pisar 2016-02-03 12:08:27 UTC
I confirm that quota-3.17-23.el6.x86_64 misreports XFS quota accounting state with "quotaon -p" and "quotaoff -p". I also note that "quotaoff" cannot disable XFS quota enforcing on.

A workaround for getting the status are "repquota -v" or "xfs_quota -x -c 'state -ug'" commands.

Is this an old bug or a new regression and it sometimes worked before on RHEL-6?

Comment 5 Petr Pisar 2016-02-03 12:53:01 UTC
Upstream fixed it with this two commits:

commit 86b82591a57198dbe88f5b37402f299a424e1b57
Author: jkar8572 <jkar8572>
Date:   Mon Jun 14 12:42:57 2010 +0000

    Fix kern_quota_on() to work with XFS filesystems (Jan Kara)
    Fix quotaon to work correctly with XFS filesystems (Jan Kara)

commit 22418226016a589a2ea355f1965f4123276e6bb8
Author: jkar8572 <jkar8572>
Date:   Mon Jun 14 10:06:04 2010 +0000

    For XFS, quotaon -f should turn off only limit enforcement as described in the manpage (Eric Sandeen)

Comment 6 Petr Pisar 2016-02-03 13:19:10 UTC
Created attachment 1120781 [details]
FIx ported to 3.17, first part

Comment 7 Petr Pisar 2016-02-03 13:19:53 UTC
Created attachment 1120782 [details]
Fix ported to 3.17, second part

Comment 12 Jan Kurik 2017-12-06 10:39:23 UTC
Red Hat Enterprise Linux 6 is in the Production 3 Phase. During the Production 3 Phase, Critical impact Security Advisories (RHSAs) and selected Urgent Priority Bug Fix Advisories (RHBAs) may be released as they become available.

The official life cycle policy can be reviewed here:

http://redhat.com/rhel/lifecycle

This issue does not meet the inclusion criteria for the Production 3 Phase and will be marked as CLOSED/WONTFIX. If this remains a critical requirement, please contact Red Hat Customer Support to request a re-evaluation of the issue, citing a clear business justification. Note that a strong business justification will be required for re-evaluation. Red Hat Customer Support can be contacted via the Red Hat Customer Portal at the following URL:

https://access.redhat.com/