Linux-Block Archive mirror
 help / color / mirror / Atom feed
From: Jinjie Ruan <ruanjinjie@huawei.com>
To: <axboe@kernel.dk>, <dlemoal@kernel.org>, <hare@suse.de>,
	<johannes.thumshirn@wdc.com>, <ming.lei@redhat.com>,
	<zhouchengming@bytedance.com>, <nj.shetty@samsung.com>,
	<justinstitt@google.com>, <john.g.garry@oracle.com>,
	<shinichiro.kawasaki@wdc.com>, <linux-block@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Cc: <ruanjinjie@huawei.com>
Subject: [PATCH] null_blk: Add __must_hold macro for null_flush_cache_page()
Date: Thu, 9 May 2024 17:33:04 +0800	[thread overview]
Message-ID: <20240509093304.1618775-1-ruanjinjie@huawei.com> (raw)

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


                 reply	other threads:[~2024-05-09  9:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240509093304.1618775-1-ruanjinjie@huawei.com \
    --to=ruanjinjie@huawei.com \
    --cc=axboe@kernel.dk \
    --cc=dlemoal@kernel.org \
    --cc=hare@suse.de \
    --cc=johannes.thumshirn@wdc.com \
    --cc=john.g.garry@oracle.com \
    --cc=justinstitt@google.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=nj.shetty@samsung.com \
    --cc=shinichiro.kawasaki@wdc.com \
    --cc=zhouchengming@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).