Skip to content

Commit

Permalink
block: remove the blk_execute_rq return value
Browse files Browse the repository at this point in the history
The 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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Bart Van Assche <Bart.VanAssche@sandisk.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Christoph Hellwig authored and axboe committed Apr 20, 2017
1 parent 75a500e commit b7819b9
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 28 deletions.
8 changes: 1 addition & 7 deletions block/blk-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
3 changes: 2 additions & 1 deletion block/scsi_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion drivers/block/virtio_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion drivers/cdrom/cdrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion drivers/ide/ide-atapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion drivers/ide/ide-cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion drivers/ide/ide-cd_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/ide-devsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions drivers/ide/ide-disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions drivers/ide/ide-ioctls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/ide/ide-park.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion drivers/ide/ide-pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions drivers/ide/ide-taskfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion drivers/scsi/osd/osd_initiator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions fs/nfsd/blocklayout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ extern int blk_rq_map_kern(struct request_queue *, struct request *, void *, uns
extern 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 *);
Expand Down

0 comments on commit b7819b9

Please sign in to comment.