Whamcloud - gitweb
LU-9132 utils: tuning max_sectors_kb on mount
[fs/lustre-release.git] / lustre / utils / mount_lustre.c
index 2ae59dd..588ebaf 100644 (file)
 #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"
@@ -278,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);
@@ -578,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)
@@ -685,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;
@@ -820,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 "