BLK_EH_HANDLED
Subsystems (14)
Christoph Hellwig
maintainerHi all,
this series removes the BLK_EH_HANDLED return value, and instead places responsibility of timed out commands entirely on the drivers. Except for some odd layering vilations in libiscsi this actually is surprisingly simple. The last two pathes contain a respin of Keith' series to refcount struct request in the eye of timeouts. Once the BLK_EH_HANDLED special case is gone this actually seems the EH fixing approach that seems the most sensible to me.
Christoph Hellwig
maintainerPATCH 1/14 libata: remove ata_scsi_timed_out
As far as I can tell this function can't even be called any more, given that ATA implements its own eh_strategy_handler with ata_scsi_error, which never calls ->eh_timed_out.
--- drivers/ata/libata-eh.c | 51 ----------------------------------------- include/linux/libata.h | 2 -- 2 files changed, 53 deletions(-)
drivers/ata/libata-eh.c +0 -51
@@ -500,57 +500,6 @@ void ata_eh_release(struct ata_port *ap)mutex_unlock (&ap->host->eh_mutex); } -/** -* ata_scsi_timed_out - SCSI layer time out callback -* @cmd: timed out SCSI command -* -* Handles SCSI layer timeout. We race with normal completion of -* the qc for @cmd. If the qc is already gone, we lose and let -* the scsi command finish (EH_HANDLED). Otherwise, the qc has -* timed out and EH should be invoked. Prevent ata_qc_complete() -* from finishing it by setting EH_SCHEDULED and return -* EH_NOT_HANDLED. -* -* TODO: kill this function once old EH is gone. -* -* LOCKING: -* Called from timer context -* -* RETURNS: -* EH_HANDLED or EH_NOT_HANDLED -*/ -enum blk_eh_timer_return ata_scsi_timed_out (struct scsi_cmnd *cmd) -{ -struct Scsi_Host *host = cmd->device->host; -struct ata_port *ap =ata_shost_to_port (host); -unsigned long flags; -struct ata_queued_cmd *qc; -enum blk_eh_timer_return ret; - -DPRINTK ("ENTER\n" ); - -if (ap->ops->error_handler) { - ret =BLK_EH_NOT_HANDLED ; - goto out; - } - - ret =BLK_EH_HANDLED ; -spin_lock_irqsave (ap->lock, flags); - qc =ata_qc_from_tag (ap, ap->link.active_tag); -if (qc) { -WARN_ON (qc->scsicmd != cmd); - qc->flags |=ATA_QCFLAG_EH_SCHEDULED ; - qc->err_mask |=AC_ERR_TIMEOUT ; - ret =BLK_EH_NOT_HANDLED ; - } -spin_unlock_irqrestore (ap->lock, flags); - - out: -DPRINTK ("EXIT, ret=%d\n" , ret); -return ret; -} -EXPORT_SYMBOL (ata_scsi_timed_out); -static void ata_eh_unload (struct ata_port *ap) {struct ata_link *link;
include/linux/libata.h +0 -2
@@ -1133,7 +1133,6 @@ extern int ata_sas_port_start(struct ata_port *ap);extern void ata_sas_port_stop (struct ata_port *ap);extern int ata_sas_slave_configure (struct scsi_device *,struct ata_port *);extern int ata_sas_queuecmd (struct scsi_cmnd *cmd,struct ata_port *ap); -extern enum blk_eh_timer_return ata_scsi_timed_out (struct scsi_cmnd *cmd);extern int sata_scr_valid (struct ata_link *link);extern int sata_scr_read (struct ata_link *link,int reg,u32 *val);extern int sata_scr_write (struct ata_link *link,int reg,u32 val);
@@ -1359,7 +1358,6 @@ extern struct device_attribute *ata_common_sdev_attrs[]; .proc_name = drv_name, \ .slave_configure = ata_scsi_slave_config, \ .slave_destroy = ata_scsi_slave_destroy, \ - .eh_timed_out = ata_scsi_timed_out, \ .bios_param = ata_std_bios_param, \ .unlock_native_capacity = ata_scsi_unlock_native_capacity, \ .sdev_attrs = ata_common_sdev_attrs
Signature · 1 line
2.17.0
Re: [PATCH 01/14] libata: remove ata_scsi_timed_out
Quoted 10 lines · Christoph Hellwig
As far as I can tell this function can't even be called any more, given that ATA implements its own
eh_strategy_handlerwithata_scsi_error, which never calls ->eh_timed_out.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/ata/libata-eh.c | 51 ----------------------------------------- include/linux/libata.h | 2 -- 2 files changed, 53 deletions(-)
Cheers,
Hannes
Christoph Hellwig
maintainerPATCH 2/14 block: rename BLK_EH_NOT_HANDLED to BLK_EH_DONE
In reply to Christoph HellwigThe BLK_EH_NOT_HANDLED implies nothing happen, but very often that is not what is happening - instead the driver already completed the command. Fix the symbolic name to reflect that a little better.
--- Documentation/scsi/scsi_eh.txt | 4 ++-- block/blk-mq.c | 2 +- block/blk-timeout.c | 2 +- drivers/block/nbd.c | 2 +- drivers/message/fusion/mptsas.c | 2 +- drivers/s390/block/dasd.c | 6 +++--- drivers/scsi/gdth.c | 2 +- drivers/scsi/libiscsi.c | 2 +- drivers/scsi/megaraid/megaraid_sas_base.c | 2 +- drivers/scsi/mvumi.c | 2 +- drivers/scsi/qla4xxx/ql4_os.c | 2 +- drivers/scsi/scsi_error.c | 4 ++-- drivers/scsi/scsi_transport_fc.c | 4 ++-- drivers/scsi/scsi_transport_srp.c | 4 ++-- drivers/scsi/ufs/ufshcd.c | 6 +++--- include/linux/blkdev.h | 2 +- include/scsi/scsi_host.h | 2 +- 17 files changed, 25 insertions(+), 25 deletions(-)
Documentation/scsi/scsi_eh.txt +2 -2
@@ -97,9 +97,9 @@ function This indicates that more time is required to finish the command. Timer is restarted. This action is counted as a retry and only allowed scmd->allowed + 1(!) times. Once the - limit is reached, action for BLK_EH_NOT_HANDLED is taken instead. + limit is reached, action for BLK_EH_DONE is taken instead. - - BLK_EH_NOT_HANDLED + - BLK_EH_DONE eh_timed_out() callback did not handle the command. Step #2 is taken.
block/blk-mq.c +1 -1
@@ -856,7 +856,7 @@ static void blk_mq_rq_timed_out(struct request *req, bool reserved)blk_mq_rq_update_aborted_gstate (req,0 );blk_add_timer (req);break ; -case BLK_EH_NOT_HANDLED : +case BLK_EH_DONE :break ;default :printk (KERN_ERR "block: bad eh return: %d\n" , ret);
block/blk-timeout.c +1 -1
@@ -93,7 +93,7 @@ static void blk_rq_timed_out(struct request *req)blk_add_timer (req);blk_clear_rq_complete (req);break ; -case BLK_EH_NOT_HANDLED : +case BLK_EH_DONE :/* * LLD handles this for now but in the future * we can send a request msg to abort the command
drivers/block/nbd.c +1 -1
@@ -328,7 +328,7 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req, }blk_mq_requeue_request (req, true);nbd_config_put (nbd); -return BLK_EH_NOT_HANDLED ; +return BLK_EH_DONE ; } }else { dev_err_ratelimited(nbd_to_dev(nbd),
drivers/message/fusion/mptsas.c +1 -1
@@ -1929,7 +1929,7 @@ static enum blk_eh_timer_return mptsas_eh_timed_out(struct scsi_cmnd *sc)MPT_SCSI_HOST *hd;MPT_ADAPTER *ioc;VirtDevice *vdevice; -enum blk_eh_timer_return rc =BLK_EH_NOT_HANDLED ; +enum blk_eh_timer_return rc =BLK_EH_DONE ; hd =shost_priv (sc->device->host);if (hd ==NULL ) {
drivers/s390/block/dasd.c +3 -3
@@ -3053,7 +3053,7 @@ static blk_status_t do_dasd_request(struct blk_mq_hw_ctx *hctx,* * Return values: * BLK_EH_RESET_TIMER if the request should be left running -* BLK_EH_NOT_HANDLED if the request is handled or terminated +* BLK_EH_DONE if the request is handled or terminated * by the driver. */ enum blk_eh_timer_return dasd_times_out (struct request *req,bool reserved)
@@ -3065,7 +3065,7 @@ enum blk_eh_timer_return dasd_times_out(struct request *req, bool reserved)int rc =0 ;if (!cqr) -return BLK_EH_NOT_HANDLED ; +return BLK_EH_DONE ;spin_lock_irqsave (&cqr->dq->lock, flags); device = cqr->startdev ? cqr->startdev : block->base;
@@ -3124,7 +3124,7 @@ enum blk_eh_timer_return dasd_times_out(struct request *req, bool reserved)spin_unlock (&block->queue_lock);spin_unlock_irqrestore (&cqr->dq->lock, flags); -return rc ?BLK_EH_RESET_TIMER :BLK_EH_NOT_HANDLED ; +return rc ?BLK_EH_RESET_TIMER :BLK_EH_DONE ; } static int dasd_init_hctx(struct blk_mq_hw_ctx *hctx, void *data,
drivers/scsi/gdth.c +1 -1
@@ -3882,7 +3882,7 @@ static enum blk_eh_timer_return gdth_timed_out(struct scsi_cmnd *scp)struct gdth_cmndinfo *cmndinfo =gdth_cmnd_priv (scp);u8 b, t;unsigned long flags; -enum blk_eh_timer_return retval =BLK_EH_NOT_HANDLED ; +enum blk_eh_timer_return retval =BLK_EH_DONE ;TRACE (("%s() cmd 0x%x\n" , scp->cmnd[0 ], __func__)); b = scp->device->channel;
drivers/scsi/libiscsi.c +1 -1
@@ -1963,7 +1963,7 @@ static int iscsi_has_ping_timed_out(struct iscsi_conn *conn)enum blk_eh_timer_return iscsi_eh_cmd_timed_out (struct scsi_cmnd *sc) { -enum blk_eh_timer_return rc =BLK_EH_NOT_HANDLED ; +enum blk_eh_timer_return rc =BLK_EH_DONE ;struct iscsi_task *task =NULL , *running_task;struct iscsi_cls_session *cls_session;struct iscsi_session *session;
drivers/scsi/megaraid/megaraid_sas_base.c +1 -1
@@ -2772,7 +2772,7 @@ blk_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)if (time_after (jiffies, scmd->jiffies_at_alloc + (scmd_timeout *2 ) *HZ )) { -return BLK_EH_NOT_HANDLED ; +return BLK_EH_DONE ; } instance = (struct megasas_instance *)scmd->device->host->hostdata;
drivers/scsi/mvumi.c +1 -1
@@ -2155,7 +2155,7 @@ static enum blk_eh_timer_return mvumi_timed_out(struct scsi_cmnd *scmd)mvumi_return_cmd (mhba, cmd);spin_unlock_irqrestore (mhba->shost->host_lock, flags); -return BLK_EH_NOT_HANDLED ; +return BLK_EH_DONE ; } static int
drivers/scsi/qla4xxx/ql4_os.c +1 -1
@@ -1848,7 +1848,7 @@ static enum blk_eh_timer_return qla4xxx_eh_cmd_timed_out(struct scsi_cmnd *sc)struct iscsi_cls_session *session;struct iscsi_session *sess;unsigned long flags; -enum blk_eh_timer_return ret =BLK_EH_NOT_HANDLED ; +enum blk_eh_timer_return ret =BLK_EH_DONE ; session =starget_to_session (scsi_target (sc->device)); sess = session->dd_data;
drivers/scsi/scsi_error.c +2 -2
@@ -282,7 +282,7 @@ void scsi_eh_scmd_add(struct scsi_cmnd *scmd)enum blk_eh_timer_return scsi_times_out (struct request *req) {struct scsi_cmnd *scmd =blk_mq_rq_to_pdu (req); -enum blk_eh_timer_return rtn =BLK_EH_NOT_HANDLED ; +enum blk_eh_timer_return rtn =BLK_EH_DONE ;struct Scsi_Host *host = scmd->device->host;trace_scsi_dispatch_cmd_timeout (scmd);
@@ -294,7 +294,7 @@ enum blk_eh_timer_return scsi_times_out(struct request *req)if (host->hostt->eh_timed_out) rtn = host->hostt->eh_timed_out (scmd); -if (rtn ==BLK_EH_NOT_HANDLED ) { +if (rtn ==BLK_EH_DONE ) {if (scsi_abort_command (scmd) !=SUCCESS ) {set_host_byte (scmd,DID_TIME_OUT );scsi_eh_scmd_add (scmd);
drivers/scsi/scsi_transport_fc.c +2 -2
@@ -2087,7 +2087,7 @@ fc_eh_timed_out(struct scsi_cmnd *scmd)if (rport->port_state ==FC_PORTSTATE_BLOCKED )return BLK_EH_RESET_TIMER ; -return BLK_EH_NOT_HANDLED ; +return BLK_EH_DONE ; }EXPORT_SYMBOL (fc_eh_timed_out);
@@ -3592,7 +3592,7 @@ fc_bsg_job_timeout(struct request *req)/* the blk_end_sync_io() doesn't check the error */ if (!inflight) -return BLK_EH_NOT_HANDLED ; +return BLK_EH_DONE ;else return BLK_EH_HANDLED ; }
drivers/scsi/scsi_transport_srp.c +2 -2
@@ -587,7 +587,7 @@ EXPORT_SYMBOL(srp_reconnect_rport);* * If a timeout occurs while an rport is in the blocked state, ask the SCSI * EH to continue waiting (BLK_EH_RESET_TIMER). Otherwise let the SCSI core -* handle the timeout (BLK_EH_NOT_HANDLED). +* handle the timeout (BLK_EH_DONE). * * Note: This function is called from soft-IRQ context and with the request * queue lock held.
@@ -602,7 +602,7 @@ enum blk_eh_timer_return srp_timed_out(struct scsi_cmnd *scmd)pr_debug ("timeout for sdev %s\n" ,dev_name (&sdev->sdev_gendev));return rport->fast_io_fail_tmo <0 && rport->dev_loss_tmo <0 && i->f->reset_timer_if_blocked &&scsi_device_blocked (sdev) ? -BLK_EH_RESET_TIMER :BLK_EH_NOT_HANDLED ; +BLK_EH_RESET_TIMER :BLK_EH_DONE ; }EXPORT_SYMBOL (srp_timed_out);
drivers/scsi/ufs/ufshcd.c +3 -3
@@ -6497,12 +6497,12 @@ static enum blk_eh_timer_return ufshcd_eh_timed_out(struct scsi_cmnd *scmd)bool found = false;if (!scmd || !scmd->device || !scmd->device->host) -return BLK_EH_NOT_HANDLED ; +return BLK_EH_DONE ; host = scmd->device->host; hba =shost_priv (host);if (!hba) -return BLK_EH_NOT_HANDLED ; +return BLK_EH_DONE ;spin_lock_irqsave (host->host_lock, flags);
@@ -6520,7 +6520,7 @@ static enum blk_eh_timer_return ufshcd_eh_timed_out(struct scsi_cmnd *scmd)* SCSI command was not actually dispatched to UFS driver, otherwise * let SCSI layer handle the error as usual. */ -return found ?BLK_EH_NOT_HANDLED :BLK_EH_RESET_TIMER ; +return found ?BLK_EH_DONE :BLK_EH_RESET_TIMER ; }static const struct attribute_group *ufshcd_driver_groups[] = {
include/linux/blkdev.h +1 -1
@@ -337,7 +337,7 @@ typedef int (init_rq_fn)(struct request_queue *, struct request *, gfp_t);typedef void (exit_rq_fn )(struct request_queue *,struct request *);enum blk_eh_timer_return { -BLK_EH_NOT_HANDLED , +BLK_EH_DONE ,BLK_EH_HANDLED ,BLK_EH_RESET_TIMER , };
include/scsi/scsi_host.h +1 -1
@@ -307,7 +307,7 @@ struct scsi_host_template {* EH_HANDLED: I fixed the error, please complete the command * EH_RESET_TIMER: I need more time, reset the timer and * begin counting again -* EH_NOT_HANDLED Begin normal error recovery +* EH_DONE: Begin normal error recovery * * Status: OPTIONAL */
Signature · 1 line
2.17.0
Re: [PATCH 02/14] block: rename BLK_EH_NOT_HANDLED to BLK_EH_DONE
Looks good,
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg GF: Felix Imend�rffer, Jane Smithard, Graham Norton HRB 21284 (AG N�rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH 02/14] block: rename BLK_EH_NOT_HANDLED to BLK_EH_DONE
In reply to Christoph HellwigQuoted 16 lines · Christoph Hellwig
The
BLK_EH_NOT_HANDLEDimplies nothing happen, but very often that is not what is happening - instead the driver already completed the command. Fix the symbolic name to reflect that a little better.Signed-off-by Christoph Hellwig <[email protected]>--- Documentation/scsi/scsi_eh.txt | 4 ++-- block/blk-mq.c | 2 +- block/blk-timeout.c | 2 +- drivers/block/nbd.c | 2 +- drivers/message/fusion/mptsas.c | 2 +- drivers/s390/block/dasd.c | 6 +++--- drivers/scsi/gdth.c | 2 +- drivers/scsi/libiscsi.c | 2 +- drivers/scsi/megaraid/megaraid_sas_base.c | 2 +- drivers/scsi/mvumi.c | 2 +-
Quoted 9 lines
drivers/scsi/qla4xxx/ql4_os.c | 2 +- drivers/scsi/scsi_error.c | 4 ++-- drivers/scsi/scsi_transport_fc.c | 4 ++-- drivers/scsi/scsi_transport_srp.c | 4 ++-- drivers/scsi/ufs/ufshcd.c | 6 +++--- include/linux/blkdev.h | 2 +- include/scsi/scsi_host.h | 2 +- 17 files changed, 25 insertions(+), 25 deletions(-)
Cheers,
Hannes
Christoph Hellwig
maintainerPATCH 3/14 nvme: return BLK_EH_DONE from ->timeout
In reply to Christoph HellwigNVMe always completes the request before returning from ->timeout, either by polling for it, or by disabling the controller. Return BLK_EH_DONE so that the block layer doesn't even try to complete it again.
--- drivers/nvme/host/pci.c | 14 +++++--------- drivers/nvme/host/rdma.c | 2 +- drivers/nvme/target/loop.c | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-)
drivers/nvme/host/pci.c +5 -9
@@ -1205,7 +1205,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)nvme_warn_reset (dev, csts);nvme_dev_disable (dev, false);nvme_reset_ctrl (&dev->ctrl); -return BLK_EH_HANDLED ; +return BLK_EH_DONE ; }/*
@@ -1215,14 +1215,14 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)dev_warn (dev->ctrl.device,"I/O %d QID %d timeout, completion polled\n" , req->tag, nvmeq->qid); -return BLK_EH_HANDLED ; +return BLK_EH_DONE ; }/* * Shutdown immediately if controller times out while starting. The * reset work will see the pci device disabled when it gets the forced * cancellation error. All outstanding requests are completed on -* shutdown, so we return BLK_EH_HANDLED. +* shutdown, so we return BLK_EH_DONE. */ switch (dev->ctrl.state) {case NVME_CTRL_CONNECTING :
@@ -1232,7 +1232,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved) req->tag, nvmeq->qid);nvme_dev_disable (dev, false);nvme_req (req)->flags |=NVME_REQ_CANCELLED ; -return BLK_EH_HANDLED ; +return BLK_EH_DONE ;default :break ; }
@@ -1249,12 +1249,8 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)nvme_dev_disable (dev, false);nvme_reset_ctrl (&dev->ctrl); -/* -* Mark the request as handled, since the inline shutdown -* forces all outstanding requests to complete. -*/ nvme_req (req)->flags |=NVME_REQ_CANCELLED ; -return BLK_EH_HANDLED ; +return BLK_EH_DONE ; }if (atomic_dec_return (&dev->ctrl.abort_limit) <0 ) {
drivers/nvme/host/rdma.c +1 -1
@@ -1598,7 +1598,7 @@ nvme_rdma_timeout(struct request *rq, bool reserved)/* fail with DNR on cmd timeout */ nvme_req (rq)->status =NVME_SC_ABORT_REQ |NVME_SC_DNR ; -return BLK_EH_HANDLED ; +return BLK_EH_DONE ; } static blk_status_t nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx,
drivers/nvme/target/loop.c +1 -1
@@ -146,7 +146,7 @@ nvme_loop_timeout(struct request *rq, bool reserved)/* fail with DNR on admin cmd timeout */ nvme_req (rq)->status =NVME_SC_ABORT_REQ |NVME_SC_DNR ; -return BLK_EH_HANDLED ; +return BLK_EH_DONE ; } static blk_status_t nvme_loop_queue_rq(struct blk_mq_hw_ctx *hctx,
Signature · 1 line
2.17.0
Re: [PATCH 03/14] nvme: return BLK_EH_DONE from ->timeout
Looks good,
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg GF: Felix Imend�rffer, Jane Smithard, Graham Norton HRB 21284 (AG N�rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH 03/14] nvme: return BLK_EH_DONE from ->timeout
In reply to Christoph HellwigQuoted 11 lines · Christoph Hellwig
NVMe always completes the request before returning from ->timeout, either by polling for it, or by disabling the controller. Return
BLK_EH_DONEso that the block layer doesn't even try to complete it again.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/nvme/host/pci.c | 14 +++++--------- drivers/nvme/host/rdma.c , | 2 +- drivers/nvme/target/loop.c | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-)
Is there a way of _testing_ this patch?
It looks pretty dodgy, just replacing BLK_EH_HANDLED with BLK_EH_NOT_HANDLED. And, as nothing else has changed, would imply that we can do it on older/stable versions, too. Which means that the original code was buggy to start with.
Hence a test here would be really beneficial.
But then, assuming you did some tests here:
Cheers,
Hannes
Christoph Hellwig
maintainerRe: [PATCH 03/14] nvme: return BLK_EH_DONE from ->timeout
Quoted 1 line · Hannes Reinecke
Is there a way of _testing_ this patch?
Use the error injection framework Johannes wrote? Use blktests (but make sure you have a fixed version of test 011).
Quoted 6 lines
It looks pretty dodgy, just replacing
BLK_EH_HANDLEDwithBLK_EH_NOT_HANDLED.
And, as nothing else has changed, would imply that we can do it on older/stable versions, too.
Which means that the original code was buggy to start with. Hence a test here would be really beneficial.
NVMe always completed the requests itself, so not too much changed.
Re: [PATCH 03/14] nvme: return BLK_EH_DONE from ->timeout
In reply to Christoph HellwigQuoted 93 lines · Christoph Hellwig
NVMe always completes the request before returning from ->timeout, either by polling for it, or by disabling the controller. Return
BLK_EH_DONEso that the block layer doesn't even try to complete it again.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/nvme/host/pci.c | 14 +++++--------- drivers/nvme/host/rdma.c | 2 +- drivers/nvme/target/loop.c | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-)drivers/nvme/host/pci.c +5
-9@@ -1205,7 +1205,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)nvme_warn_reset (dev, csts);nvme_dev_disable (dev, false);nvme_reset_ctrl (&dev->ctrl); -return BLK_EH_HANDLED ; +return BLK_EH_DONE ; }/* @@ -1215,14 +1215,14 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)dev_warn (dev->ctrl.device,"I/O %d QID %d timeout, completion polled\n" , req->tag, nvmeq->qid); -return BLK_EH_HANDLED ; +return BLK_EH_DONE ; }/* * Shutdown immediately if controller times out while starting. The * reset work will see the pci device disabled when it gets the forced * cancellation error. All outstanding requests are completed on -* shutdown, so we return BLK_EH_HANDLED. +* shutdown, so we return BLK_EH_DONE. */ switch (dev->ctrl.state) {case NVME_CTRL_CONNECTING :@@ -1232,7 +1232,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved) req->tag, nvmeq->qid);nvme_dev_disable (dev, false);nvme_req (req)->flags |=NVME_REQ_CANCELLED ; -return BLK_EH_HANDLED ; +return BLK_EH_DONE ;default :break ; }@@ -1249,12 +1249,8 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)nvme_dev_disable (dev, false);nvme_reset_ctrl (&dev->ctrl); -/* -* Mark the request as handled, since the inline shutdown -* forces all outstanding requests to complete. -*/ nvme_req (req)->flags |=NVME_REQ_CANCELLED ; -return BLK_EH_HANDLED ; +return BLK_EH_DONE ; }if (atomic_dec_return (&dev->ctrl.abort_limit) <0 ) {drivers/nvme/host/rdma.c +1
-1@@ -1598,7 +1598,7 @@ nvme_rdma_timeout(struct request *rq, bool reserved)/* fail with DNR on cmd timeout */ nvme_req (rq)->status =NVME_SC_ABORT_REQ |NVME_SC_DNR ; -return BLK_EH_HANDLED ; +return BLK_EH_DONE ; } static blk_status_t nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx,drivers/nvme/target/loop.c +1
-1@@ -146,7 +146,7 @@ nvme_loop_timeout(struct request *rq, bool reserved)/* fail with DNR on admin cmd timeout */ nvme_req (rq)->status =NVME_SC_ABORT_REQ |NVME_SC_DNR ; -return BLK_EH_HANDLED ; +return BLK_EH_DONE ; } static blk_status_t nvme_loop_queue_rq(struct blk_mq_hw_ctx *hctx,Signature · 1 line
2.17.0
This change should have been done after '[PATCH 13/14] blk-mq: Remove generation seqeunce', otherwise the timed-out request won't be completed by nvme_cancel_request() at all because we always marked this request as 'COMPLETE' before calling .timeout().
Thanks,
Ming
Christoph Hellwig
maintainerRe: [PATCH 03/14] nvme: return BLK_EH_DONE from ->timeout
Quoted 4 lines · Ming Lei
This change should have been done after '[PATCH 13/14] blk-mq: Remove generation seqeunce', otherwise the timed-out request won't be completed by
nvme_cancel_request()at all because we always marked this request as 'COMPLETE' before calling .timeout().
Yes. Or we should start out with reverting the whole series introducing the gstate. I think it has shown to create much more problems than it solved, and starting from a clean state without it will allow us to iterate much saner.
Re: [PATCH 03/14] nvme: return BLK_EH_DONE from ->timeout
Quoted 10 lines · Christoph Hellwig
Quoted 4 lines · Ming Lei
This change should have been done after '[PATCH 13/14] blk-mq: Remove generation seqeunce', otherwise the timed-out request won't be completed by
nvme_cancel_request()at all because we always marked this request as 'COMPLETE' before calling .timeout().Yes. Or we should start out with reverting the whole series introducing the gstate. I think it has shown to create much more problems than it solved, and starting from a clean state without it will allow us to iterate much saner.
It may not help for this case by reverting the series introducing the gstate.
This behaviour has been used from the beginning, such as, the code becomes the following after the revert:
if (!blk_mark_rq_complete(rq))
blk_mq_rq_timed_out(rq, reserved);Given the patch 13("blk-mq: Remove generation seqeunce") is the 1st one to change the behaviour, we should put this patch and other related ones after patch 13 for avoiding to break 'git bisect'.
Thanks,
Ming
Christoph Hellwig
maintainerPATCH 4/14 nbd: complete requests from ->timeout
In reply to Christoph HellwigBy completing the request entirely in the driver we can remove the BLK_EH_HANDLED return value and thus the split responsibility between the driver and the block layer that has been causing trouble.
--- drivers/block/nbd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/block/nbd.c +4 -3
@@ -300,7 +300,7 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,if (!refcount_inc_not_zero (&nbd->config_refs)) { cmd->status =BLK_STS_TIMEOUT ; -return BLK_EH_HANDLED ; + goto done; } config = nbd->config;
@@ -338,8 +338,9 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req, cmd->status =BLK_STS_IOERR ;sock_shutdown (nbd);nbd_config_put (nbd); - -return BLK_EH_HANDLED ; +done: +blk_mq_complete_request (req); +return BLK_EH_DONE ; }/*
Signature · 1 line
2.17.0
Re: [PATCH 04/14] nbd: complete requests from ->timeout
Quoted 25 lines · Christoph Hellwig
By completing the request entirely in the driver we can remove the
BLK_EH_HANDLEDreturn value and thus the split responsibility between the driver and the block layer that has been causing trouble.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/block/nbd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/block/nbd.c +1
-1@@ -300,7 +300,7 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,if (!refcount_inc_not_zero (&nbd->config_refs)) { cmd->status =BLK_STS_TIMEOUT ; -return BLK_EH_HANDLED ; + goto done; } config = nbd->config;@@ -338,8 +338,9 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req, cmd->status =BLK_STS_IOERR ;
drivers/block/nbd.c static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req, · line 346
Quoted 10 lines
drivers/block/nbd.c +3
-2sock_shutdown (nbd);nbd_config_put (nbd); - -return BLK_EH_HANDLED ; +done: +blk_mq_complete_request (req); +return BLK_EH_DONE ; }/*
Again, some testcase would be nice ...
Cheers,
Hannes
Christoph Hellwig
maintainerRe: [PATCH 04/14] nbd: complete requests from ->timeout
Quoted 1 line · Hannes Reinecke
Again, some testcase would be nice ...
For this one I don't have an actual test case. I'll have to defer to the nbd maintainers for that.
Christoph Hellwig
maintainerPATCH 5/14 mtip32xx: complete requests from ->timeout
In reply to Christoph HellwigBy completing the request entirely in the driver we can remove the BLK_EH_HANDLED return value and thus the split responsibility between the driver and the block layer that has been causing trouble.
--- drivers/block/mtip32xx/mtip32xx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/mtip32xx/mtip32xx.c +2 -1
@@ -3720,7 +3720,8 @@ static enum blk_eh_timer_return mtip_cmd_timeout(struct request *req,struct mtip_cmd *cmd =blk_mq_rq_to_pdu (req); cmd->status =BLK_STS_TIMEOUT ; -return BLK_EH_HANDLED ; +blk_mq_complete_request (req); +return BLK_EH_DONE ; }if (test_bit (req->tag, dd->port->cmds_to_issue))
Signature · 1 line
2.17.0
Re: [PATCH 05/14] mtip32xx: complete requests from ->timeout
Looks good,
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg GF: Felix Imend�rffer, Jane Smithard, Graham Norton HRB 21284 (AG N�rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH 05/14] mtip32xx: complete requests from ->timeout
In reply to Christoph HellwigQuoted 15 lines · Christoph Hellwig
By completing the request entirely in the driver we can remove the
BLK_EH_HANDLEDreturn value and thus the split responsibility between the driver and the block layer that has been causing trouble.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/block/mtip32xx/mtip32xx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/block/mtip32xx/mtip32xx.c +0
-0
drivers/block/mtip32xx/mtip32xx.c static enum blk_eh_timer_return mtip_cmd_timeout(struct request *req, · line 3727
Quoted 9 lines
drivers/block/mtip32xx/mtip32xx.c +2
-1@@ -3720,7 +3720,8 @@ static enum blk_eh_timer_return mtip_cmd_timeout(struct request *req,struct mtip_cmd *cmd =blk_mq_rq_to_pdu (req); cmd->status =BLK_STS_TIMEOUT ; -return BLK_EH_HANDLED ; +blk_mq_complete_request (req); +return BLK_EH_DONE ; }if (test_bit (req->tag, dd->port->cmds_to_issue))
Cheers,
Hannes
Christoph Hellwig
maintainerPATCH 6/14 null_blk: complete requests from ->timeout
In reply to Christoph HellwigBy completing the request entirely in the driver we can remove the BLK_EH_HANDLED return value and thus the split responsibility between the driver and the block layer that has been causing trouble.
--- drivers/block/null_blk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/block/null_blk.c +4 -2
@@ -1365,7 +1365,8 @@ static blk_qc_t null_queue_bio(struct request_queue *q, struct bio *bio)static enum blk_eh_timer_return null_rq_timed_out_fn (struct request *rq) {pr_info ("null: rq %p timed out\n" , rq); -return BLK_EH_HANDLED ; +blk_mq_complete_request (rq); +return BLK_EH_DONE ; }static int null_rq_prep_fn (struct request_queue *q,struct request *req)
@@ -1427,7 +1428,8 @@ static void null_request_fn(struct request_queue *q)static enum blk_eh_timer_return null_timeout_rq (struct request *rq,bool res) {pr_info ("null: rq %p timed out\n" , rq); -return BLK_EH_HANDLED ; +blk_mq_complete_request (rq); +return BLK_EH_DONE ; } static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx,
Signature · 1 line
2.17.0
Re: [PATCH 06/14] null_blk: complete requests from ->timeout
Looks good,
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg GF: Felix Imend�rffer, Jane Smithard, Graham Norton HRB 21284 (AG N�rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH 06/14] null_blk: complete requests from ->timeout
In reply to Christoph HellwigQuoted 9 lines · Christoph Hellwig
By completing the request entirely in the driver we can remove the
BLK_EH_HANDLEDreturn value and thus the split responsibility between the driver and the block layer that has been causing trouble.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/block/null_blk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Cheers,
Hannes
Christoph Hellwig
maintainerPATCH 7/14 scsi_transport_fc: complete requests from ->timeout
In reply to Christoph HellwigBy completing the request entirely in the driver we can remove the BLK_EH_HANDLED return value and thus the split responsibility between the driver and the block layer that has been causing trouble.
--- drivers/scsi/scsi_transport_fc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/scsi/scsi_transport_fc.c +3 -4
@@ -3591,10 +3591,9 @@ fc_bsg_job_timeout(struct request *req) }/* the blk_end_sync_io() doesn't check the error */ -if (!inflight) -return BLK_EH_DONE ; -else -return BLK_EH_HANDLED ; +if (inflight) +blk_mq_complete_request (req); +return BLK_EH_DONE ; }/**
Signature · 1 line
2.17.0
Re: [PATCH 07/14] scsi_transport_fc: complete requests from ->timeout
Looks good,
Signature · 6 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N�rnberg GF: Felix Imend�rffer, Jane Smithard, Graham Norton HRB 21284 (AG N�rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Re: [PATCH 07/14] scsi_transport_fc: complete requests from ->timeout
In reply to Christoph HellwigQuoted 18 lines · Christoph Hellwig
By completing the request entirely in the driver we can remove the
BLK_EH_HANDLEDreturn value and thus the split responsibility between the driver and the block layer that has been causing trouble.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/scsi/scsi_transport_fc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/scsi/scsi_transport_fc.c +0
-0@@ -3591,10 +3591,9 @@ fc_bsg_job_timeout(struct request *req) }/* the blk_end_sync_io() doesn't check the error */
drivers/scsi/scsi_transport_fc.c fc_bsg_job_timeout(struct request *req) · line 3599
Quoted 10 lines
drivers/scsi/scsi_transport_fc.c +3
-4-if (!inflight) -return BLK_EH_DONE ; -else -return BLK_EH_HANDLED ; +if (inflight) +blk_mq_complete_request (req); +return BLK_EH_DONE ; }/**
Cheers,
Hannes
Christoph Hellwig
maintainerPATCH 8/14 mmc: complete requests from ->timeout
In reply to Christoph HellwigBy completing the request entirely in the driver we can remove the BLK_EH_HANDLED return value and thus the split responsibility between the driver and the block layer that has been causing trouble.
[While this keeps existing behavior it seems to mismatch the comment,
maintainers please chime in!]
--- drivers/mmc/core/queue.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/mmc/core/queue.c +3 -2
@@ -111,8 +111,9 @@ static enum blk_eh_timer_return mmc_cqe_timed_out(struct request *req)__mmc_cqe_recovery_notifier (mq);return BLK_EH_RESET_TIMER ; } -/* No timeout */ -return BLK_EH_HANDLED ; +/* No timeout (XXX: huh? comment doesn't make much sense) */ +blk_mq_complete_request (req); +return BLK_EH_DONE ;default :/* Timeout is handled by mmc core */ return BLK_EH_RESET_TIMER ;
Signature · 1 line
2.17.0
Re: [PATCH 08/14] mmc: complete requests from ->timeout
Quoted 19 lines · Christoph Hellwig
By completing the request entirely in the driver we can remove the
BLK_EH_HANDLEDreturn value and thus the split responsibility between the driver and the block layer that has been causing trouble.[While this keeps existing behavior it seems to mismatch the comment,
maintainers please chime in!]Signed-off-by Christoph Hellwig <[email protected]>--- drivers/mmc/core/queue.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/mmc/core/queue.c +0
-0@@ -111,8 +111,9 @@ static enum blk_eh_timer_return mmc_cqe_timed_out(struct request *req)__mmc_cqe_recovery_notifier (mq);
drivers/mmc/core/queue.c static enum blk_eh_timer_return mmc_cqe_timed_out(struct request *req) · line 119
Quoted 10 lines
drivers/mmc/core/queue.c +3
-2return BLK_EH_RESET_TIMER ; } -/* No timeout */ -return BLK_EH_HANDLED ; +/* No timeout (XXX: huh? comment doesn't make much sense) */ +blk_mq_complete_request (req); +return BLK_EH_DONE ;default :/* Timeout is handled by mmc core */ return BLK_EH_RESET_TIMER ;
Cheers,
Hannes
Christoph Hellwig
maintainerPATCH 9/14 libiscsi: don't try to bypass SCSI EH
In reply to Christoph Hellwiglibiscsi is the only SCSI code that return BLK_EH_HANDLED, thus trying to bypass the normal SCSI EH code. We are going to remove this return value at the block layer, and at least from a quick look it doesn't look too harmful to try to send an abort for these cases, especially as the first one should not actually be possible. If this doesn't work out iscsi will probably need its own eh_strategy_handler instead to just do the right thing.
--- drivers/scsi/libiscsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/libiscsi.c +2 -2
@@ -1982,7 +1982,7 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)* Raced with completion. Blk layer has taken ownership * so let timeout code complete it now. */ - rc =BLK_EH_HANDLED ; + rc =BLK_EH_DONE ; goto done; }
@@ -1997,7 +1997,7 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)if (unlikely (system_state !=SYSTEM_RUNNING )) { sc->result =DID_NO_CONNECT <<16 ;ISCSI_DBG_EH (session,"sc on shutdown, handled\n" ); - rc =BLK_EH_HANDLED ; + rc =BLK_EH_DONE ; goto done; }/*
Signature · 1 line
2.17.0
Re: [PATCH 09/14] libiscsi: don't try to bypass SCSI EH
Quoted 28 lines · Christoph Hellwig
libiscsi is the only SCSI code that return
BLK_EH_HANDLED, thus trying to bypass the normal SCSI EH code. We are going to remove this return value at the block layer, and at least from a quick look it doesn't look too harmful to try to send an abort for these cases, especially as the first one should not actually be possible. If this doesn't work out iscsi will probably need its owneh_strategy_handlerinstead to just do the right thing.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/scsi/libiscsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/scsi/libiscsi.c +1
-1@@ -1982,7 +1982,7 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)* Raced with completion. Blk layer has taken ownership * so let timeout code complete it now. */ - rc =BLK_EH_HANDLED ; + rc =BLK_EH_DONE ; goto done; }
drivers/scsi/libiscsi.c enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc) · line 2003
Quoted 8 lines
drivers/scsi/libiscsi.c +1
-1@@ -1997,7 +1997,7 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)if (unlikely (system_state !=SYSTEM_RUNNING )) { sc->result =DID_NO_CONNECT <<16 ;ISCSI_DBG_EH (session,"sc on shutdown, handled\n" ); - rc =BLK_EH_HANDLED ; + rc =BLK_EH_DONE ; goto done; }/*
That should be okay, as these two returns are the pathological case where the command has already completed before the timeout handler got invoked. IE the very same issue which triggered this patchset in the first place.
Cheers,
Hannes
Christoph Hellwig
maintainerPATCH 10/14 block: remove BLK_EH_HANDLED
In reply to Christoph Hellwig--- Documentation/scsi/scsi_eh.txt | 11 ----------- block/blk-mq.c | 3 --- block/blk-timeout.c | 3 --- include/linux/blkdev.h | 1 - 4 files changed, 18 deletions(-)
Documentation/scsi/scsi_eh.txt +0 -11
@@ -82,17 +82,6 @@ function 1. invokes optional hostt->eh_timed_out() callback. Return value can be one of - - BLK_EH_HANDLED - This indicates that eh_timed_out() dealt with the timeout. - The command is passed back to the block layer and completed - via __blk_complete_requests(). - - *NOTE* After returning BLK_EH_HANDLED the SCSI layer is - assumed to be finished with the command, and no other - functions from the SCSI layer will be called. So this - should typically only be returned if the eh_timed_out() - handler raced with normal completion. - - BLK_EH_RESET_TIMER This indicates that more time is required to finish the command. Timer is restarted. This action is counted as a
block/blk-mq.c +0 -3
@@ -844,9 +844,6 @@ static void blk_mq_rq_timed_out(struct request *req, bool reserved) ret = ops->timeout (req, reserved);switch (ret) { -case BLK_EH_HANDLED : -__blk_mq_complete_request (req); -break ;case BLK_EH_RESET_TIMER :/* * As nothing prevents from completion happening while
block/blk-timeout.c +0 -3
@@ -86,9 +86,6 @@ static void blk_rq_timed_out(struct request *req)if (q->rq_timed_out_fn) ret = q->rq_timed_out_fn (req);switch (ret) { -case BLK_EH_HANDLED : -__blk_complete_request (req); -break ;case BLK_EH_RESET_TIMER :blk_add_timer (req);blk_clear_rq_complete (req);
include/linux/blkdev.h +0 -1
@@ -338,7 +338,6 @@ typedef void (exit_rq_fn)(struct request_queue *, struct request *);enum blk_eh_timer_return {BLK_EH_DONE , -BLK_EH_HANDLED ,BLK_EH_RESET_TIMER , };
Signature · 1 line
2.17.0
Re: [PATCH 10/14] block: remove BLK_EH_HANDLED
Quoted 8 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>--- Documentation/scsi/scsi_eh.txt | 11 ----------- block/blk-mq.c | 3 --- block/blk-timeout.c | 3 --- include/linux/blkdev.h | 1 - 4 files changed, 18 deletions(-)
Cheers,
Hannes
Christoph Hellwig
maintainerPATCH 11/14 block: document the blk_eh_timer_return values
In reply to Christoph Hellwig--- include/linux/blkdev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/blkdev.h +2 -2
@@ -337,8 +337,8 @@ typedef int (init_rq_fn)(struct request_queue *, struct request *, gfp_t);typedef void (exit_rq_fn )(struct request_queue *,struct request *);enum blk_eh_timer_return { -BLK_EH_DONE , -BLK_EH_RESET_TIMER , +BLK_EH_DONE ,/* drivers has completed the command */ +BLK_EH_RESET_TIMER ,/* reset timer and try again */ };typedef enum blk_eh_timer_return (rq_timed_out_fn )(struct request *);
Signature · 1 line
2.17.0
Re: [PATCH 11/14] block: document the blk_eh_timer_return values
Quoted 11 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>--- include/linux/blkdev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)include/linux/blkdev.h +0
-0
include/linux/blkdev.h typedef int (init_rq_fn)(struct request_queue *, struct request *, gfp_t); · line 344
Quoted 10 lines
include/linux/blkdev.h +2
-2@@ -337,8 +337,8 @@ typedef int (init_rq_fn)(struct request_queue *, struct request *, gfp_t);typedef void (exit_rq_fn )(struct request_queue *,struct request *);enum blk_eh_timer_return { -BLK_EH_DONE , -BLK_EH_RESET_TIMER , +BLK_EH_DONE ,/* drivers has completed the command */ +BLK_EH_RESET_TIMER ,/* reset timer and try again */ };typedef enum blk_eh_timer_return (rq_timed_out_fn )(struct request *);
Cheers,
Hannes
Christoph Hellwig
maintainerPATCH 12/14 blk-mq: Fix timeout and state order
In reply to Christoph HellwigFrom: Keith Busch <[email protected]>
The block layer had been setting the state to in-flight prior to updating the timer. This is the wrong order since the timeout handler could observe the in-flight state with the older timeout, believing the request had expired when in fact it is just getting started.
--- block/blk-mq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/blk-mq.c +1 -1
@@ -697,8 +697,8 @@ void blk_mq_start_request(struct request *rq)preempt_disable ();write_seqcount_begin (&rq->gstate_seq); -blk_mq_rq_update_state (rq,MQ_RQ_IN_FLIGHT );blk_add_timer (rq); +blk_mq_rq_update_state (rq,MQ_RQ_IN_FLIGHT );write_seqcount_end (&rq->gstate_seq);preempt_enable ();
Signature · 1 line
2.17.0
Re: [PATCH 12/14] blk-mq: Fix timeout and state order
Quoted 18 lines · Christoph Hellwig
From: Keith Busch <[email protected]>
The block layer had been setting the state to in-flight prior to updating the timer. This is the wrong order since the timeout handler could observe the in-flight state with the older timeout, believing the request had expired when in fact it is just getting started.
Signed-off-by Keith Busch <[email protected]>--- block/blk-mq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/blk-mq.c +0
-0
block/blk-mq.c void blk_mq_start_request(struct request *rq) · line 704
Quoted 9 lines
block/blk-mq.c +1
-1@@ -697,8 +697,8 @@ void blk_mq_start_request(struct request *rq)preempt_disable ();write_seqcount_begin (&rq->gstate_seq); -blk_mq_rq_update_state (rq,MQ_RQ_IN_FLIGHT );blk_add_timer (rq); +blk_mq_rq_update_state (rq,MQ_RQ_IN_FLIGHT );write_seqcount_end (&rq->gstate_seq);preempt_enable ();
Cheers,
Hannes
Christoph Hellwig
maintainerPATCH 13/14 blk-mq: Remove generation seqeunce
In reply to Christoph HellwigFrom: Keith Busch <[email protected]>
This patch simplifies the timeout handling by relying on the request reference counting to ensure the iterator is operating on an inflight and truly timed out request. Since the reference counting prevents the tag from being reallocated, the block layer no longer needs to prevent drivers from completing their requests while the timeout handler is operating on it: a driver completing a request is allowed to proceed to the next state without additional syncronization with the block layer.
This also removes any need for generation sequence numbers since the request lifetime is prevented from being reallocated as a new sequence while timeout handling is operating on it.
To enables this a refcount is added to struct request so that request users can be sure they're operating on the same request without it changing while they're processing it. The request's tag won't be released for reuse until both the timeout handler and the completion are done with it.
[hch: slight cleanups]
--- block/blk-core.c | 6 - block/blk-mq-debugfs.c | 1 - block/blk-mq.c | 318 +++++++++++------------------------------ block/blk-mq.h | 42 +----- block/blk-timeout.c | 1 - include/linux/blkdev.h | 35 ++--- 6 files changed, 98 insertions(+), 305 deletions(-)
block/blk-core.c +0 -6
@@ -198,12 +198,6 @@ void blk_rq_init(struct request_queue *q, struct request *rq) rq->internal_tag =-1 ; rq->start_time_ns =ktime_get_ns (); rq->part =NULL ; -seqcount_init (&rq->gstate_seq); -u64_stats_init (&rq->aborted_gstate_sync); -/* -* See comment of blk_mq_init_request -*/ -WRITE_ONCE (rq->gstate,MQ_RQ_GEN_INC ); }EXPORT_SYMBOL (blk_rq_init);
block/blk-mq-debugfs.c +0 -1
@@ -344,7 +344,6 @@ static const char *const rqf_name[] = {RQF_NAME (STATS ),RQF_NAME (SPECIAL_PAYLOAD ),RQF_NAME (ZONE_WRITE_LOCKED ), -RQF_NAME (MQ_TIMEOUT_EXPIRED ), RQF_NAME(MQ_POLL_SLEPT), };#undef RQF_NAME
block/blk-mq.c +84 -234
480 lines not on this page · raw message
block/blk-mq.h +2 -40
55 lines not on this page · raw message
block/blk-timeout.c +0 -1
@@ -211,7 +211,6 @@ void blk_add_timer(struct request *req) req->timeout = q->rq_timeout;blk_rq_set_deadline (req, jiffies + req->timeout); - req->rq_flags &= ~RQF_MQ_TIMEOUT_EXPIRED ;/* * Only the non-mq case needs to add the request to a protected list.
include/linux/blkdev.h +12 -23
@@ -125,15 +125,22 @@ typedef __u32 __bitwise req_flags_t;#define RQF_SPECIAL_PAYLOAD ((__force req_flags_t)(1 << 18))/* The per-zone write lock is held for this request */ #define RQF_ZONE_WRITE_LOCKED ((__force req_flags_t)(1 << 19)) -/* timeout is expired */ -#define RQF_MQ_TIMEOUT_EXPIRED ((__force req_flags_t)(1 << 20))/* already slept for hybrid poll */ -#define RQF_MQ_POLL_SLEPT ((__force req_flags_t)(1 << 21)) +#define RQF_MQ_POLL_SLEPT ((__force req_flags_t)(1 << 20))/* flags that prevent us from merging requests: */ #define RQF_NOMERGE_FLAGS \ (RQF_STARTED | RQF_SOFTBARRIER | RQF_FLUSH_SEQ | RQF_SPECIAL_PAYLOAD) +/* +* Request state for blk-mq. +*/ +enum mq_rq_state { +MQ_RQ_IDLE =0 , +MQ_RQ_IN_FLIGHT =1 , +MQ_RQ_COMPLETE =2 , +}; +/* * Try to put the fields that are referenced together in the same cacheline. *
@@ -236,26 +243,8 @@ struct request {unsigned int extra_len;/* length of alignment and padding */ -/* -* On blk-mq, the lower bits of ->gstate (generation number and -* state) carry the MQ_RQ_* state value and the upper bits the -* generation number which is monotonically incremented and used to -* distinguish the reuse instances. -* -* ->gstate_seq allows updates to ->gstate and other fields -* (currently ->deadline) during request start to be read -* atomically from the timeout path, so that it can operate on a -* coherent set of information. -*/ -seqcount_t gstate_seq; -u64 gstate; - -/* -* ->aborted_gstate is used by the timeout to claim a specific -* recycle instance of this request. See blk_mq_timeout_work(). -*/ -struct u64_stats_sync aborted_gstate_sync; -u64 aborted_gstate; +enum mq_rq_state state; +refcount_t ref;/* access through blk_rq_set_deadline, blk_rq_deadline */ unsigned long __deadline;
Signature · 1 line
2.17.0
Re: [PATCH 13/14] blk-mq: Remove generation seqeunce
Quoted 9 lines · Christoph Hellwig
block/blk-mq.c +0
-9-static void hctx_unlock (struct blk_mq_hw_ctx *hctx,int srcu_idx) - __releases(hctx->srcu) -{ -if (!(hctx->flags &BLK_MQ_F_BLOCKING )) -rcu_read_unlock (); -else -srcu_read_unlock (hctx->srcu, srcu_idx); -} -
block/blk-mq.c static void __blk_mq_complete_request(struct request *rq) · line 594
Quoted 10 lines
block/blk-mq.c +0
-10-static void hctx_lock (struct blk_mq_hw_ctx *hctx,int *srcu_idx) - __acquires(hctx->srcu) -{ -if (!(hctx->flags &BLK_MQ_F_BLOCKING )) { -/* shut up gcc false positive */ - *srcu_idx =0 ; -rcu_read_lock (); - }else - *srcu_idx =srcu_read_lock (hctx->srcu); -}
I may have too ambitious on removing hctx_lock. That's actually nothing to do with the completion issues, but it is necessary for quiesce to work reliably. Otherwise, I still think there is some promise to the reset of the approach.
Christoph Hellwig
maintainerPATCH 14/14 blk-mq: simplify blk_mq_rq_timed_out
In reply to Christoph Hellwig--- block/blk-mq.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
block/blk-mq.c +8 -14
@@ -747,22 +747,16 @@ EXPORT_SYMBOL(blk_mq_tag_to_rq);static void blk_mq_rq_timed_out (struct request *req,bool reserved) { -const struct blk_mq_ops *ops = req->q->mq_ops; -enum blk_eh_timer_return ret =BLK_EH_RESET_TIMER ; +if (req->q->mq_ops->timeout) { +enum blk_eh_timer_return ret; -if (ops->timeout) - ret = ops->timeout (req, reserved); - -switch (ret) { -case BLK_EH_RESET_TIMER : -blk_add_timer (req); -break ; -case BLK_EH_DONE : -break ; -default : -printk (KERN_ERR "block: bad eh return: %d\n" , ret); -break ; + ret = req->q->mq_ops->timeout (req, reserved); +if (ret ==BLK_EH_DONE ) +return ; +WARN_ON_ONCE (ret !=BLK_EH_RESET_TIMER ); } + +blk_add_timer (req); }static bool blk_mq_req_expired (struct request *rq,unsigned long *next)
Signature · 1 line
2.17.0
Quoted 10 lines · Christoph Hellwig
Hi all,
this series removes the
BLK_EH_HANDLEDreturn value, and instead places responsibility of timed out commands entirely on the drivers. Except for some odd layering vilations in libiscsi this actually is surprisingly simple. The last two pathes contain a respin of Keith' series to refcount struct request in the eye of timeouts. Once theBLK_EH_HANDLEDspecial case is gone this actually seems the EH fixing approach that seems the most sensible to me.
YES!
Cheers,
Hannes