Skip to content

Commit 88c9979

Browse files
Ming Leiaxboe
authored andcommitted
nvme-loop: use blk_mq_hctx_set_fq_lock_class to set loop's lock class
Set nvme-loop's lock class via blk_mq_hctx_set_fq_lock_class for avoiding lockdep possible recursive locking, then we can remove the dynamically allocated lock class for each flush queue, finally we can avoid horrible SCSI probe delay. This way may not address situation in which one nvme-loop is backed on another nvme-loop. However, in reality, people seldom uses this way for test. Even though someone played in this way, it is just one recursive locking false positive, no real deadlock issue. Tested-by: Kashyap Desai <[email protected]> Reported-by: Qian Cai <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Cc: Sumit Saxena <[email protected]> Cc: John Garry <[email protected]> Cc: Kashyap Desai <[email protected]> Cc: Bart Van Assche <[email protected]> Cc: Hannes Reinecke <[email protected]> Signed-off-by: Ming Lei <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent fb01a29 commit 88c9979

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/nvme/target/loop.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ static int nvme_loop_init_request(struct blk_mq_tag_set *set,
211211
(set == &ctrl->tag_set) ? hctx_idx + 1 : 0);
212212
}
213213

214+
static struct lock_class_key loop_hctx_fq_lock_key;
215+
214216
static int nvme_loop_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,
215217
unsigned int hctx_idx)
216218
{
@@ -219,6 +221,14 @@ static int nvme_loop_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,
219221

220222
BUG_ON(hctx_idx >= ctrl->ctrl.queue_count);
221223

224+
/*
225+
* flush_end_io() can be called recursively for us, so use our own
226+
* lock class key for avoiding lockdep possible recursive locking,
227+
* then we can remove the dynamically allocated lock class for each
228+
* flush queue, that way may cause horrible boot delay.
229+
*/
230+
blk_mq_hctx_set_fq_lock_class(hctx, &loop_hctx_fq_lock_key);
231+
222232
hctx->driver_data = queue;
223233
return 0;
224234
}

0 commit comments

Comments
 (0)