aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2009-05-07 22:54:16 -0400
committerJens Axboe <jens.axboe@oracle.com>2009-05-11 03:52:18 -0400
commit9934c8c04561413609d2bc38c6b9f268cba774a4 (patch)
tree30dd8f7be54f9b2e03094de9cd03b6a9ee2909cd
parent2343046826a8ca426b07601d9593ee046c298b68 (diff)
block: implement and enforce request peek/start/fetch
Till now block layer allowed two separate modes of request execution. A request is always acquired from the request queue via elv_next_request(). After that, drivers are free to either dequeue it or process it without dequeueing. Dequeue allows elv_next_request() to return the next request so that multiple requests can be in flight. Executing requests without dequeueing has its merits mostly in allowing drivers for simpler devices which can't do sg to deal with segments only without considering request boundary. However, the benefit this brings is dubious and declining while the cost of the API ambiguity is increasing. Segment based drivers are usually for very old or limited devices and as converting to dequeueing model isn't difficult, it doesn't justify the API overhead it puts on block layer and its more modern users. Previous patches converted all block low level drivers to dequeueing model. This patch completes the API transition by... * renaming elv_next_request() to blk_peek_request() * renaming blkdev_dequeue_request() to blk_start_request() * adding blk_fetch_request() which is combination of peek and start * disallowing completion of queued (not started) requests * applying new API to all LLDs Renamings are for consistency and to break out of tree code so that it's apparent that out of tree drivers need updating. [ Impact: block request issue API cleanup, no functional change ] Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Cc: Mike Miller <mike.miller@hp.com> Cc: unsik Kim <donari75@gmail.com> Cc: Paul Clements <paul.clements@steeleye.com> Cc: Tim Waugh <tim@cyberelk.net> Cc: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> Cc: David S. Miller <davem@davemloft.net> Cc: Laurent Vivier <Laurent@lvivier.info> Cc: Jeff Garzik <jgarzik@pobox.com> Cc: Jeremy Fitzhardinge <jeremy@xensource.com> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: Adrian McMenamin <adrian@mcmen.demon.co.uk> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Cc: Borislav Petkov <petkovbb@googlemail.com> Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com> Cc: Alex Dubov <oakad@yahoo.com> Cc: Pierre Ossman <drzeus@drzeus.cx> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Markus Lidel <Markus.Lidel@shadowconnect.com> Cc: Stefan Weinhuber <wein@de.ibm.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Pete Zaitcev <zaitcev@redhat.com> Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r--arch/arm/plat-omap/mailbox.c12
-rw-r--r--arch/um/drivers/ubd_kern.c3
-rw-r--r--block/blk-barrier.c4
-rw-r--r--block/blk-core.c105
-rw-r--r--block/blk-tag.c2
-rw-r--r--block/blk.h1
-rw-r--r--drivers/block/DAC960.c4
-rw-r--r--drivers/block/amiflop.c3
-rw-r--r--drivers/block/ataflop.c3
-rw-r--r--drivers/block/cciss.c4
-rw-r--r--drivers/block/cpqarray.c4
-rw-r--r--drivers/block/floppy.c6
-rw-r--r--drivers/block/hd.c3
-rw-r--r--drivers/block/mg_disk.c12
-rw-r--r--drivers/block/nbd.c4
-rw-r--r--drivers/block/paride/pcd.c3
-rw-r--r--drivers/block/paride/pd.c7
-rw-r--r--drivers/block/paride/pf.c3
-rw-r--r--drivers/block/ps3disk.c4
-rw-r--r--drivers/block/sunvdc.c3
-rw-r--r--drivers/block/swim.c12
-rw-r--r--drivers/block/swim3.c3
-rw-r--r--drivers/block/sx8.c8
-rw-r--r--drivers/block/ub.c8
-rw-r--r--drivers/block/viodasd.c4
-rw-r--r--drivers/block/virtio_blk.c4
-rw-r--r--drivers/block/xd.c12
-rw-r--r--drivers/block/xen-blkfront.c4
-rw-r--r--drivers/block/xsysace.c10
-rw-r--r--drivers/block/z2ram.c12
-rw-r--r--drivers/cdrom/gdrom.c4
-rw-r--r--drivers/cdrom/viocd.c4
-rw-r--r--drivers/ide/ide-atapi.c2
-rw-r--r--drivers/ide/ide-io.c9
-rw-r--r--drivers/memstick/core/mspro_block.c9
-rw-r--r--drivers/message/i2o/i2o_block.c6
-rw-r--r--drivers/mmc/card/queue.c11
-rw-r--r--drivers/mtd/mtd_blkdevs.c7
-rw-r--r--drivers/s390/block/dasd.c16
-rw-r--r--drivers/s390/char/tape_block.c7
-rw-r--r--drivers/sbus/char/jsflash.c12
-rw-r--r--drivers/scsi/scsi_lib.c10
-rw-r--r--drivers/scsi/scsi_transport_sas.c4
-rw-r--r--include/linux/blkdev.h9
-rw-r--r--include/linux/elevator.h2
45 files changed, 172 insertions, 207 deletions
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index 7a1f5c25fd17..40424edae939 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -197,9 +197,7 @@ static void mbox_tx_work(struct work_struct *work)
197 struct omap_msg_tx_data *tx_data; 197 struct omap_msg_tx_data *tx_data;
198 198
199 spin_lock(q->queue_lock); 199 spin_lock(q->queue_lock);
200 rq = elv_next_request(q); 200 rq = blk_fetch_request(q);
201 if (rq)
202 blkdev_dequeue_request(rq);
203 spin_unlock(q->queue_lock); 201 spin_unlock(q->queue_lock);
204 202
205 if (!rq) 203 if (!rq)
@@ -242,9 +240,7 @@ static void mbox_rx_work(struct work_struct *work)
242 240
243 while (1) { 241 while (1) {
244 spin_lock_irqsave(q->queue_lock, flags); 242 spin_lock_irqsave(q->queue_lock, flags);
245 rq = elv_next_request(q); 243 rq = blk_fetch_request(q);
246 if (rq)
247 blkdev_dequeue_request(rq);
248 spin_unlock_irqrestore(q->queue_lock, flags); 244 spin_unlock_irqrestore(q->queue_lock, flags);
249 if (!rq) 245 if (!rq)
250 break; 246 break;
@@ -351,9 +347,7 @@ omap_mbox_read(struct device *dev, struct device_attribute *attr, char *buf)
351 347
352 while (1) { 348 while (1) {
353 spin_lock_irqsave(q->queue_lock, flags); 349 spin_lock_irqsave(q->queue_lock, flags);
354 rq = elv_next_request(q); 350 rq = blk_fetch_request(q);
355 if (rq)
356 blkdev_dequeue_request(rq);
357 spin_unlock_irqrestore(q->queue_lock, flags); 351 spin_unlock_irqrestore(q->queue_lock, flags);
358 352
359 if (!rq) 353 if (!rq)
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 402ba8f70fc9..aa9e926e13d7 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1228,12 +1228,11 @@ static void do_ubd_request(struct request_queue *q)
1228 while(1){ 1228 while(1){
1229 struct ubd *dev = q->queuedata; 1229 struct ubd *dev = q->queuedata;
1230 if(dev->end_sg == 0){ 1230 if(dev->end_sg == 0){
1231 struct request *req = elv_next_request(q); 1231 struct request *req = blk_fetch_request(q);
1232 if(req == NULL) 1232 if(req == NULL)
1233 return; 1233 return;
1234 1234
1235 dev->request = req; 1235 dev->request = req;
1236 blkdev_dequeue_request(req);
1237 dev->start_sg = 0; 1236 dev->start_sg = 0;
1238 dev->end_sg = blk_rq_map_sg(q, req, dev->sg); 1237 dev->end_sg = blk_rq_map_sg(q, req, dev->sg);
1239 } 1238 }
diff --git a/block/blk-barrier.c b/block/blk-barrier.c
index 8713c2fbc4f6..0ab81a0a7502 100644
--- a/block/blk-barrier.c
+++ b/block/blk-barrier.c
@@ -180,7 +180,7 @@ static inline bool start_ordered(struct request_queue *q, struct request **rqp)
180 } 180 }
181 181
182 /* stash away the original request */ 182 /* stash away the original request */
183 elv_dequeue_request(q, rq); 183 blk_dequeue_request(rq);
184 q->orig_bar_rq = rq; 184 q->orig_bar_rq = rq;
185 rq = NULL; 185 rq = NULL;
186 186
@@ -248,7 +248,7 @@ bool blk_do_ordered(struct request_queue *q, struct request **rqp)
248 * Queue ordering not supported. Terminate 248 * Queue ordering not supported. Terminate
249 * with prejudice. 249 * with prejudice.
250 */ 250 */
251 elv_dequeue_request(q, rq); 251 blk_dequeue_request(rq);
252 __blk_end_request_all(rq, -EOPNOTSUPP); 252 __blk_end_request_all(rq, -EOPNOTSUPP);
253 *rqp = NULL; 253 *rqp = NULL;
254 return false; 254 return false;
diff --git a/block/blk-core.c b/block/blk-core.c
index 6226a380fb6d..93691d2ac5a0 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -902,6 +902,8 @@ EXPORT_SYMBOL(blk_get_request);
902 */ 902 */
903void blk_requeue_request(struct request_queue *q, struct request *rq) 903void blk_requeue_request(struct request_queue *q, struct request *rq)
904{ 904{
905 BUG_ON(blk_queued_rq(rq));
906
905 blk_delete_timer(rq); 907 blk_delete_timer(rq);
906 blk_clear_rq_complete(rq); 908 blk_clear_rq_complete(rq);
907 trace_block_rq_requeue(q, rq); 909 trace_block_rq_requeue(q, rq);
@@ -1610,28 +1612,6 @@ int blk_insert_cloned_request(struct request_queue *q, struct request *rq)
1610} 1612}
1611EXPORT_SYMBOL_GPL(blk_insert_cloned_request); 1613EXPORT_SYMBOL_GPL(blk_insert_cloned_request);
1612 1614
1613/**
1614 * blkdev_dequeue_request - dequeue request and start timeout timer
1615 * @req: request to dequeue
1616 *
1617 * Dequeue @req and start timeout timer on it. This hands off the
1618 * request to the driver.
1619 *
1620 * Block internal functions which don't want to start timer should
1621 * call elv_dequeue_request().
1622 */
1623void blkdev_dequeue_request(struct request *req)
1624{
1625 elv_dequeue_request(req->q, req);
1626
1627 /*
1628 * We are now handing the request to the hardware, add the
1629 * timeout handler.
1630 */
1631 blk_add_timer(req);
1632}
1633EXPORT_SYMBOL(blkdev_dequeue_request);
1634
1635static void blk_account_io_completion(struct request *req, unsigned int bytes) 1615static void blk_account_io_completion(struct request *req, unsigned int bytes)
1636{ 1616{
1637 if (blk_do_io_stat(req)) { 1617 if (blk_do_io_stat(req)) {
@@ -1671,7 +1651,23 @@ static void blk_account_io_done(struct request *req)
1671 } 1651 }
1672} 1652}
1673 1653
1674struct request *elv_next_request(struct request_queue *q) 1654/**
1655 * blk_peek_request - peek at the top of a request queue
1656 * @q: request queue to peek at
1657 *
1658 * Description:
1659 * Return the request at the top of @q. The returned request
1660 * should be started using blk_start_request() before LLD starts
1661 * processing it.
1662 *
1663 * Return:
1664 * Pointer to the request at the top of @q if available. Null
1665 * otherwise.
1666 *
1667 * Context:
1668 * queue_lock must be held.
1669 */
1670struct request *blk_peek_request(struct request_queue *q)
1675{ 1671{
1676 struct request *rq; 1672 struct request *rq;
1677 int ret; 1673 int ret;
@@ -1748,10 +1744,12 @@ struct request *elv_next_request(struct request_queue *q)
1748 1744
1749 return rq; 1745 return rq;
1750} 1746}
1751EXPORT_SYMBOL(elv_next_request); 1747EXPORT_SYMBOL(blk_peek_request);
1752 1748
1753void elv_dequeue_request(struct request_queue *q, struct request *rq) 1749void blk_dequeue_request(struct request *rq)
1754{ 1750{
1751 struct request_queue *q = rq->q;
1752
1755 BUG_ON(list_empty(&rq->queuelist)); 1753 BUG_ON(list_empty(&rq->queuelist));
1756 BUG_ON(ELV_ON_HASH(rq)); 1754 BUG_ON(ELV_ON_HASH(rq));
1757 1755
@@ -1767,6 +1765,58 @@ void elv_dequeue_request(struct request_queue *q, struct request *rq)
1767} 1765}
1768 1766
1769/** 1767/**
1768 * blk_start_request - start request processing on the driver
1769 * @req: request to dequeue
1770 *
1771 * Description:
1772 * Dequeue @req and start timeout timer on it. This hands off the
1773 * request to the driver.
1774 *
1775 * Block internal functions which don't want to start timer should
1776 * call blk_dequeue_request().
1777 *
1778 * Context:
1779 * queue_lock must be held.
1780 */
1781void blk_start_request(struct request *req)
1782{
1783 blk_dequeue_request(req);
1784
1785 /*
1786 * We are now handing the request to the hardware, add the
1787 * timeout handler.
1788 */
1789 blk_add_timer(req);
1790}
1791EXPORT_SYMBOL(blk_start_request);
1792
1793/**
1794 * blk_fetch_request - fetch a request from a request queue
1795 * @q: request queue to fetch a request from
1796 *
1797 * Description:
1798 * Return the request at the top of @q. The request is started on
1799 * return and LLD can start processing it immediately.
1800 *
1801 * Return:
1802 * Pointer to the request at the top of @q if available. Null
1803 * otherwise.
1804 *
1805 * Context:
1806 * queue_lock must be held.
1807 */
1808struct request *blk_fetch_request(struct request_queue *q)
1809{
1810 struct request *rq;
1811
1812 rq = blk_peek_request(q);
1813 if (rq)
1814 blk_start_request(rq);
1815 return rq;
1816}
1817EXPORT_SYMBOL(blk_fetch_request);
1818
1819/**
1770 * blk_update_request - Special helper function for request stacking drivers 1820 * blk_update_request - Special helper function for request stacking drivers
1771 * @rq: the request being processed 1821 * @rq: the request being processed
1772 * @error: %0 for success, < %0 for error 1822 * @error: %0 for success, < %0 for error
@@ -1937,12 +1987,11 @@ static bool blk_update_bidi_request(struct request *rq, int error,
1937 */ 1987 */
1938static void blk_finish_request(struct request *req, int error) 1988static void blk_finish_request(struct request *req, int error)
1939{ 1989{
1990 BUG_ON(blk_queued_rq(req));
1991
1940 if (blk_rq_tagged(req)) 1992 if (blk_rq_tagged(req))
1941 blk_queue_end_tag(req->q, req); 1993 blk_queue_end_tag(req->q, req);
1942 1994
1943 if (blk_queued_rq(req))
1944 elv_dequeue_request(req->q, req);
1945
1946 if (unlikely(laptop_mode) && blk_fs_request(req)) 1995 if (unlikely(laptop_mode) && blk_fs_request(req))
1947 laptop_io_completion(); 1996 laptop_io_completion();
1948 1997
diff --git a/block/blk-tag.c b/block/blk-tag.c
index 3c518e3303ae..c260f7c30dda 100644
--- a/block/blk-tag.c
+++ b/block/blk-tag.c
@@ -374,7 +374,7 @@ int blk_queue_start_tag(struct request_queue *q, struct request *rq)
374 rq->cmd_flags |= REQ_QUEUED; 374 rq->cmd_flags |= REQ_QUEUED;
375 rq->tag = tag; 375 rq->tag = tag;
376 bqt->tag_index[tag] = rq; 376 bqt->tag_index[tag] = rq;
377 blkdev_dequeue_request(rq); 377 blk_start_request(rq);
378 list_add(&rq->queuelist, &q->tag_busy_list); 378 list_add(&rq->queuelist, &q->tag_busy_list);
379 return 0; 379 return 0;
380} 380}
diff --git a/block/blk.h b/block/blk.h
index ab54529103c0..9e0042ca9495 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -13,6 +13,7 @@ extern struct kobj_type blk_queue_ktype;
13void init_request_from_bio(struct request *req, struct bio *bio); 13void init_request_from_bio(struct request *req, struct bio *bio);
14void blk_rq_bio_prep(struct request_queue *q, struct request *rq, 14void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
15 struct bio *bio); 15 struct bio *bio);
16void blk_dequeue_request(struct request *rq);
16void __blk_queue_free_tags(struct request_queue *q); 17void __blk_queue_free_tags(struct request_queue *q);
17 18
18void blk_unplug_work(struct work_struct *work); 19void blk_unplug_work(struct work_struct *work);
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 774ab05973a9..668dc234b8e2 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -3321,7 +3321,7 @@ static int DAC960_process_queue(DAC960_Controller_T *Controller, struct request_
3321 DAC960_Command_T *Command; 3321 DAC960_Command_T *Command;
3322 3322
3323 while(1) { 3323 while(1) {
3324 Request = elv_next_request(req_q); 3324 Request = blk_peek_request(req_q);
3325 if (!Request) 3325 if (!Request)
3326 return 1; 3326 return 1;
3327 3327
@@ -3341,7 +3341,7 @@ static int DAC960_process_queue(DAC960_Controller_T *Controller, struct request_
3341 Command->BlockNumber = blk_rq_pos(Request); 3341 Command->BlockNumber = blk_rq_pos(Request);
3342 Command->BlockCount = blk_rq_sectors(Request); 3342 Command->BlockCount = blk_rq_sectors(Request);
3343 Command->Request = Request; 3343 Command->Request = Request;
3344 blkdev_dequeue_request(Request); 3344 blk_start_request(Request);
3345 Command->SegmentCount = blk_rq_map_sg(req_q, 3345 Command->SegmentCount = blk_rq_map_sg(req_q,
3346 Command->Request, Command->cmd_sglist); 3346 Command->Request, Command->cmd_sglist);
3347 /* pci_map_sg MAY change the value of SegCount */ 3347 /* pci_map_sg MAY change the value of SegCount */
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 80a68b2e0451..9c6e5b0fe894 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -1342,12 +1342,11 @@ static void redo_fd_request(void)
1342 int err; 1342 int err;
1343 1343
1344next_req: 1344next_req:
1345 rq = elv_next_request(floppy_queue); 1345 rq = blk_fetch_request(floppy_queue);
1346 if (!rq) { 1346 if (!rq) {
1347 /* Nothing left to do */ 1347 /* Nothing left to do */
1348 return; 1348 return;
1349 } 1349 }
1350 blkdev_dequeue_request(rq);
1351 1350
1352 floppy = rq->rq_disk->private_data; 1351 floppy = rq->rq_disk->private_data;
1353 drive = floppy - unit; 1352 drive = floppy - unit;
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index 89a591d9c83b..f5e7180d7f47 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -1404,10 +1404,9 @@ static void redo_fd_request(void)
1404 1404
1405repeat: 1405repeat:
1406 if (!fd_request) { 1406 if (!fd_request) {
1407 fd_request = elv_next_request(floppy_queue); 1407 fd_request = blk_fetch_request(floppy_queue);
1408 if (!fd_request) 1408 if (!fd_request)
1409 goto the_end; 1409 goto the_end;
1410 blkdev_dequeue_request(fd_request);
1411 } 1410 }
1412 1411
1413 floppy = fd_request->rq_disk->private_data; 1412 floppy = fd_request->rq_disk->private_data;
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index ab7b04c0db70..e714e7cce6f2 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -2801,7 +2801,7 @@ static void do_cciss_request(struct request_queue *q)
2801 goto startio; 2801 goto startio;
2802 2802
2803 queue: 2803 queue:
2804 creq = elv_next_request(q); 2804 creq = blk_peek_request(q);
2805 if (!creq) 2805 if (!creq)
2806 goto startio; 2806 goto startio;
2807 2807
@@ -2810,7 +2810,7 @@ static void do_cciss_request(struct request_queue *q)
2810 if ((c = cmd_alloc(h, 1)) == NULL) 2810 if ((c = cmd_alloc(h, 1)) == NULL)
2811 goto full; 2811 goto full;
2812 2812
2813 blkdev_dequeue_request(creq); 2813 blk_start_request(creq);
2814 2814
2815 spin_unlock_irq(q->queue_lock); 2815 spin_unlock_irq(q->queue_lock);
2816 2816
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index a5caeff4718e..a02dcfc00f13 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -903,7 +903,7 @@ static void do_ida_request(struct request_queue *q)
903 goto startio; 903 goto startio;
904 904
905queue_next: 905queue_next:
906 creq = elv_next_request(q); 906 creq = blk_peek_request(q);
907 if (!creq) 907 if (!creq)
908 goto startio; 908 goto startio;
909 909
@@ -912,7 +912,7 @@ queue_next:
912 if ((c = cmd_alloc(h,1)) == NULL) 912 if ((c = cmd_alloc(h,1)) == NULL)
913 goto startio; 913 goto startio;
914 914
915 blkdev_dequeue_request(creq); 915 blk_start_request(creq);
916 916
917 c->ctlr = h->ctlr; 917 c->ctlr = h->ctlr;
918 c->hdr.unit = (drv_info_t *)(creq->rq_disk->private_data) - h->drv; 918 c->hdr.unit = (drv_info_t *)(creq->rq_disk->private_data) - h->drv;
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index e2c70d2085ae..90877fee0ee0 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -931,7 +931,7 @@ static inline void unlock_fdc(void)
931 del_timer(&fd_timeout); 931 del_timer(&fd_timeout);
932 cont = NULL; 932 cont = NULL;
933 clear_bit(0, &fdc_busy); 933 clear_bit(0, &fdc_busy);
934 if (current_req || elv_next_request(floppy_queue)) 934 if (current_req || blk_peek_request(floppy_queue))
935 do_fd_request(floppy_queue); 935 do_fd_request(floppy_queue);
936 spin_unlock_irqrestore(&floppy_lock, flags); 936 spin_unlock_irqrestore(&floppy_lock, flags);
937 wake_up(&fdc_wait); 937 wake_up(&fdc_wait);
@@ -2912,9 +2912,7 @@ static void redo_fd_request(void)
2912 struct request *req; 2912 struct request *req;
2913 2913
2914 spin_lock_irq(floppy_queue->queue_lock); 2914 spin_lock_irq(floppy_queue->queue_lock);
2915 req = elv_next_request(floppy_queue); 2915 req = blk_fetch_request(floppy_queue);
2916 if (req)
2917 blkdev_dequeue_request(req);
2918 spin_unlock_irq(floppy_queue->queue_lock); 2916 spin_unlock_irq(floppy_queue->queue_lock);
2919 if (!req) { 2917 if (!req) {
2920 do_floppy = NULL; 2918 do_floppy = NULL;
diff --git a/drivers/block/hd.c b/drivers/block/hd.c
index 288ab63c1029..961de56d00a9 100644
--- a/drivers/block/hd.c
+++ b/drivers/block/hd.c
@@ -592,12 +592,11 @@ repeat:
592 del_timer(&device_timer); 592 del_timer(&device_timer);
593 593
594 if (!hd_req) { 594 if (!hd_req) {
595 hd_req = elv_next_request(hd_queue); 595 hd_req = blk_fetch_request(hd_queue);
596 if (!hd_req) { 596 if (!hd_req) {
597 do_hd = NULL; 597 do_hd = NULL;
598 return; 598 return;
599 } 599 }
600 blkdev_dequeue_request(hd_req);
601 } 600 }
602 req = hd_req; 601 req = hd_req;
603 602
diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c
index 1ca5d1423fa3..c0cd0a03f698 100644
--- a/drivers/block/mg_disk.c
+++ b/drivers/block/mg_disk.c
@@ -671,10 +671,8 @@ static void mg_request_poll(struct request_queue *q)
671 671
672 while (1) { 672 while (1) {
673 if (!host->req) { 673 if (!host->req) {
674 host->req = elv_next_request(q); 674 host->req = blk_fetch_request(q);
675 if (host->req) 675 if (!host->req)
676 blkdev_dequeue_request(host->req);
677 else
678 break; 676 break;
679 } 677 }
680 678
@@ -744,10 +742,8 @@ static void mg_request(struct request_queue *q)
744 742
745 while (1) { 743 while (1) {
746 if (!host->req) { 744 if (!host->req) {
747 host->req = elv_next_request(q); 745 host->req = blk_fetch_request(q);
748 if (host->req) 746 if (!host->req)
749 blkdev_dequeue_request(host->req);
750 else
751 break; 747 break;
752 } 748 }
753 req = host->req; 749 req = host->req;
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index fad167de23b4..5d23ffad7c77 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -533,11 +533,9 @@ static void do_nbd_request(struct request_queue *q)
533{ 533{
534 struct request *req; 534 struct request *req;
535 535
536 while ((req = elv_next_request(q)) != NULL) { 536 while ((req = blk_fetch_request(q)) != NULL) {
537 struct nbd_device *lo; 537 struct nbd_device *lo;
538 538
539 blkdev_dequeue_request(req);
540
541 spin_unlock_irq(q->queue_lock); 539 spin_unlock_irq(q->queue_lock);
542 540
543 dprintk(DBG_BLKDEV, "%s: request %p: dequeued (flags=%x)\n", 541 dprintk(DBG_BLKDEV, "%s: request %p: dequeued (flags=%x)\n",
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index 425f81586a31..911dfd98d813 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -720,10 +720,9 @@ static void do_pcd_request(struct request_queue * q)
720 return; 720 return;
721 while (1) { 721 while (1) {
722 if (!pcd_req) { 722 if (!pcd_req) {
723 pcd_req = elv_next_request(q); 723 pcd_req = blk_fetch_request(q);
724 if (!pcd_req) 724 if (!pcd_req)
725 return; 725 return;
726 blkdev_dequeue_request(pcd_req);
727 } 726 }
728 727
729 if (rq_data_dir(pcd_req) == READ) { 728 if (rq_data_dir(pcd_req) == READ) {
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
index d2ca3f552061..bf5955b3d873 100644
--- a/drivers/block/paride/pd.c
+++ b/drivers/block/paride/pd.c
@@ -412,11 +412,9 @@ static void run_fsm(void)
412 spin_lock_irqsave(&pd_lock, saved_flags); 412 spin_lock_irqsave(&pd_lock, saved_flags);
413 if (!__blk_end_request_cur(pd_req, 413 if (!__blk_end_request_cur(pd_req,
414 res == Ok ? 0 : -EIO)) { 414 res == Ok ? 0 : -EIO)) {
415 pd_req = elv_next_request(pd_queue); 415 pd_req = blk_fetch_request(pd_queue);
416 if (!pd_req) 416 if (!pd_req)
417 stop = 1; 417 stop = 1;
418 else
419 blkdev_dequeue_request(pd_req);
420 } 418 }
421 spin_unlock_irqrestore(&pd_lock, saved_flags); 419 spin_unlock_irqrestore(&pd_lock, saved_flags);
422 if (stop) 420 if (stop)
@@ -706,10 +704,9 @@ static void do_pd_request(struct request_queue * q)
706{ 704{
707 if (pd_req) 705 if (pd_req)
708 return; 706 return;
709 pd_req = elv_next_request(q); 707 pd_req = blk_fetch_request(q);
710 if (!pd_req) 708 if (!pd_req)
711 return; 709 return;
712 blkdev_dequeue_request(pd_req);
713 710
714 schedule_fsm(); 711 schedule_fsm();
715} 712}
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index d6f7bd84ed39..68a90834e993 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -762,10 +762,9 @@ static void do_pf_request(struct request_queue * q)
762 return; 762 return;
763repeat: 763repeat:
764 if (!pf_req) { 764 if (!pf_req) {
765 pf_req = elv_next_request(q); 765 pf_req = blk_fetch_request(q);
766 if (!pf_req) 766 if (!pf_req)
767 return; 767 return;
768 blkdev_dequeue_request(pf_req);
769 } 768 }
770 769
771 pf_current = pf_req->rq_disk->private_data; 770 pf_current = pf_req->rq_disk->private_data;
diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c
index f4d8db944e7d..338cee4cc0ba 100644
--- a/drivers/block/ps3disk.c
+++ b/drivers/block/ps3disk.c
@@ -194,9 +194,7 @@ static void ps3disk_do_request(struct ps3_storage_device *dev,
194 194
195 dev_dbg(&dev->sbd.core, "%s:%u\n", __func__, __LINE__); 195 dev_dbg(&dev->sbd.core, "%s:%u\n", __func__, __LINE__);
196 196
197 while ((req = elv_next_request(q))) { 197 while ((req = blk_fetch_request(q))) {
198 blkdev_dequeue_request(req);
199
200 if (blk_fs_request(req)) { 198 if (blk_fs_request(req)) {
201 if (ps3disk_submit_request_sg(dev, req)) 199 if (ps3disk_submit_request_sg(dev, req))
202 break; 200 break;
diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c
index 9f351bfa15ea..cbfd9c0aef03 100644
--- a/drivers/block/sunvdc.c
+++ b/drivers/block/sunvdc.c
@@ -441,12 +441,11 @@ out:
441static void do_vdc_request(struct request_queue *q) 441static void do_vdc_request(struct request_queue *q)
442{ 442{
443 while (1) { 443 while (1) {
444 struct request *req = elv_next_request(q); 444 struct request *req = blk_fetch_request(q);
445 445
446 if (!req) 446 if (!req)
447 break; 447 break;
448 448
449 blkdev_dequeue_request(req);
450 if (__send_request(req) < 0) 449 if (__send_request(req) < 0)
451 __blk_end_request_all(req, -EIO); 450 __blk_end_request_all(req, -EIO);
452 } 451 }
diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index dedd4893f5ea..cf7877fb8a7d 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c
@@ -528,10 +528,7 @@ static void redo_fd_request(struct request_queue *q)
528 struct request *req; 528 struct request *req;
529 struct floppy_state *fs; 529 struct floppy_state *fs;
530 530
531 req = elv_next_request(q); 531 req = blk_fetch_request(q);
532 if (req)
533 blkdev_dequeue_request(req);
534
535 while (req) { 532 while (req) {
536 int err = -EIO; 533 int err = -EIO;
537 534
@@ -554,11 +551,8 @@ static void redo_fd_request(struct request_queue *q)
554 break; 551 break;
555 } 552 }
556 done: 553 done:
557 if (!__blk_end_request_cur(req, err)) { 554 if (!__blk_end_request_cur(req, err))
558 req = elv_next_request(q); 555 req = blk_fetch_request(q);
559 if (req)
560 blkdev_dequeue_request(req);
561 }
562 } 556 }
563} 557}
564 558
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index f48c6dd47e04..80df93e3cdd0 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -326,10 +326,9 @@ static void start_request(struct floppy_state *fs)
326 } 326 }
327 while (fs->state == idle) { 327 while (fs->state == idle) {
328 if (!fd_req) { 328 if (!fd_req) {
329 fd_req = elv_next_request(swim3_queue); 329 fd_req = blk_fetch_request(swim3_queue);
330 if (!fd_req) 330 if (!fd_req)
331 break; 331 break;
332 blkdev_dequeue_request(fd_req);
333 } 332 }
334 req = fd_req; 333 req = fd_req;
335#if 0 334#if 0
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index 087c94c8b2da..da403b6a7f43 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -810,12 +810,10 @@ static void carm_oob_rq_fn(struct request_queue *q)
810 810
811 while (1) { 811 while (1) {
812 DPRINTK("get req\n"); 812 DPRINTK("get req\n");
813 rq = elv_next_request(q); 813 rq = blk_fetch_request(q);
814 if (!rq) 814 if (!rq)
815 break; 815 break;
816 816
817 blkdev_dequeue_request(rq);
818
819 crq = rq->special; 817 crq = rq->special;
820 assert(crq != NULL); 818 assert(crq != NULL);
821 assert(crq->rq == rq); 819 assert(crq->rq == rq);
@@ -846,7 +844,7 @@ static void carm_rq_fn(struct request_queue *q)
846 844
847queue_one_request: 845queue_one_request:
848 VPRINTK("get req\n"); 846 VPRINTK("get req\n");
849 rq = elv_next_request(q); 847 rq = blk_peek_request(q);
850 if (!rq) 848 if (!rq)
851 return; 849 return;
852 850
@@ -857,7 +855,7 @@ queue_one_request:
857 } 855 }
858 crq->rq = rq; 856 crq->rq = rq;
859 857
860 blkdev_dequeue_request(rq); 858 blk_start_request(rq);
861 859
862 if (rq_data_dir(rq) == WRITE) { 860 if (rq_data_dir(rq) == WRITE) {
863 writing = 1; 861 writing = 1;
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 40d03cf63f2e..178f459a50ed 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -627,7 +627,7 @@ static void ub_request_fn(struct request_queue *q)
627 struct ub_lun *lun = q->queuedata; 627 struct ub_lun *lun = q->queuedata;
628 struct request *rq; 628 struct request *rq;
629 629
630 while ((rq = elv_next_request(q)) != NULL) { 630 while ((rq = blk_peek_request(q)) != NULL) {
631 if (ub_request_fn_1(lun, rq) != 0) { 631 if (ub_request_fn_1(lun, rq) != 0) {
632 blk_stop_queue(q); 632 blk_stop_queue(q);
633 break; 633 break;
@@ -643,13 +643,13 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
643 int n_elem; 643 int n_elem;
644 644
645 if (atomic_read(&sc->poison)) { 645 if (atomic_read(&sc->poison)) {
646 blkdev_dequeue_request(rq); 646 blk_start_request(rq);
647 ub_end_rq(rq, DID_NO_CONNECT << 16, blk_rq_bytes(rq)); 647 ub_end_rq(rq, DID_NO_CONNECT << 16, blk_rq_bytes(rq));
648 return 0; 648 return 0;
649 } 649 }
650 650
651 if (lun->changed && !blk_pc_request(rq)) { 651 if (lun->changed && !blk_pc_request(rq)) {
652 blkdev_dequeue_request(rq); 652 blk_start_request(rq);
653 ub_end_rq(rq, SAM_STAT_CHECK_CONDITION, blk_rq_bytes(rq)); 653 ub_end_rq(rq, SAM_STAT_CHECK_CONDITION, blk_rq_bytes(rq));
654 return 0; 654 return 0;
655 } 655 }
@@ -660,7 +660,7 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
660 return -1; 660 return -1;
661 memset(cmd, 0, sizeof(struct ub_scsi_cmd)); 661 memset(cmd, 0, sizeof(struct ub_scsi_cmd));
662 662
663 blkdev_dequeue_request(rq); 663 blk_start_request(rq);
664 664
665 urq = &lun->urq; 665 urq = &lun->urq;
666 memset(urq, 0, sizeof(struct ub_request)); 666 memset(urq, 0, sizeof(struct ub_request));
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c
index 2086cb12d3ec..390d69bb7c48 100644
--- a/drivers/block/viodasd.c
+++ b/drivers/block/viodasd.c
@@ -361,11 +361,9 @@ static void do_viodasd_request(struct request_queue *q)
361 * back later. 361 * back later.
362 */ 362 */
363 while (num_req_outstanding < VIOMAXREQ) { 363 while (num_req_outstanding < VIOMAXREQ) {
364 req = elv_next_request(q); 364 req = blk_fetch_request(q);
365 if (req == NULL) 365 if (req == NULL)
366 return; 366 return;
367 /* dequeue the current request from the queue */
368 blkdev_dequeue_request(req);
369 /* check that request contains a valid command */ 367 /* check that request contains a valid command */
370 if (!blk_fs_request(req)) { 368 if (!blk_fs_request(req)) {
371 viodasd_end_request(req, -EIO, blk_rq_sectors(req)); 369 viodasd_end_request(req, -EIO, blk_rq_sectors(req));
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 1980ab456356..29a9daf48621 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -128,7 +128,7 @@ static void do_virtblk_request(struct request_queue *q)
128 struct request *req; 128 struct request *req;
129 unsigned int issued = 0; 129 unsigned int issued = 0;
130 130
131 while ((req = elv_next_request(q)) != NULL) { 131 while ((req = blk_peek_request(q)) != NULL) {
132 vblk = req->rq_disk->private_data; 132 vblk = req->rq_disk->private_data;
133 BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems); 133 BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems);
134 134
@@ -138,7 +138,7 @@ static void do_virtblk_request(struct request_queue *q)
138 blk_stop_queue(q); 138 blk_stop_queue(q);
139 break; 139 break;
140 } 140 }
141 blkdev_dequeue_request(req); 141 blk_start_request(req);
142 issued++; 142 issued++;
143 } 143 }
144 144
diff --git a/drivers/block/xd.c b/drivers/block/xd.c
index d4c4352354b5..ce2429219925 100644
--- a/drivers/block/xd.c
+++ b/drivers/block/xd.c
@@ -305,10 +305,7 @@ static void do_xd_request (struct request_queue * q)
305 if (xdc_busy) 305 if (xdc_busy)
306 return; 306 return;
307 307
308 req = elv_next_request(q); 308 req = blk_fetch_request(q);
309 if (req)
310 blkdev_dequeue_request(req);
311
312 while (req) { 309 while (req) {
313 unsigned block = blk_rq_pos(req); 310 unsigned block = blk_rq_pos(req);
314 unsigned count = blk_rq_cur_sectors(req); 311 unsigned count = blk_rq_cur_sectors(req);
@@ -325,11 +322,8 @@ static void do_xd_request (struct request_queue * q)
325 block, count); 322 block, count);
326 done: 323 done:
327 /* wrap up, 0 = success, -errno = fail */ 324 /* wrap up, 0 = success, -errno = fail */
328 if (!__blk_end_request_cur(req, res)) { 325 if (!__blk_end_request_cur(req, res))
329 req = elv_next_request(q); 326 req = blk_fetch_request(q);
330 if (req)
331 blkdev_dequeue_request(req);
332 }
333 } 327 }
334} 328}
335 329
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 66f834571b88..6d4ac76c2806 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -299,13 +299,13 @@ static void do_blkif_request(struct request_queue *rq)
299 299
300 queued = 0; 300 queued = 0;
301 301
302 while ((req = elv_next_request(rq)) != NULL) { 302 while ((req = blk_peek_request(rq)) != NULL) {
303 info = req->rq_disk->private_data; 303 info = req->rq_disk->private_data;
304 304
305 if (RING_FULL(&info->ring)) 305 if (RING_FULL(&info->ring))
306 goto wait; 306 goto wait;
307 307
308 blkdev_dequeue_request(req); 308 blk_start_request(req);
309 309
310 if (!blk_fs_request(req)) { 310 if (!blk_fs_request(req)) {
311 __blk_end_request_all(req, -EIO); 311 __blk_end_request_all(req, -EIO);
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index edf137b6c379..3a4397edab71 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -463,10 +463,10 @@ struct request *ace_get_next_request(struct request_queue * q)
463{ 463{
464 struct request *req; 464 struct request *req;
465 465
466 while ((req = elv_next_request(q)) != NULL) { 466 while ((req = blk_peek_request(q)) != NULL) {
467 if (blk_fs_request(req)) 467 if (blk_fs_request(req))
468 break; 468 break;
469 blkdev_dequeue_request(req); 469 blk_start_request(req);
470 __blk_end_request_all(req, -EIO); 470 __blk_end_request_all(req, -EIO);
471 } 471 }
472 return req; 472 return req;
@@ -498,10 +498,8 @@ static void ace_fsm_dostate(struct ace_device *ace)
498 __blk_end_request_all(ace->req, -EIO); 498 __blk_end_request_all(ace->req, -EIO);
499 ace->req = NULL; 499 ace->req = NULL;
500 } 500 }
501 while ((req = elv_next_request(ace->queue)) != NULL) { 501 while ((req = blk_fetch_request(ace->queue)) != NULL)
502 blkdev_dequeue_request(req);
503 __blk_end_request_all(req, -EIO); 502 __blk_end_request_all(req, -EIO);
504 }
505 503
506 /* Drop back to IDLE state and notify waiters */ 504 /* Drop back to IDLE state and notify waiters */
507 ace->fsm_state = ACE_FSM_STATE_IDLE; 505 ace->fsm_state = ACE_FSM_STATE_IDLE;
@@ -649,7 +647,7 @@ static void ace_fsm_dostate(struct ace_device *ace)
649 ace->fsm_state = ACE_FSM_STATE_IDLE; 647 ace->fsm_state = ACE_FSM_STATE_IDLE;
650 break; 648 break;
651 } 649 }
652 blkdev_dequeue_request(req); 650 blk_start_request(req);
653 651
654 /* Okay, it's a data request, set it up for transfer */ 652 /* Okay, it's a data request, set it up for transfer */
655 dev_dbg(ace->dev, 653 dev_dbg(ace->dev,
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index c909c1a3f650..4575171e5beb 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -71,10 +71,7 @@ static void do_z2_request(struct request_queue *q)
71{ 71{
72 struct request *req; 72 struct request *req;
73 73
74 req = elv_next_request(q); 74 req = blk_fetch_request(q);
75 if (req)
76 blkdev_dequeue_request(req);
77
78 while (req) { 75 while (req) {
79 unsigned long start = blk_rq_pos(req) << 9; 76 unsigned long start = blk_rq_pos(req) << 9;
80 unsigned long len = blk_rq_cur_bytes(req); 77 unsigned long len = blk_rq_cur_bytes(req);
@@ -100,11 +97,8 @@ static void do_z2_request(struct request_queue *q)
100 len -= size; 97 len -= size;
101 } 98 }
102 done: 99 done:
103 if (!__blk_end_request_cur(req, err)) { 100 if (!__blk_end_request_cur(req, err))
104 req = elv_next_request(q); 101 req = blk_fetch_request(q);
105 if (req)
106 blkdev_dequeue_request(req);
107 }
108 } 102 }
109} 103}
110 104
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
index 3cc02bfe828d..1e366ad8f680 100644
--- a/drivers/cdrom/gdrom.c
+++ b/drivers/cdrom/gdrom.c
@@ -642,9 +642,7 @@ static void gdrom_request(struct request_queue *rq)
642{ 642{
643 struct request *req; 643 struct request *req;
644 644
645 while ((req = elv_next_request(rq)) != NULL) { 645 while ((req = blk_fetch_request(rq)) != NULL) {
646 blkdev_dequeue_request(req);
647
648 if (!blk_fs_request(req)) { 646 if (!blk_fs_request(req)) {
649 printk(KERN_DEBUG "GDROM: Non-fs request ignored\n"); 647 printk(KERN_DEBUG "GDROM: Non-fs request ignored\n");
650 __blk_end_request_all(req, -EIO); 648 __blk_end_request_all(req, -EIO);
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c
index bbe9f0867347..ca741c21e4aa 100644
--- a/drivers/cdrom/viocd.c
+++ b/drivers/cdrom/viocd.c
@@ -297,9 +297,7 @@ static void do_viocd_request(struct request_queue *q)
297{ 297{
298 struct request *req; 298 struct request *req;
299 299
300 while ((rwreq == 0) && ((req = elv_next_request(q)) != NULL)) { 300 while ((rwreq == 0) && ((req = blk_fetch_request(q)) != NULL)) {
301 blkdev_dequeue_request(req);
302
303 if (!blk_fs_request(req)) 301 if (!blk_fs_request(req))
304 __blk_end_request_all(req, -EIO); 302 __blk_end_request_all(req, -EIO);
305 else if (send_request(req) < 0) { 303 else if (send_request(req) < 0) {
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 2874c3d703a9..8a894fa37b53 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -269,7 +269,7 @@ void ide_retry_pc(ide_drive_t *drive)
269 blk_requeue_request(failed_rq->q, failed_rq); 269 blk_requeue_request(failed_rq->q, failed_rq);
270 drive->hwif->rq = NULL; 270 drive->hwif->rq = NULL;
271 if (ide_queue_sense_rq(drive, pc)) { 271 if (ide_queue_sense_rq(drive, pc)) {
272 blkdev_dequeue_request(failed_rq); 272 blk_start_request(failed_rq);
273 ide_complete_rq(drive, -EIO, blk_rq_bytes(failed_rq)); 273 ide_complete_rq(drive, -EIO, blk_rq_bytes(failed_rq));
274 } 274 }
275} 275}
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index abda7337b3f4..e4e3a0e3201e 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -519,11 +519,8 @@ repeat:
519 * we know that the queue isn't empty, but this can happen 519 * we know that the queue isn't empty, but this can happen
520 * if the q->prep_rq_fn() decides to kill a request 520 * if the q->prep_rq_fn() decides to kill a request
521 */ 521 */
522 if (!rq) { 522 if (!rq)
523 rq = elv_next_request(drive->queue); 523 rq = blk_fetch_request(drive->queue);
524 if (rq)
525 blkdev_dequeue_request(rq);
526 }
527 524
528 spin_unlock_irq(q->queue_lock); 525 spin_unlock_irq(q->queue_lock);
529 spin_lock_irq(&hwif->lock); 526 spin_lock_irq(&hwif->lock);
@@ -536,7 +533,7 @@ repeat:
536 /* 533 /*
537 * Sanity: don't accept a request that isn't a PM request 534 * Sanity: don't accept a request that isn't a PM request
538 * if we are currently power managed. This is very important as 535 * if we are currently power managed. This is very important as
539 * blk_stop_queue() doesn't prevent the elv_next_request() 536 * blk_stop_queue() doesn't prevent the blk_fetch_request()
540 * above to return us whatever is in the queue. Since we call 537 * above to return us whatever is in the queue. Since we call
541 * ide_do_request() ourselves, we end up taking requests while 538 * ide_do_request() ourselves, we end up taking requests while
542 * the queue is blocked... 539 * the queue is blocked...
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c
index 58f5be8cd69e..c0bebc6a2f2c 100644
--- a/drivers/memstick/core/mspro_block.c
+++ b/drivers/memstick/core/mspro_block.c
@@ -704,13 +704,12 @@ try_again:
704 return 0; 704 return 0;
705 } 705 }
706 706
707 dev_dbg(&card->dev, "elv_next\n"); 707 dev_dbg(&card->dev, "blk_fetch\n");
708 msb->block_req = elv_next_request(msb->queue); 708 msb->block_req = blk_fetch_request(msb->queue);
709 if (!msb->block_req) { 709 if (!msb->block_req) {
710 dev_dbg(&card->dev, "issue end\n"); 710 dev_dbg(&card->dev, "issue end\n");
711 return -EAGAIN; 711 return -EAGAIN;
712 } 712 }
713 blkdev_dequeue_request(msb->block_req);
714 713
715 dev_dbg(&card->dev, "trying again\n"); 714 dev_dbg(&card->dev, "trying again\n");
716 chunk = 1; 715 chunk = 1;
@@ -825,10 +824,8 @@ static void mspro_block_submit_req(struct request_queue *q)
825 return; 824 return;
826 825
827 if (msb->eject) { 826 if (msb->eject) {
828 while ((req = elv_next_request(q)) != NULL) { 827 while ((req = blk_fetch_request(q)) != NULL)
829 blkdev_dequeue_request(req);
830 __blk_end_request_all(req, -ENODEV); 828 __blk_end_request_all(req, -ENODEV);
831 }
832 829
833 return; 830 return;
834 } 831 }
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index 8b5cbfc3ba97..6573ef4408f1 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -877,7 +877,7 @@ static void i2o_block_request_fn(struct request_queue *q)
877 struct request *req; 877 struct request *req;
878 878
879 while (!blk_queue_plugged(q)) { 879 while (!blk_queue_plugged(q)) {
880 req = elv_next_request(q); 880 req = blk_peek_request(q);
881 if (!req) 881 if (!req)
882 break; 882 break;
883 883
@@ -890,7 +890,7 @@ static void i2o_block_request_fn(struct request_queue *q)
890 890
891 if (queue_depth < I2O_BLOCK_MAX_OPEN_REQUESTS) { 891 if (queue_depth < I2O_BLOCK_MAX_OPEN_REQUESTS) {
892 if (!i2o_block_transfer(req)) { 892 if (!i2o_block_transfer(req)) {
893 blkdev_dequeue_request(req); 893 blk_start_request(req);
894 continue; 894 continue;
895 } else 895 } else
896 osm_info("transfer error\n"); 896 osm_info("transfer error\n");
@@ -917,7 +917,7 @@ static void i2o_block_request_fn(struct request_queue *q)
917 break; 917 break;
918 } 918 }
919 } else { 919 } else {
920 blkdev_dequeue_request(req); 920 blk_start_request(req);
921 __blk_end_request_all(req, -EIO); 921 __blk_end_request_all(req, -EIO);
922 } 922 }
923 } 923 }
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index 4b70f1e28347..49e582356c65 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -54,11 +54,8 @@ static int mmc_queue_thread(void *d)
54 54
55 spin_lock_irq(q->queue_lock); 55 spin_lock_irq(q->queue_lock);
56 set_current_state(TASK_INTERRUPTIBLE); 56 set_current_state(TASK_INTERRUPTIBLE);
57 if (!blk_queue_plugged(q)) { 57 if (!blk_queue_plugged(q))
58 req = elv_next_request(q); 58 req = blk_fetch_request(q);
59 if (req)
60 blkdev_dequeue_request(req);
61 }
62 mq->req = req; 59 mq->req = req;
63 spin_unlock_irq(q->queue_lock); 60 spin_unlock_irq(q->queue_lock);
64 61
@@ -94,10 +91,8 @@ static void mmc_request(struct request_queue *q)
94 91
95 if (!mq) { 92 if (!mq) {
96 printk(KERN_ERR "MMC: killing requests for dead queue\n"); 93 printk(KERN_ERR "MMC: killing requests for dead queue\n");
97 while ((req = elv_next_request(q)) != NULL) { 94 while ((req = blk_fetch_request(q)) != NULL)
98 blkdev_dequeue_request(req);
99 __blk_end_request_all(req, -EIO); 95 __blk_end_request_all(req, -EIO);
100 }
101 return; 96 return;
102 } 97 }
103 98
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 3e10442615d1..502622f628bc 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -100,12 +100,7 @@ static int mtd_blktrans_thread(void *arg)
100 struct mtd_blktrans_dev *dev; 100 struct mtd_blktrans_dev *dev;
101 int res; 101 int res;
102 102
103 if (!req) { 103 if (!req && !(req = blk_fetch_request(rq))) {
104 req = elv_next_request(rq);
105 if (req)
106 blkdev_dequeue_request(req);
107 }
108 if (!req) {
109 set_current_state(TASK_INTERRUPTIBLE); 104 set_current_state(TASK_INTERRUPTIBLE);
110 spin_unlock_irq(rq->queue_lock); 105 spin_unlock_irq(rq->queue_lock);
111 schedule(); 106 schedule();
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 7df03c7aea0d..e64f62d5e0fc 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -1656,17 +1656,13 @@ static void __dasd_process_request_queue(struct dasd_block *block)
1656 if (basedev->state < DASD_STATE_READY) 1656 if (basedev->state < DASD_STATE_READY)
1657 return; 1657 return;
1658 /* Now we try to fetch requests from the request queue */ 1658 /* Now we try to fetch requests from the request queue */
1659 while (!blk_queue_plugged(queue) && 1659 while (!blk_queue_plugged(queue) && (req = blk_peek_request(queue))) {
1660 elv_next_request(queue)) {
1661
1662 req = elv_next_request(queue);
1663
1664 if (basedev->features & DASD_FEATURE_READONLY && 1660 if (basedev->features & DASD_FEATURE_READONLY &&
1665 rq_data_dir(req) == WRITE) { 1661 rq_data_dir(req) == WRITE) {
1666 DBF_DEV_EVENT(DBF_ERR, basedev, 1662 DBF_DEV_EVENT(DBF_ERR, basedev,
1667 "Rejecting write request %p", 1663 "Rejecting write request %p",
1668 req); 1664 req);
1669 blkdev_dequeue_request(req); 1665 blk_start_request(req);
1670 __blk_end_request_all(req, -EIO); 1666 __blk_end_request_all(req, -EIO);
1671 continue; 1667 continue;
1672 } 1668 }
@@ -1695,7 +1691,7 @@ static void __dasd_process_request_queue(struct dasd_block *block)
1695 "CCW creation failed (rc=%ld) " 1691 "CCW creation failed (rc=%ld) "
1696 "on request %p", 1692 "on request %p",
1697 PTR_ERR(cqr), req); 1693 PTR_ERR(cqr), req);
1698 blkdev_dequeue_request(req); 1694 blk_start_request(req);
1699 __blk_end_request_all(req, -EIO); 1695 __blk_end_request_all(req, -EIO);
1700 continue; 1696 continue;
1701 } 1697 }
@@ -1705,7 +1701,7 @@ static void __dasd_process_request_queue(struct dasd_block *block)
1705 */ 1701 */
1706 cqr->callback_data = (void *) req; 1702 cqr->callback_data = (void *) req;
1707 cqr->status = DASD_CQR_FILLED; 1703 cqr->status = DASD_CQR_FILLED;
1708 blkdev_dequeue_request(req); 1704 blk_start_request(req);
1709 list_add_tail(&cqr->blocklist, &block->ccw_queue); 1705 list_add_tail(&cqr->blocklist, &block->ccw_queue);
1710 dasd_profile_start(block, cqr, req); 1706 dasd_profile_start(block, cqr, req);
1711 } 1707 }
@@ -2029,10 +2025,8 @@ static void dasd_flush_request_queue(struct dasd_block *block)
2029 return; 2025 return;
2030 2026
2031 spin_lock_irq(&block->request_queue_lock); 2027 spin_lock_irq(&block->request_queue_lock);
2032 while ((req = elv_next_request(block->request_queue))) { 2028 while ((req = blk_fetch_request(block->request_queue)))
2033 blkdev_dequeue_request(req);
2034 __blk_end_request_all(req, -EIO); 2029 __blk_end_request_all(req, -EIO);
2035 }
2036 spin_unlock_irq(&block->request_queue_lock); 2030 spin_unlock_irq(&block->request_queue_lock);
2037} 2031}
2038 2032
diff --git a/drivers/s390/char/tape_block.c b/drivers/s390/char/tape_block.c
index 5d035e4939dc..1e7967675980 100644
--- a/drivers/s390/char/tape_block.c
+++ b/drivers/s390/char/tape_block.c
@@ -93,7 +93,7 @@ __tapeblock_end_request(struct tape_request *ccw_req, void *data)
93 device->blk_data.block_position = -1; 93 device->blk_data.block_position = -1;
94 device->discipline->free_bread(ccw_req); 94 device->discipline->free_bread(ccw_req);
95 if (!list_empty(&device->req_queue) || 95 if (!list_empty(&device->req_queue) ||
96 elv_next_request(device->blk_data.request_queue)) 96 blk_peek_request(device->blk_data.request_queue))
97 tapeblock_trigger_requeue(device); 97 tapeblock_trigger_requeue(device);
98} 98}
99 99
@@ -162,19 +162,16 @@ tapeblock_requeue(struct work_struct *work) {
162 spin_lock_irq(&device->blk_data.request_queue_lock); 162 spin_lock_irq(&device->blk_data.request_queue_lock);
163 while ( 163 while (
164 !blk_queue_plugged(queue) && 164 !blk_queue_plugged(queue) &&
165 elv_next_request(queue) && 165 (req = blk_fetch_request(queue)) &&
166 nr_queued < TAPEBLOCK_MIN_REQUEUE 166 nr_queued < TAPEBLOCK_MIN_REQUEUE
167 ) { 167 ) {
168 req = elv_next_request(queue);
169 if (rq_data_dir(req) == WRITE) { 168 if (rq_data_dir(req) == WRITE) {
170 DBF_EVENT(1, "TBLOCK: Rejecting write request\n"); 169 DBF_EVENT(1, "TBLOCK: Rejecting write request\n");
171 blkdev_dequeue_request(req);
172 spin_unlock_irq(&device->blk_data.request_queue_lock); 170 spin_unlock_irq(&device->blk_data.request_queue_lock);
173 blk_end_request_all(req, -EIO); 171 blk_end_request_all(req, -EIO);
174 spin_lock_irq(&device->blk_data.request_queue_lock); 172 spin_lock_irq(&device->blk_data.request_queue_lock);
175 continue; 173 continue;
176 } 174 }
177 blkdev_dequeue_request(req);
178 nr_queued++; 175 nr_queued++;
179 spin_unlock_irq(&device->blk_data.request_queue_lock); 176 spin_unlock_irq(&device->blk_data.request_queue_lock);
180 rc = tapeblock_start_request(device, req); 177 rc = tapeblock_start_request(device, req);
diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c
index f572a4a1d141..6d4651684688 100644
--- a/drivers/sbus/char/jsflash.c
+++ b/drivers/sbus/char/jsflash.c
@@ -186,10 +186,7 @@ static void jsfd_do_request(struct request_queue *q)
186{ 186{
187 struct request *req; 187 struct request *req;
188 188
189 req = elv_next_request(q); 189 req = blk_fetch_request(q);
190 if (req)
191 blkdev_dequeue_request(req);
192
193 while (req) { 190 while (req) {
194 struct jsfd_part *jdp = req->rq_disk->private_data; 191 struct jsfd_part *jdp = req->rq_disk->private_data;
195 unsigned long offset = blk_rq_pos(req) << 9; 192 unsigned long offset = blk_rq_pos(req) << 9;
@@ -212,11 +209,8 @@ static void jsfd_do_request(struct request_queue *q)
212 jsfd_read(req->buffer, jdp->dbase + offset, len); 209 jsfd_read(req->buffer, jdp->dbase + offset, len);
213 err = 0; 210 err = 0;
214 end: 211 end:
215 if (!__blk_end_request_cur(req, err)) { 212 if (!__blk_end_request_cur(req, err))
216 req = elv_next_request(q); 213 req = blk_fetch_request(q);
217 if (req)
218 blkdev_dequeue_request(req);
219 }
220 } 214 }
221} 215}
222 216
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ee308f6f7982..b12750f82169 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1207,7 +1207,7 @@ int scsi_prep_return(struct request_queue *q, struct request *req, int ret)
1207 break; 1207 break;
1208 case BLKPREP_DEFER: 1208 case BLKPREP_DEFER:
1209 /* 1209 /*
1210 * If we defer, the elv_next_request() returns NULL, but the 1210 * If we defer, the blk_peek_request() returns NULL, but the
1211 * queue must be restarted, so we plug here if no returning 1211 * queue must be restarted, so we plug here if no returning
1212 * command will automatically do that. 1212 * command will automatically do that.
1213 */ 1213 */
@@ -1385,7 +1385,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
1385 struct scsi_target *starget = scsi_target(sdev); 1385 struct scsi_target *starget = scsi_target(sdev);
1386 struct Scsi_Host *shost = sdev->host; 1386 struct Scsi_Host *shost = sdev->host;
1387 1387
1388 blkdev_dequeue_request(req); 1388 blk_start_request(req);
1389 1389
1390 if (unlikely(cmd == NULL)) { 1390 if (unlikely(cmd == NULL)) {
1391 printk(KERN_CRIT "impossible request in %s.\n", 1391 printk(KERN_CRIT "impossible request in %s.\n",
@@ -1477,7 +1477,7 @@ static void scsi_request_fn(struct request_queue *q)
1477 1477
1478 if (!sdev) { 1478 if (!sdev) {
1479 printk("scsi: killing requests for dead queue\n"); 1479 printk("scsi: killing requests for dead queue\n");
1480 while ((req = elv_next_request(q)) != NULL) 1480 while ((req = blk_peek_request(q)) != NULL)
1481 scsi_kill_request(req, q); 1481 scsi_kill_request(req, q);
1482 return; 1482 return;
1483 } 1483 }
@@ -1498,7 +1498,7 @@ static void scsi_request_fn(struct request_queue *q)
1498 * that the request is fully prepared even if we cannot 1498 * that the request is fully prepared even if we cannot
1499 * accept it. 1499 * accept it.
1500 */ 1500 */
1501 req = elv_next_request(q); 1501 req = blk_peek_request(q);
1502 if (!req || !scsi_dev_queue_ready(q, sdev)) 1502 if (!req || !scsi_dev_queue_ready(q, sdev))
1503 break; 1503 break;
1504 1504
@@ -1514,7 +1514,7 @@ static void scsi_request_fn(struct request_queue *q)
1514 * Remove the request from the request list. 1514 * Remove the request from the request list.
1515 */ 1515 */
1516 if (!(blk_queue_tagged(q) && !blk_queue_start_tag(q, req))) 1516 if (!(blk_queue_tagged(q) && !blk_queue_start_tag(q, req)))
1517 blkdev_dequeue_request(req); 1517 blk_start_request(req);
1518 sdev->device_busy++; 1518 sdev->device_busy++;
1519 1519
1520 spin_unlock(q->queue_lock); 1520 spin_unlock(q->queue_lock);
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index 50988cbf7b2d..d606452297cf 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -163,12 +163,10 @@ static void sas_smp_request(struct request_queue *q, struct Scsi_Host *shost,
163 int (*handler)(struct Scsi_Host *, struct sas_rphy *, struct request *); 163 int (*handler)(struct Scsi_Host *, struct sas_rphy *, struct request *);
164 164
165 while (!blk_queue_plugged(q)) { 165 while (!blk_queue_plugged(q)) {
166 req = elv_next_request(q); 166 req = blk_fetch_request(q);
167 if (!req) 167 if (!req)
168 break; 168 break;
169 169
170 blkdev_dequeue_request(req);
171
172 spin_unlock_irq(q->queue_lock); 170 spin_unlock_irq(q->queue_lock);
173 171
174 handler = to_sas_internal(shost->transportt)->f->smp_handler; 172 handler = to_sas_internal(shost->transportt)->f->smp_handler;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index c75580345700..6e59d3b92ff2 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -818,8 +818,6 @@ static inline void blk_run_address_space(struct address_space *mapping)
818 blk_run_backing_dev(mapping->backing_dev_info, NULL); 818 blk_run_backing_dev(mapping->backing_dev_info, NULL);
819} 819}
820 820
821extern void blkdev_dequeue_request(struct request *req);
822
823/* 821/*
824 * blk_rq_pos() : the current sector 822 * blk_rq_pos() : the current sector
825 * blk_rq_bytes() : bytes left in the entire request 823 * blk_rq_bytes() : bytes left in the entire request
@@ -853,6 +851,13 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq)
853} 851}
854 852
855/* 853/*
854 * Request issue related functions.
855 */
856extern struct request *blk_peek_request(struct request_queue *q);
857extern void blk_start_request(struct request *rq);
858extern struct request *blk_fetch_request(struct request_queue *q);
859
860/*
856 * Request completion related functions. 861 * Request completion related functions.
857 * 862 *
858 * blk_update_request() completes given number of bytes and updates 863 * blk_update_request() completes given number of bytes and updates
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index 4e462878c9ca..1cb3372e65d8 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -103,10 +103,8 @@ extern int elv_merge(struct request_queue *, struct request **, struct bio *);
103extern void elv_merge_requests(struct request_queue *, struct request *, 103extern void elv_merge_requests(struct request_queue *, struct request *,
104 struct request *); 104 struct request *);
105extern void elv_merged_request(struct request_queue *, struct request *, int); 105extern void elv_merged_request(struct request_queue *, struct request *, int);
106extern void elv_dequeue_request(struct request_queue *, struct request *);
107extern void elv_requeue_request(struct request_queue *, struct request *); 106extern void elv_requeue_request(struct request_queue *, struct request *);
108extern int elv_queue_empty(struct request_queue *); 107extern int elv_queue_empty(struct request_queue *);
109extern struct request *elv_next_request(struct request_queue *q);
110extern struct request *elv_former_request(struct request_queue *, struct request *); 108extern struct request *elv_former_request(struct request_queue *, struct request *);
111extern struct request *elv_latter_request(struct request_queue *, struct request *); 109extern struct request *elv_latter_request(struct request_queue *, struct request *);
112extern int elv_register_queue(struct request_queue *q); 110extern int elv_register_queue(struct request_queue *q);