Whamcloud - gitweb
LU-4810 utils: print messages when set tunables 65/9865/5
authorNiu Yawei <yawei.niu@intel.com>
Mon, 28 Apr 2014 04:39:38 +0000 (00:39 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 4 Nov 2014 17:53:25 +0000 (17:53 +0000)
When set scheduler and max_sectors_kb on mount, error messages should
be printed to notify user that these tunables are changed by lustre.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Change-Id: I6a3618b7e5eb0127e9aea18631397cd4dcbde546
Reviewed-on: http://review.whamcloud.com/9865
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Reviewed-by: Blake Caldwell <blakec@ornl.gov>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/utils/mount_utils_ldiskfs.c

index 0eb2ed8..456267c 100644 (file)
@@ -984,7 +984,7 @@ static int write_file(const char *path, const char *buf)
 
 static int set_blockdev_scheduler(const char *path, const char *scheduler)
 {
-       char buf[PATH_MAX], *c;
+       char buf[PATH_MAX], *s, *e, orig_sched[50];
        int rc;
 
        /* Before setting the scheduler, we need to check to see if it's
@@ -1001,18 +1001,21 @@ static int set_blockdev_scheduler(const char *path, const char *scheduler)
        }
 
        /* The expected format of buf: noop anticipatory deadline [cfq] */
-       c = strchr(buf, '[');
+       s = strchr(buf, '[');
+       e = strchr(buf, ']');
 
-       /* If c is NULL, the format is not what we expect. Play it safe
-        * and error out. */
-       if (c == NULL) {
+       /* If the format is not what we expect. Play it safe and error out. */
+       if (s == NULL || e == NULL) {
                if (verbose)
                        fprintf(stderr, "%s: cannot parse scheduler "
                                        "options for '%s'\n", progname, path);
                return -EINVAL;
        }
 
-       if (strncmp(c+1, "noop", 4) == 0)
+       snprintf(orig_sched, e - s, "%s", s + 1);
+
+       if (strcmp(orig_sched, "noop") == 0 ||
+           strcmp(orig_sched, scheduler) == 0)
                return 0;
 
        rc = write_file(path, scheduler);
@@ -1022,6 +1025,9 @@ static int set_blockdev_scheduler(const char *path, const char *scheduler)
                                        "'%s': %s\n", progname, path,
                                        strerror(errno));
                return rc;
+       } else {
+               fprintf(stderr, "%s: change scheduler of %s from %s to %s\n",
+                       progname, path, orig_sched, scheduler);
        }
 
        return rc;
@@ -1178,6 +1184,9 @@ set_params:
                        /* No MAX_SECTORS_KB_PATH isn't necessary an
                         * error for some device. */
                        rc = 0;
+               } else {
+                       fprintf(stderr, "%s: set %s to %s\n", progname,
+                               real_path, buf);
                }
        }