text-based mount.nfs: add a function to do foreground retries
Subsystems (2)
PATCH 14/19 text-based mount.nfs: add a function to do foreground retries
Make the differences between the foreground and background mount logic explicit by creating separate functions to handle each -- think of them as separate scripts for doing a foreground or a background mount.
NFS foreground mounts are supposed to retry for a little while before giving up. Add a function that handles this.
---
utils/mount/stropts.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 54 insertions(+), 1 deletions(-)
utils/mount/stropts.c +54 -1
@@ -350,7 +350,10 @@ static int rewrite_mount_opts(struct mount_options *options) }/* -* Attempt an NFS mount via a mount(2) system call. +* Attempt an NFS mount via a mount(2) system call. If the kernel +* claims the requested service isn't supported on the server, probe +* the server to see what's supported, rewrite the mount options, +* and retry the request. * * Returns 1 if successful. Otherwise, returns zero. * "errno" is set to reflect the individual error.
@@ -399,6 +402,56 @@ parse_err: }/* +* Handle "foreground" NFS mounts. +* +* Retry the mount request for as long as the 'retry=' option says. +* +* Returns a valid mount command return code: zero if successful, +* EX_FAIL if a failure occurred. +*/ +static int nfsmount_fg (const char *spec,const char *node, +int flags,struct mount_options *options, +int fake,char **extra_opts) +{ +unsigned int secs =1 ; +time_t timeout =time (NULL ); +char *retry; + + retry =po_get (options,"retry" ); +if (!retry) + timeout +=60 *2 ;/* default: 2 minutes */ +else + timeout +=60 *atoi (retry); + +for (;;) { +if (try_nfsmount (spec, node, flags, options, + fake, extra_opts)) +return 0 ; + +if (errno ==EINVAL ) +break ; + +if (time (NULL ) > timeout) { + errno =ETIMEDOUT ; +break ; + } + +if (verbose) +printf (_ ("%s: will retry until %s\n" ), + progname,ctime (&timeout)); + +if (sleep (secs)) +break ; + secs <<=1 ; +if (secs >5 ) + secs =5 ; + }; + +mount_error (spec, node, errno); +return EX_FAIL ; +} + +/* * nfsmount_s - Mount an NFSv2 or v3 file system using C string options * * @spec: C string hostname:path specifying remoteshare to mount
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs