- if (rc == GLOB_NOMATCH) {
- /* no slave device is not an error */
- rc = 0;
- } else if (rc && verbose) {
- if (slave == NULL) {
- fprintf(stderr, "warning: %s, failed to read"
- " entries under %s/slaves\n",
- strerror(errno), path);
- } else {
- fprintf(stderr, "unable to set tunables for"
- " slave device %s (slave would be"
- " unable to handle IO request from"
- " master %s)\n",
- real_path, source);
- }
+ snprintf(sys_path, sizeof(sys_path), "/sys/dev/block/%u:%u/..",
+ major(st.st_rdev), minor(st.st_rdev));
+
+have_whole_dev:
+ /* Since we recurse on slave devices we resolve the sys_path to
+ * avoid path buffer overflows. */
+ real_sys_path = realpath(sys_path, NULL);
+ if (real_sys_path == NULL) {
+ if (verbose)
+ fprintf(stderr,
+ "warning: cannot resolve '%s': %s\n",
+ sys_path, strerror(errno));
+ rc = errno;
+ goto out;
+ }
+
+ if (major(st.st_rdev) == MD_MAJOR) {
+ rc = tune_md_stripe_cache_size(real_sys_path, mop);
+ } else {
+ /* Ignore errors from tune_max_sectors_kb() and
+ * tune_scheduler(). The worst that will happen is a block
+ * device with an "incorrect" scheduler. */
+ tune_max_sectors_kb(real_sys_path, mop);
+ tune_block_dev_scheduler(real_sys_path, DEFAULT_SCHEDULER);
+
+ /* If device is multipath device then tune its slave
+ * devices. */
+ rc = tune_block_dev_slaves(real_sys_path, mop);