Messages in this thread Patch in this message | | | From | Jinjie Ruan <> | Subject | [PATCH] null_blk: Add __must_hold macro for null_flush_cache_page() | Date | Thu, 9 May 2024 17:33:04 +0800 |
| |
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 --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
| |