From: Niu Yawei Date: Mon, 28 Apr 2014 04:39:38 +0000 (-0400) Subject: LU-4810 utils: print messages when set tunables X-Git-Tag: 2.5.3.90~44 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=ef5c7bb4a638d50628e91af0c19eb10aab6ec1f5;p=fs%2Flustre-release.git LU-4810 utils: print messages when set tunables When set scheduler and max_sectors_kb on mount, error messages should be printed to notify user that these tunables are changed by lustre. Lustre-commit: 9813961151e8f6e19eac9cf5a8db676f7aa70f50 Lustre-change: http://review.whamcloud.com/9865 Signed-off-by: Niu Yawei Change-Id: I6a3618b7e5eb0127e9aea18631397cd4dcbde546 Reviewed-on: http://review.whamcloud.com/9865 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Blake Caldwell Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Reviewed-on: http://review.whamcloud.com/12553 Reviewed-by: James Nunez --- diff --git a/lustre/utils/mount_utils_ldiskfs.c b/lustre/utils/mount_utils_ldiskfs.c index 80cb249..b2d5b43 100644 --- a/lustre/utils/mount_utils_ldiskfs.c +++ b/lustre/utils/mount_utils_ldiskfs.c @@ -974,7 +974,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 @@ -991,18 +991,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); @@ -1012,6 +1015,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; @@ -1168,6 +1174,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); } }