Bug 1633657

Summary: mount -a always tries to mount CIFS share subdir despite being already mounted
Product: Red Hat Enterprise Linux 7 Reporter: Roberto Bergantinos <rbergant>
Component: util-linuxAssignee: Karel Zak <kzak>
Status: CLOSED ERRATA QA Contact: Radka Brychtova <rskvaril>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.5CC: kdsouza, rskvaril
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: util-linux-2.23.2-61.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-08-06 13:10:37 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: 1630908    

Description Roberto Bergantinos 2018-09-27 13:30:55 UTC
Description of problem:

Running mount -a several times causes mount attempts of CIFS shares subdir included in fstab even though they are already mounted :

[root@rhel74-2 tmp]# grep cifs /etc/fstab
//rhel73/myshare/mydir  /mnt/mnt2   cifs    credentials=/etc/fstab.d/cifs/myshare,uid=1000,gid=1000,dir_mode=0777,file_mode=0666 0       0
[root@rhel74-2 tmp]# grep cifs /proc/mounts 
//rhel73/myshare/mydir /mnt/mnt2 cifs rw,relatime,vers=1.0,cache=strict,username=roberto,domain=RHEL73,uid=1000,forceuid,gid=1000,forcegid,addr=172.23.1.225,file_mode=0666,dir_mode=0777,nounix,serverino,mapposix,rsize=61440,wsize=65536,echo_interval=60,actimeo=1 0 0
[root@rhel74-2 tmp]# df -k -t cifs
Filesystem             1K-blocks    Used Available Use% Mounted on
//rhel73/myshare/mydir   8374272 7982708    391564  96% /mnt/mnt2
[root@rhel74-2 tmp]# mount -vvv -a
/                        : ignored
/boot                    : already mounted
swap                     : ignored
/mnt                     : already mounted
mount.cifs kernel mount options: ip=172.23.1.225,unc=\\rhel73\myshare,dir_mode=0777,file_mode=0666,uid=1000,gid=1000,user=roberto,prefixpath=mydir,pass=********
mount error(16): Device or resource busy
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
[root@rhel74-2 tmp]# mount -vvv -a
/                        : ignored
/boot                    : already mounted
swap                     : ignored
/mnt                     : already mounted
mount.cifs kernel mount options: ip=172.23.1.225,unc=\\rhel73\myshare,dir_mode=0777,file_mode=0666,uid=1000,gid=1000,user=roberto,prefixpath=mydir,pass=********
mount error(16): Device or resource busy
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

You may get EBUSY or a successful mount depending on CIFS client/server setup
(in this latter case, /proc/mounts gets duplicate entries each time mount -a 
runs) but mount is always tried. 

Enabling libmount debug, mnt_table_is_fs_mounted returns 0 :

...
12895: libmount:      TAB: [0x557c440630d0]: mnt_table_is_fs_mounted: //rhel73/myshare/mydir2 [rc=0]
...

As opposed to mount whole share :

...
13035: libmount:      TAB: [0x557a077df0d0]: mnt_table_is_fs_mounted: //rhel73/myshare [rc=1]
...

This is fixed in the following commit :

https://github.com/karelzak/util-linux/commit/76d4fba2e47808264f5c4c883127b0d275e31949

Indeed it cannot be reproduced on FC27 which contains the commit:

[root@idlethread /]# grep cifs /proc/mounts 
//rhel73/myshare/mydir /mnt2 cifs rw,relatime,vers=default,cache=strict,username=roberto,domain=,uid=0,noforceuid,gid=0,noforcegid,addr=172.23.1.225,file_mode=0755,dir_mode=0755,nounix,serverino,mapposix,rsize=1048576,wsize=1048576,echo_interval=60,actimeo=1 0 0
[root@idlethread /]# df -k -t cifs
Filesystem             1K-blocks    Used Available Use% Mounted on
//rhel73/myshare/mydir   8374272 7984600    389672  96% /mnt2
[root@idlethread /]# mount -vvv -a
/                        : ignored
/boot                    : already mounted
/home                    : already mounted
swap                     : ignored
/ISOs                    : already mounted
/mnt2                    : already mounted  <<<== GOOD
 

but customer running RHEL7 request backport of this fix to RHEĹ7

Version-Release number of selected component (if applicable): RHEL7 

How reproducible:

100 %


Steps to Reproduce:
1. add fstab entry to mount a subdir from a share
2. mount -a
3. mount -a

Actual results:

filesystem mount is tried despite being already mounted

Expected results:

skip that entry :

Additional info:

Comment 2 Karel Zak 2018-09-27 18:14:17 UTC
Fixed by upstream commit 76d4fba2e47808264f5c4c883127b0d275e31949.

Comment 8 errata-xmlrpc 2019-08-06 13:10:37 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:2252