lkml.org 
[lkml]   [2024]   [May]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] null_blk: Add __must_hold macro for null_flush_cache_page()
Date
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

\
 
 \ /
  Last update: 2024-05-09 11:33    [W:0.022 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site