Skip to content

Commit 193820e

Browse files
bvanasschegregkh
authored andcommitted
nbd: Improve the documentation of the locking assumptions
[ Upstream commit 2a6751e ] Document locking assumptions with lockdep_assert_held() instead of source code comments. The advantage of lockdep_assert_held() is that it is verified at runtime if lockdep is enabled in the kernel config. Cc: Christoph Hellwig <hch@lst.de> Cc: Josef Bacik <jbacik@fb.com> Cc: Yu Kuai <yukuai3@huawei.com> Cc: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Link: https://lore.kernel.org/r/20240510202313.25209-4-bvanassche@acm.org Signed-off-by: Jens Axboe <axboe@kernel.dk> Stable-dep-of: e56d4b6 ("nbd: Fix signal handling") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent afcd1a3 commit 193820e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/block/nbd.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,6 @@ static inline int was_interrupted(int result)
569569
return result == -ERESTARTSYS || result == -EINTR;
570570
}
571571

572-
/* always call with the tx_lock held */
573572
static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
574573
{
575574
struct request *req = blk_mq_rq_from_pdu(cmd);
@@ -586,6 +585,9 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
586585
u32 nbd_cmd_flags = 0;
587586
int sent = nsock->sent, skip = 0;
588587

588+
lockdep_assert_held(&cmd->lock);
589+
lockdep_assert_held(&nsock->tx_lock);
590+
589591
iov_iter_kvec(&from, ITER_SOURCE, &iov, 1, sizeof(request));
590592

591593
type = req_to_nbd_cmd_type(req);
@@ -996,6 +998,8 @@ static int nbd_handle_cmd(struct nbd_cmd *cmd, int index)
996998
struct nbd_sock *nsock;
997999
int ret;
9981000

1001+
lockdep_assert_held(&cmd->lock);
1002+
9991003
config = nbd_get_config_unlocked(nbd);
10001004
if (!config) {
10011005
dev_err_ratelimited(disk_to_dev(nbd->disk),

0 commit comments

Comments
 (0)