Skip to content

Commit aec89dc

Browse files
Christoph Hellwigaxboe
Christoph Hellwig
authored andcommitted
block: keep q_usage_counter in atomic mode after del_gendisk
Don't switch back to percpu mode to avoid the double RCU grace period when tearing down SCSI devices. After removing the disk only passthrough commands can be send anyway. Suggested-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Tested-by: Darrick J. Wong <djwong@kernel.org> Link: https://lore.kernel.org/r/20210929071241.934472-6-hch@lst.de Tested-by: Yi Zhang <yi.zhang@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 8e141f9 commit aec89dc

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

block/blk-mq.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,11 @@ void blk_mq_freeze_queue(struct request_queue *q)
188188
}
189189
EXPORT_SYMBOL_GPL(blk_mq_freeze_queue);
190190

191-
void blk_mq_unfreeze_queue(struct request_queue *q)
191+
void __blk_mq_unfreeze_queue(struct request_queue *q, bool force_atomic)
192192
{
193193
mutex_lock(&q->mq_freeze_lock);
194+
if (force_atomic)
195+
q->q_usage_counter.data->force_atomic = true;
194196
q->mq_freeze_depth--;
195197
WARN_ON_ONCE(q->mq_freeze_depth < 0);
196198
if (!q->mq_freeze_depth) {
@@ -199,6 +201,11 @@ void blk_mq_unfreeze_queue(struct request_queue *q)
199201
}
200202
mutex_unlock(&q->mq_freeze_lock);
201203
}
204+
205+
void blk_mq_unfreeze_queue(struct request_queue *q)
206+
{
207+
__blk_mq_unfreeze_queue(q, false);
208+
}
202209
EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);
203210

204211
/*

block/blk.h

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ struct blk_flush_queue *blk_alloc_flush_queue(int node, int cmd_size,
5151
void blk_free_flush_queue(struct blk_flush_queue *q);
5252

5353
void blk_freeze_queue(struct request_queue *q);
54+
void __blk_mq_unfreeze_queue(struct request_queue *q, bool force_atomic);
5455
void blk_queue_start_drain(struct request_queue *q);
5556

5657
#define BIO_INLINE_VECS 4

block/genhd.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,8 @@ void del_gendisk(struct gendisk *disk)
596596
/*
597597
* Allow using passthrough request again after the queue is torn down.
598598
*/
599-
blk_mq_unfreeze_queue(q);
599+
blk_queue_flag_clear(QUEUE_FLAG_INIT_DONE, q);
600+
__blk_mq_unfreeze_queue(q, true);
600601

601602
if (!(disk->flags & GENHD_FL_HIDDEN)) {
602603
sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi");

0 commit comments

Comments
 (0)