[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240509093304.1618775-1-ruanjinjie@huawei.com>
Date: Thu, 9 May 2024 17:33:04 +0800
From: Jinjie Ruan <ruanjinjie@...wei.com>
To: <axboe@...nel.dk>, <dlemoal@...nel.org>, <hare@...e.de>,
<johannes.thumshirn@....com>, <ming.lei@...hat.com>,
<zhouchengming@...edance.com>, <nj.shetty@...sung.com>,
<justinstitt@...gle.com>, <john.g.garry@...cle.com>,
<shinichiro.kawasaki@....com>, <linux-block@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
CC: <ruanjinjie@...wei.com>
Subject: [PATCH] null_blk: Add __must_hold macro for null_flush_cache_page()
It seems that call null_flush_cache_page() must hold nullb->lock and it
returns with nullb->lock held. However, this is not clearly described, and
the caller may forget to hold the lock. Therefore, add __must_hold() macro
to the function entry to show that the lock is held on function entry and
exit, which allows sparse to do lock checking.
Signed-off-by: Jinjie Ruan <ruanjinjie@...wei.com>
---
drivers/block/null_blk/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index ed33cf7192d2..adca31e55deb 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -1013,7 +1013,7 @@ static int null_flush_cache_page(struct nullb *nullb, struct nullb_page *c_page)
return 0;
}
-static int null_make_cache_space(struct nullb *nullb, unsigned long n)
+static int null_make_cache_space(struct nullb *nullb, unsigned long n) __must_hold(&nullb->lock)
{
int i, err, nr_pages;
struct nullb_page *c_pages[FREE_BATCH];
--
2.34.1
Powered by blists - more mailing lists