From 9813961151e8f6e19eac9cf5a8db676f7aa70f50 Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Mon, 28 Apr 2014 00:39:38 -0400 Subject: [PATCH 1/1] 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. 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 --- lustre/utils/mount_utils_ldiskfs.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lustre/utils/mount_utils_ldiskfs.c b/lustre/utils/mount_utils_ldiskfs.c index 0eb2ed8a..456267c 100644 --- a/lustre/utils/mount_utils_ldiskfs.c +++ b/lustre/utils/mount_utils_ldiskfs.c @@ -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); } } -- 1.8.3.1