From: Andreas Dilger Date: Wed, 1 Apr 2015 16:35:29 +0000 (-0400) Subject: LU-5888 utils: limit max_sectors_kb tunable setting X-Git-Tag: 2.7.58~40 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=0484a16883a951f27c30ee926c9a1c305f7cf489;p=fs%2Flustre-release.git LU-5888 utils: limit max_sectors_kb tunable setting Properly limit the max_sectors_kb tunable if larger than 32MB, as added in commit 73bd456e896 (http://review.whamcloud.com/12723). It was using the old value in "buf" instead of the updated "newval". Change write_file() to use a file descriptor directly instead of streams, since it only writes a single value before closing again. Signed-off-by: Andreas Dilger Change-Id: I43a5b4c9d0e45649e0666fd58634286de53ebbe5 Reviewed-on: http://review.whamcloud.com/13240 Tested-by: Jenkins Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- diff --git a/lustre/utils/mount_utils_ldiskfs.c b/lustre/utils/mount_utils_ldiskfs.c index e7e39a5..d07e996 100644 --- a/lustre/utils/mount_utils_ldiskfs.c +++ b/lustre/utils/mount_utils_ldiskfs.c @@ -974,15 +974,16 @@ static int read_file(const char *path, char *buf, int size) static int write_file(const char *path, const char *buf) { - FILE *fd; + int fd, rc; - fd = fopen(path, "w"); - if (fd == NULL) + fd = open(path, O_WRONLY); + if (fd < 0) return errno; - fputs(buf, fd); - fclose(fd); - return 0; + rc = write(fd, buf, strlen(buf)); + close(fd); + + return rc < 0 ? errno : 0; } static int set_blockdev_scheduler(const char *path, const char *scheduler) @@ -1156,7 +1157,7 @@ set_params: snprintf(buf, sizeof(buf), "%d", mop->mo_md_stripe_cache_size); rc = write_file(real_path, buf); - if (rc && verbose) + if (rc != 0 && verbose) fprintf(stderr, "warning: opening %s: %s\n", real_path, strerror(errno)); } @@ -1195,9 +1196,11 @@ set_params: goto subdevs; /* Don't increase IO request size limit past 32MB. It is about - * 2x PTLRPC_MAX_BRW_SIZE, but that isn't defined publicly. */ - if (newval > 32 * 1024) + * 2x PTLRPC_MAX_BRW_SIZE, but that isn't in a public header. */ + if (newval > 32 * 1024) { newval = 32 * 1024; + snprintf(buf, sizeof(buf), "%llu", newval); + } oldval = strtoull(oldbuf, &end, 0); /* Don't shrink the current limit. */ @@ -1205,7 +1208,7 @@ set_params: goto subdevs; rc = write_file(real_path, buf); - if (rc) { + if (rc != 0) { if (verbose) fprintf(stderr, "warning: writing to %s: %s\n", real_path, strerror(errno));