Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1679840

Summary: xfs_info fails when mounted device name is specified as argument
Product: Red Hat Enterprise Linux 8 Reporter: Yuki Okada <yuokada>
Component: xfsprogsAssignee: Eric Sandeen <esandeen>
Status: CLOSED ERRATA QA Contact: Zorro Lang <zlang>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.0CC: dwysocha, rhandlin, tbecker, xzhou, yuokada
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 8.0   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-11-05 22:30:49 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:
Embargoed:

Description Yuki Okada 2019-02-22 01:58:49 UTC
Description of problem:
xfs_info fails with "contains a mounted filesystem" error when a mounted device name is specified as an argument. It works without error if a mount point is specified.

$ mount | grep "type xfs"
/dev/mapper/rhel-root on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)

$ xfs_info /dev/mapper/rhel-root 
xfs_info: /dev/mapper/rhel-root contains a mounted filesystem

fatal error -- couldn't initialize XFS library

$ xfs_info /
meta-data=/dev/mapper/rhel-root  isize=512    agcount=4, agsize=1113856 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=4455424, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

According to xfs_info(8), both mount-point and block-device can be specified.

SYNOPSIS
       xfs_info [ -t mtab ] [ mount-point | block-device | file-image ]
       xfs_info -V

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

How reproducible:
100%

Steps to Reproduce:
1. Run "xfs_info <mounted device name which contains XFS>"

Actual results:
Fails with following error.

xfs_info: XXX contains a mounted filesystem

fatal error -- couldn't initialize XFS library

Expected results:
Returns XFS information.

Additional info:
In RHEL 7.6 (xfsprogs-4.5.0-18.el7.x86_64, kernel-3.10.0-957.el7.x86_64), xfs_info works even if a mounted device name is specified.

$ mount | grep "type xfs"
/dev/mapper/rhel-root on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)

$ xfs_info /dev/mapper/rhel-root 
meta-data=/dev/mapper/rhel-root  isize=512    agcount=4, agsize=1113856 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=4455424, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

Comment 1 Eric Sandeen 2019-02-22 02:37:51 UTC
The man page is clear that the argument to the xfs_info command is the mount point, not the device.

So what is considered to be a bug here?

Comment 2 Eric Sandeen 2019-02-22 02:41:47 UTC
Apologies, I see that the manpage has changed.  Let me look into this.

Comment 3 Eric Sandeen 2019-02-22 03:31:21 UTC
Ok, I believe the intent here may have been that a block device can be queried with xfs_info only if it is unmounted, but that restriction is not made clear in the manpage.

On the other hand, opening a mounted block device readonly /may/ be safe to gather geometry information.

I'll discuss this with other upstream maintainers, thank you for the bug report.

Comment 4 Eric Sandeen 2019-02-23 04:23:02 UTC
We may have a workable patch to automatically query the proper device based on mounted state, this will need to be worked out upstream.

Comment 5 Eric Sandeen 2019-05-22 15:22:45 UTC
Built in xfsprogs-5.0.0-1.el8

Comment 7 Zorro Lang 2019-06-13 08:09:14 UTC
Reproduced on xfsprogs xfsprogs-4.19.0-2.el8:
# rpm -q xfsprogs
xfsprogs-4.19.0-2.el8.x86_64
# mount /dev/loop0 /mnt/scratch
# xfs_info /mnt/scratch
meta-data=/dev/loop0             isize=512    agcount=4, agsize=327680 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=1310720, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
# xfs_info /dev/loop0
xfs_info: /dev/loop0 contains a mounted filesystem

fatal error -- couldn't initialize XFS library

Test passed on xfsprogs-5.0.0-1.el8:
# rpm -q xfsprogs
xfsprogs-5.0.0-1.el8.x86_64
# mount /dev/loop0 /mnt/scratch
# xfs_info /mnt/scratch
meta-data=/dev/loop0             isize=512    agcount=4, agsize=327680 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=1310720, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
# xfs_info /dev/loop0
meta-data=/dev/loop0             isize=512    agcount=4, agsize=327680 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=1310720, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

Comment 9 errata-xmlrpc 2019-11-05 22:30:49 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:3628