]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
mount.nfs4: Backgrounding mount broken with NFS versions <4
authorWolfram Gloger <bugzilla1@malloc.de>
Mon, 15 Oct 2012 19:31:23 +0000 (15:31 -0400)
committerSteve Dickson <steved@redhat.com>
Mon, 15 Oct 2012 19:31:23 +0000 (15:31 -0400)
When the NFS version isn't specified in the mount options, mount.nfs
attempts V4 first and appends 'vers=4' to the extra_options string in
the mount options.  If the server isn't immediately reachable, this
attempt fails.  However, if the background option is specified and the
server comes up later on, the extra_options are used again for all
further attempts and thus they fail if the server only supports
vers<4.

Fix this by only amending extra_options on a successful vers=4 mount.

This is now Debian bug #690181 and has apparently been around for
ages.

Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Wolfram Gloger <bugzilla1@malloc.de>
Signed-off-by: Steve Dickson <steved@redhat.com>
utils/mount/stropts.c

index 0aa9a7586dbe6eadf877450e715844907a9aa945..9b4197b7f93d812958da2b4eaffd73cba5600836 100644 (file)
@@ -680,6 +680,7 @@ static int nfs_do_mount_v4(struct nfsmount_info *mi,
 {
        struct mount_options *options = po_dup(mi->options);
        int result = 0;
+       char *extra_opts = NULL;
 
        if (!options) {
                errno = ENOMEM;
@@ -715,20 +716,26 @@ static int nfs_do_mount_v4(struct nfsmount_info *mi,
                goto out_fail;
        }
 
-       /*
-        * Update option string to be recorded in /etc/mtab.
-        */
-       if (po_join(options, mi->extra_opts) == PO_FAILED) {
+       if (po_join(options, &extra_opts) == PO_FAILED) {
                errno = ENOMEM;
                goto out_fail;
        }
 
        if (verbose)
                printf(_("%s: trying text-based options '%s'\n"),
-                       progname, *mi->extra_opts);
+                       progname, extra_opts);
 
        result = nfs_sys_mount(mi, options);
 
+       /*
+        * If success, update option string to be recorded in /etc/mtab.
+        */
+       if (result) {
+           free(*mi->extra_opts);
+           *mi->extra_opts = extra_opts;
+       } else
+           free(extra_opts);
+
 out_fail:
        po_destroy(options);
        return result;