Whamcloud - gitweb
LU-9132 utils: tuning max_sectors_kb on mount 83/25483/4
authorNiu Yawei <yawei.niu@intel.com>
Thu, 16 Feb 2017 02:45:23 +0000 (21:45 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 1 Mar 2017 05:12:33 +0000 (05:12 +0000)
Sometimes user doesn't want the max_sectors_kb being
overwritten on MDT/OST mount, we should provide a way for
user to have more control over this important parameter,
a new mount option 'max_sectors_kb' is introduced:

- When max_sectors_kb isn't specified on mount, change the
  max_sectors_kb to max_hw_sectors_kb, it's default behavior
  suited for most users;
- When max_sectors_kb is specified as zero, leave the old
  setting of max_sectors_kb untouched;
- When max_sectors_kb is specified as a positive number,
  change the max_sectors_kb to this number arbitrarily;

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Change-Id: I251d75bbdf16d8cb6d503bbbfc69fb18993f7a3e
Reviewed-on: https://review.whamcloud.com/25483
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Gu Zheng <gzheng@ddn.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/doc/mount.lustre.8
lustre/utils/mount_lustre.c
lustre/utils/mount_utils.h
lustre/utils/mount_utils_ldiskfs.c

index c744822..fd9a6b5 100644 (file)
@@ -150,6 +150,15 @@ Abort client recovery and start the target service immediately.
 Sets the stripe cache size for server side disk with a striped raid
 configuration.
 .TP
+.BI max_sectors_kb
+Automatically Sets the block device parameter of 'max_sectors_kb' for the
+MDT or OST target. When max_sectors_kb isn't specified, that parameter for
+block device will be set to same as it's own 'max_hw_sectors_kb' (up to a
+maximum of 16M), this is default behavior suited for most users. When
+max_sectors_kb is specified as zero, the old parameter value will be kept.
+When max_sectors_kb is specified as a positive number, the parameter will
+be set to this number arbitrarily.
+.TP
 .BI recovery_time_soft= timeout
 Allow 'timeout' seconds for clients to reconnect for recovery after a server
 crash.  This timeout will be incrementally extended if it is about to expire
index 8c597cd..588ebaf 100644 (file)
@@ -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)
index 427e4c5..16206a0 100644 (file)
@@ -107,6 +107,7 @@ struct mount_opts {
        int      mo_have_mgsnid;
        int      mo_md_stripe_cache_size;
        int      mo_nosvc;
+       int      mo_max_sectors_kb;
 };
 
 int get_mountdata(char *, struct lustre_disk_data *);
index a010a40..6e566ba 100644 (file)
@@ -1194,16 +1194,20 @@ set_params:
                return rc;
        }
 
-       snprintf(real_path, sizeof(real_path), "%s/%s", path,
-                MAX_HW_SECTORS_KB_PATH);
-       rc = read_file(real_path, buf, sizeof(buf));
-       if (rc) {
-               if (verbose)
-                       fprintf(stderr, "warning: opening %s: %s\n",
-                               real_path, strerror(errno));
-               /* No MAX_HW_SECTORS_KB_PATH isn't necessary an
-                * error for some device. */
-               goto subdevs;
+       if (mop->mo_max_sectors_kb >= 0) {
+               snprintf(buf, sizeof(buf), "%d", mop->mo_max_sectors_kb);
+       } else {
+               snprintf(real_path, sizeof(real_path), "%s/%s", path,
+                        MAX_HW_SECTORS_KB_PATH);
+               rc = read_file(real_path, buf, sizeof(buf));
+               if (rc) {
+                       if (verbose)
+                               fprintf(stderr, "warning: opening %s: %s\n",
+                                       real_path, strerror(errno));
+                       /* No MAX_HW_SECTORS_KB_PATH isn't necessary an
+                        * error for some device. */
+                       goto subdevs;
+               }
        }
 
        if (strlen(buf) - 1 > 0) {
@@ -1228,14 +1232,15 @@ set_params:
                 * PTLRPC_MAX_BRW_SIZE, but that isn't in a public header.
                 * Note that even though the block layer allows larger values,
                 * setting max_sectors_kb = 32768 causes crashes (LU-6974). */
-               if (newval > 16 * 1024) {
+               if (mop->mo_max_sectors_kb < 0 && newval > 16 * 1024) {
                        newval = 16 * 1024;
                        snprintf(buf, sizeof(buf), "%llu", newval);
                }
 
                oldval = strtoull(oldbuf, &end, 0);
                /* Don't shrink the current limit. */
-               if (oldval != ULLONG_MAX && newval <= oldval)
+               if (mop->mo_max_sectors_kb < 0 && oldval != ULLONG_MAX &&
+                   newval <= oldval)
                        goto subdevs;
 
                rc = write_file(real_path, buf);