Skip to content

Commit 40cbbb7

Browse files
htejunJens Axboe
authored andcommitted
block: implement and use [__]blk_end_request_all()
There are many [__]blk_end_request() call sites which call it with full request length and expect full completion. Many of them ensure that the request actually completes by doing BUG_ON() the return value, which is awkward and error-prone. This patch adds [__]blk_end_request_all() which takes @rq and @error and fully completes the request. BUG_ON() is added to to ensure that this actually happens. Most conversions are simple but there are a few noteworthy ones. * cdrom/viocd: viocd_end_request() replaced with direct calls to __blk_end_request_all(). * s390/block/dasd: dasd_end_request() replaced with direct calls to __blk_end_request_all(). * s390/char/tape_block: tapeblock_end_request() replaced with direct calls to blk_end_request_all(). [ Impact: cleanup ] Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Russell King <rmk@arm.linux.org.uk> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Cc: Mike Miller <mike.miller@hp.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Jeff Garzik <jgarzik@pobox.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Jeremy Fitzhardinge <jeremy@xensource.com> Cc: Alex Dubov <oakad@yahoo.com> Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
1 parent b243ddc commit 40cbbb7

15 files changed

Lines changed: 58 additions & 73 deletions

File tree

‎arch/arm/plat-omap/mailbox.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ static void mbox_tx_work(struct work_struct *work)
192192
}
193193

194194
spin_lock(q->queue_lock);
195-
if (__blk_end_request(rq, 0, 0))
196-
BUG();
195+
__blk_end_request_all(rq, 0);
197196
spin_unlock(q->queue_lock);
198197
}
199198
}
@@ -224,10 +223,7 @@ static void mbox_rx_work(struct work_struct *work)
224223
break;
225224

226225
msg = (mbox_msg_t) rq->data;
227-
228-
if (blk_end_request(rq, 0, 0))
229-
BUG();
230-
226+
blk_end_request_all(rq, 0);
231227
mbox->rxq->callback((void *)msg);
232228
}
233229
}
@@ -337,8 +333,7 @@ omap_mbox_read(struct device *dev, struct device_attribute *attr, char *buf)
337333

338334
*p = (mbox_msg_t) rq->data;
339335

340-
if (blk_end_request(rq, 0, 0))
341-
BUG();
336+
blk_end_request_all(rq, 0);
342337

343338
if (unlikely(mbox_seq_test(mbox, *p))) {
344339
pr_info("mbox: Illegal seq bit!(%08x) ignored\n", *p);

‎block/blk-barrier.c‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,7 @@ bool blk_ordered_complete_seq(struct request_queue *q, unsigned seq, int error)
106106
*/
107107
q->ordseq = 0;
108108
rq = q->orig_bar_rq;
109-
110-
if (__blk_end_request(rq, q->orderr, blk_rq_bytes(rq)))
111-
BUG();
112-
109+
__blk_end_request_all(rq, q->orderr);
113110
return true;
114111
}
115112

@@ -252,9 +249,7 @@ bool blk_do_ordered(struct request_queue *q, struct request **rqp)
252249
* with prejudice.
253250
*/
254251
elv_dequeue_request(q, rq);
255-
if (__blk_end_request(rq, -EOPNOTSUPP,
256-
blk_rq_bytes(rq)))
257-
BUG();
252+
__blk_end_request_all(rq, -EOPNOTSUPP);
258253
*rqp = NULL;
259254
return false;
260255
}

‎block/blk-core.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1780,7 +1780,7 @@ struct request *elv_next_request(struct request_queue *q)
17801780
break;
17811781
} else if (ret == BLKPREP_KILL) {
17821782
rq->cmd_flags |= REQ_QUIET;
1783-
__blk_end_request(rq, -EIO, blk_rq_bytes(rq));
1783+
__blk_end_request_all(rq, -EIO);
17841784
} else {
17851785
printk(KERN_ERR "%s: bad return=%d\n", __func__, ret);
17861786
break;

‎block/elevator.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ void elv_abort_queue(struct request_queue *q)
810810
rq = list_entry_rq(q->queue_head.next);
811811
rq->cmd_flags |= REQ_QUIET;
812812
trace_block_rq_abort(q, rq);
813-
__blk_end_request(rq, -EIO, blk_rq_bytes(rq));
813+
__blk_end_request_all(rq, -EIO);
814814
}
815815
}
816816
EXPORT_SYMBOL(elv_abort_queue);

