]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Sep 2023 07:48:13 +0000 (09:48 +0200)
commit4355a1c3a58c5e36a7ea27834f503acdbd6ca8d2
tree8be2a426e82c8136735c78b45ac006c2080457ec
parentdb22fcbad57cdf3694c30ada8389d492ba1b4fdc
block: don't allow enabling a cache on devices that don't support it

[ Upstream commit 43c9835b144c7ce29efe142d662529662a9eb376 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/blk-settings.c
block/blk-sysfs.c
include/linux/blkdev.h