]> git.baikalelectronics.ru Git - kernel.git/commit
bcache: store disk name in struct cache and struct cached_dev
authorColy Li <colyli@suse.de>
Thu, 3 May 2018 10:51:32 +0000 (18:51 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 3 May 2018 14:35:08 +0000 (08:35 -0600)
commitc36225238f34c70e4c75d2ba0374b73364f3cc2d
tree1acd8ac86d6485f322003d6ca64a7194ce34b427
parent32b4c045fd39c504edf94e2eb983479e2a32e51a
bcache: store disk name in struct cache and struct cached_dev

Current code uses bdevname() or bio_devname() to reference gendisk
disk name when bcache needs to display the disk names in kernel message.
It was safe before bcache device failure handling patch set merged in,
because when devices are failed, there was deadlock to prevent bcache
printing error messages with gendisk disk name. But after the failure
handling patch set merged, the deadlock is fixed, so it is possible
that the gendisk structure bdev->hd_disk is released when bdevname() is
called to reference bdev->bd_disk->disk_name[]. This is why I receive
bug report of NULL pointers deference panic.

This patch stores gendisk disk name in a buffer inside struct cache and
struct cached_dev, then print out the offline device name won't reference
bdev->hd_disk anymore. And this patch also avoids extra function calls
of bdevname() and bio_devnmae().

Changelog:
v3, add Reviewed-by from Hannes.
v2, call bdevname() earlier in register_bdev()
v1, first version with segguestion from Junhui Tang.

Fixes: 1c26c93cc8473 ("bcache: add io_disable to struct cached_dev")
Fixes: 9213da3ebd703 ("bcache: fix misleading error message in bch_count_io_errors()")
Signed-off-by: Coly Li <colyli@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/bcache.h
drivers/md/bcache/debug.c
drivers/md/bcache/io.c
drivers/md/bcache/request.c
drivers/md/bcache/super.c