‎drivers/block/cpqarray.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,8 +1024,7 @@ static inline void complete_command(cmdlist_t *cmd, int timeout)
10241024
cmd->req.sg[i].size, ddir);
10251025

10261026
DBGPX(printk("Done with %p\n", rq););
1027-
if (__blk_end_request(rq, error, blk_rq_bytes(rq)))
1028-
BUG();
1027+
__blk_end_request_all(rq, error);
10291028
}
10301029

10311030
/*

‎drivers/block/sx8.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,8 +749,7 @@ static inline void carm_end_request_queued(struct carm_host *host,
749749
struct request *req = crq->rq;
750750
int rc;
751751

752-
rc = __blk_end_request(req, error, blk_rq_bytes(req));
753-
assert(rc == 0);
752+
__blk_end_request_all(req, error);
754753

755754
rc = carm_put_request(host, crq);
756755
assert(rc == 0);

‎drivers/block/virtio_blk.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void blk_done(struct virtqueue *vq)
6262
break;
6363
}
6464

65-
__blk_end_request(vbr->req, error, blk_rq_bytes(vbr->req));
65+
__blk_end_request_all(vbr->req, error);
6666
list_del(&vbr->list);
6767
mempool_free(vbr, vblk->pool);
6868
}

‎drivers/block/xen-blkfront.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,6 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
551551

552552
for (i = info->ring.rsp_cons; i != rp; i++) {
553553
unsigned long id;
554-
int ret;
555554

556555
bret = RING_GET_RESPONSE(&info->ring, i);
557556
id = bret->id;
@@ -578,8 +577,7 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
578577
dev_dbg(&info->xbdev->dev, "Bad return from blkdev data "
579578
"request: %x\n", bret->status);
580579

581-
ret = __blk_end_request(req, error, blk_rq_bytes(req));
582-
BUG_ON(ret);
580+
__blk_end_request_all(req, error);
583581
break;
584582
default:
585583
BUG();

‎drivers/cdrom/gdrom.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ static void gdrom_readdisk_dma(struct work_struct *work)
632632
* before handling ending the request */
633633
spin_lock(&gdrom_lock);
634634
list_del_init(&req->queuelist);
635-
__blk_end_request(req, err, blk_rq_bytes(req));
635+
__blk_end_request_all(req, err);
636636
}
637637
spin_unlock(&gdrom_lock);
638638
kfree(read_command);

‎drivers/cdrom/viocd.c‎

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -291,23 +291,6 @@ static int send_request(struct request *req)
291291
return 0;
292292
}
293293

294-
static void viocd_end_request(struct request *req, int error)
295-
{
296-
int nsectors = req->hard_nr_sectors;
297-
298-
/*
299-
* Make sure it's fully ended, and ensure that we process
300-
* at least one sector.
301-
*/
302-
if (blk_pc_request(req))
303-
nsectors = (req->data_len + 511) >> 9;
304-
if (!nsectors)
305-
nsectors = 1;
306-
307-
if (__blk_end_request(req, error, nsectors << 9))
308-
BUG();
309-
}
310-
311294
static int rwreq;
312295

313296
static void do_viocd_request(struct request_queue *q)
@@ -316,11 +299,11 @@ static void do_viocd_request(struct request_queue *q)
316299

317300
while ((rwreq == 0) && ((req = elv_next_request(q)) != NULL)) {
318301
if (!blk_fs_request(req))
319-
viocd_end_request(req, -EIO);
302+
__blk_end_request_all(req, -EIO);
320303
else if (send_request(req) < 0) {
321304
printk(VIOCD_KERN_WARNING
322305
"unable to send message to OS/400!");
323-
viocd_end_request(req, -EIO);
306+
__blk_end_request_all(req, -EIO);
324307
} else
325308
rwreq++;
326309
}
@@ -531,9 +514,9 @@ static void vio_handle_cd_event(struct HvLpEvent *event)
531514
"with rc %d:0x%04X: %s\n",
532515
req, event->xRc,
533516
bevent->sub_result, err->msg);
534-
viocd_end_request(req, -EIO);
517+
__blk_end_request_all(req, -EIO);
535518
} else
536-
viocd_end_request(req, 0);
519+
__blk_end_request_all(req, 0);
537520

538521
/* restart handling of incoming requests */
539522
spin_unlock_irqrestore(&viocd_reqlock, flags);

0 commit comments

Comments
 (0)