block: don't allow enabling a cache on devices that don't support it
authorChristoph Hellwig <hch@lst.de>
Fri, 7 Jul 2023 09:42:39 +0000 (11:42 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 17 Jul 2023 14:18:18 +0000 (08:18 -0600)
commit43c9835b144c7ce29efe142d662529662a9eb376
tree9a76f7e28e76f520ceb20966493710c10bcc49cb
parentc4e21bcd0f9d01f9c5d6c52007f5541871a5b1de
block: don't allow enabling a cache on devices that don't support it

Currently the write_cache attribute allows enabling the QUEUE_FLAG_WC
flag on devices that never claimed the capability.

Fix that by adding a QUEUE_FLAG_HW_WC flag that is set by
blk_queue_write_cache and guards re-enabling the cache through sysfs.

Note that any rescan that calls blk_queue_write_cache will still
re-enable the write cache as in the current code.

Fixes: 93e9d8e836cb ("block: add ability to flag write back caching on a device")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20230707094239.107968-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-settings.c
block/blk-sysfs.c
include/linux/blkdev.h