backend: fix switch_ioscheduler()
authorDamien Le Moal <damien.lemoal@wdc.com>
Thu, 15 Apr 2021 02:16:54 +0000 (11:16 +0900)
committerJens Axboe <axboe@kernel.dk>
Fri, 16 Apr 2021 16:25:24 +0000 (10:25 -0600)
commit5592e99219864e21b425cfc66fa05ece5b514259
tree40334a2932f243fada153248131dc8780377ff3a
parent5561e9dddca8479f182f0269a760dcabe7ff59ad
backend: fix switch_ioscheduler()

The backend.c function switch_ioscheduler() suffers from several
problems:
1) This function only considers the first file of a job. For jobs using
   multiple files, the ioscheduler switch will done only for that file.
2) If the job file is a character device, a pipe or a regular file for
   which the hosting block device file cannot be determined (e.g. a
   remote file), thring to switch the IO scheduler causes a crash as the
   file disk_util field is NULL.
Fix both problems by introducing the helper function set_ioscheduler()
and changing switch_ioscheduler() to repeatdly call this helper for all
files of the job, ignoring character device files, pipe files and files
without a hosting device information.

Also update the man page to better explain when the ioscheduler option
applies.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
backend.c
fio.1