diff mbox series

[2/8] block: correctly report cache type

Message ID 20240625145955.115252-3-hch@lst.de (mailing list archive)
State Superseded, archived
Headers show
Series [1/8] md: set md-specific flags for all queue limits | expand

Checks

Context Check Description
mdraidci/vmtest-md-6_11-PR fail merge-conflict

Commit Message

Christoph Hellwig June 25, 2024, 2:59 p.m. UTC
Check the features flag and the override flag, otherwise we're going to
always report "write through".

Fixes: 1122c0c1cc71 ("block: move cache control settings out of queue->flags")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-sysfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Damien Le Moal June 25, 2024, 9:22 p.m. UTC | #1
On 6/25/24 23:59, Christoph Hellwig wrote:
> Check the features flag and the override flag, otherwise we're going to
> always report "write through".
> 
> Fixes: 1122c0c1cc71 ("block: move cache control settings out of queue->flags")
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
John Garry June 26, 2024, 7:59 a.m. UTC | #2
On 25/06/2024 15:59, Christoph Hellwig wrote:
> Check the features flag and the override flag, otherwise we're going to
> always report "write through".
> 
> Fixes: 1122c0c1cc71 ("block: move cache control settings out of queue->flags")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   block/blk-sysfs.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index 1a984179f3acc5..6db65886e7ed5a 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -453,7 +453,8 @@ static ssize_t queue_io_timeout_store(struct request_queue *q, const char *page,
>   
>   static ssize_t queue_wc_show(struct request_queue *q, char *page)
>   {
> -	if (q->limits.features & BLK_FLAG_WRITE_CACHE_DISABLED)
> +	if (!(q->limits.features & BLK_FEAT_WRITE_CACHE) ||
> +	    (q->limits.flags & BLK_FLAG_WRITE_CACHE_DISABLED))

Could you use blk_queue_write_cache() helper here to reduce duplication?

>   		return sprintf(page, "write through\n");
>   	return sprintf(page, "write back\n");
>   }
diff mbox series

Patch

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 1a984179f3acc5..6db65886e7ed5a 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -453,7 +453,8 @@  static ssize_t queue_io_timeout_store(struct request_queue *q, const char *page,
 
 static ssize_t queue_wc_show(struct request_queue *q, char *page)
 {
-	if (q->limits.features & BLK_FLAG_WRITE_CACHE_DISABLED)
+	if (!(q->limits.features & BLK_FEAT_WRITE_CACHE) ||
+	    (q->limits.flags & BLK_FLAG_WRITE_CACHE_DISABLED))
 		return sprintf(page, "write through\n");
 	return sprintf(page, "write back\n");
 }