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 1979814

Summary: df: duplicates listed for remote filesystems (NFS) with same fsid/device without "-a" [rhel-9]
Product: Red Hat Enterprise Linux 9 Reporter: Kamil Dudka <kdudka>
Component: coreutilsAssignee: Kamil Dudka <kdudka>
Status: CLOSED CURRENTRELEASE QA Contact: Vojtech Eichler <veichler>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 9.0CC: kdudka, rbergant, veichler
Target Milestone: betaKeywords: Triaged
Target Release: 9.0 BetaFlags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: coreutils-8.32-30.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1962515 Environment:
Last Closed: 2021-12-07 21:44:43 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:
Bug Depends On:    
Bug Blocks: 1962515    

Description Kamil Dudka 2021-07-07 07:27:52 UTC
+++ This bug was initially created as a clone of Bug #1962515 +++

Description of problem:

Without -a, duplicates listed for remote filesystems under same device (same exported fsid), test case for NFS :


## RHEL7 :

[root@rhel77 ~]# rpm -q coreutils
coreutils-8.22-24.el7.x86_64
[root@rhel77 ~]# mkdir -p /testdir ; mkdir -p /mnt/testdir
[root@rhel77 ~]# mkdir -p /mnt/testdir/share1 ; mkdir -p /mnt/testdir/share2
[root@rhel77 ~]# mount -o bind /mnt/testdir /testdir
[root@rhel77 ~]# mount -o vers=4.1 rhel73:/share /testdir/share1
[root@rhel77 ~]# mount -o vers=4.1 rhel73:/workvol /testdir/share2
[root@rhel77 ~]# df -h -t nfs4
Filesystem       Size  Used Avail Use% Mounted on
rhel73:/share    8.0G  5.4G  2.7G  67% /testdir/share1
rhel73:/workvol  8.0G  5.4G  2.7G  67% /testdir/share2

[root@rhel77 ~]# cat /proc/fs/nfsfs/volumes 
NV SERVER   PORT DEV          FSID                              FSC
v4 ac1701e1  801 0:41         628fdfac389143b8:b4ef233ffd082203 no 
[root@rhel77 ~]# grep "0:41" /proc/self/mountinfo 
88 84 0:41 / /testdir/share1 rw,relatime shared:67 - nfs4 ...
91 39 0:41 / /mnt/testdir/share1 rw,relatime shared:67 - nfs4 ...
89 84 0:41 / /testdir/share2 rw,relatime shared:72 - nfs4 ...
95 39 0:41 / /mnt/testdir/share2 rw,relatime shared:72 - ...


## RHEL8 :

[root@rhel8 ~]# rpm -q coreutils
coreutils-8.30-8.el8.x86_64
[root@rhel8 ~]# mkdir -p /testdir ; mkdir -p /mnt/testdir
[root@rhel8 ~]# mkdir -p /mnt/testdir/share1 ; mkdir -p /mnt/testdir/share2
[root@rhel8 ~]# mount -o bind /mnt/testdir /testdir
[root@rhel8 ~]# mount -o vers=4.1 rhel73:/share /testdir/share1
[root@rhel8 ~]# mount -o vers=4.1 rhel73:/workvol /testdir/share2
[root@rhel8 ~]# df -h -t nfs4
Filesystem                        Size  Used Avail Use% Mounted on
rhel73:/share                     8.0G  5.4G  2.7G  67% /testdir/share1
rhel73:/workvol                   8.0G  5.4G  2.7G  67% /testdir/share2
rhel73:/workvol                   8.0G  5.4G  2.7G  67% /mnt/testdir/share2 <<<--- dupe

[root@rhel8 coreutils]# cat /proc/fs/nfsfs/volumes 
NV SERVER   PORT DEV          FSID                              FSC
v4 ac1701e1  801 0:48         628fdfac389143b8:b4ef233ffd082203 no 
[root@rhel8 coreutils]# grep "0:48" /proc/self/mountinfo 
335 326 0:48 / /testdir/share1 rw,relatime shared:177 - nfs4 ...
338 92 0:48 / /mnt/testdir/share1 rw,relatime shared:177 - nfs4 ...
336 326 0:48 / /testdir/share2 rw,relatime shared:186 - nfs4 ...
356 92 0:48 / /mnt/testdir/share2 rw,relatime shared:186 - nfs4 ...


This is based on a concrete field setup including the bind mount which sort of replicate mount tree.

Difference in behaviour between rhel7 and rhel8 is due to inclusion of this upstream commit :

1c17f61ef df: improve performance with many mount points

Which essentially uses a hash table on filter_mount_list() instead of a linked list.
As a result, when only introduce one entry on the hash table for first filesystem with
same device and we compare "devname" to that, that would be "seen_dev", when using linked 
list we simply compare with the latest element added to the list "device_list", that's why, 
for rhel7, and in this example no dupes are listed, since entries are consecutive.

I've tried this patch to make the behaviour rhel7-like for rhel8, resinserting 
on the table latest element found if already present :

diff --git a/src/df.c b/src/df.c
index 42cfeed2c..d011c6088 100644
--- a/src/df.c
+++ b/src/df.c
@@ -795,12 +795,28 @@ filter_mount_list (bool devices_only)
         {
           /* Add the device number to the device_table.  */
           struct devlist *devlist = xmalloc (sizeof *devlist);
+         union {
+                 const void *ptr;
+                 struct devlist *my_dev;
+          } entry;
+
           devlist->me = me;
           devlist->dev_num = buf.st_dev;
           devlist->next = device_list;
           device_list = devlist;
-          if (hash_insert (devlist_table, devlist) == NULL)
-            xalloc_die ();
+          switch (hash_insert_if_absent (devlist_table, devlist, &entry.ptr))
+            {
+                   case -1:
+                         xalloc_die ();
+                         break;
+                   case 0:
+                         if ((hash_remove(devlist_table, entry.my_dev) == NULL) ||
+                             (hash_insert (devlist_table, devlist) == NULL))
+                                 xalloc_die ();
+                         break;
+                   default:
+                         break;
+           }
 
           me = me->me_next;
         }


Seems to work :

[root@rhel8 coreutils]# /tmp/df -h -t nfs4   <<------- df with above patch
Filesystem       Size  Used Avail Use% Mounted on
rhel73:/share    8.0G  5.4G  2.7G  67% /testdir/share1
rhel73:/workvol  8.0G  5.4G  2.7G  67% /testdir/share2
[root@rhel8 coreutils]# df -h -t nfs4
Filesystem       Size  Used Avail Use% Mounted on
rhel73:/share    8.0G  5.4G  2.7G  67% /testdir/share1
rhel73:/workvol  8.0G  5.4G  2.7G  67% /testdir/share2
rhel73:/workvol  8.0G  5.4G  2.7G  67% /mnt/testdir/share2

But maybe it should be considered a more general case and modify devlist_compare and/or devlist_hash
to consider devname for hashing comparing purposes


Version-Release number of selected component (if applicable): 8.3, coreutils-8.30-8.el8.x86_64


How reproducible: 100%


Steps to Reproduce: see above


--- Additional comment from Kamil Dudka on 2021-07-07 09:22:27 CEST ---

upstream commit: https://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=v8.32-169-gd6125af095c

Comment 2 Kamil Dudka 2021-07-07 16:10:50 UTC
CentOS Stream merge request: https://gitlab.com/redhat/centos-stream/rpms/coreutils/-/merge_requests/7