text-based mount.nfs: Create fg/bg helpers for NFSv4 mounts
Subsystems (2)
PATCH 18/19 text-based mount.nfs: Create fg/bg helpers for NFSv4 mounts
Clone the NFSv2/3 fg/bg helpers for use with NFSv4 mounts.
The fg/bg helpers are very similar to each other... when we've decided they can be exactly the same except for calling either try_nfsmount or try_nfs4mount, we'll refactor these so there is only one set for both v2/3 and v4.
Signed-off-by Chuck Lever <[email protected]>
---
utils/mount/stropts.c | 124 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 124 insertions(+), 0 deletions(-)
utils/mount/stropts.c +124 -0
@@ -608,6 +608,130 @@ static int try_nfs4mount(const char *spec, const char *node, }/* +* Handle "foreground" NFSv4 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 nfs4mount_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_nfs4mount (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 ; +} + +/* +* Handle "background" NFSv4 mount [first try] +* +* Returns a valid mount command return code: zero if successful, +* EX_BG if a temporary failure occurred, EX_FAIL if a permanent +* error occurred. +* +* EX_BG should cause the caller to fork and invoke nfsmount_child. +*/ +static int nfs4mount_parent (const char *spec,const char *node, +char *hostname,int flags, +struct mount_options *options, +int fake,char **extra_opts) +{ +if (try_nfs4mount (spec, node, flags, options, fake, extra_opts)) +return 0 ; + +switch (errno) { +/* Permanent errors */ +case EINVAL : +case EBUSY : +mount_error (spec, node, errno); +return EX_FAIL ; +/* Everything else */ +default : +sys_mount_errors (hostname, errno,1 ,1 ); +return EX_BG ; + } +} + +/* +* Handle "background" NFSv4 mount [retry daemon] +* +* Returns a valid mount command return code: zero if successful, +* EX_FAIL if a failure occurred. There's nothing to catch the +* error return, though, so we use sys_mount_errors to log the +* failure. +*/ +static int nfs4mount_child (const char *spec,const char *node, +char *hostname,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 *10000 ;/* default: 10,000 minutes */ +else + timeout +=60 *atoi (retry); + +for (;;) { +if (sleep (secs)) +break ; + secs <<=1 ; +if (secs >30 ) + secs =30 ; + +if (!try_nfs4mount (spec, node, flags, options, + fake, extra_opts)) +return 0 ; + +if (time (NULL ) > timeout) +break ; + +sys_mount_errors (hostname, errno,1 ,1 ); + }; + +sys_mount_errors (hostname, errno,1 ,0 ); +return EX_FAIL ; +} + +/* * nfs4mount_s - Mount an NFSv4 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