From 10e80751e18661c916ab84b93db1d377e604db48 Mon Sep 17 00:00:00 2001 From: yangsheng Date: Wed, 17 Sep 2008 14:24:30 +0000 Subject: [PATCH] Branch b1_8_gate b=16953 i=johann, robert.read Add mount retry support for liblustre. --- lustre/liblustre/llite_lib.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lustre/liblustre/llite_lib.c b/lustre/liblustre/llite_lib.c index 624641a..96c27ef 100644 --- a/lustre/liblustre/llite_lib.c +++ b/lustre/liblustre/llite_lib.c @@ -325,6 +325,8 @@ int _sysio_lustre_init(void) extern int _sysio_native_init(); +static int mnt_retry = 0; + char *lustre_path = NULL; void __liblustre_setup_(void) @@ -332,13 +334,20 @@ void __liblustre_setup_(void) char *target = NULL; char *lustre_driver = "lustre"; unsigned mntflgs = 0; - int err; + int err, count; lustre_path = getenv("LIBLUSTRE_MOUNT_POINT"); if (!lustre_path) { lustre_path = "/mnt/lustre"; } + target = getenv("LIBLUSTRE_MOUNT_RETRY"); + if (target) { + mnt_retry = atoi(target); + if (mnt_retry < 0) + mnt_retry = 0; + } + /* mount target */ target = getenv("LIBLUSTRE_MOUNT_TARGET"); if (!target) { @@ -367,7 +376,16 @@ void __liblustre_setup_(void) exit(1); #endif /* INIT_SYSIO */ - err = mount(target, lustre_path, lustre_driver, mntflgs, NULL); + count = mnt_retry; + do { + err = mount(target, lustre_path, lustre_driver, mntflgs, NULL); + if (err && mnt_retry && (-- count)) { + fprintf(stderr, "Lustre mount failed: %s. " + "Will retry %d more times\n", + strerror(errno), mnt_retry - count ); + sleep(2); + } + } while (err && count > 0); if (err) { fprintf(stderr, "Lustre mount failed: %s\n", strerror(errno)); exit(1); -- 1.8.3.1