Bug 497830

Summary: 'df' doesn't wait for automount with indirect maps that use browse option
Product: Red Hat Enterprise Linux 5 Reporter: Tomas Smetana <tsmetana>
Component: coreutilsAssignee: Ondrej Vasik <ovasik>
Status: CLOSED ERRATA QA Contact: BaseOS QE <qe-baseos-auto>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.3CC: agk, cward, jscotka, meyering, rvokal, tao
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-09-02 09:17:24 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Example patch
none
Ian's patch rewritten according to Jim's instructions. none

Description Tomas Smetana 2009-04-27 13:43:01 UTC
Description of problem:
running df <automounted path> may not show the disk space usage as expected.

Version-Release number of selected component (if applicable):
coreutils-5.97-22

How reproducible:
always

Steps to Reproduce:
1. Export a NFS volume on a server, e.g. write something like the following to /etc/exports:
/tmp *(rw)

2. On the client machine configure the autofs:
Add to the /etc/auto.master (the --ghost parameter is important):
/misc	/etc/auto.misc --ghost

And to /etc/auto.misc ('server' is the machine used in step 1):
test	server:/tmp

3. On the client machine run the following (make sure /misc/test is not mounted yet):
df /misc/test; df /misc/test
  
Actual results:
[root@hp-dl360-02 ~]# df /misc/test; df /misc/test
Filesystem           1K-blocks      Used Available Use% Mounted on
-                            0         0         0   -  /misc
Filesystem           1K-blocks      Used Available Use% Mounted on
/tmp                  15013664   7302844   6935860  52% /misc/test

(i.e, the first run doesn't mount the automounted volume before getting the disk usage info)

Expected results:
[root@hp-dl360-02 ~]# df /misc/test; df /misc/test
Filesystem           1K-blocks      Used Available Use% Mounted on
/tmp                  15013664   7302844   6935860  52% /misc/test
Filesystem           1K-blocks      Used Available Use% Mounted on
/tmp                  15013664   7302844   6935860  52% /misc/test

Additional info:
According to Ian Kent who maintains autofs the problem is in the df utility which uses only stat/stafs calls that do not trigger the mount of the filesystem.  He has also provided an example patch that uses diropen to mount the filesystem.

Comment 1 Tomas Smetana 2009-04-27 13:48:18 UTC
Created attachment 341431 [details]
Example patch

This is patch for the RHEL-5 coreutils that calls diropen() to mount the filesystem.  Replacing diropen() with open() seems to work too.  I'm not sure whether this is the best way to solve the problem but it looks to work OK.

Comment 2 Jim Meyering 2009-04-27 14:18:46 UTC
Hi Tomas,

It appears that automounters have changed since that part of df.c was written.
Before, using "stat" was sufficient to cause the automounter to do its job.
If "open" works, please use that, and then, upon success, use the resulting file descriptor in a call to fstat in place of the existing "stat" call.
I.e., your patch is along the right lines, but use open instead of diropen.
And declare any new variables (like int fd;) in the innermost scope possible.

Please use these flags when calling open: O_RDONLY | O_NOCTTY | O_NONBLOCK

It'd be great if you would submit the patch upstream, following guidelines in
http://git.sv.gnu.org/cgit/coreutils.git/plain/HACKING

Thanks!

Comment 3 Jim Meyering 2009-04-27 14:33:24 UTC
Actually, O_NONBLOCK is probably best omitted in this context.

Comment 4 Tomas Smetana 2009-04-27 15:03:04 UTC
Created attachment 341439 [details]
Ian's patch rewritten according to Jim's instructions.

Comment 11 Chris Ward 2009-07-03 18:42:55 UTC
~~ Attention - RHEL 5.4 Beta Released! ~~

RHEL 5.4 Beta has been released! There should be a fix present in the Beta release that addresses this particular request. Please test and report back results here, at your earliest convenience. RHEL 5.4 General Availability release is just around the corner!

If you encounter any issues while testing Beta, please describe the issues you have encountered and set the bug into NEED_INFO. If you encounter new issues, please clone this bug to open a new issue and request it be reviewed for inclusion in RHEL 5.4 or a later update, if it is not of urgent severity.

Please do not flip the bug status to VERIFIED. Only post your verification results, and if available, update Verified field with the appropriate value.

Questions can be posted to this bug or your customer or partner representative.

Comment 14 errata-xmlrpc 2009-09-02 09:17:24 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2009-1262.html