Skip to content

Commit 8448828

Browse files
shroffnikeithbusch
authored andcommitted
Revert "nvme: make keep-alive synchronous operation"
This reverts commit d069236. It was realized that the fix implemented to contain the race condition among the keep alive task and the fabric shutdown code path in the commit d06923670b5ia ("nvme: make keep-alive synchronous operation") is not optimal. The reason being keep-alive runs under the workqueue and making it synchronous would waste a workqueue context. Furthermore, we later found that the above race condition is a regression caused due to the changes implemented in commit a54a93d ("nvme: move stopping keep-alive into nvme_uninit_ctrl()"). So we decided to revert the commit d069236 ("nvme: make keep-alive synchronous operation") and then fix the regression. Link: https://lore.kernel.org/all/196f4013-3bbf-43ff-98b4-9cb2a96c20c2@grimberg.me/ Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Nilay Shroff <nilay@linux.ibm.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 6fad84a commit 8448828

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

drivers/nvme/host/core.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,9 +1294,10 @@ static void nvme_queue_keep_alive_work(struct nvme_ctrl *ctrl)
12941294
queue_delayed_work(nvme_wq, &ctrl->ka_work, delay);
12951295
}
12961296

1297-
static void nvme_keep_alive_finish(struct request *rq,
1298-
blk_status_t status, struct nvme_ctrl *ctrl)
1297+
static enum rq_end_io_ret nvme_keep_alive_end_io(struct request *rq,
1298+
blk_status_t status)
12991299
{
1300+
struct nvme_ctrl *ctrl = rq->end_io_data;
13001301
unsigned long rtt = jiffies - (rq->deadline - rq->timeout);
13011302
unsigned long delay = nvme_keep_alive_work_period(ctrl);
13021303
enum nvme_ctrl_state state = nvme_ctrl_state(ctrl);
@@ -1313,17 +1314,20 @@ static void nvme_keep_alive_finish(struct request *rq,
13131314
delay = 0;
13141315
}
13151316

1317+
blk_mq_free_request(rq);
1318+
13161319
if (status) {
13171320
dev_err(ctrl->device,
13181321
"failed nvme_keep_alive_end_io error=%d\n",
13191322
status);
1320-
return;
1323+
return RQ_END_IO_NONE;
13211324
}
13221325

13231326
ctrl->ka_last_check_time = jiffies;
13241327
ctrl->comp_seen = false;
13251328
if (state == NVME_CTRL_LIVE || state == NVME_CTRL_CONNECTING)
13261329
queue_delayed_work(nvme_wq, &ctrl->ka_work, delay);
1330+
return RQ_END_IO_NONE;
13271331
}
13281332

13291333
static void nvme_keep_alive_work(struct work_struct *work)
@@ -1332,7 +1336,6 @@ static void nvme_keep_alive_work(struct work_struct *work)
13321336
struct nvme_ctrl, ka_work);
13331337
bool comp_seen = ctrl->comp_seen;
13341338
struct request *rq;
1335-
blk_status_t status;
13361339

13371340
ctrl->ka_last_check_time = jiffies;
13381341

@@ -1355,9 +1358,9 @@ static void nvme_keep_alive_work(struct work_struct *work)
13551358
nvme_init_request(rq, &ctrl->ka_cmd);
13561359

13571360
rq->timeout = ctrl->kato * HZ;
1358-
status = blk_execute_rq(rq, false);
1359-
nvme_keep_alive_finish(rq, status, ctrl);
1360-
blk_mq_free_request(rq);
1361+
rq->end_io = nvme_keep_alive_end_io;
1362+
rq->end_io_data = ctrl;
1363+
blk_execute_rq_nowait(rq, false);
13611364
}
13621365

13631366
static void nvme_start_keep_alive(struct nvme_ctrl *ctrl)

0 commit comments

Comments
 (0)