]> git.baikalelectronics.ru Git - kernel.git/commit
bcache: only set BCACHE_DEV_WB_RUNNING when cached device attached
authorColy Li <colyli@suse.de>
Sun, 9 Jun 2019 22:13:35 +0000 (06:13 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 13 Jun 2019 09:09:15 +0000 (03:09 -0600)
commit1378681025fe670c0cd4e0ff8e289288c4911e51
treee3fecad087a9cdac7eba72f96da496a3f29f814e
parente6367739465dbe4bafdfc176040abe66c2df2bc4
bcache: only set BCACHE_DEV_WB_RUNNING when cached device attached

When people set a writeback percent via sysfs file,
  /sys/block/bcache<N>/bcache/writeback_percent
current code directly sets BCACHE_DEV_WB_RUNNING to dc->disk.flags
and schedules kworker dc->writeback_rate_update.

If there is no cache set attached to, the writeback kernel thread is
not running indeed, running dc->writeback_rate_update does not make
sense and may cause NULL pointer deference when reference cache set
pointer inside update_writeback_rate().

This patch checks whether the cache set point (dc->disk.c) is NULL in
sysfs interface handler, and only set BCACHE_DEV_WB_RUNNING and
schedule dc->writeback_rate_update when dc->disk.c is not NULL (it
means the cache device is attached to a cache set).

This problem might be introduced from initial bcache commit, but
commit f4a44f100035 ("bcache: stop dc->writeback_rate_update properly")
changes part of the original code piece, so I add 'Fixes: f4a44f100035'
to indicate from which commit this patch can be applied.

Fixes: f4a44f100035 ("bcache: stop dc->writeback_rate_update properly")
Reported-by: Bjørn Forsman <bjorn.forsman@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
Reviewed-by: Bjørn Forsman <bjorn.forsman@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/sysfs.c