Whamcloud - gitweb
LU-9132 utils: tuning max_sectors_kb on mount
[fs/lustre-release.git] / lustre / utils / mount_lustre.c
index 6e7b75d..588ebaf 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2014, Intel Corporation.
+ * Copyright (c) 2011, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 #include <errno.h>
 #include <string.h>
 #include <sys/mount.h>
+#include <sys/param.h>
 #include <lustre_ver.h>
 #include <ctype.h>
 #include <limits.h>
 #include <lnet/nidstr.h>
-#include <lustre/lustre_idl.h>
 #include <libcfs/util/string.h>
 
 #include "obdctl.h"
@@ -282,7 +278,10 @@ int parse_options(struct mount_opts *mop, char *orig_options,
                /* please note that some ldiskfs mount options are also in
                 * the form of param=value. We should pay attention not to
                 * remove those mount options, see bug 22097. */
-               if (val && strncmp(arg, "md_stripe_cache_size", 20) == 0) {
+               if (val && strncmp(arg, "max_sectors_kb", 14) == 0) {
+                       mop->mo_max_sectors_kb = atoi(val + 1);
+               } else if (val &&
+                          strncmp(arg, "md_stripe_cache_size", 20) == 0) {
                        mop->mo_md_stripe_cache_size = atoi(val + 1);
                } else if (val && strncmp(arg, "retry", 5) == 0) {
                        mop->mo_retry = atoi(val + 1);
@@ -582,6 +581,7 @@ static void set_defaults(struct mount_opts *mop)
        mop->mo_md_stripe_cache_size = 16384;
        mop->mo_orig_options = "";
        mop->mo_nosvc = 0;
+       mop->mo_max_sectors_kb = -1;
 }
 
 static int parse_opts(int argc, char *const argv[], struct mount_opts *mop)
@@ -689,6 +689,34 @@ static int parse_opts(int argc, char *const argv[], struct mount_opts *mop)
        return 0;
 }
 
+/* change label from <fsname>:<index> to
+ * <fsname>-<index> to indicate the device has
+ * been registered. only if the label is
+ * supposed to be changed and target service
+ * is supposed to start */
+static void label_lustre(struct mount_opts *mop)
+{
+       if (mop->mo_nosvc)
+               return;
+
+       if (mop->mo_ldd.ldd_flags & (LDD_F_VIRGIN | LDD_F_WRITECONF)) {
+               (void)osd_label_lustre(mop);
+       } else {
+               struct lustre_disk_data ldd;
+               int rc;
+
+               /* device label could be changed after journal recovery,
+                * it should also be relabeled for mount has succeeded. */
+               memset(&ldd, 0, sizeof(ldd));
+               rc = osd_read_ldd(mop->mo_source, &ldd);
+               if (rc == 0) {
+                       rc = strlen(ldd.ldd_svname);
+                       if (rc >= 8 && ldd.ldd_svname[rc - 8] != '-')
+                               (void)osd_label_lustre(mop);
+               }
+       }
+}
+
 int main(int argc, char *const argv[])
 {
        struct mount_opts mop;
@@ -824,16 +852,8 @@ int main(int argc, char *const argv[])
                        rc = mount(mop.mo_source, mop.mo_target, "lustre",
                                   flags, (void *)options);
                        if (rc == 0) {
-                               /* change label from <fsname>:<index> to
-                                * <fsname>-<index> to indicate the device has
-                                *  been registered. only if the label is
-                                *  supposed to be changed and target service
-                                *  is supposed to start */
-                               if (mop.mo_ldd.ldd_flags &
-                                  (LDD_F_VIRGIN | LDD_F_WRITECONF)) {
-                                       if (mop.mo_nosvc == 0)
-                                               (void)osd_label_lustre(&mop);
-                               }
+                               if (!client)
+                                       label_lustre(&mop);
                        } else {
                                 if (verbose) {
                                         fprintf(stderr, "%s: mount %s at %s "