Whamcloud - gitweb
LU-6013 utils: don't initialize OSD code for client mount 19/13019/4
authorAndreas Dilger <andreas.dilger@intel.com>
Wed, 10 Dec 2014 10:53:49 +0000 (03:53 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 13 Nov 2015 18:24:35 +0000 (18:24 +0000)
Don't even try to initialize the server OSD handling code if this
is a client mountpoint.  That avoids potential problems if the OSD
code isn't working or available when it isn't needed on a client.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: I104b70b9d27811d306879fc047a83f85ea3ebbe5
Reviewed-on: http://review.whamcloud.com/13019
Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Tested-by: Jenkins
Reviewed-by: Faccini Bruno <bruno.faccini@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/utils/mount_lustre.c

index e4cc51a..9261b75 100644 (file)
@@ -625,21 +625,17 @@ int main(int argc, char *const argv[])
 
        set_defaults(&mop);
 
-       rc = osd_init();
-       if (rc)
-               return rc;
-
        rc = parse_opts(argc, argv, &mop);
        if (rc || version)
                return rc;
 
-        if (verbose) {
-                for (i = 0; i < argc; i++)
-                        printf("arg[%d] = %s\n", i, argv[i]);
+       if (verbose) {
+               for (i = 0; i < argc; i++)
+                       printf("arg[%d] = %s\n", i, argv[i]);
                printf("source = %s (%s), target = %s\n", mop.mo_usource,
                       mop.mo_source, mop.mo_target);
                printf("options = %s\n", mop.mo_orig_options);
-        }
+       }
 
        options = malloc(MAXOPT);
         if (options == NULL) {
@@ -674,29 +670,33 @@ int main(int argc, char *const argv[])
                mop.mo_nomtab++;
 
        rc = access(mop.mo_target, F_OK);
-        if (rc) {
-                rc = errno;
+       if (rc) {
+               rc = errno;
                fprintf(stderr, "%s: %s inaccessible: %s\n", progname,
                        mop.mo_target, strerror(errno));
-                return rc;
-        }
+               return rc;
+       }
+
+       if (strstr(mop.mo_usource, ":/") == NULL) {
+               rc = osd_init();
+               if (rc)
+                       return rc;
 
-       if (!strstr(mop.mo_usource, ":/")) {
                rc = parse_ldd(mop.mo_source, &mop, options);
                if (rc)
                        return rc;
        }
 
-        /* In Linux 2.4, the target device doesn't get passed to any of our
-           functions.  So we'll stick it on the end of the options. */
+       /* In Linux 2.4, the target device doesn't get passed to any of our
+          functions.  So we'll stick it on the end of the options. */
        append_option(options, "device=");
        strcat(options, mop.mo_source);
 
-        if (verbose)
-                printf("mounting device %s at %s, flags=%#x options=%s\n",
+       if (verbose)
+               printf("mounting device %s at %s, flags=%#x options=%s\n",
                       mop.mo_source, mop.mo_target, flags, options);
 
-       if (!strstr(mop.mo_usource, ":/") &&
+       if (strstr(mop.mo_usource, ":/") == NULL &&
            osd_tune_lustre(mop.mo_source, &mop)) {
                if (verbose)
                        fprintf(stderr, "%s: unable to set tunables for %s"
@@ -705,10 +705,10 @@ int main(int argc, char *const argv[])
        }
 
        if (!mop.mo_fake) {
-                /* flags and target get to lustre_get_sb, but not
-                   lustre_fill_super.  Lustre ignores the flags, but mount
-                   does not. */
-                for (i = 0, rc = -EAGAIN; i <= mop.mo_retry && rc != 0; i++) {
+               /* flags and target get to lustre_get_sb(), but not
+                * lustre_fill_super().  Lustre ignores the flags, but mount
+                * does not. */
+               for (i = 0, rc = -EAGAIN; i <= mop.mo_retry && rc != 0; i++) {
                        rc = mount(mop.mo_source, mop.mo_target, "lustre",
                                   flags, (void *)options);
                        if (rc == 0) {
@@ -815,7 +815,8 @@ int main(int argc, char *const argv[])
        /* mo_usource should be freed, but we can rely on the kernel */
        free(mop.mo_source);
 
-       osd_fini();
+       if (strstr(mop.mo_usource, ":/") == NULL)
+               osd_fini();
 
-        return rc;
+       return rc;
 }