nvme-fabrics: reject I/O to offline device
PATCH v4 1/1 nvme-fabrics: reject I/O to offline device
From: Victor Gladkov <[email protected]>
Commands get stuck while Host NVMe controller (TCP or RDMA) is in reconnect state. NVMe controller enters into reconnect state when it loses connection with the target. It tries to reconnect every 10 seconds (default) until successful reconnection or until reconnect time-out is reached. The default reconnect time out is 10 minutes.
To fix this long delay due to the default timeout we introduce new session parameter "fast_io_fail_tmo". The timeout is measured in seconds from the controller reconnect, any command beyond that timeout is rejected. The new parameter value may be passed during 'connect'. The default value of 0 means no timeout (similar to current behavior).
We add a new controller NVME_CTRL_FAILFAST_EXPIRED and respective delayed work that updates the NVME_CTRL_FAILFAST_EXPIRED flag.
When the controller is entering the CONNECTING state, we schedule the delayed_work based on failfast timeout value. If the transition is out of CONNECTING, terminate delayed work item and ensure failfast_expired is false. If delayed work item expires then set "NVME_CTRL_FAILFAST_EXPIRED" flag to true.
We also update nvmf_fail_nonready_command() and nvme_available_path() functions with check the "NVME_CTRL_FAILFAST_EXPIRED" controller flag.
---
Changes From V3:
1. BUG_FIX: Fix a bug in nvme_start_failfast_work() amd nvme_stop_failfast_work() when accessing ctrl->opts as it will fail for PCIe transport when is called nvme_change_ctrl_state() from nvme_reset_work(), since we don't set the ctrl->opts for PCIe transport.
2. Line wrap in nvme_start_failfast_work(), nvme_parse_option() and for macro NVMF_ALLOWED_OPTS definition.
3. Just like all the state change code add a switch for newly added state handling outside of the state machine in nvme_state_change().
4. nvme_available_path() add /* fallthru */ after if..break inside switch which is under list_for_each_entry_rcu().
5. Align newly added member nvmf_ctrl_options fast_io_fail_tmp.
6. Fix the tabs before if in nvme_available_path() and line wrap for the same.
7. In nvme_failfast_work() use state != NVME_CTRL_CONNECTING instead of == to get rid of the parentheses and avoid char > 80.
8. Get rid of the ";" at the end of the comment for @fast_io_fail_tmp.
9. Change the commit log style to match the one we have in the NVMe repo.
Changes from V2:
1. Several coding style and small fixes.
2. Fix the comment for NVMF_DEF_FAIL_FAST_TMO.
3. Don't call functionality from the state machine.
4. Rename fast_fail_tmo -> fast_io_fail_tmo to match SCSI semantics.
Changes from V1:
1. Add a new session parameter called "fast_fail_tmo". The timeout is measured in seconds from the controller reconnect, any command beyond that timeout is rejected. The new parameter value may be passed during 'connect', and its default value is 30 seconds. A value of 0 means no timeout (similar to current behavior).
2. Add a controller flag of "failfast_expired".
3. Add dedicated delayed_work that update the "failfast_expired" controller flag.
4. When entering CONNECTING, schedule the delayed_work based on failfast timeout value. If transition out of CONNECTING, terminate delayed work item and ensure failfast_expired is false. If delayed work item expires: set "failfast_expired" flag to true.
5. Update nvmf_fail_nonready_command() with check the "failfast_expired" controller flag.
--- drivers/nvme/host/core.c | 53 +++++++++++++++++++++++++++++++++-- drivers/nvme/host/fabrics.c | 32 +++++++++++++++++---- drivers/nvme/host/fabrics.h | 5 ++++ drivers/nvme/host/multipath.c | 6 +++- drivers/nvme/host/nvme.h | 3 ++ 5 files changed, 90 insertions(+), 9 deletions(-)
drivers/nvme/host/core.c +51 -2
@@ -136,6 +136,39 @@ int nvme_try_sched_reset(struct nvme_ctrl *ctrl) }EXPORT_SYMBOL_GPL (nvme_try_sched_reset); +static void nvme_failfast_work (struct work_struct *work) +{ +struct nvme_ctrl *ctrl =container_of (to_delayed_work (work), + struct nvme_ctrl, failfast_work); + +spin_lock_irq (&ctrl->lock); +if (ctrl->state !=NVME_CTRL_CONNECTING ) + goto out; + +set_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags); +dev_info (ctrl->device,"failfast expired set for controller %s\n" , + ctrl->opts->subsysnqn); +nvme_kick_requeue_lists (ctrl); +out: +spin_unlock_irq (&ctrl->lock); +} + +static inline void nvme_start_failfast_work (struct nvme_ctrl *ctrl) +{ +if (!ctrl->opts || ctrl->opts->fast_io_fail_tmo ==0 ) +return ; +schedule_delayed_work (&ctrl->failfast_work, + ctrl->opts->fast_io_fail_tmo *HZ ); +} + +static inline void nvme_stop_failfast_work (struct nvme_ctrl *ctrl) +{ +if (!ctrl->opts || ctrl->opts->fast_io_fail_tmo ==0 ) +return ; +cancel_delayed_work_sync (&ctrl->failfast_work); +clear_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags); +} +int nvme_reset_ctrl (struct nvme_ctrl *ctrl) {if (!nvme_change_ctrl_state (ctrl,NVME_CTRL_RESETTING ))
@@ -395,8 +428,21 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, }spin_unlock_irqrestore (&ctrl->lock, flags); -if (changed && ctrl->state ==NVME_CTRL_LIVE ) -nvme_kick_requeue_lists (ctrl); +if (changed) { +switch (ctrl->state) { +case NVME_CTRL_LIVE : +nvme_kick_requeue_lists (ctrl); +if (old_state ==NVME_CTRL_CONNECTING ) +nvme_stop_failfast_work (ctrl); +break ; +case NVME_CTRL_CONNECTING : +if (old_state ==NVME_CTRL_RESETTING ) +nvme_start_failfast_work (ctrl); +break ; +default : +break ; + } + }return changed; }EXPORT_SYMBOL_GPL (nvme_change_ctrl_state);
@@ -3992,6 +4038,7 @@ void nvme_stop_ctrl(struct nvme_ctrl *ctrl) {nvme_mpath_stop (ctrl);nvme_stop_keep_alive (ctrl); +nvme_stop_failfast_work (ctrl);flush_work (&ctrl->async_event_work);cancel_work_sync (&ctrl->fw_act_work); }
@@ -4056,6 +4103,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,int ret; ctrl->state =NVME_CTRL_NEW ; +clear_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags);spin_lock_init (&ctrl->lock);mutex_init (&ctrl->scan_lock);INIT_LIST_HEAD (&ctrl->namespaces);
@@ -4070,6 +4118,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,init_waitqueue_head (&ctrl->state_wq);INIT_DELAYED_WORK (&ctrl->ka_work, nvme_keep_alive_work); +INIT_DELAYED_WORK (&ctrl->failfast_work, nvme_failfast_work);memset (&ctrl->ka_cmd,0 ,sizeof (ctrl->ka_cmd)); ctrl->ka_cmd.common.opcode = nvme_admin_keep_alive;
drivers/nvme/host/fabrics.c +26 -6
@@ -549,6 +549,7 @@ blk_status_t nvmf_fail_nonready_command(struct nvme_ctrl *ctrl, {if (ctrl->state !=NVME_CTRL_DELETING && ctrl->state !=NVME_CTRL_DEAD && + !test_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags) && !blk_noretry_request (rq) && !(rq->cmd_flags &REQ_NVME_MPATH ))return BLK_STS_RESOURCE ;
@@ -612,6 +613,7 @@ static const match_table_t opt_tokens = { { NVMF_OPT_NR_WRITE_QUEUES, "nr_write_queues=%d" }, { NVMF_OPT_NR_POLL_QUEUES, "nr_poll_queues=%d" }, { NVMF_OPT_TOS, "tos=%d" }, + { NVMF_OPT_FAIL_FAST_TMO, "fast_io_fail_tmo=%d" }, { NVMF_OPT_ERR, NULL } };
@@ -631,6 +633,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, opts->reconnect_delay =NVMF_DEF_RECONNECT_DELAY ; opts->kato =NVME_DEFAULT_KATO ; opts->duplicate_connect = false; + opts->fast_io_fail_tmo =NVMF_DEF_FAIL_FAST_TMO ; opts->hdr_digest = false; opts->data_digest = false; opts->tos =-1 ;/* < 0 == use transport default */
@@ -751,6 +754,19 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,pr_warn ("ctrl_loss_tmo < 0 will reconnect forever\n" ); ctrl_loss_tmo = token;break ; +case NVMF_OPT_FAIL_FAST_TMO : +if (match_int (args, &token)) { + ret = -EINVAL ; + goto out; + } + +if (token) +pr_warn ("fail_fast_tmo != 0, I/O will fail on" +" reconnect controller after %d sec\n" , + token); + + opts->fast_io_fail_tmo = token; +break ;case NVMF_OPT_HOSTNQN :if (opts->host) { pr_err("hostnqn already user-assigned: %s\n",
@@ -881,11 +897,14 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, opts->nr_poll_queues =0 ; opts->duplicate_connect = true; } -if (ctrl_loss_tmo <0 ) +if (ctrl_loss_tmo <0 ) { opts->max_reconnects =-1 ; -else - opts->max_reconnects =DIV_ROUND_UP (ctrl_loss_tmo, - opts->reconnect_delay); + }else { +if (ctrl_loss_tmo < opts->fast_io_fail_tmo) +pr_warn ("failfast tmo (%d) larger than controller " +"loss tmo (%d)\n" , + opts->fast_io_fail_tmo, ctrl_loss_tmo); + }if (!opts->host) {kref_get (&nvmf_default_host->ref);
@@ -984,8 +1003,9 @@ EXPORT_SYMBOL_GPL(nvmf_free_options);#define NVMF_REQUIRED_OPTS (NVMF_OPT_TRANSPORT | NVMF_OPT_NQN)#define NVMF_ALLOWED_OPTS (NVMF_OPT_QUEUE_SIZE | NVMF_OPT_NR_IO_QUEUES | \ NVMF_OPT_KATO | NVMF_OPT_HOSTNQN | \ - NVMF_OPT_HOST_ID | NVMF_OPT_DUP_CONNECT |\ - NVMF_OPT_DISABLE_SQFLOW) + NVMF_OPT_HOST_ID | NVMF_OPT_DUP_CONNECT | \ + NVMF_OPT_DISABLE_SQFLOW | \ + NVMF_OPT_FAIL_FAST_TMO)static struct nvme_ctrl *nvmf_create_ctrl (struct device *dev,const char *buf)
drivers/nvme/host/fabrics.h +5 -0
@@ -15,6 +15,8 @@#define NVMF_DEF_RECONNECT_DELAY 10/* default to 600 seconds of reconnect attempts before giving up */ #define NVMF_DEF_CTRL_LOSS_TMO 600 +/* default is 0: the fail fast mechanism is disable */ +#define NVMF_DEF_FAIL_FAST_TMO 0/* * Define a host as seen by the target. We allocate one at boot, but also
@@ -56,6 +58,7 @@ enum {NVMF_OPT_NR_WRITE_QUEUES =1 <<17 ,NVMF_OPT_NR_POLL_QUEUES =1 <<18 ,NVMF_OPT_TOS =1 <<19 , + NVMF_OPT_FAIL_FAST_TMO = 1 << 20, };/**
@@ -89,6 +92,7 @@ enum {* @nr_write_queues: number of queues for write I/O * @nr_poll_queues: number of queues for polling I/O * @tos: type of service +* @fast_io_fail_tmo: Fast I/O fail timeout in seconds */ struct nvmf_ctrl_options {unsigned mask;
@@ -111,6 +115,7 @@ struct nvmf_ctrl_options {unsigned int nr_write_queues;unsigned int nr_poll_queues;int tos; +unsigned int fast_io_fail_tmo; };/*
drivers/nvme/host/multipath.c +5 -1
@@ -281,9 +281,13 @@ static bool nvme_available_path(struct nvme_ns_head *head)list_for_each_entry_rcu (ns, &head->list, siblings) {switch (ns->ctrl->state) { +case NVME_CTRL_CONNECTING : +if (test_bit (NVME_CTRL_FAILFAST_EXPIRED , + &ns->ctrl->flags)) +break ; +/* fallthru */ case NVME_CTRL_LIVE :case NVME_CTRL_RESETTING : -case NVME_CTRL_CONNECTING :/* fallthru */ return true;default :
drivers/nvme/host/nvme.h +3 -0
@@ -256,6 +256,7 @@ struct nvme_ctrl {struct work_struct scan_work;struct work_struct async_event_work;struct delayed_work ka_work; +struct delayed_work failfast_work;struct nvme_command ka_cmd;struct work_struct fw_act_work;unsigned long events;
@@ -289,6 +290,8 @@ struct nvme_ctrl {u16 icdoff;u16 maxcmd;int nr_reconnects; +unsigned long flags; +#define NVME_CTRL_FAILFAST_EXPIRED 0struct nvmf_ctrl_options *opts;struct page *discard_page;
Signature · 7 lines
2.22.1 _______________________________________________ linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 131 lines · Chaitanya Kulkarni
From: Victor Gladkov <[email protected]>
Commands get stuck while Host NVMe controller (TCP or RDMA) is in reconnect state. NVMe controller enters into reconnect state when it loses connection with the target. It tries to reconnect every 10 seconds (default) until successful reconnection or until reconnect time-out is reached. The default reconnect time out is 10 minutes.
To fix this long delay due to the default timeout we introduce new session parameter "
fast_io_fail_tmo". The timeout is measured in seconds from the controller reconnect, any command beyond that timeout is rejected. The new parameter value may be passed during 'connect'. The default value of 0 means no timeout (similar to current behavior).We add a new controller
NVME_CTRL_FAILFAST_EXPIREDand respective delayed work that updates theNVME_CTRL_FAILFAST_EXPIREDflag.When the controller is entering the CONNECTING state, we schedule the
delayed_workbased on failfast timeout value. If the transition is out of CONNECTING, terminate delayed work item and ensurefailfast_expiredis false. If delayed work item expires then set "NVME_CTRL_FAILFAST_EXPIRED" flag to true.We also update
nvmf_fail_nonready_command()andnvme_available_path()functions with check the "NVME_CTRL_FAILFAST_EXPIRED" controller flag.Signed-off-by Victor Gladkov <[email protected]>Signed-off-by Chaitanya Kulkarni <[email protected]>---
Changes From V3:1.
BUG_FIX: Fix a bug innvme_start_failfast_work()amdnvme_stop_failfast_work() when accessing ctrl->opts as it will fail for PCIe transport when is called nvme_change_ctrl_state() from nvme_reset_work(), since we don't set the ctrl->opts for PCIe transport.2. Line wrap in
nvme_start_failfast_work(),nvme_parse_option()and for macroNVMF_ALLOWED_OPTSdefinition.
3. Just like all the state change code add a switch for newly added state handling outside of the state machine innvme_state_change().
4.nvme_available_path()add /* fallthru */ after if..break inside switch which is underlist_for_each_entry_rcu().
5. Align newly added membernvmf_ctrl_optionsfast_io_fail_tmp.
6. Fix the tabs before if innvme_available_path()and line wrap for the same.
7. Innvme_failfast_work()use state !=NVME_CTRL_CONNECTINGinstead of == to get rid of the parentheses and avoid char > 80.8. Get rid of the ";" at the end of the comment for @fast_io_fail_tmp.
9. Change the commit log style to match the one we have in the NVMe repo.Changes from V2:
1. Several coding style and small fixes.
2. Fix the comment forNVMF_DEF_FAIL_FAST_TMO.
3. Don't call functionality from the state machine.
4. Renamefast_fail_tmo->fast_io_fail_tmoto match SCSI semantics.Changes from V1:
1. Add a new session parameter called "
fast_fail_tmo". The timeout is measured in seconds from the controller reconnect, any command beyond that timeout is rejected. The new parameter value may be passed during 'connect', and its default value is 30 seconds. A value of 0 means no timeout (similar to current behavior).
2. Add a controller flag of "failfast_expired".
3. Add dedicateddelayed_workthat update the "failfast_expired" controller flag.
4. When entering CONNECTING, schedule thedelayed_workbased on failfast timeout value. If transition out of CONNECTING, terminate delayed work item and ensurefailfast_expiredis false. If delayed work item expires: set "failfast_expired" flag to true.
5. Updatenvmf_fail_nonready_command()with check the "failfast_expired" controller flag.--- drivers/nvme/host/core.c | 53 +++++++++++++++++++++++++++++++++-- drivers/nvme/host/fabrics.c | 32 +++++++++++++++++---- drivers/nvme/host/fabrics.h | 5 ++++ drivers/nvme/host/multipath.c | 6 +++- drivers/nvme/host/nvme.h | 3 ++ 5 files changed, 90 insertions(+), 9 deletions(-)drivers/nvme/host/core.c +33
-0@@ -136,6 +136,39 @@ int nvme_try_sched_reset(struct nvme_ctrl *ctrl) }EXPORT_SYMBOL_GPL (nvme_try_sched_reset); +static void nvme_failfast_work (struct work_struct *work) +{ +struct nvme_ctrl *ctrl =container_of (to_delayed_work (work), + struct nvme_ctrl, failfast_work); + +spin_lock_irq (&ctrl->lock); +if (ctrl->state !=NVME_CTRL_CONNECTING ) + goto out; + +set_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags); +dev_info (ctrl->device,"failfast expired set for controller %s\n" , + ctrl->opts->subsysnqn); +nvme_kick_requeue_lists (ctrl); +out: +spin_unlock_irq (&ctrl->lock); +} + +static inline void nvme_start_failfast_work (struct nvme_ctrl *ctrl) +{ +if (!ctrl->opts || ctrl->opts->fast_io_fail_tmo ==0 ) +return ; +schedule_delayed_work (&ctrl->failfast_work, + ctrl->opts->fast_io_fail_tmo *HZ ); +} + +static inline void nvme_stop_failfast_work (struct nvme_ctrl *ctrl) +{ +if (!ctrl->opts || ctrl->opts->fast_io_fail_tmo ==0 ) +return ; +cancel_delayed_work_sync (&ctrl->failfast_work); +clear_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags); +} +int nvme_reset_ctrl (struct nvme_ctrl *ctrl) {if (!nvme_change_ctrl_state (ctrl,NVME_CTRL_RESETTING ))@@ -395,8 +428,21 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, }
drivers/nvme/host/core.c bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, · line 437
Quoted 10 lines
drivers/nvme/host/core.c +7
-2spin_unlock_irqrestore (&ctrl->lock, flags); -if (changed && ctrl->state ==NVME_CTRL_LIVE ) -nvme_kick_requeue_lists (ctrl); +if (changed) { +switch (ctrl->state) { +case NVME_CTRL_LIVE : +nvme_kick_requeue_lists (ctrl); +if (old_state ==NVME_CTRL_CONNECTING ) +nvme_stop_failfast_work (ctrl); +break ;
This is a bit awkward; nvme_stop_failfast_work() will callcancel_delayed_work_sync(), which in turn might need to wait for an already running workqueue function, which already has the ctrl lock. Deadlock.
So you need to call 'nvme_stop_failfast_work()' without the ctrl lock held.
Other than that I'm very much in favour of this approach.
Cheers,
Hannes
Signature · 9 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer _______________________________________________ linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 6 lines · Hannes Reinecke
Quoted 6 lines
int
nvme_reset_ctrl(struct nvme_ctrl *ctrl)Quoted 5 lines
{ if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_RESETTING))(quoted diff) +0
-0@@ -395,8 +428,21 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, }
Quoted 16 lines
Quoted 10 lines
drivers/nvme/host/core.c bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, · line 437
Quoted 10 lines
drivers/nvme/host/core.c +7
-2spin_unlock_irqrestore (&ctrl->lock, flags); -if (changed && ctrl->state ==NVME_CTRL_LIVE ) -nvme_kick_requeue_lists (ctrl); +if (changed) { +switch (ctrl->state) { +case NVME_CTRL_LIVE : +nvme_kick_requeue_lists (ctrl); +if (old_state ==NVME_CTRL_CONNECTING ) +nvme_stop_failfast_work (ctrl); +break ;This is a bit awkward;
nvme_stop_failfast_work()will callcancel_delayed_work_sync(), which in turn might need to wait for an already running workqueue function, which already has the ctrl lock. Deadlock.
So you need to call 'nvme_stop_failfast_work()' without the ctrl lock held.
There are two calls for the nvme_stop_failfast_work() in host/core.c :-
1. nvme_change_ctrl_state() :-
Here we unlock the ctrl->lock, then call nvme_stop_failfast_work().
2. nvme_stop_ctrl() :-
This is not taking ctrl->lock.I'll read some more code, but please correct me if I did not understand the scenario that you have mentioned.
Quoted 5 lines
Other than that I'm very much in favour of this approach.
Cheers,
Hannes
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Hello Chaitanya, Victor,
Quoted 24 lines · Chaitanya Kulkarni
From: Victor Gladkov <[email protected]>
Commands get stuck while Host NVMe controller (TCP or RDMA) is in reconnect state. NVMe controller enters into reconnect state when it loses connection with the target. It tries to reconnect every 10 seconds (default) until successful reconnection or until reconnect time-out is reached. The default reconnect time out is 10 minutes.
To fix this long delay due to the default timeout we introduce new session parameter "
fast_io_fail_tmo". The timeout is measured in seconds from the controller reconnect, any command beyond that timeout is rejected. The new parameter value may be passed during 'connect'. The default value of 0 means no timeout (similar to current behavior).We add a new controller
NVME_CTRL_FAILFAST_EXPIREDand respective delayed work that updates theNVME_CTRL_FAILFAST_EXPIREDflag.When the controller is entering the CONNECTING state, we schedule the
delayed_workbased on failfast timeout value. If the transition is out of CONNECTING, terminate delayed work item and ensurefailfast_expiredis false. If delayed work item expires then set "NVME_CTRL_FAILFAST_EXPIRED" flag to true.
Quoted 5 lines
We also update
nvmf_fail_nonready_command()andnvme_available_path()functions with check the "NVME_CTRL_FAILFAST_EXPIRED" controller flag.Signed-off-by Victor Gladkov <[email protected]>Signed-off-by Chaitanya Kulkarni <[email protected]>
Thank you for addressing this issue. I asked about this scenario in June 2019 in http://lists.infradead.org/pipermail/linux-nvme/2019-June/024766.html.
I tested the patch on top of Mellanox OFED 4.7 with kernel 4.14. From my perspective, the direction is very good. But I think the problem is only partially addressed.
When a controller enters a CONNECTING state and the fast_io_fail_tmo expires, all new IOs to this controller are failed immediately. This is great!
However, in-flight IOs, i.e., those that were issued before the controller got disconnected, are still stuck until the controller succeeds to reconnect, or forever. I believe those IOs need to be errored out as well after fast_io_fail_tmo expires.
I did some debugging to try to accomplish that. I thought that the crux is that in-flight IOs are failed, and retried due to non-zero nvme_max_retries parameter. And by this time the request queue is quiesced by blk_mq_quiesce_queue(), and that's why in-flight IOs get stuck. I indeed see that nvme_retry_req() is called for some IOs. But I also see that after that, the request queue is un-quiesced via:nvme_rdma_error_recovery_work() =>
nvme_rdma_teardown_io_queues() => nvme_stop_queues() // this
quiesces the queue
nvme_start_queues() // this un-quiesces the queue
Can anybody perhaps give a hint on the approach to error out the in-flight IOs? I can modify the patch and test.
Thanks,
Alex.
Quoted 308 lines
---
Changes From V3:1.
BUG_FIX: Fix a bug innvme_start_failfast_work()amdnvme_stop_failfast_work()when accessingctrl->optsas it will fail for PCIe transport when is callednvme_change_ctrl_state()fromnvme_reset_work(), since we don't set thectrl->optsfor PCIe transport.
2. Line wrap innvme_start_failfast_work(),nvme_parse_option()and for macroNVMF_ALLOWED_OPTSdefinition.
3. Just like all the state change code add a switch for newly added state handling outside of the state machine innvme_state_change().
4.nvme_available_path()add /* fallthru */ after if..break inside switch which is underlist_for_each_entry_rcu().
5. Align newly added membernvmf_ctrl_optionsfast_io_fail_tmp.
6. Fix the tabs before if innvme_available_path()and line wrap for the same.
7. Innvme_failfast_work()use state !=NVME_CTRL_CONNECTINGinstead of == to get rid of the parentheses and avoid char > 80.
8. Get rid of the ";" at the end of the comment for @fast_io_fail_tmp.
9. Change the commit log style to match the one we have in the NVMe repo.Changes from V2:
1. Several coding style and small fixes.
2. Fix the comment forNVMF_DEF_FAIL_FAST_TMO.
3. Don't call functionality from the state machine.
4. Renamefast_fail_tmo->fast_io_fail_tmoto match SCSI semantics.Changes from V1:
1. Add a new session parameter called "
fast_fail_tmo". The timeout is measured in seconds from the controller reconnect, any command beyond that timeout is rejected. The new parameter value may be passed during 'connect', and its default value is 30 seconds. A value of 0 means no timeout (similar to current behavior).
2. Add a controller flag of "failfast_expired".
3. Add dedicateddelayed_workthat update the "failfast_expired" controller flag.
4. When entering CONNECTING, schedule thedelayed_workbased on failfast timeout value. If transition out of CONNECTING, terminate delayed work item and ensurefailfast_expiredis false. If delayed work item expires: set "failfast_expired" flag to true.
5. Updatenvmf_fail_nonready_command()with check the "failfast_expired" controller flag.--- drivers/nvme/host/core.c | 53 +++++++++++++++++++++++++++++++++-- drivers/nvme/host/fabrics.c | 32 +++++++++++++++++---- drivers/nvme/host/fabrics.h | 5 ++++ drivers/nvme/host/multipath.c | 6 +++- drivers/nvme/host/nvme.h | 3 ++ 5 files changed, 90 insertions(+), 9 deletions(-)drivers/nvme/host/core.c +51
-2@@ -136,6 +136,39 @@ int nvme_try_sched_reset(struct nvme_ctrl *ctrl) }EXPORT_SYMBOL_GPL (nvme_try_sched_reset); +static void nvme_failfast_work (struct work_struct *work) +{ +struct nvme_ctrl *ctrl =container_of (to_delayed_work (work), + struct nvme_ctrl, failfast_work); + +spin_lock_irq (&ctrl->lock); +if (ctrl->state !=NVME_CTRL_CONNECTING ) + goto out; + +set_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags); +dev_info (ctrl->device,"failfast expired set for controller %s\n" , + ctrl->opts->subsysnqn); +nvme_kick_requeue_lists (ctrl); +out: +spin_unlock_irq (&ctrl->lock); +} + +static inline void nvme_start_failfast_work (struct nvme_ctrl *ctrl) +{ +if (!ctrl->opts || ctrl->opts->fast_io_fail_tmo ==0 ) +return ; +schedule_delayed_work (&ctrl->failfast_work, + ctrl->opts->fast_io_fail_tmo *HZ ); +} + +static inline void nvme_stop_failfast_work (struct nvme_ctrl *ctrl) +{ +if (!ctrl->opts || ctrl->opts->fast_io_fail_tmo ==0 ) +return ; +cancel_delayed_work_sync (&ctrl->failfast_work); +clear_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags); +} +int nvme_reset_ctrl (struct nvme_ctrl *ctrl) {if (!nvme_change_ctrl_state (ctrl,NVME_CTRL_RESETTING ))@@ -395,8 +428,21 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, }spin_unlock_irqrestore (&ctrl->lock, flags); -if (changed && ctrl->state ==NVME_CTRL_LIVE ) -nvme_kick_requeue_lists (ctrl); +if (changed) { +switch (ctrl->state) { +case NVME_CTRL_LIVE : +nvme_kick_requeue_lists (ctrl); +if (old_state ==NVME_CTRL_CONNECTING ) +nvme_stop_failfast_work (ctrl); +break ; +case NVME_CTRL_CONNECTING : +if (old_state ==NVME_CTRL_RESETTING ) +nvme_start_failfast_work (ctrl); +break ; +default : +break ; + } + }return changed; }EXPORT_SYMBOL_GPL (nvme_change_ctrl_state);@@ -3992,6 +4038,7 @@ void nvme_stop_ctrl(struct nvme_ctrl *ctrl) {nvme_mpath_stop (ctrl);nvme_stop_keep_alive (ctrl); +nvme_stop_failfast_work (ctrl);flush_work (&ctrl->async_event_work);cancel_work_sync (&ctrl->fw_act_work); }@@ -4056,6 +4103,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,int ret; ctrl->state =NVME_CTRL_NEW ; +clear_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags);spin_lock_init (&ctrl->lock);mutex_init (&ctrl->scan_lock);INIT_LIST_HEAD (&ctrl->namespaces);@@ -4070,6 +4118,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,init_waitqueue_head (&ctrl->state_wq);INIT_DELAYED_WORK (&ctrl->ka_work, nvme_keep_alive_work); +INIT_DELAYED_WORK (&ctrl->failfast_work, nvme_failfast_work);memset (&ctrl->ka_cmd,0 ,sizeof (ctrl->ka_cmd)); ctrl->ka_cmd.common.opcode = nvme_admin_keep_alive;drivers/nvme/host/fabrics.c +26
-6@@ -549,6 +549,7 @@ blk_status_t nvmf_fail_nonready_command(struct nvme_ctrl *ctrl, {if (ctrl->state !=NVME_CTRL_DELETING && ctrl->state !=NVME_CTRL_DEAD && + !test_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags) && !blk_noretry_request (rq) && !(rq->cmd_flags &REQ_NVME_MPATH ))return BLK_STS_RESOURCE ;@@ -612,6 +613,7 @@ static const match_table_t opt_tokens = { { NVMF_OPT_NR_WRITE_QUEUES, "nr_write_queues=%d" }, { NVMF_OPT_NR_POLL_QUEUES, "nr_poll_queues=%d" }, { NVMF_OPT_TOS, "tos=%d" }, + { NVMF_OPT_FAIL_FAST_TMO, "fast_io_fail_tmo=%d" }, { NVMF_OPT_ERR, NULL } };@@ -631,6 +633,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, opts->reconnect_delay =NVMF_DEF_RECONNECT_DELAY ; opts->kato =NVME_DEFAULT_KATO ; opts->duplicate_connect = false; + opts->fast_io_fail_tmo =NVMF_DEF_FAIL_FAST_TMO ; opts->hdr_digest = false; opts->data_digest = false; opts->tos =-1 ;/* < 0 == use transport default */ @@ -751,6 +754,19 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,pr_warn ("ctrl_loss_tmo < 0 will reconnect forever\n" ); ctrl_loss_tmo = token;break ; +case NVMF_OPT_FAIL_FAST_TMO : +if (match_int (args, &token)) { + ret = -EINVAL ; + goto out; + } + +if (token) +pr_warn ("fail_fast_tmo != 0, I/O will fail on" +" reconnect controller after %d sec\n" , + token); + + opts->fast_io_fail_tmo = token; +break ;case NVMF_OPT_HOSTNQN :if (opts->host) { pr_err("hostnqn already user-assigned: %s\n",@@ -881,11 +897,14 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, opts->nr_poll_queues =0 ; opts->duplicate_connect = true; } -if (ctrl_loss_tmo <0 ) +if (ctrl_loss_tmo <0 ) { opts->max_reconnects =-1 ; -else - opts->max_reconnects =DIV_ROUND_UP (ctrl_loss_tmo, - opts->reconnect_delay); + }else { +if (ctrl_loss_tmo < opts->fast_io_fail_tmo) +pr_warn ("failfast tmo (%d) larger than controller " +"loss tmo (%d)\n" , + opts->fast_io_fail_tmo, ctrl_loss_tmo); + }if (!opts->host) {kref_get (&nvmf_default_host->ref);@@ -984,8 +1003,9 @@ EXPORT_SYMBOL_GPL(nvmf_free_options);#define NVMF_REQUIRED_OPTS (NVMF_OPT_TRANSPORT | NVMF_OPT_NQN)#define NVMF_ALLOWED_OPTS (NVMF_OPT_QUEUE_SIZE | NVMF_OPT_NR_IO_QUEUES | \ NVMF_OPT_KATO | NVMF_OPT_HOSTNQN | \ - NVMF_OPT_HOST_ID | NVMF_OPT_DUP_CONNECT |\ - NVMF_OPT_DISABLE_SQFLOW) + NVMF_OPT_HOST_ID | NVMF_OPT_DUP_CONNECT | \ + NVMF_OPT_DISABLE_SQFLOW | \ + NVMF_OPT_FAIL_FAST_TMO)static struct nvme_ctrl *nvmf_create_ctrl (struct device *dev,const char *buf)drivers/nvme/host/fabrics.h +5
-0@@ -15,6 +15,8 @@#define NVMF_DEF_RECONNECT_DELAY 10/* default to 600 seconds of reconnect attempts before giving up */ #define NVMF_DEF_CTRL_LOSS_TMO 600 +/* default is 0: the fail fast mechanism is disable */ +#define NVMF_DEF_FAIL_FAST_TMO 0/* * Define a host as seen by the target. We allocate one at boot, but also @@ -56,6 +58,7 @@ enum {NVMF_OPT_NR_WRITE_QUEUES =1 <<17 ,NVMF_OPT_NR_POLL_QUEUES =1 <<18 ,NVMF_OPT_TOS =1 <<19 , + NVMF_OPT_FAIL_FAST_TMO = 1 << 20, };/** @@ -89,6 +92,7 @@ enum {* @nr_write_queues: number of queues for write I/O * @nr_poll_queues: number of queues for polling I/O * @tos: type of service +* @fast_io_fail_tmo: Fast I/O fail timeout in seconds */ struct nvmf_ctrl_options {unsigned mask;@@ -111,6 +115,7 @@ struct nvmf_ctrl_options {unsigned int nr_write_queues;unsigned int nr_poll_queues;int tos; +unsigned int fast_io_fail_tmo; };/* drivers/nvme/host/multipath.c +5
-1@@ -281,9 +281,13 @@ static bool nvme_available_path(struct nvme_ns_head *head)list_for_each_entry_rcu (ns, &head->list, siblings) {switch (ns->ctrl->state) { +case NVME_CTRL_CONNECTING : +if (test_bit (NVME_CTRL_FAILFAST_EXPIRED , + &ns->ctrl->flags)) +break ; +/* fallthru */ case NVME_CTRL_LIVE :case NVME_CTRL_RESETTING : -case NVME_CTRL_CONNECTING :/* fallthru */ return true;default :drivers/nvme/host/nvme.h +3
-1@@ -256,6 +256,7 @@ struct nvme_ctrl {struct work_struct scan_work;struct work_struct async_event_work;struct delayed_work ka_work; +struct delayed_work failfast_work;struct nvme_command ka_cmd;struct work_struct fw_act_work;unsigned long events;@@ -289,6 +290,8 @@ struct nvme_ctrl {u16 icdoff;u16 maxcmd;int nr_reconnects; +unsigned long flags; +#define NVME_CTRL_FAILFAST_EXPIRED 0struct nvmf_ctrl_options *opts;struct page *discard_page; --2.22.1
Quoted 4 lines
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 27 lines · Alex Lyakas
Thank you for addressing this issue. I asked about this scenario in June 2019 in http://lists.infradead.org/pipermail/linux-nvme/2019-June/024766.html.
I tested the patch on top of Mellanox OFED 4.7 with kernel 4.14. From my perspective, the direction is very good. But I think the problem is only partially addressed.
When a controller enters a CONNECTING state and the
fast_io_fail_tmoexpires, all new IOs to this controller are failed immediately. This is great!However, in-flight IOs, i.e., those that were issued before the controller got disconnected, are still stuck until the controller succeeds to reconnect, or forever. I believe those IOs need to be errored out as well after
fast_io_fail_tmoexpires.I did some debugging to try to accomplish that. I thought that the crux is that in-flight IOs are failed, and retried due to non-zero
nvme_max_retriesparameter. And by this time the request queue is quiesced byblk_mq_quiesce_queue(), and that's why in-flight IOs get stuck. I indeed see thatnvme_retry_req()is called for some IOs. But I also see that after that, the request queue is un-quiesced via:nvme_rdma_error_recovery_work()=>
nvme_rdma_teardown_io_queues()=>nvme_stop_queues()// this
quiesces the queue
nvme_start_queues()// this un-quiesces the queue
Quoted 5 lines
Can anybody perhaps give a hint on the approach to error out the in-flight IOs? I can modify the patch and test.
Thanks,
Alex.
Thanks for the feedback. Let me see if I can generate the scenario and have a test for this.
I'll send out the updated patch soon.
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Hi Chaitanya, Victor,
I believe the following modification to nvme_failfast_work addresses the issue:
static void nvme_failfast_work(struct work_struct *work)
{
struct nvme_ctrl *ctrl = container_of(to_delayed_work(work),
struct nvme_ctrl, failfast_work);
bool run_queues = false;
spin_lock_irq(&ctrl->lock);
if (ctrl->state != NVME_CTRL_CONNECTING)
goto out;
set_bit(NVME_CTRL_FAILFAST_EXPIRED, &ctrl->flags);
dev_info(ctrl->device, "failfast expired set for controller %s\n",
ctrl->opts->subsysnqn);
nvme_kick_requeue_lists(ctrl);
run_queues = true;
out:
spin_unlock_irq(&ctrl->lock);
if (run_queues) {
struct nvme_ns *ns = NULL;
down_read(&ctrl->namespaces_rwsem);
list_for_each_entry(ns, &ctrl->namespaces, list) {
blk_mq_run_hw_queues(ns->queue, true/*async*/);
}
up_read(&ctrl->namespaces_rwsem);
}
}Basically, calling blk_mq_run_hw_queues(). I see that in-flight IO also fails after fast_io_fail_tmo, as expected.
Can you please comment?
Thanks,
Alex.
Quoted 32 lines · Chaitanya Kulkarni
Quoted 30 lines · Alex Lyakas
Thank you for addressing this issue. I asked about this scenario in June 2019 in http://lists.infradead.org/pipermail/linux-nvme/2019-June/024766.html.
I tested the patch on top of Mellanox OFED 4.7 with kernel 4.14. From my perspective, the direction is very good. But I think the problem is only partially addressed.
When a controller enters a CONNECTING state and the
fast_io_fail_tmoexpires, all new IOs to this controller are failed immediately. This is great!However, in-flight IOs, i.e., those that were issued before the controller got disconnected, are still stuck until the controller succeeds to reconnect, or forever. I believe those IOs need to be errored out as well after
fast_io_fail_tmoexpires.I did some debugging to try to accomplish that. I thought that the crux is that in-flight IOs are failed, and retried due to non-zero
nvme_max_retriesparameter. And by this time the request queue is quiesced byblk_mq_quiesce_queue(), and that's why in-flight IOs get stuck. I indeed see thatnvme_retry_req()is called for some IOs. But I also see that after that, the request queue is un-quiesced via:nvme_rdma_error_recovery_work()=>
nvme_rdma_teardown_io_queues()=>nvme_stop_queues()// this
quiesces the queue
nvme_start_queues()// this un-quiesces the queueCan anybody perhaps give a hint on the approach to error out the in-flight IOs? I can modify the patch and test.
Quoted 9 lines
Quoted 2 lines
Thanks,
Alex.Thanks for the feedback. Let me see if I can generate the scenario and have a test for this.
I'll send out the updated patch soon.
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v4 1/1 nvme-fabrics: reject I/O to offline device
I'd like to remind you that this improvement is awaiting for commit.
Commands get stuck while Host NVMe controller (TCP or RDMA) is in reconnect state. NVMe controller enters into reconnect state when it loses connection with the target. It tries to reconnect every 10 seconds (default) until successful reconnection or until reconnect time-out is reached. The default reconnect time out is 10 minutes.
To fix this long delay due to the default timeout we introduce new session parameter "fast_io_fail_tmo". The timeout is measured in seconds from the controller reconnect, any command beyond that timeout is rejected. The new parameter value may be passed during 'connect'.
The default value of 0 means no timeout (similar to current behavior).
We add a new controller NVME_CTRL_FAILFAST_EXPIRED and respective delayed work that updates the NVME_CTRL_FAILFAST_EXPIRED flag.
When the controller is entering the CONNECTING state, we schedule the delayed_work based on failfast timeout value. If the transition is out of CONNECTING, terminate delayed work item and ensure failfast_expired is false. If delayed work item expires then set "NVME_CTRL_FAILFAST_EXPIRED" flag to true.
We also update nvmf_fail_nonready_command() andnvme_available_path() functions with check the
"NVME_CTRL_FAILFAST_EXPIRED" controller flag.
---
Changes From V3:
1. BUG_FIX: Fix a bug in nvme_start_failfast_work() amd
nvme_stop_failfast_work() when accessing ctrl->opts as it will fail
for PCIe transport when is called nvme_change_ctrl_state()
from nvme_reset_work(), since we don't set the ctrl->opts for
PCIe transport.2. Line wrap in nvme_start_failfast_work(), nvme_parse_option() and for macro NVMF_ALLOWED_OPTS definition.
3. Just like all the state change code add a switch for newly added state handling outside of the state machine in nvme_state_change().
4. nvme_available_path() add /* fallthru */ after if..break inside switch which is under list_for_each_entry_rcu().
5. Align newly added member nvmf_ctrl_options fast_io_fail_tmp.
6. Fix the tabs before if in nvme_available_path() and line wrap for the same.
7. In nvme_failfast_work() use state != NVME_CTRL_CONNECTING
instead of == to get rid of the parentheses and avoid char > 80.
8. Get rid of the ";" at the end of the comment for @fast_io_fail_tmp.
9. Change the commit log style to match the one we have in the NVMe repo.
Changes from V2:
1. Several coding style and small fixes.
2. Fix the comment for NVMF_DEF_FAIL_FAST_TMO.
3. Don't call functionality from the state machine.
4. Rename fast_fail_tmo -> fast_io_fail_tmo to match SCSI semantics.
Changes from V1:
1. Add a new session parameter called "fast_fail_tmo". The timeout is measured in seconds from the controller reconnect, any command beyond that timeout is rejected. The new parameter value may be passed during 'connect', and its default value is 30 seconds. A value of 0 means no timeout (similar to current behavior).
2. Add a controller flag of "failfast_expired".
3. Add dedicated delayed_work that update the "failfast_expired" controller flag.
4. When entering CONNECTING, schedule the delayed_work based on failfast timeout value. If transition out of CONNECTING, terminate delayed work item and ensure failfast_expired is false. If delayed work item expires: set "failfast_expired" flag to true.
5. Update nvmf_fail_nonready_command() with check the "failfast_expired" controller flag.
--- drivers/nvme/host/core.c | 51 ++++++++++++++++++++++++++++++++++++++++++- drivers/nvme/host/fabrics.c | 30 ++++++++++++++++++++----- drivers/nvme/host/fabrics.h | 5 +++++ drivers/nvme/host/multipath.c | 6 ++++- drivers/nvme/host/nvme.h | 3 +++ 5 files changed, 88 insertions(+), 7 deletions(-)
drivers/nvme/host/core.c +50 -1
@@ -137,6 +137,39 @@ int nvme_try_sched_reset(struct nvme_ctrl *ctrl) }EXPORT_SYMBOL_GPL (nvme_try_sched_reset); +static void nvme_failfast_work (struct work_struct *work) +{ +struct nvme_ctrl *ctrl =container_of (to_delayed_work (work), + struct nvme_ctrl, failfast_work); + +spin_lock_irq (&ctrl->lock); +if (ctrl->state !=NVME_CTRL_CONNECTING ) + goto out; + +set_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags); +dev_info (ctrl->device,"failfast expired set for controller %s\n" , + ctrl->opts->subsysnqn); +nvme_kick_requeue_lists (ctrl); +out: +spin_unlock_irq (&ctrl->lock); +} + +static inline void nvme_start_failfast_work (struct nvme_ctrl *ctrl) +{ +if (!ctrl->opts || ctrl->opts->fast_io_fail_tmo ==0 ) +return ; +schedule_delayed_work (&ctrl->failfast_work, + ctrl->opts->fast_io_fail_tmo *HZ ); +} + +static inline void nvme_stop_failfast_work (struct nvme_ctrl *ctrl) +{ +if (!ctrl->opts || ctrl->opts->fast_io_fail_tmo ==0 ) +return ; +cancel_delayed_work_sync (&ctrl->failfast_work); +clear_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags); +} +int nvme_reset_ctrl (struct nvme_ctrl *ctrl) {if (!nvme_change_ctrl_state (ctrl,NVME_CTRL_RESETTING ))
@@ -387,8 +420,21 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, }spin_unlock_irqrestore (&ctrl->lock, flags); -if (changed && ctrl->state ==NVME_CTRL_LIVE ) +if (changed) { +switch (ctrl->state) { +case NVME_CTRL_LIVE :nvme_kick_requeue_lists (ctrl); +if (old_state ==NVME_CTRL_CONNECTING ) +nvme_stop_failfast_work (ctrl); +break ; +case NVME_CTRL_CONNECTING : +if (old_state ==NVME_CTRL_RESETTING ) +nvme_start_failfast_work (ctrl); +break ; +default : +break ; + } + }return changed; }EXPORT_SYMBOL_GPL (nvme_change_ctrl_state);
@@ -4045,6 +4091,7 @@ void nvme_stop_ctrl(struct nvme_ctrl *ctrl) {nvme_mpath_stop (ctrl);nvme_stop_keep_alive (ctrl); +nvme_stop_failfast_work (ctrl);flush_work (&ctrl->async_event_work);cancel_work_sync (&ctrl->fw_act_work); }
@@ -4111,6 +4158,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,int ret; ctrl->state =NVME_CTRL_NEW ; +clear_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags);spin_lock_init (&ctrl->lock);mutex_init (&ctrl->scan_lock);INIT_LIST_HEAD (&ctrl->namespaces);
@@ -4125,6 +4173,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,init_waitqueue_head (&ctrl->state_wq);INIT_DELAYED_WORK (&ctrl->ka_work, nvme_keep_alive_work); +INIT_DELAYED_WORK (&ctrl->failfast_work, nvme_failfast_work);memset (&ctrl->ka_cmd,0 ,sizeof (ctrl->ka_cmd)); ctrl->ka_cmd.common.opcode = nvme_admin_keep_alive;
drivers/nvme/host/fabrics.c +25 -5
@@ -549,6 +549,7 @@ blk_status_t nvmf_fail_nonready_command(struct nvme_ctrl *ctrl, {if (ctrl->state !=NVME_CTRL_DELETING && ctrl->state !=NVME_CTRL_DEAD && + !test_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags) && !blk_noretry_request (rq) && !(rq->cmd_flags &REQ_NVME_MPATH ))return BLK_STS_RESOURCE ;
@@ -612,6 +613,7 @@ bool __nvmf_check_ready(struct nvme_ctrl *ctrl, struct request *rq, { NVMF_OPT_NR_WRITE_QUEUES, "nr_write_queues=%d" }, { NVMF_OPT_NR_POLL_QUEUES, "nr_poll_queues=%d" }, { NVMF_OPT_TOS, "tos=%d" }, + { NVMF_OPT_FAIL_FAST_TMO, "fast_io_fail_tmo=%d" }, { NVMF_OPT_ERR, NULL } };
@@ -631,6 +633,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, opts->reconnect_delay =NVMF_DEF_RECONNECT_DELAY ; opts->kato =NVME_DEFAULT_KATO ; opts->duplicate_connect = false; + opts->fast_io_fail_tmo =NVMF_DEF_FAIL_FAST_TMO ; opts->hdr_digest = false; opts->data_digest = false; opts->tos =-1 ;/* < 0 == use transport default */
@@ -751,6 +754,19 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,pr_warn ("ctrl_loss_tmo < 0 will reconnect forever\n" ); ctrl_loss_tmo = token;break ; +case NVMF_OPT_FAIL_FAST_TMO : +if (match_int (args, &token)) { + ret = -EINVAL ; + goto out; + } + +if (token) +pr_warn ("fail_fast_tmo != 0, I/O will fail on" +" reconnect controller after %d sec\n" , + token); + + opts->fast_io_fail_tmo = token; +break ;case NVMF_OPT_HOSTNQN :if (opts->host) { pr_err("hostnqn already user-assigned: %s\n",
@@ -881,11 +897,14 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, opts->nr_poll_queues =0 ; opts->duplicate_connect = true; } -if (ctrl_loss_tmo <0 ) +if (ctrl_loss_tmo <0 ) { opts->max_reconnects =-1 ; -else - opts->max_reconnects =DIV_ROUND_UP (ctrl_loss_tmo, - opts->reconnect_delay); + }else { +if (ctrl_loss_tmo < opts->fast_io_fail_tmo) +pr_warn ("failfast tmo (%d) larger than controller " +"loss tmo (%d)\n" , + opts->fast_io_fail_tmo, ctrl_loss_tmo); + }if (!opts->host) {kref_get (&nvmf_default_host->ref);
@@ -985,7 +1004,8 @@ void nvmf_free_options(struct nvmf_ctrl_options *opts)#define NVMF_ALLOWED_OPTS (NVMF_OPT_QUEUE_SIZE | NVMF_OPT_NR_IO_QUEUES | \ NVMF_OPT_KATO | NVMF_OPT_HOSTNQN | \ NVMF_OPT_HOST_ID | NVMF_OPT_DUP_CONNECT | \ - NVMF_OPT_DISABLE_SQFLOW) + NVMF_OPT_DISABLE_SQFLOW | \ + NVMF_OPT_FAIL_FAST_TMO)static struct nvme_ctrl *nvmf_create_ctrl (struct device *dev,const char *buf)
drivers/nvme/host/fabrics.h +5 -0
@@ -15,6 +15,8 @@#define NVMF_DEF_RECONNECT_DELAY 10/* default to 600 seconds of reconnect attempts before giving up */ #define NVMF_DEF_CTRL_LOSS_TMO 600 +/* default is 0: the fail fast mechanism is disable */ +#define NVMF_DEF_FAIL_FAST_TMO 0/* * Define a host as seen by the target. We allocate one at boot, but also
@@ -56,6 +58,7 @@ enum {NVMF_OPT_NR_WRITE_QUEUES =1 <<17 ,NVMF_OPT_NR_POLL_QUEUES =1 <<18 ,NVMF_OPT_TOS =1 <<19 , + NVMF_OPT_FAIL_FAST_TMO = 1 << 20, };/**
@@ -89,6 +92,7 @@ enum {* @nr_write_queues: number of queues for write I/O * @nr_poll_queues: number of queues for polling I/O * @tos: type of service +* @fast_io_fail_tmo: Fast I/O fail timeout in seconds */ struct nvmf_ctrl_options {unsigned mask;
@@ -111,6 +115,7 @@ struct nvmf_ctrl_options {unsigned int nr_write_queues;unsigned int nr_poll_queues;int tos; +unsigned int fast_io_fail_tmo; };/*
drivers/nvme/host/multipath.c +5 -1
@@ -278,9 +278,13 @@ static bool nvme_available_path(struct nvme_ns_head *head)list_for_each_entry_rcu (ns, &head->list, siblings) {switch (ns->ctrl->state) { +case NVME_CTRL_CONNECTING : +if (test_bit (NVME_CTRL_FAILFAST_EXPIRED , + &ns->ctrl->flags)) +break ; +/* fallthru */ case NVME_CTRL_LIVE :case NVME_CTRL_RESETTING : -case NVME_CTRL_CONNECTING :/* fallthru */ return true;default :
drivers/nvme/host/nvme.h +3 -0
@@ -256,6 +256,7 @@ struct nvme_ctrl {struct work_struct scan_work;struct work_struct async_event_work;struct delayed_work ka_work; +struct delayed_work failfast_work;struct nvme_command ka_cmd;struct work_struct fw_act_work;unsigned long events;
@@ -290,6 +291,8 @@ struct nvme_ctrl {u16 icdoff;u16 maxcmd;int nr_reconnects; +unsigned long flags; +#define NVME_CTRL_FAILFAST_EXPIRED 0struct nvmf_ctrl_options *opts;struct page *discard_page;
--
1.8.3.1
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Sagi Grimberg
maintainerQuoted 11 lines
drivers/nvme/host/core.c +2
-0@@ -137,6 +137,39 @@ int nvme_try_sched_reset(struct nvme_ctrl *ctrl) }EXPORT_SYMBOL_GPL (nvme_try_sched_reset); +static void nvme_failfast_work (struct work_struct *work) +{
drivers/nvme/host/core.c int nvme_try_sched_reset(struct nvme_ctrl *ctrl) · line 151
Quoted 10 lines
drivers/nvme/host/core.c +10
-0+struct nvme_ctrl *ctrl =container_of (to_delayed_work (work), + struct nvme_ctrl, failfast_work); + +spin_lock_irq (&ctrl->lock); +if (ctrl->state !=NVME_CTRL_CONNECTING ) + goto out; + +set_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags); +dev_info (ctrl->device,"failfast expired set for controller %s\n" , + ctrl->opts->subsysnqn);
What does the subsysnqn has to do with anything? just keep "failfast expired"
drivers/nvme/host/core.c int nvme_try_sched_reset(struct nvme_ctrl *ctrl) · line 154
Quoted 3 lines
drivers/nvme/host/core.c +3
-0+nvme_kick_requeue_lists (ctrl); +out: +spin_unlock_irq (&ctrl->lock);
What is the lock protecting against? I don't see why this is needed.
drivers/nvme/host/core.c int nvme_try_sched_reset(struct nvme_ctrl *ctrl) · line 159
Quoted 5 lines
drivers/nvme/host/core.c +5
-0+} + +static inline void nvme_start_failfast_work (struct nvme_ctrl *ctrl) +{ +if (!ctrl->opts || ctrl->opts->fast_io_fail_tmo ==0 )
the timeout disabled should be -1, 0 is to fail I/O right away.
Maybe also add "off" string as a -1 equivalent.
Quoted 98 lines
drivers/nvme/host/core.c +30
-1+return ; +schedule_delayed_work (&ctrl->failfast_work, + ctrl->opts->fast_io_fail_tmo *HZ ); +} + +static inline void nvme_stop_failfast_work (struct nvme_ctrl *ctrl) +{ +if (!ctrl->opts || ctrl->opts->fast_io_fail_tmo ==0 ) +return ; +cancel_delayed_work_sync (&ctrl->failfast_work); +clear_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags); +} +int nvme_reset_ctrl (struct nvme_ctrl *ctrl) {if (!nvme_change_ctrl_state (ctrl,NVME_CTRL_RESETTING ))@@ -387,8 +420,21 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, }spin_unlock_irqrestore (&ctrl->lock, flags); -if (changed && ctrl->state ==NVME_CTRL_LIVE ) +if (changed) { +switch (ctrl->state) { +case NVME_CTRL_LIVE :nvme_kick_requeue_lists (ctrl); +if (old_state ==NVME_CTRL_CONNECTING ) +nvme_stop_failfast_work (ctrl); +break ; +case NVME_CTRL_CONNECTING : +if (old_state ==NVME_CTRL_RESETTING ) +nvme_start_failfast_work (ctrl); +break ; +default : +break ; + } + }return changed; }EXPORT_SYMBOL_GPL (nvme_change_ctrl_state);@@ -4045,6 +4091,7 @@ void nvme_stop_ctrl(struct nvme_ctrl *ctrl) {nvme_mpath_stop (ctrl);nvme_stop_keep_alive (ctrl); +nvme_stop_failfast_work (ctrl);flush_work (&ctrl->async_event_work);cancel_work_sync (&ctrl->fw_act_work); }@@ -4111,6 +4158,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,int ret; ctrl->state =NVME_CTRL_NEW ; +clear_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags);spin_lock_init (&ctrl->lock);mutex_init (&ctrl->scan_lock);INIT_LIST_HEAD (&ctrl->namespaces);@@ -4125,6 +4173,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,init_waitqueue_head (&ctrl->state_wq);INIT_DELAYED_WORK (&ctrl->ka_work, nvme_keep_alive_work); +INIT_DELAYED_WORK (&ctrl->failfast_work, nvme_failfast_work);memset (&ctrl->ka_cmd,0 ,sizeof (ctrl->ka_cmd)); ctrl->ka_cmd.common.opcode = nvme_admin_keep_alive;drivers/nvme/host/fabrics.c +6
-0@@ -549,6 +549,7 @@ blk_status_t nvmf_fail_nonready_command(struct nvme_ctrl *ctrl, {if (ctrl->state !=NVME_CTRL_DELETING && ctrl->state !=NVME_CTRL_DEAD && + !test_bit (NVME_CTRL_FAILFAST_EXPIRED , &ctrl->flags) && !blk_noretry_request (rq) && !(rq->cmd_flags &REQ_NVME_MPATH ))return BLK_STS_RESOURCE ;@@ -612,6 +613,7 @@ bool __nvmf_check_ready(struct nvme_ctrl *ctrl, struct request *rq, { NVMF_OPT_NR_WRITE_QUEUES, "nr_write_queues=%d" }, { NVMF_OPT_NR_POLL_QUEUES, "nr_poll_queues=%d" }, { NVMF_OPT_TOS, "tos=%d" }, + { NVMF_OPT_FAIL_FAST_TMO, "fast_io_fail_tmo=%d" }, { NVMF_OPT_ERR, NULL } };@@ -631,6 +633,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, opts->reconnect_delay =NVMF_DEF_RECONNECT_DELAY ; opts->kato =NVME_DEFAULT_KATO ; opts->duplicate_connect = false; + opts->fast_io_fail_tmo =NVMF_DEF_FAIL_FAST_TMO ; opts->hdr_digest = false; opts->data_digest = false; opts->tos =-1 ;/* < 0 == use transport default */ @@ -751,6 +754,19 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,pr_warn ("ctrl_loss_tmo < 0 will reconnect forever\n" ); ctrl_loss_tmo = token;break ; +case NVMF_OPT_FAIL_FAST_TMO : +if (match_int (args, &token)) { + ret = -EINVAL ;
drivers/nvme/host/fabrics.c static int nvmf_parse_options(struct nvmf_ctrl_options *opts, · line 769
Quoted 10 lines
drivers/nvme/host/fabrics.c +10
-0+ goto out; + } + +if (token) +pr_warn ("fail_fast_tmo != 0, I/O will fail on" +" reconnect controller after %d sec\n" , + token); + + opts->fast_io_fail_tmo = token; +break ;
Again, -1 should disable, not 0.
Quoted 9 lines
drivers/nvme/host/fabrics.c +1
-1case NVMF_OPT_HOSTNQN :if (opts->host) { pr_err("hostnqn already user-assigned: %s\n",@@ -881,11 +897,14 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, opts->nr_poll_queues =0 ; opts->duplicate_connect = true; } -if (ctrl_loss_tmo <0 ) +if (ctrl_loss_tmo <0 ) {
drivers/nvme/host/fabrics.c static int nvmf_parse_options(struct nvmf_ctrl_options *opts, · line 907
Quoted 10 lines
drivers/nvme/host/fabrics.c +6
-3opts->max_reconnects =-1 ; - else - opts->max_reconnects = DIV_ROUND_UP(ctrl_loss_tmo, - opts->reconnect_delay); + }else { +if (ctrl_loss_tmo < opts->fast_io_fail_tmo) +pr_warn ("failfast tmo (%d) larger than controller " +"loss tmo (%d)\n" , + opts->fast_io_fail_tmo, ctrl_loss_tmo); + }
it can be that ctrl_loss_tmo=-1 which means reconnect forever.
Quoted 55 lines
drivers/nvme/host/fabrics.c +2
-1if (!opts->host) {kref_get (&nvmf_default_host->ref);@@ -985,7 +1004,8 @@ void nvmf_free_options(struct nvmf_ctrl_options *opts)#define NVMF_ALLOWED_OPTS (NVMF_OPT_QUEUE_SIZE | NVMF_OPT_NR_IO_QUEUES | \ NVMF_OPT_KATO | NVMF_OPT_HOSTNQN | \ NVMF_OPT_HOST_ID | NVMF_OPT_DUP_CONNECT | \ - NVMF_OPT_DISABLE_SQFLOW) + NVMF_OPT_DISABLE_SQFLOW | \ + NVMF_OPT_FAIL_FAST_TMO)static struct nvme_ctrl *nvmf_create_ctrl (struct device *dev,const char *buf)drivers/nvme/host/fabrics.h +5
-0@@ -15,6 +15,8 @@#define NVMF_DEF_RECONNECT_DELAY 10/* default to 600 seconds of reconnect attempts before giving up */ #define NVMF_DEF_CTRL_LOSS_TMO 600 +/* default is 0: the fail fast mechanism is disable */ +#define NVMF_DEF_FAIL_FAST_TMO 0/* * Define a host as seen by the target. We allocate one at boot, but also @@ -56,6 +58,7 @@ enum {NVMF_OPT_NR_WRITE_QUEUES =1 <<17 ,NVMF_OPT_NR_POLL_QUEUES =1 <<18 ,NVMF_OPT_TOS =1 <<19 , + NVMF_OPT_FAIL_FAST_TMO = 1 << 20, };/** @@ -89,6 +92,7 @@ enum {* @nr_write_queues: number of queues for write I/O * @nr_poll_queues: number of queues for polling I/O * @tos: type of service +* @fast_io_fail_tmo: Fast I/O fail timeout in seconds */ struct nvmf_ctrl_options {unsigned mask;@@ -111,6 +115,7 @@ struct nvmf_ctrl_options {unsigned int nr_write_queues;unsigned int nr_poll_queues;int tos; +unsigned int fast_io_fail_tmo; };/* drivers/nvme/host/multipath.c +0
-0
drivers/nvme/host/multipath.c static bool nvme_available_path(struct nvme_ns_head *head) · line 285
Quoted 8 lines
drivers/nvme/host/multipath.c +5
-0@@ -278,9 +278,13 @@ static bool nvme_available_path(struct nvme_ns_head *head)list_for_each_entry_rcu (ns, &head->list, siblings) {switch (ns->ctrl->state) { +case NVME_CTRL_CONNECTING : +if (test_bit (NVME_CTRL_FAILFAST_EXPIRED , + &ns->ctrl->flags)) +break ; +/* fallthru */
I absolutely don't see why this needs to happen. this setting is on a controller, so this absolutely should not affect the mpath device node. so nak on this.
Quoted 28 lines
drivers/nvme/host/multipath.c +0
-1case NVME_CTRL_LIVE :case NVME_CTRL_RESETTING : -case NVME_CTRL_CONNECTING :/* fallthru */ return true;default :drivers/nvme/host/nvme.h +3
-1@@ -256,6 +256,7 @@ struct nvme_ctrl {struct work_struct scan_work;struct work_struct async_event_work;struct delayed_work ka_work; +struct delayed_work failfast_work;struct nvme_command ka_cmd;struct work_struct fw_act_work;unsigned long events;@@ -290,6 +291,8 @@ struct nvme_ctrl {u16 icdoff;u16 maxcmd;int nr_reconnects; +unsigned long flags; +#define NVME_CTRL_FAILFAST_EXPIRED 0struct nvmf_ctrl_options *opts;struct page *discard_page; --
Quoted 6 lines
1.8.3.1
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Hi Sagi.
Thank you for reviewing.
I'm going pull out new patch updated according to your comments. In the meantime, see my comments below.
Quoted 1 line
drivers/nvme/host/core.c index
Quoted 1 line
drivers/nvme/host/core.c index renamed from drivers/nvme/host/core.c +0
-0
set_bit(NVME_CTRL_FAILFAST_EXPIRED, &ctrl->flags);
Quoted 4 lines
drivers/nvme/host/core.c index
Quoted 2 lines
drivers/nvme/host/core.c index renamed from drivers/nvme/host/core.c +2
-0+ dev_info(ctrl->device, "failfast expired set for controller %s\n", + ctrl->opts->subsysnqn);What does the subsysnqn has to do with anything? just keep "failfast expired"[VG]
[VG] I agree with you
Quoted 7 lines
drivers/nvme/host/core.c index
Quoted 4 lines
drivers/nvme/host/core.c index renamed from drivers/nvme/host/core.c +3
-0+ nvme_kick_requeue_lists(ctrl); +out: + spin_unlock_irq(&ctrl->lock);What is the lock protecting against? I don't see why this is needed.
[VG] You're right.
Quoted 9 lines
drivers/nvme/host/core.c index
Quoted 4 lines
drivers/nvme/host/core.c index renamed from drivers/nvme/host/core.c +4
-0+} + +static inline void nvme_start_failfast_work(struct nvme_ctrl *ctrl) { + if (!ctrl->opts || ctrl->opts->fast_io_fail_tmo == 0)the timeout disabled should be -1, 0 is to fail I/O right away.
Maybe also add "off" string as a -1 equivalent.
[VG] It's ok to me. I'll add "off" string option.
Quoted 25 lines
drivers/nvme/host/fabrics.c static int nvmf_parse_options(struct
Quoted 5 lines
drivers/nvme/host/fabrics.c +0
-0@@ -631,6 +633,7 @@ static int nvmf_parse_options(struct
nvmf_ctrl_options*opts,drivers/nvme/host/fabrics.c static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
Quoted 9 lines
drivers/nvme/host/fabrics.c +2
-0opts->reconnect_delay =NVMF_DEF_RECONNECT_DELAY ; opts->kato =NVME_DEFAULT_KATO ; opts->duplicate_connect = false; + opts->fast_io_fail_tmo =NVMF_DEF_FAIL_FAST_TMO ; opts->hdr_digest = false; opts->data_digest = false; opts->tos = -1; /* < 0 == use transport default */ @@ -751,6 +754,19 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, pr_warn("ctrl_loss_tmo < 0 will reconnectforever\n");
Quoted 9 lines
ctrl_loss_tmo = token; break;drivers/nvme/host/fabrics.c +7
-0+case NVMF_OPT_FAIL_FAST_TMO : +if (match_int (args, &token)) { + ret = -EINVAL ; + goto out; + } + +if (token)
Quoted 8 lines
drivers/nvme/host/fabrics.c static int nvmf_parse_options(struct nvmf_ctrl_options *opts, · line 769
Quoted 6 lines
drivers/nvme/host/fabrics.c +6
-0+pr_warn ("fail_fast_tmo != 0, I/O will fail on" +" reconnect controller after %d sec\n" , + token); + + opts->fast_io_fail_tmo = token; +break ;Again, -1 should disable, not 0.
[VG] You're right.
Quoted 15 lines
Quoted 4 lines
case NVMF_OPT_HOSTNQN: if (opts->host) { pr_err("hostnqn already user-assigned: %s\n", @@ -881,11 +897,14
Quoted 10 lines
@@ static int nvmf_parse_options(struct
nvmf_ctrl_options*opts,
opts->nr_poll_queues= 0;opts->duplicate_connect= true;
}drivers/nvme/host/fabrics.c +1
-4-if (ctrl_loss_tmo <0 ) +if (ctrl_loss_tmo <0 ) { opts->max_reconnects =-1 ; -else - opts->max_reconnects =DIV_ROUND_UP (ctrl_loss_tmo, - opts->reconnect_delay);
Quoted 8 lines
drivers/nvme/host/fabrics.c static int nvmf_parse_options(struct nvmf_ctrl_options *opts, · line 907
Quoted 6 lines
drivers/nvme/host/fabrics.c +6
-0+ }else { +if (ctrl_loss_tmo < opts->fast_io_fail_tmo) +pr_warn ("failfast tmo (%d) larger than controller " +"loss tmo (%d)\n" , + opts->fast_io_fail_tmo, ctrl_loss_tmo); + }it can be that ctrl_loss_tmo=-1 which means reconnect forever.
[VG] OK
Quoted 7 lines
Quoted 7 lines
(quoted diff) +0
-0
b/drivers/nvme/host/multipath.cindex 54603bd..4b66504 100644drivers/nvme/host/multipath.c +0
-0@@ -278,9 +278,13 @@ static bool nvme_available_path(struct nvme_ns_head *head)
Quoted 10 lines
drivers/nvme/host/multipath.c static bool nvme_available_path(struct nvme_ns_head *head) · line 285
Quoted 7 lines
drivers/nvme/host/multipath.c +5
-0list_for_each_entry_rcu (ns, &head->list, siblings) {switch (ns->ctrl->state) { +case NVME_CTRL_CONNECTING : +if (test_bit (NVME_CTRL_FAILFAST_EXPIRED , + &ns->ctrl->flags)) +break ; +/* fallthru */ I absolutely don't see why this needs to happen. this setting is on a controller, so this absolutely should not affect the mpath device node. so nak on this.
[VG] In case of multipath is enabled we need announce the path as unavailable,
otherwise the command will requeue but not aborted.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 81 lines · Victor Gladkov
I'd like to remind you that this improvement is awaiting for commit.
Commands get stuck while Host NVMe controller (TCP or RDMA) is in reconnect state. NVMe controller enters into reconnect state when it loses connection with the target. It tries to reconnect every 10 seconds (default) until successful reconnection or until reconnect time-out is reached. The default reconnect time out is 10 minutes.
To fix this long delay due to the default timeout we introduce new session parameter "
fast_io_fail_tmo". The timeout is measured in seconds from the controller reconnect, any command beyond that timeout is rejected. The new parameter value may be passed during 'connect'.
The default value of 0 means no timeout (similar to current behavior).We add a new controller
NVME_CTRL_FAILFAST_EXPIREDand respective delayed work that updates theNVME_CTRL_FAILFAST_EXPIREDflag.When the controller is entering the CONNECTING state, we schedule the
delayed_workbased on failfast timeout value. If the transition is out of CONNECTING, terminate delayed work item and ensurefailfast_expiredis false. If delayed work item expires then set "NVME_CTRL_FAILFAST_EXPIRED" flag to true.We also update
nvmf_fail_nonready_command()andnvme_available_path()functions with check the
"NVME_CTRL_FAILFAST_EXPIRED" controller flag.Signed-off-by Victor Gladkov <[email protected]>Signed-off-by Chaitanya Kulkarni <[email protected]>---
Changes From V3:1.
BUG_FIX: Fix a bug innvme_start_failfast_work()amdnvme_stop_failfast_work() when accessing ctrl->opts as it will fail for PCIe transport when is called nvme_change_ctrl_state() from nvme_reset_work(), since we don't set the ctrl->opts for PCIe transport.2. Line wrap in
nvme_start_failfast_work(),nvme_parse_option()and for macroNVMF_ALLOWED_OPTSdefinition.
3. Just like all the state change code add a switch for newly added state handling outside of the state machine innvme_state_change().
4.nvme_available_path()add /* fallthru */ after if..break inside switch which is underlist_for_each_entry_rcu().
5. Align newly added membernvmf_ctrl_optionsfast_io_fail_tmp.
6. Fix the tabs before if innvme_available_path()and line wrap for the same.
7. Innvme_failfast_work()use state !=NVME_CTRL_CONNECTINGinstead of == to get rid of the parentheses and avoid char > 80.8. Get rid of the ";" at the end of the comment for @fast_io_fail_tmp.
9. Change the commit log style to match the one we have in the NVMe repo.Changes from V2:
1. Several coding style and small fixes.
2. Fix the comment forNVMF_DEF_FAIL_FAST_TMO.
3. Don't call functionality from the state machine.
4. Renamefast_fail_tmo->fast_io_fail_tmoto match SCSI semantics.Changes from V1:
1. Add a new session parameter called "
fast_fail_tmo". The timeout is measured in seconds from the controller reconnect, any command beyond that timeout is rejected. The new parameter value may be passed during 'connect', and its default value is 30 seconds. A value of 0 means no timeout (similar to current behavior).
2. Add a controller flag of "failfast_expired".
3. Add dedicateddelayed_workthat update the "failfast_expired" controller flag.
4. When entering CONNECTING, schedule thedelayed_workbased on failfast timeout value. If transition out of CONNECTING, terminate delayed work item and ensurefailfast_expiredis false. If delayed work item expires: set "failfast_expired" flag to true.
5. Updatenvmf_fail_nonready_command()with check the "failfast_expired" controller flag.
Quoted 8 lines
--- drivers/nvme/host/core.c | 51 ++++++++++++++++++++++++++++++++++++++++++- drivers/nvme/host/fabrics.c | 30 ++++++++++++++++++++----- drivers/nvme/host/fabrics.h | 5 +++++ drivers/nvme/host/multipath.c | 6 ++++- drivers/nvme/host/nvme.h | 3 +++ 5 files changed, 88 insertions(+), 7 deletions(-)
Cheers,
Hanne
Signature · 9 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme