diff mbox series

null_blk: Add __must_hold macro for null_flush_cache_page()

Message ID 20240509093304.1618775-1-ruanjinjie@huawei.com (mailing list archive)
State New
Headers show
Series null_blk: Add __must_hold macro for null_flush_cache_page() | expand

Commit Message

Jinjie Ruan May 9, 2024, 9:33 a.m. UTC
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@huawei.com>
---
 drivers/block/null_blk/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

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];