Skip to content

Commit c199fac

Browse files
shroffnikeithbusch
authored andcommitted
nvme-loop: flush off pending I/O while shutting down loop controller
While shutting down loop controller, we first quiesce the admin/IO queue, delete the admin/IO tag-set and then at last destroy the admin/IO queue. However it's quite possible that during the window between quiescing and destroying of the admin/IO queue, some admin/IO request might sneak in and if that happens then we could potentially encounter a hung task because shutdown operation can't forward progress until any pending I/O is flushed off. This commit helps ensure that before destroying the admin/IO queue, we unquiesce the admin/IO queue so that any outstanding requests, which are added after the admin/IO queue is quiesced, are now flushed to its completion. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nilay Shroff <nilay@linux.ibm.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 26bc0a8 commit c199fac

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/nvme/target/loop.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,13 @@ static void nvme_loop_destroy_admin_queue(struct nvme_loop_ctrl *ctrl)
265265
{
266266
if (!test_and_clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[0].flags))
267267
return;
268+
/*
269+
* It's possible that some requests might have been added
270+
* after admin queue is stopped/quiesced. So now start the
271+
* queue to flush these requests to the completion.
272+
*/
273+
nvme_unquiesce_admin_queue(&ctrl->ctrl);
274+
268275
nvmet_sq_destroy(&ctrl->queues[0].nvme_sq);
269276
nvme_remove_admin_tag_set(&ctrl->ctrl);
270277
}
@@ -297,6 +304,12 @@ static void nvme_loop_destroy_io_queues(struct nvme_loop_ctrl *ctrl)
297304
nvmet_sq_destroy(&ctrl->queues[i].nvme_sq);
298305
}
299306
ctrl->ctrl.queue_count = 1;
307+
/*
308+
* It's possible that some requests might have been added
309+
* after io queue is stopped/quiesced. So now start the
310+
* queue to flush these requests to the completion.
311+
*/
312+
nvme_unquiesce_io_queues(&ctrl->ctrl);
300313
}
301314

302315
static int nvme_loop_init_io_queues(struct nvme_loop_ctrl *ctrl)

0 commit comments

Comments
 (0)