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 <andreas.dilger@intel.com>
Change-Id: I43a5b4c9d0e45649e0666fd58634286de53ebbe5
Reviewed-on: http://review.whamcloud.com/13240
Tested-by: Jenkins
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
static int write_file(const char *path, const char *buf)
{
static int write_file(const char *path, const char *buf)
{
- fd = fopen(path, "w");
- if (fd == NULL)
+ fd = open(path, O_WRONLY);
+ if (fd < 0)
- 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)
}
static int set_blockdev_scheduler(const char *path, const char *scheduler)
snprintf(buf, sizeof(buf), "%d",
mop->mo_md_stripe_cache_size);
rc = write_file(real_path, buf);
snprintf(buf, sizeof(buf), "%d",
mop->mo_md_stripe_cache_size);
rc = write_file(real_path, buf);
+ if (rc != 0 && verbose)
fprintf(stderr, "warning: opening %s: %s\n",
real_path, strerror(errno));
}
fprintf(stderr, "warning: opening %s: %s\n",
real_path, strerror(errno));
}
goto subdevs;
/* Don't increase IO request size limit past 32MB. It is about
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) {
+ snprintf(buf, sizeof(buf), "%llu", newval);
+ }
oldval = strtoull(oldbuf, &end, 0);
/* Don't shrink the current limit. */
oldval = strtoull(oldbuf, &end, 0);
/* Don't shrink the current limit. */
goto subdevs;
rc = write_file(real_path, buf);
goto subdevs;
rc = write_file(real_path, buf);
if (verbose)
fprintf(stderr, "warning: writing to %s: %s\n",
real_path, strerror(errno));
if (verbose)
fprintf(stderr, "warning: writing to %s: %s\n",
real_path, strerror(errno));