kill req->errors V4
Subsystems (21)
Christoph Hellwig
maintainerCurrently the request structure has an errors field that is used in various different ways. The oldest drivers use it as an error count, blk-mq and the generic timeout code assume that it holds a Linux errno for block completions, and various drivers use it for internal status values, often overwriting them with Linux errnos later, that is unless they are processing passthrough requests in which case they'll leave their errors in it.
This series kills the ->errors field and replaced it with new fields in the drivers (or an odd hack in a union in struct request for two bitrotting old drivers).
Also available in the following git tree:
git://git.infradead.org/users/hch/block.git request-errors
Gitweb:
http://git.infradead.org/users/hch/block.git/shortlog/refs/heads/request-errors
Changes since V3:
- SCSI OSD fix
- Various Reviewed-by: tags
Changes since V2;
- reorder one patch to be earlier in the series
- fix the argument to a bsg dprintk
- fix a kerneldoc comment
Changes since V1:
- rebased on top the latest block for-next tree
- fix error handling in nfsd blocklayout
- dropped "scsi: fix fast-fail for non-passthrough requests"
Christoph Hellwig
maintainerPATCH 1/23 pd: don't check blk_execute_rq return value.
The driver never sets req->errors, so blk_execute_rq will always return 0.
--- drivers/block/paride/pd.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/block/paride/pd.c +2 -5
@@ -739,18 +739,15 @@ static int pd_special_command(struct pd_unit *disk, enum action (*func)(struct pd_unit *disk)) {struct request *rq; -int err =0 ; rq =blk_get_request (disk->gd->queue,REQ_OP_DRV_IN , __GFP_RECLAIM);if (IS_ERR (rq))return PTR_ERR (rq); rq->special = func; - - err =blk_execute_rq (disk->gd->queue, disk->gd, rq,0 ); - +blk_execute_rq (disk->gd->queue, disk->gd, rq,0 );blk_put_request (rq); -return err; +return 0 ; }/* kernel glue structures */
Signature · 1 line
2.11.0
Re: [PATCH 01/23] pd: don't check blk_execute_rq return value.
Quoted 5 lines · Christoph Hellwig
The driver never sets
req->errors, soblk_execute_rqwill always return 0.Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Bart Van Assche <[email protected]>---
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
Christoph Hellwig
maintainerPATCH 2/23 block: remove the blk_execute_rq return value
In reply to Christoph HellwigThe function only returns -EIO if rq->errors is non-zero, which is not very useful and lets a large number of callers ignore the return value.
Just let the callers figure out their error themselves.
--- block/blk-exec.c | 8 +------- block/scsi_ioctl.c | 3 ++- drivers/block/virtio_blk.c | 3 ++- drivers/cdrom/cdrom.c | 3 ++- drivers/ide/ide-atapi.c | 3 ++- drivers/ide/ide-cd.c | 3 ++- drivers/ide/ide-cd_ioctl.c | 3 ++- drivers/ide/ide-devsets.c | 4 ++-- drivers/ide/ide-disk.c | 3 +-- drivers/ide/ide-ioctls.c | 7 ++++--- drivers/ide/ide-park.c | 3 ++- drivers/ide/ide-pm.c | 3 ++- drivers/ide/ide-taskfile.c | 4 ++-- drivers/scsi/osd/osd_initiator.c | 5 ++++- fs/nfsd/blocklayout.c | 5 +++-- include/linux/blkdev.h | 2 +- 16 files changed, 34 insertions(+), 28 deletions(-)
block/blk-exec.c +1 -7
@@ -92,11 +92,10 @@ EXPORT_SYMBOL_GPL(blk_execute_rq_nowait);* Insert a fully prepared request at the back of the I/O scheduler queue * for execution and wait for completion. */ -int blk_execute_rq (struct request_queue *q,struct gendisk *bd_disk, +void blk_execute_rq (struct request_queue *q,struct gendisk *bd_disk,struct request *rq,int at_head) {DECLARE_COMPLETION_ONSTACK (wait); -int err =0 ;unsigned long hang_check; rq->end_io_data = &wait;
@@ -108,10 +107,5 @@ int blk_execute_rq(struct request_queue *q, struct gendisk *bd_disk,while (!wait_for_completion_io_timeout (&wait, hang_check * (HZ /2 ))); else wait_for_completion_io(&wait); - -if (rq->errors) - err = -EIO ; - -return err; }EXPORT_SYMBOL (blk_execute_rq);
block/scsi_ioctl.c +2 -1
@@ -547,7 +547,8 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk,scsi_req (rq)->cmd[0 ] = cmd;scsi_req (rq)->cmd[4 ] = data;scsi_req (rq)->cmd_len =6 ; - err =blk_execute_rq (q, bd_disk, rq,0 ); +blk_execute_rq (q, bd_disk, rq,0 ); + err = rq->errors ? -EIO :0 ;blk_put_request (rq);return err;
drivers/block/virtio_blk.c +2 -1
@@ -310,7 +310,8 @@ static int virtblk_get_id(struct gendisk *disk, char *id_str)if (err) goto out; - err =blk_execute_rq (vblk->disk->queue, vblk->disk, req, false); +blk_execute_rq (vblk->disk->queue, vblk->disk, req, false); + err = req->errors ? -EIO :0 ; out:blk_put_request (req);return err;
drivers/cdrom/cdrom.c +2 -1
@@ -2218,7 +2218,8 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf, rq->timeout =60 *HZ ; bio = rq->bio; -if (blk_execute_rq (q, cdi->disk, rq,0 )) { +blk_execute_rq (q, cdi->disk, rq,0 ); +if (rq->errors) {struct request_sense *s = req->sense; ret = -EIO ; cdi->last_sense = s->sense_key;
drivers/ide/ide-atapi.c +2 -1
@@ -107,7 +107,8 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,memcpy (scsi_req (rq)->cmd, pc->c,12 );if (drive->media == ide_tape)scsi_req (rq)->cmd[13 ] =REQ_IDETAPE_PC1 ; - error =blk_execute_rq (drive->queue, disk, rq,0 ); +blk_execute_rq (drive->queue, disk, rq,0 ); + error = rq->errors ? -EIO :0 ; put_req:blk_put_request (rq);return error;
drivers/ide/ide-cd.c +2 -1
@@ -452,7 +452,8 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd, } } - error =blk_execute_rq (drive->queue, info->disk, rq,0 ); +blk_execute_rq (drive->queue, info->disk, rq,0 ); + error = rq->errors ? -EIO :0 ;if (buffer) *bufflen =scsi_req (rq)->resid_len;
drivers/ide/ide-cd_ioctl.c +2 -1
@@ -307,7 +307,8 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi)scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_MISC ; rq->rq_flags =RQF_QUIET ; - ret =blk_execute_rq (drive->queue, cd->disk, rq,0 ); +blk_execute_rq (drive->queue, cd->disk, rq,0 ); + ret = rq->errors ? -EIO :0 ;blk_put_request (rq);/* * A reset will unlock the door. If it was previously locked,
drivers/ide/ide-devsets.c +2 -2
@@ -173,8 +173,8 @@ int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting, *(int *)&scsi_req (rq)->cmd[1 ] = arg; rq->special = setting->set; -if (blk_execute_rq (q,NULL , rq,0 )) - ret = rq->errors; +blk_execute_rq (q,NULL , rq,0 ); + ret = rq->errors;blk_put_request (rq);return ret;
drivers/ide/ide-disk.c +1 -2
@@ -470,7 +470,6 @@ ide_devset_get(multcount, mult_count);static int set_multcount (ide_drive_t *drive,int arg) {struct request *rq; -int error;if (arg <0 || arg > (drive->id[ATA_ID_MAX_MULTSECT ] &0xff ))return -EINVAL ;
@@ -484,7 +483,7 @@ static int set_multcount(ide_drive_t *drive, int arg) drive->mult_req = arg; drive->special_flags |=IDE_SFLAG_SET_MULTMODE ; - error =blk_execute_rq (drive->queue,NULL , rq,0 ); +blk_execute_rq (drive->queue,NULL , rq,0 );blk_put_request (rq);return (drive->mult_count == arg) ?0 : -EIO ;
drivers/ide/ide-ioctls.c +4 -3
@@ -128,7 +128,8 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg) rq =blk_get_request (drive->queue,REQ_OP_DRV_IN , __GFP_RECLAIM);scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_TASKFILE ; - err =blk_execute_rq (drive->queue,NULL , rq,0 ); +blk_execute_rq (drive->queue,NULL , rq,0 ); + err = rq->errors ? -EIO :0 ;blk_put_request (rq);return err;
@@ -227,8 +228,8 @@ static int generic_drive_reset(ide_drive_t *drive)ide_req (rq)->type =ATA_PRIV_MISC ;scsi_req (rq)->cmd_len =1 ;scsi_req (rq)->cmd[0 ] =REQ_DRIVE_RESET ; -if (blk_execute_rq (drive->queue,NULL , rq,1 )) - ret = rq->errors; +blk_execute_rq (drive->queue,NULL , rq,1 ); + ret = rq->errors;blk_put_request (rq);return ret; }
drivers/ide/ide-park.c +2 -1
@@ -37,7 +37,8 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)scsi_req (rq)->cmd_len =1 ;ide_req (rq)->type =ATA_PRIV_MISC ; rq->special = &timeout; - rc =blk_execute_rq (q,NULL , rq,1 ); +blk_execute_rq (q,NULL , rq,1 ); + rc = rq->errors ? -EIO :0 ;blk_put_request (rq);if (rc) goto out;
drivers/ide/ide-pm.c +2 -1
@@ -27,7 +27,8 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg) mesg.event =PM_EVENT_FREEZE ; rqpm.pm_state = mesg.event; - ret =blk_execute_rq (drive->queue,NULL , rq,0 ); +blk_execute_rq (drive->queue,NULL , rq,0 ); + ret = rq->errors ? -EIO :0 ;blk_put_request (rq);if (ret ==0 &&ide_port_acpi (hwif)) {
drivers/ide/ide-taskfile.c +2 -2
@@ -452,8 +452,8 @@ int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf, rq->special = cmd; cmd->rq = rq; - error =blk_execute_rq (drive->queue,NULL , rq,0 ); - +blk_execute_rq (drive->queue,NULL , rq,0 ); + error = rq->errors ? -EIO :0 ; put_req:blk_put_request (rq);return error;
drivers/scsi/osd/osd_initiator.c +4 -1
@@ -489,7 +489,10 @@ static void _set_error_resid(struct osd_request *or, struct request *req,int osd_execute_request (struct osd_request *or) { -int error =blk_execute_rq (or->request->q,NULL , or->request,0 ); +int error; + +blk_execute_rq (or->request->q,NULL , or->request,0 ); + error = or->request->errors ? -EIO :0 ;_set_error_resid (or, or->request, error);return error;
fs/nfsd/blocklayout.c +3 -2
@@ -242,10 +242,11 @@ static int nfsd4_scsi_identify_device(struct block_device *bdev, req->cmd[4 ] = bufflen &0xff ; req->cmd_len =COMMAND_SIZE (INQUIRY ); - error =blk_execute_rq (rq->q,NULL , rq,1 ); -if (error) { +blk_execute_rq (rq->q,NULL , rq,1 ); +if (rq->errors) {pr_err ("pNFS: INQUIRY 0x83 failed with: %x\n" , rq->errors); + error = -EIO ; goto out_put_request; }
include/linux/blkdev.h +1 -1
@@ -970,7 +970,7 @@ extern int blk_rq_map_kern(struct request_queue *, struct request *, void *, unsextern int blk_rq_map_user_iov (struct request_queue *,struct request *,struct rq_map_data *,const struct iov_iter *,gfp_t ); -extern int blk_execute_rq (struct request_queue *,struct gendisk *, +extern void blk_execute_rq (struct request_queue *,struct gendisk *,struct request *,int );extern void blk_execute_rq_nowait (struct request_queue *,struct gendisk *,struct request *,int ,rq_end_io_fn *);
Signature · 1 line
2.11.0
Re: [PATCH 02/23] block: remove the blk_execute_rq return value
Quoted 4 lines · Christoph Hellwig
The function only returns
-EIOifrq->errorsis non-zero, which is not very useful and lets a large number of callers ignore the return value.Just let the callers figure out their error themselves.
Christoph Hellwig
maintainerPATCH 3/23 nvme-fc: fix status code handling in nvme_fc_fcpio_done
In reply to Christoph Hellwignvme_complete_async_event expects the little endian status code including the phase bit, and a new completion handler I plan to introduce will do so as well.
Change the status variable into the little endian format with the phase bit used in the NVMe CQE to fix / enable this.
--- drivers/nvme/host/fc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/nvme/host/fc.c +8 -8
@@ -1147,7 +1147,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)struct nvme_fc_ctrl *ctrl = op->ctrl;struct nvme_fc_queue *queue = op->queue;struct nvme_completion *cqe = &op->rsp_iu.cqe; -u16 status =NVME_SC_SUCCESS ; +__le16 status =cpu_to_le16 (NVME_SC_SUCCESS <<1 );/* * WARNING:
@@ -1182,9 +1182,9 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) sizeof(op->rsp_iu), DMA_FROM_DEVICE);if (atomic_read (&op->state) ==FCPOP_STATE_ABORTED ) - status =NVME_SC_ABORT_REQ |NVME_SC_DNR ; + status =cpu_to_le16 ((NVME_SC_ABORT_REQ |NVME_SC_DNR ) <<1 );else if (freq->status) - status =NVME_SC_FC_TRANSPORT_ERROR ; + status =cpu_to_le16 (NVME_SC_FC_TRANSPORT_ERROR <<1 );/* * For the linux implementation, if we have an unsuccesful
@@ -1212,7 +1212,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)*/ if (freq->transferred_length !=be32_to_cpu (op->cmd_iu.data_len)) { - status =NVME_SC_FC_TRANSPORT_ERROR ; + status =cpu_to_le16 (NVME_SC_FC_TRANSPORT_ERROR <<1 ); goto done; } op->nreq.result.u64 =0 ;
@@ -1229,15 +1229,15 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) freq->transferred_length || op->rsp_iu.status_code || op->rqno != le16_to_cpu(cqe->command_id))) { - status =NVME_SC_FC_TRANSPORT_ERROR ; + status =cpu_to_le16 (NVME_SC_FC_TRANSPORT_ERROR <<1 ); goto done; } op->nreq.result = cqe->result; - status =le16_to_cpu (cqe->status) >>1 ; + status = cqe->status;break ;default : - status =NVME_SC_FC_TRANSPORT_ERROR ; + status =cpu_to_le16 (NVME_SC_FC_TRANSPORT_ERROR <<1 ); goto done; }
@@ -1249,7 +1249,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)return ; } -blk_mq_complete_request (rq, status); +blk_mq_complete_request (rq,le16_to_cpu (status) >>1 ); } static int
Signature · 1 line
2.11.0
Christoph Hellwig
maintainerPATCH 4/23 nvme: split nvme status from block req->errors
In reply to Christoph HellwigWe want our own clearly defined error field for NVMe passthrough commands, and the request errors field is going away in its current form.
Just store the status and result field in the nvme_request field from hardirq completion context (using a new helper) and then generate a Linux errno for the block layer only when we actually need it.
Because we can't overload the status value with a negative error code for cancelled command we now have a flags filed in struct nvme_request that contains a bit for this condition.
--- drivers/nvme/host/core.c | 50 +++++++++++++++++++++++++++----------------- drivers/nvme/host/fc.c | 10 ++++----- drivers/nvme/host/lightnvm.c | 9 +++++--- drivers/nvme/host/nvme.h | 33 +++++++++++++---------------- drivers/nvme/host/pci.c | 11 +++++----- drivers/nvme/host/rdma.c | 5 ++--- drivers/nvme/target/loop.c | 7 ++----- 7 files changed, 65 insertions(+), 60 deletions(-)
drivers/nvme/host/core.c +31 -19
@@ -66,11 +66,24 @@ static DEFINE_SPINLOCK(dev_list_lock);static struct class *nvme_class; +int nvme_error_status (struct request *req) +{ +switch (nvme_req (req)->status &0x7ff ) { +case NVME_SC_SUCCESS : +return 0 ; +case NVME_SC_CAP_EXCEEDED : +return -ENOSPC ; +default : +return -EIO ; + } +} +EXPORT_SYMBOL_GPL (nvme_error_status); +static inline bool nvme_req_needs_retry (struct request *req) {if (blk_noretry_request (req))return false; -if (req->errors &NVME_SC_DNR ) +if (nvme_req (req)->status &NVME_SC_DNR )return false;if (jiffies - req->start_time >= req->timeout)return false;
@@ -81,23 +94,13 @@ static inline bool nvme_req_needs_retry(struct request *req)void nvme_complete_rq (struct request *req) { -int error =0 ; - -if (unlikely (req->errors)) { -if (nvme_req_needs_retry (req)) { -nvme_req (req)->retries++; -blk_mq_requeue_request (req, - !blk_mq_queue_stopped (req->q)); -return ; - } - -if (blk_rq_is_passthrough (req)) - error = req->errors; -else - error =nvme_error_status (req->errors); +if (unlikely (nvme_req (req)->status &&nvme_req_needs_retry (req))) { +nvme_req (req)->retries++; +blk_mq_requeue_request (req, !blk_mq_queue_stopped (req->q)); +return ; } -blk_mq_end_request (req, error); +blk_mq_end_request (req,nvme_error_status (req)); }EXPORT_SYMBOL_GPL (nvme_complete_rq);
@@ -114,7 +117,9 @@ void nvme_cancel_request(struct request *req, void *data, bool reserved) status =NVME_SC_ABORT_REQ ;if (blk_queue_dying (req->q)) status |=NVME_SC_DNR ; -blk_mq_complete_request (req, status); +nvme_req (req)->status = status; +blk_mq_complete_request (req,0 ); + }EXPORT_SYMBOL_GPL (nvme_cancel_request);
@@ -357,6 +362,7 @@ int nvme_setup_cmd(struct nvme_ns *ns, struct request *req,if (!(req->rq_flags &RQF_DONTPREP )) {nvme_req (req)->retries =0 ; +nvme_req (req)->flags =0 ; req->rq_flags |=RQF_DONTPREP ; }
@@ -413,7 +419,10 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,blk_execute_rq (req->q,NULL , req, at_head);if (result) *result =nvme_req (req)->result; - ret = req->errors; +if (nvme_req (req)->flags &NVME_REQ_CANCELLED ) + ret = -EINTR ; +else + ret =nvme_req (req)->status; out:blk_mq_free_request (req);return ret;
@@ -498,7 +507,10 @@ int __nvme_submit_user_cmd(struct request_queue *q, struct nvme_command *cmd, } submit:blk_execute_rq (req->q, disk, req,0 ); - ret = req->errors; +if (nvme_req (req)->flags &NVME_REQ_CANCELLED ) + ret = -EINTR ; +else + ret =nvme_req (req)->status;if (result) *result =le32_to_cpu (nvme_req (req)->result.u32);if (meta && !ret && !write) {
drivers/nvme/host/fc.c +5 -5
@@ -1148,6 +1148,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req)struct nvme_fc_queue *queue = op->queue;struct nvme_completion *cqe = &op->rsp_iu.cqe;__le16 status =cpu_to_le16 (NVME_SC_SUCCESS <<1 ); +union nvme_result result;/* * WARNING:
@@ -1215,7 +1216,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) status =cpu_to_le16 (NVME_SC_FC_TRANSPORT_ERROR <<1 ); goto done; } - op->nreq.result.u64 =0 ; + result.u64 =0 ;break ;case sizeof (struct nvme_fc_ersp_iu ):
@@ -1232,7 +1233,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) status =cpu_to_le16 (NVME_SC_FC_TRANSPORT_ERROR <<1 ); goto done; } - op->nreq.result = cqe->result; + result = cqe->result; status = cqe->status;break ;
@@ -1243,13 +1244,12 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) done:if (!queue->qnum && op->rqno >=AEN_CMDID_BASE ) { -nvme_complete_async_event (&queue->ctrl->ctrl, status, - &op->nreq.result); +nvme_complete_async_event (&queue->ctrl->ctrl, status, &result);nvme_fc_ctrl_put (ctrl);return ; } -blk_mq_complete_request (rq,le16_to_cpu (status) >>1 ); +nvme_end_request (rq, status, result); } static int
drivers/nvme/host/lightnvm.c +6 -3
@@ -484,7 +484,7 @@ static void nvme_nvm_end_io(struct request *rq, int error)struct nvm_rq *rqd = rq->end_io_data; rqd->ppa_status =nvme_req (rq)->result.u64; - rqd->error = error; + rqd->error =nvme_req (rq)->status;nvm_end_io (rqd);kfree (nvme_req (rq)->cmd);
@@ -665,9 +665,12 @@ static int nvme_nvm_submit_user_cmd(struct request_queue *q,wait_for_completion_io (&wait); - ret =nvme_error_status (rq->errors); +if (nvme_req (rq)->flags &NVME_REQ_CANCELLED ) + ret = -EINTR ; +else + ret =nvme_error_status (rq);if (result) - *result = rq->errors &0x7ff ; + *result =nvme_req (rq)->status &0x7ff ;if (status) *status =le64_to_cpu (nvme_req (rq)->result.u64);
drivers/nvme/host/nvme.h +14 -19
@@ -21,16 +21,6 @@#include <linux/lightnvm.h> #include <linux/sed-opal.h> -enum { -/* -* Driver internal status code for commands that were cancelled due -* to timeouts or controller shutdown. The value is negative so -* that it a) doesn't overlap with the unsigned hardware error codes, -* and b) can easily be tested for. -*/ -NVME_SC_CANCELLED = -EINTR , -}; -extern unsigned char nvme_io_timeout;#define NVME_IO_TIMEOUT (nvme_io_timeout * HZ)
@@ -91,6 +81,12 @@ struct nvme_request {struct nvme_command *cmd;union nvme_result result;u8 retries; +u8 flags; +u16 status; +}; + +enum { +NVME_REQ_CANCELLED = (1 <<0 ), };static inline struct nvme_request *nvme_req (struct request *req)
@@ -248,18 +244,17 @@ static inline void nvme_cleanup_cmd(struct request *req) } } -static inline int nvme_error_status (u16 status) +static inline void nvme_end_request (struct request *req,__le16 status, +union nvme_result result) { -switch (status &0x7ff ) { -case NVME_SC_SUCCESS : -return 0 ; -case NVME_SC_CAP_EXCEEDED : -return -ENOSPC ; -default : -return -EIO ; - } +struct nvme_request *rq =nvme_req (req); + + rq->status =le16_to_cpu (status) >>1 ; + rq->result = result; +blk_mq_complete_request (req,0 ); } +int nvme_error_status (struct request *req);void nvme_complete_rq (struct request *req);void nvme_cancel_request (struct request *req,void *data,bool reserved); bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
drivers/nvme/host/pci.c +5 -6
@@ -679,8 +679,7 @@ static void __nvme_process_cq(struct nvme_queue *nvmeq, unsigned int *tag) } req =blk_mq_tag_to_rq (*nvmeq->tags, cqe.command_id); -nvme_req (req)->result = cqe.result; -blk_mq_complete_request (req,le16_to_cpu (cqe.status) >>1 ); +nvme_end_request (req, cqe.status, cqe.result); }if (head == nvmeq->cq_head && phase == nvmeq->cq_phase)
@@ -817,9 +816,9 @@ static void abort_endio(struct request *req, int error) {struct nvme_iod *iod =blk_mq_rq_to_pdu (req);struct nvme_queue *nvmeq = iod->nvmeq; -u16 status = req->errors; -dev_warn (nvmeq->dev->ctrl.device,"Abort status: 0x%x" , status); +dev_warn (nvmeq->dev->ctrl.device, +"Abort status: 0x%x" ,nvme_req (req)->status);atomic_inc (&nvmeq->dev->ctrl.abort_limit);blk_mq_free_request (req); }
@@ -843,7 +842,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)"I/O %d QID %d timeout, disable controller\n" , req->tag, nvmeq->qid);nvme_dev_disable (dev, false); - req->errors =NVME_SC_CANCELLED ; +nvme_req (req)->flags |=NVME_REQ_CANCELLED ;return BLK_EH_HANDLED ; }
@@ -863,7 +862,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)* Mark the request as handled, since the inline shutdown * forces all outstanding requests to complete. */ - req->errors =NVME_SC_CANCELLED ; +nvme_req (req)->flags |=NVME_REQ_CANCELLED ;return BLK_EH_HANDLED ; }
drivers/nvme/host/rdma.c +2 -3
@@ -1178,8 +1178,7 @@ static int nvme_rdma_process_nvme_rsp(struct nvme_rdma_queue *queue, wc->ex.invalidate_rkey == req->mr->rkey) req->mr->need_inval = false; - req->req.result = cqe->result; -blk_mq_complete_request (rq,le16_to_cpu (cqe->status) >>1 ); +nvme_end_request (rq, cqe->status, cqe->result);return ret; }
@@ -1416,7 +1415,7 @@ nvme_rdma_timeout(struct request *rq, bool reserved)nvme_rdma_error_recovery (req->queue->ctrl);/* fail with DNR on cmd timeout */ - rq->errors =NVME_SC_ABORT_REQ |NVME_SC_DNR ; +nvme_req (rq)->status =NVME_SC_ABORT_REQ |NVME_SC_DNR ;return BLK_EH_HANDLED ; }
drivers/nvme/target/loop.c +2 -5
@@ -124,7 +124,6 @@ static void nvme_loop_queue_response(struct nvmet_req *req) &cqe->result); }else {struct request *rq; -struct nvme_loop_iod *iod; rq =blk_mq_tag_to_rq (nvme_loop_tagset (queue), cqe->command_id);if (!rq) {
@@ -134,9 +133,7 @@ static void nvme_loop_queue_response(struct nvmet_req *req)return ; } - iod =blk_mq_rq_to_pdu (rq); - iod->nvme_req.result = cqe->result; -blk_mq_complete_request (rq,le16_to_cpu (cqe->status) >>1 ); +nvme_end_request (rq, cqe->status, cqe->result); } }
@@ -157,7 +154,7 @@ nvme_loop_timeout(struct request *rq, bool reserved)schedule_work (&iod->queue->ctrl->reset_work);/* fail with DNR on admin cmd timeout */ - rq->errors =NVME_SC_ABORT_REQ |NVME_SC_DNR ; +nvme_req (rq)->status =NVME_SC_ABORT_REQ |NVME_SC_DNR ;return BLK_EH_HANDLED ; }
Signature · 1 line
2.11.0
Christoph Hellwig
maintainerPATCH 5/23 nvme: make nvme_error_status private
In reply to Christoph HellwigCurrently it's used by the lighnvm passthrough ioctl, but we'd like to make it private in preparation of block layer specific error code. Lighnvm already returns the real NVMe status anyway, so I think we can just limit it to returning -EIO for any status set.
This will need a careful audit from the lightnvm folks, though.
--- drivers/nvme/host/core.c | 3 +-- drivers/nvme/host/lightnvm.c | 6 +++--- drivers/nvme/host/nvme.h | 1 - 3 files changed, 4 insertions(+), 6 deletions(-)
drivers/nvme/host/core.c +1 -2
@@ -66,7 +66,7 @@ static DEFINE_SPINLOCK(dev_list_lock);static struct class *nvme_class; -int nvme_error_status (struct request *req) +static int nvme_error_status (struct request *req) {switch (nvme_req (req)->status &0x7ff ) {case NVME_SC_SUCCESS :
@@ -77,7 +77,6 @@ int nvme_error_status(struct request *req)return -EIO ; } } -EXPORT_SYMBOL_GPL (nvme_error_status);static inline bool nvme_req_needs_retry (struct request *req) {
drivers/nvme/host/lightnvm.c +3 -3
@@ -595,7 +595,7 @@ static int nvme_nvm_submit_user_cmd(struct request_queue *q,__le64 *metadata =NULL ;dma_addr_t metadata_dma;DECLARE_COMPLETION_ONSTACK (wait); -int ret; +int ret =0 ; rq =nvme_alloc_request (q, (struct nvme_command *)vcmd,0 ,NVME_QID_ANY );
@@ -667,8 +667,8 @@ static int nvme_nvm_submit_user_cmd(struct request_queue *q,if (nvme_req (rq)->flags &NVME_REQ_CANCELLED ) ret = -EINTR ; -else - ret =nvme_error_status (rq); +else if (nvme_req (rq)->status &0x7ff ) + ret = -EIO ;if (result) *result =nvme_req (rq)->status &0x7ff ;if (status)
drivers/nvme/host/nvme.h +0 -1
@@ -254,7 +254,6 @@ static inline void nvme_end_request(struct request *req, __le16 status,blk_mq_complete_request (req,0 ); } -int nvme_error_status (struct request *req);void nvme_complete_rq (struct request *req);void nvme_cancel_request (struct request *req,void *data,bool reserved); bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
Signature · 1 line
2.11.0
Christoph Hellwig
maintainerPATCH 6/23 virtio: fix spelling of virtblk_scsi_request_done
In reply to Christoph Hellwig--- drivers/block/virtio_blk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/block/virtio_blk.c +3 -3
@@ -111,7 +111,7 @@ static int virtblk_add_req_scsi(struct virtqueue *vq, struct virtblk_req *vbr,return virtqueue_add_sgs (vq, sgs, num_out, num_in, vbr,GFP_ATOMIC ); } -static inline void virtblk_scsi_reques_done (struct request *req) +static inline void virtblk_scsi_request_done (struct request *req) {struct virtblk_req *vbr =blk_mq_rq_to_pdu (req);struct virtio_blk *vblk = req->q->queuedata;
@@ -144,7 +144,7 @@ static inline int virtblk_add_req_scsi(struct virtqueue *vq, {return -EIO ; } -static inline void virtblk_scsi_reques_done (struct request *req) +static inline void virtblk_scsi_request_done (struct request *req) { }#define virtblk_ioctl NULL
@@ -180,7 +180,7 @@ static inline void virtblk_request_done(struct request *req)switch (req_op (req)) {case REQ_OP_SCSI_IN :case REQ_OP_SCSI_OUT : -virtblk_scsi_reques_done (req); +virtblk_scsi_request_done (req);break ;case REQ_OP_DRV_IN : req->errors = (error !=0 );
Signature · 1 line
2.11.0
Christoph Hellwig
maintainerPATCH 7/23 virtio_blk: don't use req->errors
In reply to Christoph HellwigRemove passing req->errors (which at that point is always 0) to blk_mq_complete_request, and rely on the virtio status code for the serial number passthrough request.
--- drivers/block/virtio_blk.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/block/virtio_blk.c +3 -7
@@ -175,19 +175,15 @@ static int virtblk_add_req(struct virtqueue *vq, struct virtblk_req *vbr,static inline void virtblk_request_done (struct request *req) {struct virtblk_req *vbr =blk_mq_rq_to_pdu (req); -int error =virtblk_result (vbr);switch (req_op (req)) {case REQ_OP_SCSI_IN :case REQ_OP_SCSI_OUT :virtblk_scsi_request_done (req);break ; -case REQ_OP_DRV_IN : - req->errors = (error !=0 ); -break ; } -blk_mq_end_request (req, error); +blk_mq_end_request (req,virtblk_result (vbr)); }static void virtblk_done (struct virtqueue *vq)
@@ -205,7 +201,7 @@ static void virtblk_done(struct virtqueue *vq)while ((vbr =virtqueue_get_buf (vblk->vqs[qid].vq, &len)) !=NULL ) {struct request *req =blk_mq_rq_from_pdu (vbr); -blk_mq_complete_request (req, req->errors); +blk_mq_complete_request (req,0 ); req_done = true; }if (unlikely (virtqueue_is_broken (vq)))
@@ -311,7 +307,7 @@ static int virtblk_get_id(struct gendisk *disk, char *id_str) goto out;blk_execute_rq (vblk->disk->queue, vblk->disk, req, false); - err = req->errors ? -EIO :0 ; + err =virtblk_result (blk_mq_rq_to_pdu (req)); out:blk_put_request (req);return err;
Signature · 1 line
2.11.0
Christoph Hellwig
maintainerPATCH 8/23 scsi: introduce a result field in struct scsi_request
In reply to Christoph HellwigThis passes on the scsi_cmnd result field to users of passthrough requests. Currently we abuse req->errors for this purpose, but that field will go away in its current form.
Note that the old IDE code abuses the errors field in very creative ways and stores all kinds of different values in it. I didn't dare to touch this magic, so the abuses are brought forward 1:1.
--- block/bsg-lib.c | 8 ++++---- block/bsg.c | 12 +++++------ block/scsi_ioctl.c | 14 ++++++------- drivers/block/cciss.c | 42 +++++++++++++++++++------------------- drivers/block/pktcdvd.c | 2 +- drivers/block/virtio_blk.c | 2 +- drivers/cdrom/cdrom.c | 2 +- drivers/ide/ide-atapi.c | 10 ++++----- drivers/ide/ide-cd.c | 20 +++++++++--------- drivers/ide/ide-cd_ioctl.c | 2 +- drivers/ide/ide-devsets.c | 4 ++-- drivers/ide/ide-dma.c | 2 +- drivers/ide/ide-eh.c | 36 ++++++++++++++++---------------- drivers/ide/ide-floppy.c | 10 ++++----- drivers/ide/ide-io.c | 10 ++++----- drivers/ide/ide-ioctls.c | 4 ++-- drivers/ide/ide-park.c | 2 +- drivers/ide/ide-pm.c | 8 ++++---- drivers/ide/ide-tape.c | 4 ++-- drivers/ide/ide-taskfile.c | 6 +++--- drivers/scsi/osd/osd_initiator.c | 4 ++-- drivers/scsi/osst.c | 2 +- drivers/scsi/qla2xxx/qla_bsg.c | 6 +++--- drivers/scsi/scsi_lib.c | 15 +++++++------- drivers/scsi/scsi_transport_sas.c | 2 +- drivers/scsi/sg.c | 2 +- drivers/scsi/st.c | 6 +++--- drivers/target/target_core_pscsi.c | 2 +- fs/nfsd/blocklayout.c | 4 ++-- include/linux/ide.h | 2 +- include/scsi/scsi_request.h | 1 + 31 files changed, 123 insertions(+), 123 deletions(-)
block/bsg-lib.c +4 -4
@@ -37,7 +37,7 @@ static void bsg_destroy_job(struct kref *kref) struct bsg_job *job = container_of(kref, struct bsg_job, kref);struct request *rq = job->req; -blk_end_request_all (rq, rq->errors); +blk_end_request_all (rq,scsi_req (rq)->result);put_device (job->dev);/* release reference for the request */
@@ -74,7 +74,7 @@ void bsg_job_done(struct bsg_job *job, int result,struct scsi_request *rq =scsi_req (req);int err; - err = job->req->errors = result; + err =scsi_req (job->req)->result = result;if (err <0 )/* we're only returning the result field in the reply */ rq->sense_len =sizeof (u32);
@@ -177,7 +177,7 @@ static int bsg_create_job(struct device *dev, struct request *req)* @q: request queue to manage * * On error the create_bsg_job function should return a -Exyz error value -* that will be set to the req->errors. +* that will be set to ->result. * * Drivers/subsys should pass this to the queue init function. */
@@ -201,7 +201,7 @@ static void bsg_request_fn(struct request_queue *q) ret =bsg_create_job (dev, req);if (ret) { - req->errors = ret; +scsi_req (req)->result = ret;blk_end_request_all (req, ret);spin_lock_irq (q->queue_lock);continue ;
block/bsg.c +6 -6
@@ -391,13 +391,13 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr,struct scsi_request *req =scsi_req (rq);int ret =0 ; -dprintk ("rq %p bio %p 0x%x\n" , rq, bio, rq->errors); +dprintk ("rq %p bio %p 0x%x\n" , rq, bio, req->result);/* * fill in all the output members */ - hdr->device_status = rq->errors &0xff ; - hdr->transport_status =host_byte (rq->errors); - hdr->driver_status =driver_byte (rq->errors); + hdr->device_status = req->result &0xff ; + hdr->transport_status =host_byte (req->result); + hdr->driver_status =driver_byte (req->result); hdr->info =0 ;if (hdr->device_status || hdr->transport_status || hdr->driver_status) hdr->info |=SG_INFO_CHECK ;
@@ -431,8 +431,8 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr,* just a protocol response (i.e. non negative), that gets * processed above. */ -if (!ret && rq->errors <0 ) - ret = rq->errors; +if (!ret && req->result <0 ) + ret = req->result;blk_rq_unmap_user (bio);scsi_req_free_cmd (req);
block/scsi_ioctl.c +7 -7
@@ -262,11 +262,11 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,/* * fill in all the output members */ - hdr->status = rq->errors &0xff ; - hdr->masked_status =status_byte (rq->errors); - hdr->msg_status =msg_byte (rq->errors); - hdr->host_status =host_byte (rq->errors); - hdr->driver_status =driver_byte (rq->errors); + hdr->status = req->result &0xff ; + hdr->masked_status =status_byte (req->result); + hdr->msg_status =msg_byte (req->result); + hdr->host_status =host_byte (req->result); + hdr->driver_status =driver_byte (req->result); hdr->info =0 ;if (hdr->masked_status || hdr->host_status || hdr->driver_status) hdr->info |=SG_INFO_CHECK ;
@@ -509,7 +509,7 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,blk_execute_rq (q, disk, rq,0 ); - err = rq->errors &0xff ;/* only 8 bit SCSI status */ + err = req->result &0xff ;/* only 8 bit SCSI status */ if (err) {if (req->sense_len && req->sense) { bytes = (OMAX_SB_LEN > req->sense_len) ?
@@ -548,7 +548,7 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk,scsi_req (rq)->cmd[4 ] = data;scsi_req (rq)->cmd_len =6 ;blk_execute_rq (q, bd_disk, rq,0 ); - err = rq->errors ? -EIO :0 ; + err =scsi_req (rq)->result ? -EIO :0 ;blk_put_request (rq);return err;
drivers/block/cciss.c +21 -21
135 lines not on this page · raw message
drivers/block/pktcdvd.c +1 -1
@@ -724,7 +724,7 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command * rq->rq_flags |=RQF_QUIET ;blk_execute_rq (rq->q, pd->bdev->bd_disk, rq,0 ); -if (rq->errors) +if (scsi_req (rq)->result) ret = -EIO ; out:blk_put_request (rq);
drivers/block/virtio_blk.c +1 -1
@@ -119,7 +119,7 @@ static inline void virtblk_scsi_request_done(struct request *req) sreq->resid_len =virtio32_to_cpu (vblk->vdev, vbr->in_hdr.residual); sreq->sense_len =virtio32_to_cpu (vblk->vdev, vbr->in_hdr.sense_len); - req->errors =virtio32_to_cpu (vblk->vdev, vbr->in_hdr.errors); + sreq->result =virtio32_to_cpu (vblk->vdev, vbr->in_hdr.errors); } static int virtblk_ioctl(struct block_device *bdev, fmode_t mode,
drivers/cdrom/cdrom.c +1 -1
@@ -2219,7 +2219,7 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf, bio = rq->bio;blk_execute_rq (q, cdi->disk, rq,0 ); -if (rq->errors) { +if (scsi_req (rq)->result) {struct request_sense *s = req->sense; ret = -EIO ; cdi->last_sense = s->sense_key;
drivers/ide/ide-atapi.c +5 -5
@@ -108,7 +108,7 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,if (drive->media == ide_tape)scsi_req (rq)->cmd[13 ] =REQ_IDETAPE_PC1 ;blk_execute_rq (drive->queue, disk, rq,0 ); - error = rq->errors ? -EIO :0 ; + error =scsi_req (rq)->result ? -EIO :0 ; put_req:blk_put_request (rq);return error;
@@ -455,7 +455,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)debug_log ("%s: I/O error\n" , drive->name);if (drive->media != ide_tape) - pc->rq->errors++; +scsi_req (pc->rq)->result++;if (scsi_req (rq)->cmd[0 ] ==REQUEST_SENSE ) { printk(KERN_ERR PFX "%s: I/O error in request "
@@ -489,13 +489,13 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) drive->failed_pc =NULL ;if (ata_misc_request (rq)) { - rq->errors =0 ; +scsi_req (rq)->result =0 ; error =0 ; }else {if (blk_rq_is_passthrough (rq) && uptodate <=0 ) { -if (rq->errors ==0 ) - rq->errors = -EIO ; +if (scsi_req (rq)->result ==0 ) +scsi_req (rq)->result = -EIO ; } error = uptodate ?0 : -EIO ;
drivers/ide/ide-cd.c +10 -10
@@ -247,10 +247,10 @@ static int ide_cd_breathe(ide_drive_t *drive, struct request *rq)struct cdrom_info *info = drive->driver_data; -if (!rq->errors) +if (!scsi_req (rq)->result) info->write_timeout = jiffies +ATAPI_WAIT_WRITE_BUSY ; - rq->errors =1 ; +scsi_req (rq)->result =1 ;if (time_after (jiffies, info->write_timeout))return 0 ;
@@ -294,8 +294,8 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat) }/* if we have an error, pass CHECK_CONDITION as the SCSI status byte */ -if (blk_rq_is_scsi (rq) && !rq->errors) - rq->errors =SAM_STAT_CHECK_CONDITION ; +if (blk_rq_is_scsi (rq) && !scsi_req (rq)->result) +scsi_req (rq)->result =SAM_STAT_CHECK_CONDITION ;if (blk_noretry_request (rq)) do_end_request =1 ;
@@ -325,7 +325,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)* Arrange to retry the request but be sure to give up if we've * retried too many times. */ -if (++rq->errors >ERROR_MAX ) +if (++scsi_req (rq)->result >ERROR_MAX ) do_end_request =1 ;break ;case ILLEGAL_REQUEST :
@@ -372,7 +372,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)/* go to the default handler for other errors */ ide_error (drive,"cdrom_decode_status" , stat);return 1 ; - }else if (++rq->errors >ERROR_MAX ) + }else if (++scsi_req (rq)->result >ERROR_MAX )/* we've racked up too many retries, abort */ do_end_request =1 ; }
@@ -453,7 +453,7 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd, }blk_execute_rq (drive->queue, info->disk, rq,0 ); - error = rq->errors ? -EIO :0 ; + error =scsi_req (rq)->result ? -EIO :0 ;if (buffer) *bufflen =scsi_req (rq)->resid_len;
@@ -684,8 +684,8 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)if (cmd->nleft ==0 ) uptodate =1 ; }else { -if (uptodate <=0 && rq->errors ==0 ) - rq->errors = -EIO ; +if (uptodate <=0 &&scsi_req (rq)->result ==0 ) +scsi_req (rq)->result = -EIO ; }if (uptodate ==0 && rq->bio)
@@ -1380,7 +1380,7 @@ static int ide_cdrom_prep_pc(struct request *rq)* appropriate action */ if (c[0 ] ==MODE_SENSE || c[0 ] ==MODE_SELECT ) { - rq->errors =ILLEGAL_REQUEST ; +scsi_req (rq)->result =ILLEGAL_REQUEST ;return BLKPREP_KILL ; }
drivers/ide/ide-cd_ioctl.c +1 -1
@@ -308,7 +308,7 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi)ide_req (rq)->type =ATA_PRIV_MISC ; rq->rq_flags =RQF_QUIET ;blk_execute_rq (drive->queue, cd->disk, rq,0 ); - ret = rq->errors ? -EIO :0 ; + ret =scsi_req (rq)->result ? -EIO :0 ;blk_put_request (rq);/* * A reset will unlock the door. If it was previously locked,
drivers/ide/ide-devsets.c +2 -2
@@ -174,7 +174,7 @@ int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting, rq->special = setting->set;blk_execute_rq (q,NULL , rq,0 ); - ret = rq->errors; + ret =scsi_req (rq)->result;blk_put_request (rq);return ret;
@@ -186,7 +186,7 @@ ide_startstop_t ide_do_devset(ide_drive_t *drive, struct request *rq) err =setfunc (drive, *(int *)&scsi_req (rq)->cmd[1 ]);if (err) - rq->errors = err; +scsi_req (rq)->result = err;ide_complete_rq (drive, err,blk_rq_bytes (rq));return ide_stopped; }
drivers/ide/ide-dma.c +1 -1
@@ -490,7 +490,7 @@ ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)* make sure request is sane */ if (hwif->rq) - hwif->rq->errors =0 ; +scsi_req (hwif->rq)->result =0 ;return ret; }
drivers/ide/ide-eh.c +18 -18
@@ -12,7 +12,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq,if ((stat &ATA_BUSY ) || ((stat &ATA_DF ) && (drive->dev_flags &IDE_DFLAG_NOWERR ) ==0 )) {/* other bits are useless when BUSY */ - rq->errors |=ERROR_RESET ; +scsi_req (rq)->result |=ERROR_RESET ; }else if (stat &ATA_ERR ) {/* err has different meaning on cdrom and tape */ if (err ==ATA_ABORTED ) {
@@ -25,10 +25,10 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, drive->crc_count++; }else if (err & (ATA_BBK |ATA_UNC )) {/* retries won't help these */ - rq->errors =ERROR_MAX ; +scsi_req (rq)->result =ERROR_MAX ; }else if (err &ATA_TRK0NF ) {/* help it find track zero */ - rq->errors |=ERROR_RECAL ; +scsi_req (rq)->result |=ERROR_RECAL ; } }
@@ -39,23 +39,23 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq,ide_pad_transfer (drive,READ , nsect *SECTOR_SIZE ); } -if (rq->errors >=ERROR_MAX ||blk_noretry_request (rq)) { +if (scsi_req (rq)->result >=ERROR_MAX ||blk_noretry_request (rq)) {ide_kill_rq (drive, rq);return ide_stopped; }if (hwif->tp_ops->read_status (hwif) & (ATA_BUSY |ATA_DRQ )) - rq->errors |=ERROR_RESET ; +scsi_req (rq)->result |=ERROR_RESET ; -if ((rq->errors &ERROR_RESET ) ==ERROR_RESET ) { - ++rq->errors; +if ((scsi_req (rq)->result &ERROR_RESET ) ==ERROR_RESET ) { + ++scsi_req (rq)->result;return ide_do_reset (drive); } -if ((rq->errors &ERROR_RECAL ) ==ERROR_RECAL ) +if ((scsi_req (rq)->result &ERROR_RECAL ) ==ERROR_RECAL ) drive->special_flags |=IDE_SFLAG_RECALIBRATE ; - ++rq->errors; + ++scsi_req (rq)->result;return ide_stopped; }
@@ -68,7 +68,7 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq,if ((stat &ATA_BUSY ) || ((stat &ATA_DF ) && (drive->dev_flags &IDE_DFLAG_NOWERR ) ==0 )) {/* other bits are useless when BUSY */ - rq->errors |=ERROR_RESET ; +scsi_req (rq)->result |=ERROR_RESET ; }else {/* add decoding error stuff */ }
@@ -77,14 +77,14 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq,/* force an abort */ hwif->tp_ops->exec_command (hwif,ATA_CMD_IDLEIMMEDIATE ); -if (rq->errors >=ERROR_MAX ) { +if (scsi_req (rq)->result >=ERROR_MAX ) {ide_kill_rq (drive, rq); }else { -if ((rq->errors &ERROR_RESET ) ==ERROR_RESET ) { - ++rq->errors; +if ((scsi_req (rq)->result &ERROR_RESET ) ==ERROR_RESET ) { + ++scsi_req (rq)->result;return ide_do_reset (drive); } - ++rq->errors; + ++scsi_req (rq)->result; }return ide_stopped;
@@ -130,11 +130,11 @@ ide_startstop_t ide_error(ide_drive_t *drive, const char *msg, u8 stat)if (cmd)ide_complete_cmd (drive, cmd, stat, err); }else if (ata_pm_request (rq)) { - rq->errors =1 ; +scsi_req (rq)->result =1 ;ide_complete_pm_rq (drive, rq);return ide_stopped; } - rq->errors = err; +scsi_req (rq)->result = err;ide_complete_rq (drive, err ? -EIO :0 ,blk_rq_bytes (rq));return ide_stopped; }
@@ -149,8 +149,8 @@ static inline void ide_complete_drive_reset(ide_drive_t *drive, int err)if (rq &&ata_misc_request (rq) &&scsi_req (rq)->cmd[0 ] ==REQ_DRIVE_RESET ) { -if (err <=0 && rq->errors ==0 ) - rq->errors = -EIO ; +if (err <=0 &&scsi_req (rq)->result ==0 ) +scsi_req (rq)->result = -EIO ;ide_complete_rq (drive, err ? err :0 ,blk_rq_bytes (rq)); } }
drivers/ide/ide-floppy.c +5 -5
@@ -98,7 +98,7 @@ static int ide_floppy_callback(ide_drive_t *drive, int dsc) }if (ata_misc_request (rq)) - rq->errors = uptodate ?0 :IDE_DRV_ERROR_GENERAL ; +scsi_req (rq)->result = uptodate ?0 :IDE_DRV_ERROR_GENERAL ;return uptodate; }
@@ -239,7 +239,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, ? rq->rq_disk->disk_name : "dev?")); -if (rq->errors >=ERROR_MAX ) { +if (scsi_req (rq)->result >=ERROR_MAX ) {if (drive->failed_pc) {ide_floppy_report_error (floppy, drive->failed_pc); drive->failed_pc =NULL ;
@@ -247,7 +247,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, printk(KERN_ERR PFX "%s: I/O error\n", drive->name);if (ata_misc_request (rq)) { - rq->errors =0 ; +scsi_req (rq)->result =0 ;ide_complete_rq (drive,0 ,blk_rq_bytes (rq));return ide_stopped; }else
@@ -301,8 +301,8 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,return ide_floppy_issue_pc (drive, &cmd, pc); out_end: drive->failed_pc =NULL ; -if (blk_rq_is_passthrough (rq) && rq->errors ==0 ) - rq->errors = -EIO ; +if (blk_rq_is_passthrough (rq) &&scsi_req (rq)->result ==0 ) +scsi_req (rq)->result = -EIO ;ide_complete_rq (drive, -EIO ,blk_rq_bytes (rq));return ide_stopped; }
drivers/ide/ide-io.c +5 -5
@@ -141,12 +141,12 @@ void ide_kill_rq(ide_drive_t *drive, struct request *rq) drive->failed_pc =NULL ;if ((media == ide_floppy || media == ide_tape) && drv_req) { - rq->errors =0 ; +scsi_req (rq)->result =0 ; }else {if (media == ide_tape) - rq->errors =IDE_DRV_ERROR_GENERAL ; -else if (blk_rq_is_passthrough (rq) && rq->errors ==0 ) - rq->errors = -EIO ; +scsi_req (rq)->result =IDE_DRV_ERROR_GENERAL ; +else if (blk_rq_is_passthrough (rq) &&scsi_req (rq)->result ==0 ) +scsi_req (rq)->result = -EIO ; }ide_complete_rq (drive, -EIO ,blk_rq_bytes (rq));
@@ -271,7 +271,7 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,#ifdef DEBUG printk ("%s: DRIVE_CMD (null)\n" , drive->name);#endif - rq->errors =0 ; +scsi_req (rq)->result =0 ;ide_complete_rq (drive,0 ,blk_rq_bytes (rq));return ide_stopped;
drivers/ide/ide-ioctls.c +2 -2
@@ -129,7 +129,7 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg)scsi_req_init (rq);ide_req (rq)->type =ATA_PRIV_TASKFILE ;blk_execute_rq (drive->queue,NULL , rq,0 ); - err = rq->errors ? -EIO :0 ; + err =scsi_req (rq)->result ? -EIO :0 ;blk_put_request (rq);return err;
@@ -229,7 +229,7 @@ static int generic_drive_reset(ide_drive_t *drive)scsi_req (rq)->cmd_len =1 ;scsi_req (rq)->cmd[0 ] =REQ_DRIVE_RESET ;blk_execute_rq (drive->queue,NULL , rq,1 ); - ret = rq->errors; + ret =scsi_req (rq)->result;blk_put_request (rq);return ret; }
drivers/ide/ide-park.c +1 -1
@@ -38,7 +38,7 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)ide_req (rq)->type =ATA_PRIV_MISC ; rq->special = &timeout;blk_execute_rq (q,NULL , rq,1 ); - rc = rq->errors ? -EIO :0 ; + rc =scsi_req (rq)->result ? -EIO :0 ;blk_put_request (rq);if (rc) goto out;
drivers/ide/ide-pm.c +4 -4
@@ -28,7 +28,7 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg) rqpm.pm_state = mesg.event;blk_execute_rq (drive->queue,NULL , rq,0 ); - ret = rq->errors ? -EIO :0 ; + ret =scsi_req (rq)->result ? -EIO :0 ;blk_put_request (rq);if (ret ==0 &&ide_port_acpi (hwif)) {
@@ -56,8 +56,8 @@ static int ide_pm_execute_rq(struct request *rq)spin_lock_irq (q->queue_lock);if (unlikely (blk_queue_dying (q))) { rq->rq_flags |=RQF_QUIET ; - rq->errors = -ENXIO ; -__blk_end_request_all (rq, rq->errors); +scsi_req (rq)->result = -ENXIO ; +__blk_end_request_all (rq,scsi_req (rq)->result);spin_unlock_irq (q->queue_lock);return -ENXIO ; }
@@ -67,7 +67,7 @@ static int ide_pm_execute_rq(struct request *rq)wait_for_completion_io (&wait); -return rq->errors ? -EIO :0 ; +return scsi_req (rq)->result ? -EIO :0 ; }int generic_ide_resume (struct device *dev)
drivers/ide/ide-tape.c +2 -2
@@ -366,7 +366,7 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) err = pc->error; } } - rq->errors = err; +scsi_req (rq)->result = err;return uptodate; }
@@ -879,7 +879,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size) tape->valid =0 ; ret = size; -if (rq->errors ==IDE_DRV_ERROR_GENERAL ) +if (scsi_req (rq)->result ==IDE_DRV_ERROR_GENERAL ) ret = -EIO ; out_put:blk_put_request (rq);
drivers/ide/ide-taskfile.c +3 -3
@@ -287,7 +287,7 @@ static void ide_pio_datablock(ide_drive_t *drive, struct ide_cmd *cmd,u8 saved_io_32bit = drive->io_32bit;if (cmd->tf_flags &IDE_TFLAG_FS ) - cmd->rq->errors =0 ; +scsi_req (cmd->rq)->result =0 ;if (cmd->tf_flags &IDE_TFLAG_IO_16BIT ) drive->io_32bit =0 ;
@@ -329,7 +329,7 @@ void ide_finish_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat)u8 set_xfer = !!(cmd->tf_flags &IDE_TFLAG_SET_XFER );ide_complete_cmd (drive, cmd, stat, err); - rq->errors = err; +scsi_req (rq)->result = err;if (err ==0 && set_xfer) {ide_set_xfer_rate (drive, nsect);
@@ -453,7 +453,7 @@ int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf, cmd->rq = rq;blk_execute_rq (drive->queue,NULL , rq,0 ); - error = rq->errors ? -EIO :0 ; + error =scsi_req (rq)->result ? -EIO :0 ; put_req:blk_put_request (rq);return error;
drivers/scsi/osd/osd_initiator.c +2 -2
@@ -477,7 +477,7 @@ static void _set_error_resid(struct osd_request *or, struct request *req, int error) { or->async_error = error; - or->req_errors = req->errors ? : error; + or->req_errors =scsi_req (req)->result ? : error; or->sense_len =scsi_req (req)->sense_len;if (or->sense_len)memcpy (or->sense,scsi_req (req)->sense, or->sense_len);
@@ -492,7 +492,7 @@ int osd_execute_request(struct osd_request *or)int error;blk_execute_rq (or->request->q,NULL , or->request,0 ); - error = or->request->errors ? -EIO :0 ; + error =scsi_req (or->request)->result ? -EIO :0 ;_set_error_resid (or, or->request, error);return error;
drivers/scsi/osst.c +1 -1
@@ -327,7 +327,7 @@ static void osst_end_async(struct request *req, int update)struct osst_tape *STp = SRpnt->stp;struct rq_map_data *mdata = &SRpnt->stp->buffer->map_data; - STp->buffer->cmdstat.midlevel_result = SRpnt->result = req->errors; + STp->buffer->cmdstat.midlevel_result = SRpnt->result = rq->result;#if DEBUG STp->write_pending =0 ;#endif
drivers/scsi/qla2xxx/qla_bsg.c +3 -3
@@ -2553,13 +2553,13 @@ qla24xx_bsg_timeout(struct bsg_job *bsg_job)ql_log (ql_log_warn, vha,0x7089 ,"mbx abort_command " "failed.\n" ); - bsg_job->req->errors = +scsi_req (bsg_job->req)->result = bsg_reply->result = -EIO ; }else {ql_dbg (ql_dbg_user, vha,0x708a ,"mbx abort_command " "success.\n" ); - bsg_job->req->errors = +scsi_req (bsg_job->req)->result = bsg_reply->result =0 ; }spin_lock_irqsave (&ha->hardware_lock, flags);
@@ -2570,7 +2570,7 @@ qla24xx_bsg_timeout(struct bsg_job *bsg_job) }spin_unlock_irqrestore (&ha->hardware_lock, flags);ql_log (ql_log_info, vha,0x708b ,"SRB not found to abort.\n" ); - bsg_job->req->errors = bsg_reply->result = -ENXIO ; +scsi_req (bsg_job->req)->result = bsg_reply->result = -ENXIO ;return 0 ; done:
drivers/scsi/scsi_lib.c +7 -8
@@ -229,8 +229,8 @@ void scsi_queue_insert(struct scsi_cmnd *cmd, int reason)* @rq_flags: flags for ->rq_flags * @resid: optional residual length * -* returns the req->errors value which is the scsi_cmnd result -* field. +* Returns the scsi_cmnd result field if a command was executed, or a negative +* Linux error code if we didn't get that far. */ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, int data_direction, void *buffer, unsigned bufflen,
@@ -281,7 +281,7 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,memcpy (sense, rq->sense,SCSI_SENSE_BUFFERSIZE );if (sshdr)scsi_normalize_sense (rq->sense, rq->sense_len, sshdr); - ret = req->errors; + ret = rq->result; out:blk_put_request (req);
@@ -797,8 +797,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)/* * __scsi_error_from_host_byte may have reset the host_byte */ - req->errors = cmd->result; - +scsi_req (req)->result = cmd->result;scsi_req (req)->resid_len =scsi_get_resid (cmd);if (scsi_bidi_cmnd (cmd)) {
@@ -835,7 +834,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)/* * Recovered errors need reporting, but they're always treated as * success, so fiddle the result code here. For passthrough requests -* we already took a copy of the original into rq->errors which +* we already took a copy of the original into sreq->result which * is what gets returned to the user */ if (sense_valid && (sshdr.sense_key ==RECOVERED_ERROR )) {
@@ -1281,7 +1280,7 @@ scsi_prep_return(struct request_queue *q, struct request *req, int ret)switch (ret) {case BLKPREP_KILL :case BLKPREP_INVALID : - req->errors =DID_NO_CONNECT <<16 ; +scsi_req (req)->result =DID_NO_CONNECT <<16 ;/* release the command and kill it */ if (req->special) {struct scsi_cmnd *cmd = req->special;
@@ -1905,7 +1904,7 @@ static int scsi_mq_prep_fn(struct request *req)static void scsi_mq_done (struct scsi_cmnd *cmd) {trace_scsi_dispatch_cmd_done (cmd); -blk_mq_complete_request (cmd->request, cmd->request->errors); +blk_mq_complete_request (cmd->request,0 ); } static int scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
drivers/scsi/scsi_transport_sas.c +1 -1
@@ -184,7 +184,7 @@ static void sas_smp_request(struct request_queue *q, struct Scsi_Host *shost,blk_rq_bytes (req->next_rq); handler =to_sas_internal (shost->transportt)->f->smp_handler; ret =handler (shost, rphy, req); - req->errors = ret; +scsi_req (req)->result = ret;blk_end_request_all (req, ret);
drivers/scsi/sg.c +1 -1
@@ -1300,7 +1300,7 @@ sg_rq_end_io(struct request *rq, int uptodate)pr_info ("%s: device detaching\n" , __func__); sense = req->sense; - result = rq->errors; + result = req->result; resid = req->resid_len; SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sdp,
drivers/scsi/st.c +3 -3
@@ -480,7 +480,7 @@ static void st_do_stats(struct scsi_tape *STp, struct request *req)atomic64_add (ktime_to_ns (now), &STp->stats->tot_write_time);atomic64_add (ktime_to_ns (now), &STp->stats->tot_io_time);atomic64_inc (&STp->stats->write_cnt); -if (req->errors) { +if (scsi_req (req)->result) {atomic64_add (atomic_read (&STp->stats->last_write_size) - STp->buffer->cmdstat.residual, &STp->stats->write_byte_cnt);
@@ -494,7 +494,7 @@ static void st_do_stats(struct scsi_tape *STp, struct request *req)atomic64_add (ktime_to_ns (now), &STp->stats->tot_read_time);atomic64_add (ktime_to_ns (now), &STp->stats->tot_io_time);atomic64_inc (&STp->stats->read_cnt); -if (req->errors) { +if (scsi_req (req)->result) {atomic64_add (atomic_read (&STp->stats->last_read_size) - STp->buffer->cmdstat.residual, &STp->stats->read_byte_cnt);
@@ -518,7 +518,7 @@ static void st_scsi_execute_end(struct request *req, int uptodate)struct scsi_tape *STp = SRpnt->stp;struct bio *tmp; - STp->buffer->cmdstat.midlevel_result = SRpnt->result = req->errors; + STp->buffer->cmdstat.midlevel_result = SRpnt->result = rq->result; STp->buffer->cmdstat.residual = rq->resid_len;st_do_stats (STp, req);
drivers/target/target_core_pscsi.c +1 -1
@@ -1050,7 +1050,7 @@ static void pscsi_req_done(struct request *req, int uptodate)struct se_cmd *cmd = req->end_io_data;struct pscsi_plugin_task *pt = cmd->priv; - pt->pscsi_result = req->errors; + pt->pscsi_result =scsi_req (req)->result; pt->pscsi_resid =scsi_req (req)->resid_len; cmd->scsi_status =status_byte (pt->pscsi_result) <<1 ;
fs/nfsd/blocklayout.c +2 -2
@@ -243,9 +243,9 @@ static int nfsd4_scsi_identify_device(struct block_device *bdev, req->cmd_len =COMMAND_SIZE (INQUIRY );blk_execute_rq (rq->q,NULL , rq,1 ); -if (rq->errors) { +if (req->result) {pr_err ("pNFS: INQUIRY 0x83 failed with: %x\n" , - rq->errors); + req->result); error = -EIO ; goto out_put_request; }
include/linux/ide.h +1 -1
@@ -88,7 +88,7 @@ static inline bool ata_pm_request(struct request *rq) ide_req(rq)->type == ATA_PRIV_PM_RESUME); } -/* Error codes returned in rq->errors to the higher part of the driver. */ +/* Error codes returned in result to the higher part of the driver. */ enum {IDE_DRV_ERROR_GENERAL =101 ,IDE_DRV_ERROR_FILEMARK =102 ,
include/scsi/scsi_request.h +1 -0
@@ -9,6 +9,7 @@ struct scsi_request {unsigned char __cmd[BLK_MAX_CDB ];unsigned char *cmd;unsigned short cmd_len; +int result;unsigned int sense_len;unsigned int resid_len;/* residual count */ int retries;
Signature · 1 line
2.11.0
Re: [PATCH 08/23] scsi: introduce a result field in struct scsi_request
Quoted 7 lines · Christoph Hellwig
This passes on the
scsi_cmndresult field to users of passthrough requests. Currently we abusereq->errorsfor this purpose, but that field will go away in its current form.Note that the old IDE code abuses the errors field in very creative ways and stores all kinds of different values in it. I didn't dare to touch this magic, so the abuses are brought forward 1:1.
Christoph Hellwig
maintainerPATCH 9/23 loop: zero-fill bio on the submitting cpu
In reply to Christoph HellwigIn thruth I've just audited which blk-mq drivers don't currently have a complete callback, but I think this change is at least borderline useful.
--- drivers/block/loop.c | 30 ++++++++++++++---------------- drivers/block/loop.h | 1 + 2 files changed, 15 insertions(+), 16 deletions(-)
drivers/block/loop.c +14 -16
@@ -445,32 +445,27 @@ static int lo_req_flush(struct loop_device *lo, struct request *rq)return ret; } -static inline void handle_partial_read (struct loop_cmd *cmd,long bytes) +static void lo_complete_rq (struct request *rq) { -if (bytes <0 ||op_is_write (req_op (cmd->rq))) -return ; +struct loop_cmd *cmd =blk_mq_rq_to_pdu (rq); -if (unlikely (bytes <blk_rq_bytes (cmd->rq))) { +if (unlikely (req_op (cmd->rq) ==REQ_OP_READ && cmd->use_aio && + cmd->ret >=0 && cmd->ret <blk_rq_bytes (cmd->rq))) {struct bio *bio = cmd->rq->bio; -bio_advance (bio, bytes); +bio_advance (bio, cmd->ret);zero_fill_bio (bio); } + +blk_mq_end_request (rq, cmd->ret <0 ? -EIO :0 ); }static void lo_rw_aio_complete (struct kiocb *iocb,long ret,long ret2) { struct loop_cmd *cmd = container_of(iocb, struct loop_cmd, iocb); -struct request *rq = cmd->rq; - -handle_partial_read (cmd, ret); -if (ret >0 ) - ret =0 ; -else if (ret <0 ) - ret = -EIO ; - -blk_mq_complete_request (rq, ret); + cmd->ret = ret; +blk_mq_complete_request (cmd->rq,0 ); } static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
@@ -1688,8 +1683,10 @@ static void loop_handle_cmd(struct loop_cmd *cmd) ret =do_req_filebacked (lo, cmd->rq); failed:/* complete non-aio request */ -if (!cmd->use_aio || ret) -blk_mq_complete_request (cmd->rq, ret ? -EIO :0 ); +if (!cmd->use_aio || ret) { + cmd->ret = ret ? -EIO :0 ; +blk_mq_complete_request (cmd->rq,0 ); + } }static void loop_queue_work (struct kthread_work *work)
@@ -1715,6 +1712,7 @@ static int loop_init_request(void *data, struct request *rq,static const struct blk_mq_ops loop_mq_ops = { .queue_rq = loop_queue_rq, .init_request = loop_init_request, + .complete = lo_complete_rq, };static int loop_add (struct loop_device **l,int i)
drivers/block/loop.h +1 -0
@@ -70,6 +70,7 @@ struct loop_cmd {struct request *rq;struct list_head list;bool use_aio;/* use AIO interface to handle I/O */ +long ret;struct kiocb iocb; };
Signature · 1 line
2.11.0
Christoph Hellwig
maintainerPATCH 10/23 null_blk: don't pass always-0 req->errors to blk_mq_complete_request
In reply to Christoph Hellwig--- drivers/block/null_blk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/null_blk.c +1 -1
@@ -281,7 +281,7 @@ static inline void null_handle_cmd(struct nullb_cmd *cmd)case NULL_IRQ_SOFTIRQ :switch (queue_mode) {case NULL_Q_MQ : -blk_mq_complete_request (cmd->rq, cmd->rq->errors); +blk_mq_complete_request (cmd->rq,0 );break ;case NULL_Q_RQ :blk_complete_request (cmd->rq);
Signature · 1 line
2.11.0
Re: [PATCH 10/23] null_blk: don't pass always-0 req->errors to blk_mq_complete_request
Quoted 2 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>---
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
Christoph Hellwig
maintainerPATCH 11/23 dm rq: don't pass irrelevant error code to blk_mq_complete_request
In reply to Christoph Hellwigdm never uses rq->errors, so there is no need to pass an error argument to blk_mq_complete_request.
--- drivers/md/dm-rq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-rq.c +1 -1
@@ -363,7 +363,7 @@ static void dm_complete_request(struct request *rq, int error)if (!rq->q->mq_ops)blk_complete_request (rq);else -blk_mq_complete_request (rq, error); +blk_mq_complete_request (rq,0 ); }/*
Signature · 1 line
2.11.0
Re: [PATCH 11/23] dm rq: don't pass irrelevant error code to blk_mq_complete_request
Quoted 5 lines · Christoph Hellwig
dm never uses
rq->errors, so there is no need to pass an error argument toblk_mq_complete_request.Signed-off-by Christoph Hellwig <[email protected]>---
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 11/23] dm rq: don't pass irrelevant error code to blk_mq_complete_request
In reply to Christoph HellwigQuoted 2 lines · Christoph Hellwig
dm never uses
rq->errors, so there is no need to pass an error argument toblk_mq_complete_request.
Christoph Hellwig
maintainerPATCH 12/23 dm mpath: don't check for req->errors
In reply to Christoph HellwigWe'll get all proper errors reported through ->end_io and ->errors will go away soon.
--- drivers/md/dm-mpath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-mpath.c +1 -1
@@ -1492,7 +1492,7 @@ static int do_end_io(struct multipath *m, struct request *clone,*/ int r =DM_ENDIO_REQUEUE ; -if (!error && !clone->errors) +if (!error)return 0 ;/* I/O complete */ if (noretry_error (error))
Signature · 1 line
2.11.0
Re: [PATCH 12/23] dm mpath: don't check for req->errors
Quoted 5 lines · Christoph Hellwig
We'll get all proper errors reported through ->end_io and ->errors will go away soon.
Signed-off-by Christoph Hellwig <[email protected]>---
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 12/23] dm mpath: don't check for req->errors
In reply to Christoph HellwigQuoted 2 lines · Christoph Hellwig
We'll get all proper errors reported through ->end_io and ->errors will go away soon.
Christoph Hellwig
maintainerPATCH 13/23 nbd: don't use req->errors
In reply to Christoph HellwigAdd a nbd-specific field instead.
--- drivers/block/nbd.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/block/nbd.c +15 -15
@@ -115,6 +115,7 @@ struct nbd_cmd {int index;int cookie;struct completion send_complete; +int status; };#if IS_ENABLED (CONFIG_DEBUG_FS )
@@ -244,16 +245,14 @@ static void nbd_size_set(struct nbd_device *nbd, loff_t blocksize,nbd_size_update (nbd); } -static void nbd_end_request (struct nbd_cmd *cmd) +static void nbd_complete_rq (struct request *req) { -struct nbd_device *nbd = cmd->nbd; -struct request *req =blk_mq_rq_from_pdu (cmd); -int error = req->errors ? -EIO :0 ; +struct nbd_cmd *cmd =blk_mq_rq_to_pdu (req); -dev_dbg (nbd_to_dev (nbd),"request %p: %s\n" , cmd, - error ?"failed" :"done" ); +dev_dbg (nbd_to_dev (cmd->nbd),"request %p: %s\n" , cmd, + cmd->status ?"failed" :"done" ); -blk_mq_complete_request (req, error); +blk_mq_end_request (req, cmd->status); }/*
@@ -286,7 +285,7 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,struct nbd_config *config;if (!refcount_inc_not_zero (&nbd->config_refs)) { - req->errors = -EIO ; + cmd->status = -EIO ;return BLK_EH_HANDLED ; }
@@ -331,7 +330,7 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req, "Connection timed out\n"); }set_bit (NBD_TIMEDOUT , &config->runtime_flags); - req->errors = -EIO ; + cmd->status = -EIO ;sock_shutdown (nbd);nbd_config_put (nbd);
@@ -574,7 +573,7 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index)if (ntohl (reply.error)) {dev_err (disk_to_dev (nbd->disk),"Other side returned error (%d)\n" ,ntohl (reply.error)); - req->errors = -EIO ; + cmd->status = -EIO ;return cmd; }
@@ -599,7 +598,7 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index)*/ if (nbd_disconnected (config) || config->num_connections <=1 ) { - req->errors = -EIO ; + cmd->status = -EIO ;return cmd; }return ERR_PTR (-EIO );
@@ -636,7 +635,7 @@ static void recv_work(struct work_struct *work)break ; } -nbd_end_request (cmd); +blk_mq_complete_request (blk_mq_rq_from_pdu (cmd),0 ); }atomic_dec (&config->recv_threads);wake_up (&config->recv_wq);
@@ -651,8 +650,8 @@ static void nbd_clear_req(struct request *req, void *data, bool reserved)if (!blk_mq_request_started (req))return ; cmd =blk_mq_rq_to_pdu (req); - req->errors = -EIO ; -nbd_end_request (cmd); + cmd->status = -EIO ; +blk_mq_complete_request (req,0 ); }static void nbd_clear_que (struct nbd_device *nbd)
@@ -740,7 +739,7 @@ static int nbd_handle_cmd(struct nbd_cmd *cmd, int index)nbd_config_put (nbd);return -EINVAL ; } - req->errors =0 ; + cmd->status =0 ; again: nsock = config->socks[index];mutex_lock (&nsock->tx_lock);
@@ -1408,6 +1407,7 @@ static int nbd_init_request(void *data, struct request *rq,static const struct blk_mq_ops nbd_mq_ops = { .queue_rq = nbd_queue_rq, + .complete = nbd_complete_rq, .init_request = nbd_init_request, .timeout = nbd_xmit_timeout, };
Signature · 1 line
2.11.0
Christoph Hellwig
maintainerPATCH 14/23 mtip32xx: add a status field to struct mtip_cmd
In reply to Christoph HellwigInstead of using req->errors, which will go away.
--- drivers/block/mtip32xx/mtip32xx.c | 16 +++++++++------- drivers/block/mtip32xx/mtip32xx.h | 1 + 2 files changed, 10 insertions(+), 7 deletions(-)
drivers/block/mtip32xx/mtip32xx.c +9 -7
@@ -241,7 +241,8 @@ static void mtip_async_complete(struct mtip_port *port, rq =mtip_rq_from_tag (dd, tag); -blk_mq_complete_request (rq, status); + cmd->status = status; +blk_mq_complete_request (rq,0 ); }/*
@@ -2910,18 +2911,19 @@ static void mtip_softirq_done_fn(struct request *rq)if (unlikely (cmd->unaligned))up (&dd->port->cmd_slot_unal); -blk_mq_end_request (rq, rq->errors); +blk_mq_end_request (rq, cmd->status); }static void mtip_abort_cmd (struct request *req,void *data,bool reserved) { +struct mtip_cmd *cmd =blk_mq_rq_to_pdu (req);struct driver_data *dd = data;dbg_printk (MTIP_DRV_NAME " Aborting request, tag = %d\n" , req->tag);clear_bit (req->tag, dd->port->cmds_to_issue); - req->errors = -EIO ; + cmd->status = -EIO ;mtip_softirq_done_fn (req); }
@@ -3816,7 +3818,6 @@ static int mtip_queue_rq(struct blk_mq_hw_ctx *hctx,if (likely (!ret))return BLK_MQ_RQ_QUEUE_OK ; - rq->errors = ret;return BLK_MQ_RQ_QUEUE_ERROR ; }
@@ -4106,9 +4107,10 @@ static void mtip_no_dev_cleanup(struct request *rq, void *data, bool reserv)struct driver_data *dd = (struct driver_data *)data;struct mtip_cmd *cmd; -if (likely (!reserv)) -blk_mq_complete_request (rq, -ENODEV ); -else if (test_bit (MTIP_PF_IC_ACTIVE_BIT , &dd->port->flags)) { +if (likely (!reserv)) { + cmd->status = -ENODEV ; +blk_mq_complete_request (rq,0 ); + }else if (test_bit (MTIP_PF_IC_ACTIVE_BIT , &dd->port->flags)) { cmd =mtip_cmd_from_tag (dd,MTIP_TAG_INTERNAL );if (cmd->comp_func)
drivers/block/mtip32xx/mtip32xx.h +1 -0
@@ -352,6 +352,7 @@ struct mtip_cmd {int retries;/* The number of retries left for this command. */ int direction;/* Data transfer direction */ +int status; };/* Structure used to describe a port. */
Signature · 1 line
2.11.0
Re: [PATCH 14/23] mtip32xx: add a status field to struct mtip_cmd
Quoted 4 lines · Christoph Hellwig
Instead of using
req->errors, which will go away.Signed-off-by Christoph Hellwig <[email protected]>---
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
Christoph Hellwig
maintainerPATCH 15/23 xen-blkfront: don't use req->errors
In reply to Christoph Hellwigxen-blkfron is the last users using rq->errros for passing back error to blk-mq, and I'd like to get rid of that. In the longer run the driver should be moving more of the completion processing into .complete, but this is the minimal change to move forward for now.
--- drivers/block/xen-blkfront.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-)
drivers/block/xen-blkfront.c +25 -11
@@ -115,6 +115,15 @@ struct split_bio {atomic_t pending; }; +struct blkif_req { +int error; +}; + +static inline struct blkif_req *blkif_req (struct request *rq) +{ +return blk_mq_rq_to_pdu (rq); +} +static DEFINE_MUTEX (blkfront_mutex);static const struct block_device_operations xlvbd_block_fops;
@@ -907,8 +916,14 @@ static int blkif_queue_rq(struct blk_mq_hw_ctx *hctx,return BLK_MQ_RQ_QUEUE_BUSY ; } +static void blkif_complete_rq (struct request *rq) +{ +blk_mq_end_request (rq,blkif_req (rq)->error); +} +static const struct blk_mq_ops blkfront_mq_ops = { .queue_rq = blkif_queue_rq, + .complete = blkif_complete_rq, };static void blkif_set_queue_limits (struct blkfront_info *info)
@@ -969,7 +984,7 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size, info->tag_set.queue_depth =BLK_RING_SIZE (info); info->tag_set.numa_node =NUMA_NO_NODE ; info->tag_set.flags =BLK_MQ_F_SHOULD_MERGE |BLK_MQ_F_SG_MERGE ; - info->tag_set.cmd_size =0 ; + info->tag_set.cmd_size =sizeof (struct blkif_req ); info->tag_set.driver_data = info;if (blk_mq_alloc_tag_set (&info->tag_set))
@@ -1543,7 +1558,6 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)unsigned long flags;struct blkfront_ring_info *rinfo = (struct blkfront_ring_info *)dev_id;struct blkfront_info *info = rinfo->dev_info; -int error;if (unlikely (info->connected !=BLKIF_STATE_CONNECTED ))return IRQ_HANDLED ;
@@ -1587,37 +1601,36 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)continue ; } - error = (bret->status ==BLKIF_RSP_OKAY ) ?0 : -EIO ; +blkif_req (req)->error = (bret->status ==BLKIF_RSP_OKAY ) ?0 : -EIO ;switch (bret->operation) {case BLKIF_OP_DISCARD :if (unlikely (bret->status ==BLKIF_RSP_EOPNOTSUPP )) {struct request_queue *rq = info->rq;printk (KERN_WARNING "blkfront: %s: %s op failed\n" , info->gd->disk_name,op_name (bret->operation)); - error = -EOPNOTSUPP ; +blkif_req (req)->error = -EOPNOTSUPP ; info->feature_discard =0 ; info->feature_secdiscard =0 ;queue_flag_clear (QUEUE_FLAG_DISCARD , rq);queue_flag_clear (QUEUE_FLAG_SECERASE , rq); } -blk_mq_complete_request (req, error);break ;case BLKIF_OP_FLUSH_DISKCACHE :case BLKIF_OP_WRITE_BARRIER :if (unlikely (bret->status ==BLKIF_RSP_EOPNOTSUPP )) {printk (KERN_WARNING "blkfront: %s: %s op failed\n" , info->gd->disk_name,op_name (bret->operation)); - error = -EOPNOTSUPP ; +blkif_req (req)->error = -EOPNOTSUPP ; }if (unlikely (bret->status ==BLKIF_RSP_ERROR && rinfo->shadow[id].req.u.rw.nr_segments ==0 )) {printk (KERN_WARNING "blkfront: %s: empty %s op failed\n" , info->gd->disk_name,op_name (bret->operation)); - error = -EOPNOTSUPP ; +blkif_req (req)->error = -EOPNOTSUPP ; } -if (unlikely (error)) { -if (error == -EOPNOTSUPP ) - error =0 ; +if (unlikely (blkif_req (req)->error)) { +if (blkif_req (req)->error == -EOPNOTSUPP ) +blkif_req (req)->error =0 ; info->feature_fua =0 ; info->feature_flush =0 ;xlvbd_flush (info);
@@ -1629,11 +1642,12 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)dev_dbg (&info->xbdev->dev,"Bad return from blkdev data " "request: %x\n" , bret->status); -blk_mq_complete_request (req, error);break ;default :BUG (); } + +blk_mq_complete_request (req,0 ); } rinfo->ring.rsp_cons = i;
Signature · 1 line
2.11.0
Christoph Hellwig
maintainerPATCH 16/23 blk-mq: remove the error argument to blk_mq_complete_request
In reply to Christoph HellwigNow that all drivers that call blk_mq_complete_requests have a ->complete callback we can remove the direct call to blk_mq_end_request, as well as the error argument to blk_mq_complete_request.
--- block/blk-mq.c | 15 +++------------ drivers/block/loop.c | 4 ++-- drivers/block/mtip32xx/mtip32xx.c | 4 ++-- drivers/block/nbd.c | 4 ++-- drivers/block/null_blk.c | 2 +- drivers/block/virtio_blk.c | 2 +- drivers/block/xen-blkfront.c | 2 +- drivers/md/dm-rq.c | 2 +- drivers/nvme/host/core.c | 2 +- drivers/nvme/host/nvme.h | 2 +- drivers/scsi/scsi_lib.c | 2 +- include/linux/blk-mq.h | 2 +- 12 files changed, 17 insertions(+), 26 deletions(-)
block/blk-mq.c +3 -12
@@ -442,17 +442,10 @@ static void blk_mq_stat_add(struct request *rq)static void __blk_mq_complete_request (struct request *rq) { -struct request_queue *q = rq->q; -if (rq->internal_tag !=-1 )blk_mq_sched_completed_request (rq); -blk_mq_stat_add (rq); - -if (!q->softirq_done_fn) -blk_mq_end_request (rq, rq->errors); -else -blk_mq_ipi_complete_request (rq); +blk_mq_ipi_complete_request (rq); }/**
@@ -463,16 +456,14 @@ static void __blk_mq_complete_request(struct request *rq)* Ends all I/O on a request. It does not handle partial completions. * The actual completion happens out-of-order, through a IPI handler. **/ -void blk_mq_complete_request (struct request *rq,int error) +void blk_mq_complete_request (struct request *rq) {struct request_queue *q = rq->q;if (unlikely (blk_should_fake_timeout (q)))return ; -if (!blk_mark_rq_complete (rq)) { - rq->errors = error; +if (!blk_mark_rq_complete (rq))__blk_mq_complete_request (rq); - } }EXPORT_SYMBOL (blk_mq_complete_request);
drivers/block/loop.c +2 -2
@@ -465,7 +465,7 @@ static void lo_rw_aio_complete(struct kiocb *iocb, long ret, long ret2) struct loop_cmd *cmd = container_of(iocb, struct loop_cmd, iocb); cmd->ret = ret; -blk_mq_complete_request (cmd->rq,0 ); +blk_mq_complete_request (cmd->rq); } static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
@@ -1685,7 +1685,7 @@ static void loop_handle_cmd(struct loop_cmd *cmd)/* complete non-aio request */ if (!cmd->use_aio || ret) { cmd->ret = ret ? -EIO :0 ; -blk_mq_complete_request (cmd->rq,0 ); +blk_mq_complete_request (cmd->rq); } }
drivers/block/mtip32xx/mtip32xx.c +2 -2
@@ -242,7 +242,7 @@ static void mtip_async_complete(struct mtip_port *port, rq =mtip_rq_from_tag (dd, tag); cmd->status = status; -blk_mq_complete_request (rq,0 ); +blk_mq_complete_request (rq); }/*
@@ -4109,7 +4109,7 @@ static void mtip_no_dev_cleanup(struct request *rq, void *data, bool reserv)if (likely (!reserv)) { cmd->status = -ENODEV ; -blk_mq_complete_request (rq,0 ); +blk_mq_complete_request (rq); }else if (test_bit (MTIP_PF_IC_ACTIVE_BIT , &dd->port->flags)) { cmd =mtip_cmd_from_tag (dd,MTIP_TAG_INTERNAL );
drivers/block/nbd.c +2 -2
@@ -635,7 +635,7 @@ static void recv_work(struct work_struct *work)break ; } -blk_mq_complete_request (blk_mq_rq_from_pdu (cmd),0 ); +blk_mq_complete_request (blk_mq_rq_from_pdu (cmd)); }atomic_dec (&config->recv_threads);wake_up (&config->recv_wq);
@@ -651,7 +651,7 @@ static void nbd_clear_req(struct request *req, void *data, bool reserved)return ; cmd =blk_mq_rq_to_pdu (req); cmd->status = -EIO ; -blk_mq_complete_request (req,0 ); +blk_mq_complete_request (req); }static void nbd_clear_que (struct nbd_device *nbd)
drivers/block/null_blk.c +1 -1
@@ -281,7 +281,7 @@ static inline void null_handle_cmd(struct nullb_cmd *cmd)case NULL_IRQ_SOFTIRQ :switch (queue_mode) {case NULL_Q_MQ : -blk_mq_complete_request (cmd->rq,0 ); +blk_mq_complete_request (cmd->rq);break ;case NULL_Q_RQ :blk_complete_request (cmd->rq);
drivers/block/virtio_blk.c +1 -1
@@ -201,7 +201,7 @@ static void virtblk_done(struct virtqueue *vq)while ((vbr =virtqueue_get_buf (vblk->vqs[qid].vq, &len)) !=NULL ) {struct request *req =blk_mq_rq_from_pdu (vbr); -blk_mq_complete_request (req,0 ); +blk_mq_complete_request (req); req_done = true; }if (unlikely (virtqueue_is_broken (vq)))
drivers/block/xen-blkfront.c +1 -1
@@ -1647,7 +1647,7 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)BUG (); } -blk_mq_complete_request (req,0 ); +blk_mq_complete_request (req); } rinfo->ring.rsp_cons = i;
drivers/md/dm-rq.c +1 -1
@@ -363,7 +363,7 @@ static void dm_complete_request(struct request *rq, int error)if (!rq->q->mq_ops)blk_complete_request (rq);else -blk_mq_complete_request (rq,0 ); +blk_mq_complete_request (rq); }/*
drivers/nvme/host/core.c +1 -1
@@ -117,7 +117,7 @@ void nvme_cancel_request(struct request *req, void *data, bool reserved)if (blk_queue_dying (req->q)) status |=NVME_SC_DNR ;nvme_req (req)->status = status; -blk_mq_complete_request (req,0 ); +blk_mq_complete_request (req); }EXPORT_SYMBOL_GPL (nvme_cancel_request);
drivers/nvme/host/nvme.h +1 -1
@@ -251,7 +251,7 @@ static inline void nvme_end_request(struct request *req, __le16 status, rq->status =le16_to_cpu (status) >>1 ; rq->result = result; -blk_mq_complete_request (req,0 ); +blk_mq_complete_request (req); }void nvme_complete_rq (struct request *req);
drivers/scsi/scsi_lib.c +1 -1
@@ -1904,7 +1904,7 @@ static int scsi_mq_prep_fn(struct request *req)static void scsi_mq_done (struct scsi_cmnd *cmd) {trace_scsi_dispatch_cmd_done (cmd); -blk_mq_complete_request (cmd->request,0 ); +blk_mq_complete_request (cmd->request); } static int scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
include/linux/blk-mq.h +1 -1
@@ -228,7 +228,7 @@ void blk_mq_add_to_requeue_list(struct request *rq, bool at_head,void blk_mq_kick_requeue_list (struct request_queue *q);void blk_mq_delay_kick_requeue_list (struct request_queue *q,unsigned long msecs);void blk_mq_abort_requeue_list (struct request_queue *q); -void blk_mq_complete_request (struct request *rq,int error); +void blk_mq_complete_request (struct request *rq);bool blk_mq_queue_stopped (struct request_queue *q);void blk_mq_stop_hw_queue (struct blk_mq_hw_ctx *hctx);
Signature · 1 line
2.11.0
Re: [PATCH 16/23] blk-mq: remove the error argument to blk_mq_complete_request
Quoted 6 lines · Christoph Hellwig
Now that all drivers that call
blk_mq_complete_requestshave a ->complete callback we can remove the direct call toblk_mq_end_request, as well as the error argument toblk_mq_complete_request.Signed-off-by Christoph Hellwig <[email protected]>---
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 16/23] blk-mq: remove the error argument to blk_mq_complete_request
In reply to Christoph HellwigQuoted 3 lines · Christoph Hellwig
Now that all drivers that call
blk_mq_complete_requestshave a ->complete callback we can remove the direct call toblk_mq_end_request, as well as the error argument toblk_mq_complete_request.
Christoph Hellwig
maintainerPATCH 17/23 blk-mq: simplify __blk_mq_complete_request
In reply to Christoph HellwigMerge blk_mq_ipi_complete_request and blk_mq_stat_add into their only caller.
--- block/blk-mq.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-)
block/blk-mq.c +8 -17
@@ -406,12 +406,19 @@ static void __blk_mq_complete_request_remote(void *data) rq->q->softirq_done_fn (rq); } -static void blk_mq_ipi_complete_request (struct request *rq) +static void __blk_mq_complete_request (struct request *rq) {struct blk_mq_ctx *ctx = rq->mq_ctx;bool shared = false;int cpu; +if (rq->internal_tag !=-1 ) +blk_mq_sched_completed_request (rq); +if (rq->rq_flags &RQF_STATS ) { +blk_mq_poll_stats_start (rq->q); +blk_stat_add (rq); + } +if (!test_bit (QUEUE_FLAG_SAME_COMP , &rq->q->queue_flags)) { rq->q->softirq_done_fn (rq);return ;
@@ -432,22 +439,6 @@ static void blk_mq_ipi_complete_request(struct request *rq)put_cpu (); } -static void blk_mq_stat_add (struct request *rq) -{ -if (rq->rq_flags &RQF_STATS ) { -blk_mq_poll_stats_start (rq->q); -blk_stat_add (rq); - } -} - -static void __blk_mq_complete_request (struct request *rq) -{ -if (rq->internal_tag !=-1 ) -blk_mq_sched_completed_request (rq); -blk_mq_stat_add (rq); -blk_mq_ipi_complete_request (rq); -} -/** * blk_mq_complete_request - end I/O on a request * @rq: the request being processed
Signature · 1 line
2.11.0
Christoph Hellwig
maintainerPATCH 18/23 block: add a error_count field to struct request
In reply to Christoph HellwigThis is for the legacy floppy and ataflop drivers that currently abuse ->errors for this purpose. It's stashed away in a union to not grow the struct size, the other fields are either used by modern drivers for different purposes or the I/O scheduler before queing the I/O to drivers.
--- include/linux/blkdev.h | 1 + 1 file changed, 1 insertion(+)
include/linux/blkdev.h +1 -0
@@ -175,6 +175,7 @@ struct request {struct rb_node rb_node;/* sort/lookup */ struct bio_vec special_vec;void *completion_data; +int error_count;/* for legacy drivers, don't use */ };/*
Signature · 1 line
2.11.0
Christoph Hellwig
maintainerPATCH 19/23 floppy: switch from req->errors to req->error_count
In reply to Christoph Hellwig--- drivers/block/floppy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/block/floppy.c +4 -2
@@ -2805,8 +2805,10 @@ static int set_next_request(void) fdc_queue =0 ;if (q) { current_req =blk_fetch_request (q); -if (current_req) +if (current_req) { + current_req->error_count =0 ;break ; + } } }while (fdc_queue != old_pos);
@@ -2866,7 +2868,7 @@ static void redo_fd_request(void) _floppy = floppy_type +DP ->autodetect[DRS ->probed_format]; }else probing =0 ; - errors = &(current_req->errors); + errors = &(current_req->error_count); tmp =make_raw_rw_request ();if (tmp <2 ) {request_done (tmp);
Signature · 1 line
2.11.0
Christoph Hellwig
maintainerPATCH 20/23 ataflop: switch from req->errors to req->error_count
In reply to Christoph Hellwig--- drivers/block/ataflop.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/block/ataflop.c +7 -5
@@ -617,12 +617,12 @@ static void fd_error( void )if (!fd_request)return ; - fd_request->errors++; -if (fd_request->errors >=MAX_ERRORS ) { + fd_request->error_count++; +if (fd_request->error_count >=MAX_ERRORS ) {printk (KERN_ERR "fd%d: too many errors.\n" , SelectedDrive );fd_end_request_cur (-EIO ); } -else if (fd_request->errors ==RECALIBRATE_ERRORS ) { +else if (fd_request->error_count ==RECALIBRATE_ERRORS ) {printk (KERN_WARNING "fd%d: recalibrating\n" , SelectedDrive );if (SelectedDrive !=-1 )SUD .track =-1 ;
@@ -1386,7 +1386,7 @@ static void setup_req_params( int drive ) ReqData = ReqBuffer +512 * ReqCnt;if (UseTrackbuffer) - read_track = (ReqCmd ==READ && fd_request->errors ==0 ); + read_track = (ReqCmd ==READ && fd_request->error_count ==0 );else read_track =0 ;
@@ -1409,8 +1409,10 @@ static struct request *set_next_request(void) fdc_queue =0 ;if (q) { rq =blk_fetch_request (q); -if (rq) +if (rq) { + rq->error_count =0 ;break ; + } } }while (fdc_queue != old_pos);
Signature · 1 line
2.11.0
Christoph Hellwig
maintainerPATCH 21/23 swim3: remove (commented out) printing of req->errors
In reply to Christoph Hellwig--- drivers/block/swim3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/swim3.c +2 -2
@@ -343,8 +343,8 @@ static void start_request(struct floppy_state *fs) req->rq_disk->disk_name, req->cmd, (long )blk_rq_pos (req),blk_rq_sectors (req), bio_data(req->bio)); -swim3_dbg (" errors=%d current_nr_sectors=%u\n" , - req->errors,blk_rq_cur_sectors (req)); +swim3_dbg (" current_nr_sectors=%u\n" , +blk_rq_cur_sectors (req));#endif if (blk_rq_pos (req) >= fs->total_secs) {
Signature · 1 line
2.11.0
Re: [PATCH 21/23] swim3: remove (commented out) printing of req->errors
Quoted 2 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>---
Easy enough,
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
Christoph Hellwig
maintainerPATCH 22/23 blktrace: remove the unused block_rq_abort tracepoint
In reply to Christoph Hellwig--- include/trace/events/block.h | 44 ++++++++++---------------------------------- kernel/trace/blktrace.c | 9 --------- 2 files changed, 10 insertions(+), 43 deletions(-)
include/trace/events/block.h +10 -34
@@ -61,7 +61,16 @@ DEFINE_EVENT(block_buffer, block_dirty_buffer,TP_ARGS (bh) ); -DECLARE_EVENT_CLASS(block_rq_with_error, +/** +* block_rq_requeue - place block IO request back on a queue +* @q: queue holding operation +* @rq: block IO operation request +* +* The block operation request @rq is being placed back into queue +* @q. For some reason the request was not completed and needs to be +* put back in the queue. +*/ +TRACE_EVENT(block_rq_requeue, TP_PROTO(struct request_queue *q, struct request *rq),
@@ -94,39 +103,6 @@ DECLARE_EVENT_CLASS(block_rq_with_error, );/** -* block_rq_abort - abort block operation request -* @q: queue containing the block operation request -* @rq: block IO operation request -* -* Called immediately after pending block IO operation request @rq in -* queue @q is aborted. The fields in the operation request @rq -* can be examined to determine which device and sectors the pending -* operation would access. -*/ -DEFINE_EVENT (block_rq_with_error, block_rq_abort, - - TP_PROTO(struct request_queue *q, struct request *rq), - -TP_ARGS (q, rq) -); - -/** -* block_rq_requeue - place block IO request back on a queue -* @q: queue holding operation -* @rq: block IO operation request -* -* The block operation request @rq is being placed back into queue -* @q. For some reason the request was not completed and needs to be -* put back in the queue. -*/ -DEFINE_EVENT (block_rq_with_error, block_rq_requeue, - - TP_PROTO(struct request_queue *q, struct request *rq), - -TP_ARGS (q, rq) -); - -/** * block_rq_complete - block IO operation completed by device driver * @q: queue containing the block operation request * @rq: block operations request
kernel/trace/blktrace.c +0 -9
@@ -716,12 +716,6 @@ static void blk_add_trace_rq(struct request_queue *q, struct request *rq, rq->cmd_flags, what, rq->errors, 0, NULL); } -static void blk_add_trace_rq_abort (void *ignore, -struct request_queue *q,struct request *rq) -{ -blk_add_trace_rq (q, rq,blk_rq_bytes (rq),BLK_TA_ABORT ); -} -static void blk_add_trace_rq_insert (void *ignore,struct request_queue *q,struct request *rq) {
@@ -974,8 +968,6 @@ static void blk_register_tracepoints(void) {int ret; - ret =register_trace_block_rq_abort (blk_add_trace_rq_abort,NULL ); -WARN_ON (ret); ret =register_trace_block_rq_insert (blk_add_trace_rq_insert,NULL );WARN_ON (ret); ret =register_trace_block_rq_issue (blk_add_trace_rq_issue,NULL );
@@ -1028,7 +1020,6 @@ static void blk_unregister_tracepoints(void)unregister_trace_block_rq_requeue (blk_add_trace_rq_requeue,NULL );unregister_trace_block_rq_issue (blk_add_trace_rq_issue,NULL );unregister_trace_block_rq_insert (blk_add_trace_rq_insert,NULL ); -unregister_trace_block_rq_abort (blk_add_trace_rq_abort,NULL );tracepoint_synchronize_unregister (); }
Signature · 1 line
2.11.0
Re: [PATCH 22/23] blktrace: remove the unused block_rq_abort tracepoint
Quoted 2 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>---
Just to be sure nothings forgotten, does this change need an update for blktrace as well?
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
Christoph Hellwig
maintainerRe: [PATCH 22/23] blktrace: remove the unused block_rq_abort tracepoint
Quoted 6 lines · Johannes Thumshirn
Quoted 2 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>---
Just to be sure nothings forgotten, does this change need an update for blktrace as well?
I don't think so. It will just never get this event before or after this patch.
Johannes Thumshirn
Reviewed-byRe: [PATCH 22/23] blktrace: remove the unused block_rq_abort tracepoint
Quoted 10 lines · Christoph Hellwig
Quoted 6 lines · Johannes Thumshirn
Quoted 2 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>---
Just to be sure nothings forgotten, does this change need an update for blktrace as well?
I don't think so. It will just never get this event before or after this patch.
Ok then,
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
Jens Axboe
maintainerRe: [PATCH 22/23] blktrace: remove the unused block_rq_abort tracepoint
In reply to Johannes ThumshirnQuoted 6 lines · Johannes Thumshirn
Quoted 2 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>---
Just to be sure nothings forgotten, does this change need an update for blktrace as well?
blktrace doesn't use this event for anything internally, so the change is fine.
Signature · 1 line
Jens Axboe
Christoph Hellwig
maintainerPATCH 23/23 block: remove the errors field from struct request
In reply to Christoph Hellwig--- block/blk-core.c | 14 +------------- block/blk-exec.c | 3 +-- block/blk-mq.c | 10 +++------- block/blk-timeout.c | 1 - include/linux/blkdev.h | 2 -- include/trace/events/block.h | 17 +++++++---------- kernel/trace/blktrace.c | 26 ++++++++++++-------------- 7 files changed, 24 insertions(+), 49 deletions(-)
block/blk-core.c +1 -13
@@ -1635,7 +1635,6 @@ void blk_init_request_from_bio(struct request *req, struct bio *bio)if (bio->bi_opf &REQ_RAHEAD ) req->cmd_flags |=REQ_FAILFAST_MASK ; - req->errors =0 ; req->__sector = bio->bi_iter.bi_sector;if (ioprio_valid (bio_prio (bio))) req->ioprio =bio_prio (bio);
@@ -2573,22 +2572,11 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes) {int total_bytes; -trace_block_rq_complete (req->q, req, nr_bytes); +trace_block_rq_complete (req, error, nr_bytes);if (!req->bio)return false; -/* -* For fs requests, rq is just carrier of independent bio's -* and each partial completion should be handled separately. -* Reset per-request error on each partial completion. -* -* TODO: tj: This is too subtle. It would be better to let -* low level drivers do what they see fit. -*/ -if (!blk_rq_is_passthrough (req)) - req->errors =0 ; -if (error && !blk_rq_is_passthrough (req) && !(req->rq_flags &RQF_QUIET )) {char *error_type;
block/blk-exec.c +1 -2
@@ -69,8 +69,7 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,if (unlikely (blk_queue_dying (q))) { rq->rq_flags |=RQF_QUIET ; - rq->errors = -ENXIO ; -__blk_end_request_all (rq, rq->errors); +__blk_end_request_all (rq, -ENXIO );spin_unlock_irq (q->queue_lock);return ; }
block/blk-mq.c +3 -7
@@ -213,7 +213,6 @@ void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx,#endif rq->special =NULL ;/* tag was already set */ - rq->errors =0 ; rq->extra_len =0 ;INIT_LIST_HEAD (&rq->timeout_list);
@@ -624,8 +623,7 @@ void blk_mq_abort_requeue_list(struct request_queue *q) rq = list_first_entry(&rq_list, struct request, queuelist);list_del_init (&rq->queuelist); - rq->errors = -EIO ; -blk_mq_end_request (rq, rq->errors); +blk_mq_end_request (rq, -EIO ); } }EXPORT_SYMBOL (blk_mq_abort_requeue_list);
@@ -1032,8 +1030,7 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list)pr_err ("blk-mq: bad return on queue: %d\n" , ret);case BLK_MQ_RQ_QUEUE_ERROR : errors++; - rq->errors = -EIO ; -blk_mq_end_request (rq, rq->errors); +blk_mq_end_request (rq, -EIO );break ; }
@@ -1484,8 +1481,7 @@ static void __blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie,if (ret ==BLK_MQ_RQ_QUEUE_ERROR ) { *cookie =BLK_QC_T_NONE ; - rq->errors = -EIO ; -blk_mq_end_request (rq, rq->errors); +blk_mq_end_request (rq, -EIO );return ; }
block/blk-timeout.c +0 -1
@@ -89,7 +89,6 @@ static void blk_rq_timed_out(struct request *req) ret = q->rq_timed_out_fn (req);switch (ret) {case BLK_EH_HANDLED : -/* Can we use req->errors here? */ __blk_complete_request (req);break ;case BLK_EH_RESET_TIMER :
include/linux/blkdev.h +0 -2
@@ -220,8 +220,6 @@ struct request {void *special;/* opaque pointer available for LLD use */ -int errors; -unsigned int extra_len;/* length of alignment and padding */ unsigned long deadline;
include/trace/events/block.h +7 -10
@@ -80,7 +80,6 @@ TRACE_EVENT(block_rq_requeue, __field( dev_t, dev ) __field( sector_t, sector ) __field( unsigned int, nr_sector ) - __field( int, errors ) __array( char, rwbs, RWBS_LEN ) __dynamic_array( char, cmd, 1 ) ),
@@ -89,7 +88,6 @@ TRACE_EVENT(block_rq_requeue, __entry->dev = rq->rq_disk ?disk_devt (rq->rq_disk) :0 ; __entry->sector =blk_rq_trace_sector (rq); __entry->nr_sector =blk_rq_trace_nr_sectors (rq); - __entry->errors = rq->errors;blk_fill_rwbs (__entry->rwbs, rq->cmd_flags,blk_rq_bytes (rq));__get_str (cmd)[0 ] ='\0' ;
@@ -99,13 +97,13 @@ TRACE_EVENT(block_rq_requeue,MAJOR (__entry->dev),MINOR (__entry->dev), __entry->rwbs,__get_str (cmd), (unsigned long long )__entry->sector, - __entry->nr_sector, __entry->errors) + __entry->nr_sector, 0) );/** * block_rq_complete - block IO operation completed by device driver -* @q: queue containing the block operation request * @rq: block operations request +* @error: status code * @nr_bytes: number of completed bytes * * The block_rq_complete tracepoint event indicates that some portion
@@ -116,16 +114,15 @@ TRACE_EVENT(block_rq_requeue,*/ TRACE_EVENT(block_rq_complete, - TP_PROTO(struct request_queue *q, struct request *rq, - unsigned int nr_bytes), + TP_PROTO(struct request *rq, int error, unsigned int nr_bytes), - TP_ARGS(q, rq, nr_bytes), + TP_ARGS(rq, error, nr_bytes), TP_STRUCT__entry( __field( dev_t, dev ) __field( sector_t, sector ) __field( unsigned int, nr_sector ) - __field( int, errors ) + __field( int, error ) __array( char, rwbs, RWBS_LEN ) __dynamic_array( char, cmd, 1 ) ),
@@ -134,7 +131,7 @@ TRACE_EVENT(block_rq_complete, __entry->dev = rq->rq_disk ?disk_devt (rq->rq_disk) :0 ; __entry->sector =blk_rq_pos (rq); __entry->nr_sector = nr_bytes >>9 ; - __entry->errors = rq->errors; + __entry->error = error;blk_fill_rwbs (__entry->rwbs, rq->cmd_flags, nr_bytes);__get_str (cmd)[0 ] ='\0' ;
@@ -144,7 +141,7 @@ TRACE_EVENT(block_rq_complete,MAJOR (__entry->dev),MINOR (__entry->dev), __entry->rwbs,__get_str (cmd), (unsigned long long )__entry->sector, - __entry->nr_sector, __entry->errors) + __entry->nr_sector, __entry->error) ); DECLARE_EVENT_CLASS(block_rq,
kernel/trace/blktrace.c +12 -14
@@ -690,8 +690,8 @@ void blk_trace_shutdown(struct request_queue *q)/** * blk_add_trace_rq - Add a trace for a request oriented action -* @q: queue the io is for * @rq: the source request +* @error: return status to log * @nr_bytes: number of completed bytes * @what: the action *
@@ -699,10 +699,10 @@ void blk_trace_shutdown(struct request_queue *q)* Records an action against a request. Will log the bio offset + size. * **/ -static void blk_add_trace_rq (struct request_queue *q,struct request *rq, +static void blk_add_trace_rq (struct request *rq,int error,unsigned int nr_bytes,u32 what) { -struct blk_trace *bt = q->blk_trace; +struct blk_trace *bt = rq->q->blk_trace;if (likely (!bt))return ;
@@ -713,34 +713,32 @@ static void blk_add_trace_rq(struct request_queue *q, struct request *rq, what |=BLK_TC_ACT (BLK_TC_FS );__blk_add_trace (bt,blk_rq_trace_sector (rq), nr_bytes,req_op (rq), - rq->cmd_flags, what, rq->errors,0 ,NULL ); + rq->cmd_flags, what, error,0 ,NULL ); }static void blk_add_trace_rq_insert (void *ignore,struct request_queue *q,struct request *rq) { -blk_add_trace_rq (q, rq,blk_rq_bytes (rq),BLK_TA_INSERT ); +blk_add_trace_rq (rq,0 ,blk_rq_bytes (rq),BLK_TA_INSERT ); }static void blk_add_trace_rq_issue (void *ignore,struct request_queue *q,struct request *rq) { -blk_add_trace_rq (q, rq,blk_rq_bytes (rq),BLK_TA_ISSUE ); +blk_add_trace_rq (rq,0 ,blk_rq_bytes (rq),BLK_TA_ISSUE ); }static void blk_add_trace_rq_requeue (void *ignore,struct request_queue *q,struct request *rq) { -blk_add_trace_rq (q, rq,blk_rq_bytes (rq),BLK_TA_REQUEUE ); +blk_add_trace_rq (rq,0 ,blk_rq_bytes (rq),BLK_TA_REQUEUE ); } -static void blk_add_trace_rq_complete (void *ignore, -struct request_queue *q, -struct request *rq, -unsigned int nr_bytes) +static void blk_add_trace_rq_complete (void *ignore,struct request *rq, +int error,unsigned int nr_bytes) { -blk_add_trace_rq (q, rq, nr_bytes,BLK_TA_COMPLETE ); +blk_add_trace_rq (rq, error, nr_bytes,BLK_TA_COMPLETE ); }/**
@@ -935,7 +933,7 @@ static void blk_add_trace_rq_remap(void *ignore, r.sector_from =cpu_to_be64 (from);__blk_add_trace (bt,blk_rq_pos (rq),blk_rq_bytes (rq), -rq_data_dir (rq),0 ,BLK_TA_REMAP , !!rq->errors, +rq_data_dir (rq),0 ,BLK_TA_REMAP ,0 ,sizeof (r), &r); }
@@ -960,7 +958,7 @@ void blk_add_driver_data(struct request_queue *q,return ;__blk_add_trace (bt,blk_rq_trace_sector (rq),blk_rq_bytes (rq),0 ,0 , -BLK_TA_DRV_DATA , rq->errors, len, data); +BLK_TA_DRV_DATA ,0 , len, data); }EXPORT_SYMBOL_GPL (blk_add_driver_data);
Signature · 1 line
2.11.0
Re: [PATCH 23/23] block: remove the errors field from struct request
Quoted 5 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by Bart Van Assche <[email protected]>Acked-by Roger Pau Monné <[email protected]>Reviewed-by Konrad Rzeszutek Wilk <[email protected]>---
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
Jens Axboe
maintainerQuoted 11 lines · Christoph Hellwig
Currently the request structure has an errors field that is used in various different ways. The oldest drivers use it as an error count, blk-mq and the generic timeout code assume that it holds a Linux errno for block completions, and various drivers use it for internal status values, often overwriting them with Linux errnos later, that is unless they are processing passthrough requests in which case they'll leave their errors in it.
This series kills the ->errors field and replaced it with new fields in the drivers (or an odd hack in a union in struct request for two bitrotting old drivers).
Applied for 4.12, thanks.
Signature · 1 line
Jens Axboe