Skip to content

Commit 2a6751e

Browse files
bvanasscheaxboe
authored andcommitted
nbd: Improve the documentation of the locking assumptions
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 <[email protected]> Cc: Josef Bacik <[email protected]> Cc: Yu Kuai <[email protected]> Cc: Markus Pargmann <[email protected]> Signed-off-by: Bart Van Assche <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 40639e9 commit 2a6751e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/block/nbd.c

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

591-
/* always call with the tx_lock held */
592591
static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
593592
{
594593
struct request *req = blk_mq_rq_from_pdu(cmd);
@@ -605,6 +604,9 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
605604
u32 nbd_cmd_flags = 0;
606605
int sent = nsock->sent, skip = 0;
607606

607+
lockdep_assert_held(&cmd->lock);
608+
lockdep_assert_held(&nsock->tx_lock);
609+
608610
iov_iter_kvec(&from, ITER_SOURCE, &iov, 1, sizeof(request));
609611

610612
type = req_to_nbd_cmd_type(req);
@@ -1015,6 +1017,8 @@ static int nbd_handle_cmd(struct nbd_cmd *cmd, int index)
10151017
struct nbd_sock *nsock;
10161018
int ret;
10171019

1020+
lockdep_assert_held(&cmd->lock);
1021+
10181022
config = nbd_get_config_unlocked(nbd);
10191023
if (!config) {
10201024
dev_err_ratelimited(disk_to_dev(nbd->disk),

0 commit comments

Comments
 (0)