]> git.karo-electronics.de Git - linux-beck.git/commitdiff
block: implement and enforce request peek/start/fetch
authorTejun Heo <tj@kernel.org>
Fri, 8 May 2009 02:54:16 +0000 (11:54 +0900)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 11 May 2009 07:52:18 +0000 (09:52 +0200)
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>
45 files changed:
arch/arm/plat-omap/mailbox.c
arch/um/drivers/ubd_kern.c
block/blk-barrier.c
block/blk-core.c
block/blk-tag.c
block/blk.h
drivers/block/DAC960.c
drivers/block/amiflop.c
drivers/block/ataflop.c
drivers/block/cciss.c
drivers/block/cpqarray.c
drivers/block/floppy.c
drivers/block/hd.c
drivers/block/mg_disk.c
drivers/block/nbd.c
drivers/block/paride/pcd.c
drivers/block/paride/pd.c
drivers/block/paride/pf.c
drivers/block/ps3disk.c
drivers/block/sunvdc.c
drivers/block/swim.c
drivers/block/swim3.c
drivers/block/sx8.c
drivers/block/ub.c
drivers/block/viodasd.c
drivers/block/virtio_blk.c
drivers/block/xd.c
drivers/block/xen-blkfront.c
drivers/block/xsysace.c
drivers/block/z2ram.c
drivers/cdrom/gdrom.c
drivers/cdrom/viocd.c
drivers/ide/ide-atapi.c
drivers/ide/ide-io.c
drivers/memstick/core/mspro_block.c
drivers/message/i2o/i2o_block.c
drivers/mmc/card/queue.c
drivers/mtd/mtd_blkdevs.c
drivers/s390/block/dasd.c
drivers/s390/char/tape_block.c
drivers/sbus/char/jsflash.c
drivers/scsi/scsi_lib.c
drivers/scsi/scsi_transport_sas.c
include/linux/blkdev.h
include/linux/elevator.h

index 7a1f5c25fd17cff568e9c158dc2b96065d777b22..40424edae93912067cabd21a8ce7c4c304a91428 100644 (file)
@@ -197,9 +197,7 @@ static void mbox_tx_work(struct work_struct *work)
                struct omap_msg_tx_data *tx_data;
 
                spin_lock(q->queue_lock);
-               rq = elv_next_request(q);
-               if (rq)
-                       blkdev_dequeue_request(rq);
+               rq = blk_fetch_request(q);
                spin_unlock(q->queue_lock);
 
                if (!rq)
@@ -242,9 +240,7 @@ static void mbox_rx_work(struct work_struct *work)
 
        while (1) {
                spin_lock_irqsave(q->queue_lock, flags);
-               rq = elv_next_request(q);
-               if (rq)
-                       blkdev_dequeue_request(rq);
+               rq = blk_fetch_request(q);
                spin_unlock_irqrestore(q->queue_lock, flags);
                if (!rq)
                        break;
@@ -351,9 +347,7 @@ omap_mbox_read(struct device *dev, struct device_attribute *attr, char *buf)
 
        while (1) {
                spin_lock_irqsave(q->queue_lock, flags);
-               rq = elv_next_request(q);
-               if (rq)
-                       blkdev_dequeue_request(rq);
+               rq = blk_fetch_request(q);
                spin_unlock_irqrestore(q->queue_lock, flags);
 
                if (!rq)
index 402ba8f70fc90f36170c06e006ae47406baee7aa..aa9e926e13d73dca17015a5bd5f8e5eb76842c63 100644 (file)
@@ -1228,12 +1228,11 @@ static void do_ubd_request(struct request_queue *q)
        while(1){
                struct ubd *dev = q->queuedata;
                if(dev->end_sg == 0){
-                       struct request *req = elv_next_request(q);
+                       struct request *req = blk_fetch_request(q);
                        if(req == NULL)
                                return;
 
                        dev->request = req;
-                       blkdev_dequeue_request(req);
                        dev->start_sg = 0;
                        dev->end_sg = blk_rq_map_sg(q, req, dev->sg);
                }
index 8713c2fbc4f64cac611acc435b9fd8d2f451ffd5..0ab81a0a7502303a3f9ae06382c6a958af1d9c1e 100644 (file)
@@ -180,7 +180,7 @@ static inline bool start_ordered(struct request_queue *q, struct request **rqp)
        }
 
        /* stash away the original request */
-       elv_dequeue_request(q, rq);
+       blk_dequeue_request(rq);
        q->orig_bar_rq = rq;
        rq = NULL;
 
@@ -248,7 +248,7 @@ bool blk_do_ordered(struct request_queue *q, struct request **rqp)
                         * Queue ordering not supported.  Terminate
                         * with prejudice.
                         */
-                       elv_dequeue_request(q, rq);
+                       blk_dequeue_request(rq);
                        __blk_end_request_all(rq, -EOPNOTSUPP);
                        *rqp = NULL;
                        return false;
index 6226a380fb6d598913a9e68700be79662223bbde..93691d2ac5a078ed76539180f31ece9fc0222d42 100644 (file)
@@ -902,6 +902,8 @@ EXPORT_SYMBOL(blk_get_request);
  */
 void blk_requeue_request(struct request_queue *q, struct request *rq)
 {
+       BUG_ON(blk_queued_rq(rq));
+
        blk_delete_timer(rq);
        blk_clear_rq_complete(rq);
        trace_block_rq_requeue(q, rq);
@@ -1610,28 +1612,6 @@ int blk_insert_cloned_request(struct request_queue *q, struct request *rq)
 }
 EXPORT_SYMBOL_GPL(blk_insert_cloned_request);
 
-/**
- * blkdev_dequeue_request - dequeue request and start timeout timer
- * @req: request to dequeue
- *
- * Dequeue @req and start timeout timer on it.  This hands off the
- * request to the driver.
- *
- * Block internal functions which don't want to start timer should
- * call elv_dequeue_request().
- */
-void blkdev_dequeue_request(struct request *req)
-{
-       elv_dequeue_request(req->q, req);
-
-       /*
-        * We are now handing the request to the hardware, add the
-        * timeout handler.
-        */
-       blk_add_timer(req);
-}
-EXPORT_SYMBOL(blkdev_dequeue_request);
-
 static void blk_account_io_completion(struct request *req, unsigned int bytes)
 {
        if (blk_do_io_stat(req)) {
@@ -1671,7 +1651,23 @@ static void blk_account_io_done(struct request *req)
        }
 }
 
-struct request *elv_next_request(struct request_queue *q)
+/**
+ * blk_peek_request - peek at the top of a request queue
+ * @q: request queue to peek at
+ *
+ * Description:
+ *     Return the request at the top of @q.  The returned request
+ *     should be started using blk_start_request() before LLD starts
+ *     processing it.
+ *
+ * Return:
+ *     Pointer to the request at the top of @q if available.  Null
+ *     otherwise.
+ *
+ * Context:
+ *     queue_lock must be held.
+ */
+struct request *blk_peek_request(struct request_queue *q)
 {
        struct request *rq;
        int ret;
@@ -1748,10 +1744,12 @@ struct request *elv_next_request(struct request_queue *q)
 
        return rq;
 }
-EXPORT_SYMBOL(elv_next_request);
+EXPORT_SYMBOL(blk_peek_request);
 
-void elv_dequeue_request(struct request_queue *q, struct request *rq)
+void blk_dequeue_request(struct request *rq)
 {
+       struct request_queue *q = rq->q;
+
        BUG_ON(list_empty(&rq->queuelist));
        BUG_ON(ELV_ON_HASH(rq));
 
@@ -1766,6 +1764,58 @@ void elv_dequeue_request(struct request_queue *q, struct request *rq)
                q->in_flight++;
 }
 
+/**
+ * blk_start_request - start request processing on the driver
+ * @req: request to dequeue
+ *
+ * Description:
+ *     Dequeue @req and start timeout timer on it.  This hands off the
+ *     request to the driver.
+ *
+ *     Block internal functions which don't want to start timer should
+ *     call blk_dequeue_request().
+ *
+ * Context:
+ *     queue_lock must be held.
+ */
+void blk_start_request(struct request *req)
+{
+       blk_dequeue_request(req);
+
+       /*
+        * We are now handing the request to the hardware, add the
+        * timeout handler.
+        */
+       blk_add_timer(req);
+}
+EXPORT_SYMBOL(blk_start_request);
+
+/**
+ * blk_fetch_request - fetch a request from a request queue
+ * @q: request queue to fetch a request from
+ *
+ * Description:
+ *     Return the request at the top of @q.  The request is started on
+ *     return and LLD can start processing it immediately.
+ *
+ * Return:
+ *     Pointer to the request at the top of @q if available.  Null
+ *     otherwise.
+ *
+ * Context:
+ *     queue_lock must be held.
+ */
+struct request *blk_fetch_request(struct request_queue *q)
+{
+       struct request *rq;
+
+       rq = blk_peek_request(q);
+       if (rq)
+               blk_start_request(rq);
+       return rq;
+}
+EXPORT_SYMBOL(blk_fetch_request);
+
 /**
  * blk_update_request - Special helper function for request stacking drivers
  * @rq:              the request being processed
@@ -1937,12 +1987,11 @@ static bool blk_update_bidi_request(struct request *rq, int error,
  */
 static void blk_finish_request(struct request *req, int error)
 {
+       BUG_ON(blk_queued_rq(req));
+
        if (blk_rq_tagged(req))
                blk_queue_end_tag(req->q, req);
 
-       if (blk_queued_rq(req))
-               elv_dequeue_request(req->q, req);
-
        if (unlikely(laptop_mode) && blk_fs_request(req))
                laptop_io_completion();
 
index 3c518e3303ae34113516924f9d73a58b94a1e75c..c260f7c30ddae1e2b7b6a718337a3a3306a4658a 100644 (file)
@@ -374,7 +374,7 @@ int blk_queue_start_tag(struct request_queue *q, struct request *rq)
        rq->cmd_flags |= REQ_QUEUED;
        rq->tag = tag;
        bqt->tag_index[tag] = rq;
-       blkdev_dequeue_request(rq);
+       blk_start_request(rq);
        list_add(&rq->queuelist, &q->tag_busy_list);
        return 0;
 }
index ab54529103c003ada67f48f3b7efa368e7a540b2..9e0042ca9495909623d739c83efc6eb3d110ac53 100644 (file)
@@ -13,6 +13,7 @@ extern struct kobj_type blk_queue_ktype;
 void init_request_from_bio(struct request *req, struct bio *bio);
 void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
                        struct bio *bio);
+void blk_dequeue_request(struct request *rq);
 void __blk_queue_free_tags(struct request_queue *q);
 
 void blk_unplug_work(struct work_struct *work);
index 774ab05973a9233e7a480dea96a7301c3281df40..668dc234b8e22d5b09950950914398d6f1f61766 100644 (file)
@@ -3321,7 +3321,7 @@ static int DAC960_process_queue(DAC960_Controller_T *Controller, struct request_
        DAC960_Command_T *Command;
 
    while(1) {
-       Request = elv_next_request(req_q);
+       Request = blk_peek_request(req_q);
        if (!Request)
                return 1;
 
@@ -3341,7 +3341,7 @@ static int DAC960_process_queue(DAC960_Controller_T *Controller, struct request_
        Command->BlockNumber = blk_rq_pos(Request);
        Command->BlockCount = blk_rq_sectors(Request);
        Command->Request = Request;
-       blkdev_dequeue_request(Request);
+       blk_start_request(Request);
        Command->SegmentCount = blk_rq_map_sg(req_q,
                  Command->Request, Command->cmd_sglist);
        /* pci_map_sg MAY change the value of SegCount */
index 80a68b2e04515b9c99f4f8c7b40331893a2a7ee8..9c6e5b0fe894f9e6af94a50b87a2ec2b2f04a470 100644 (file)
@@ -1342,12 +1342,11 @@ static void redo_fd_request(void)
        int err;
 
 next_req:
-       rq = elv_next_request(floppy_queue);
+       rq = blk_fetch_request(floppy_queue);
        if (!rq) {
                /* Nothing left to do */
                return;
        }
-       blkdev_dequeue_request(rq);
 
        floppy = rq->rq_disk->private_data;
        drive = floppy - unit;
index 89a591d9c83b6901ad12b8abafd53a7fe8e27f07..f5e7180d7f47d050ed0e39a37ad748054658b52b 100644 (file)
@@ -1404,10 +1404,9 @@ static void redo_fd_request(void)
 
 repeat:
        if (!fd_request) {
-               fd_request = elv_next_request(floppy_queue);
+               fd_request = blk_fetch_request(floppy_queue);
                if (!fd_request)
                        goto the_end;
-               blkdev_dequeue_request(fd_request);
        }
 
        floppy = fd_request->rq_disk->private_data;
index ab7b04c0db70ace0296cbbdcfe88bf7fc63e2bb3..e714e7cce6f27b2a3ede8e0cccf5c2c569723acc 100644 (file)
@@ -2801,7 +2801,7 @@ static void do_cciss_request(struct request_queue *q)
                goto startio;
 
       queue:
-       creq = elv_next_request(q);
+       creq = blk_peek_request(q);
        if (!creq)
                goto startio;
 
@@ -2810,7 +2810,7 @@ static void do_cciss_request(struct request_queue *q)
        if ((c = cmd_alloc(h, 1)) == NULL)
                goto full;
 
-       blkdev_dequeue_request(creq);
+       blk_start_request(creq);
 
        spin_unlock_irq(q->queue_lock);
 
index a5caeff4718e10cffd196cfdeacbb6e017bcaea2..a02dcfc00f134e548cf15b0fbca1f515962d500f 100644 (file)
@@ -903,7 +903,7 @@ static void do_ida_request(struct request_queue *q)
                goto startio;
 
 queue_next:
-       creq = elv_next_request(q);
+       creq = blk_peek_request(q);
        if (!creq)
                goto startio;
 
@@ -912,7 +912,7 @@ queue_next:
        if ((c = cmd_alloc(h,1)) == NULL)
                goto startio;
 
-       blkdev_dequeue_request(creq);
+       blk_start_request(creq);
 
        c->ctlr = h->ctlr;
        c->hdr.unit = (drv_info_t *)(creq->rq_disk->private_data) - h->drv;
index e2c70d2085ae1e61abe001e1e319f8ac721a28a6..90877fee0ee006a61785b8807feb97ede6def977 100644 (file)
@@ -931,7 +931,7 @@ static inline void unlock_fdc(void)
        del_timer(&fd_timeout);
        cont = NULL;
        clear_bit(0, &fdc_busy);
-       if (current_req || elv_next_request(floppy_queue))
+       if (current_req || blk_peek_request(floppy_queue))
                do_fd_request(floppy_queue);
        spin_unlock_irqrestore(&floppy_lock, flags);
        wake_up(&fdc_wait);
@@ -2912,9 +2912,7 @@ static void redo_fd_request(void)
                        struct request *req;
 
                        spin_lock_irq(floppy_queue->queue_lock);
-                       req = elv_next_request(floppy_queue);
-                       if (req)
-                               blkdev_dequeue_request(req);
+                       req = blk_fetch_request(floppy_queue);
                        spin_unlock_irq(floppy_queue->queue_lock);
                        if (!req) {
                                do_floppy = NULL;
index 288ab63c1029f032cabd8b345e4d5f52ecd47e0a..961de56d00a946946a785a7f3508ac35d0633ff9 100644 (file)
@@ -592,12 +592,11 @@ repeat:
        del_timer(&device_timer);
 
        if (!hd_req) {
-               hd_req = elv_next_request(hd_queue);
+               hd_req = blk_fetch_request(hd_queue);
                if (!hd_req) {
                        do_hd = NULL;
                        return;
                }
-               blkdev_dequeue_request(hd_req);
        }
        req = hd_req;
 
index 1ca5d1423fa3a0c1abe363f9c798ff2cb75155b7..c0cd0a03f698590083759952b33a84bb3bba2c66 100644 (file)
@@ -671,10 +671,8 @@ static void mg_request_poll(struct request_queue *q)
 
        while (1) {
                if (!host->req) {
-                       host->req = elv_next_request(q);
-                       if (host->req)
-                               blkdev_dequeue_request(host->req);
-                       else
+                       host->req = blk_fetch_request(q);
+                       if (!host->req)
                                break;
                }
 
@@ -744,10 +742,8 @@ static void mg_request(struct request_queue *q)
 
        while (1) {
                if (!host->req) {
-                       host->req = elv_next_request(q);
-                       if (host->req)
-                               blkdev_dequeue_request(host->req);
-                       else
+                       host->req = blk_fetch_request(q);
+                       if (!host->req)
                                break;
                }
                req = host->req;
index fad167de23b44c590c534214711019299b3b1840..5d23ffad7c77fc31d97ff1d5e3fed081dffe16c3 100644 (file)
@@ -533,11 +533,9 @@ static void do_nbd_request(struct request_queue *q)
 {
        struct request *req;
        
-       while ((req = elv_next_request(q)) != NULL) {
+       while ((req = blk_fetch_request(q)) != NULL) {
                struct nbd_device *lo;
 
-               blkdev_dequeue_request(req);
-
                spin_unlock_irq(q->queue_lock);
 
                dprintk(DBG_BLKDEV, "%s: request %p: dequeued (flags=%x)\n",
index 425f81586a3119c6d0843e7464f4649bbbb26e09..911dfd98d813cf7ad23cdc44a77aad946580bfe0 100644 (file)
@@ -720,10 +720,9 @@ static void do_pcd_request(struct request_queue * q)
                return;
        while (1) {
                if (!pcd_req) {
-                       pcd_req = elv_next_request(q);
+                       pcd_req = blk_fetch_request(q);
                        if (!pcd_req)
                                return;
-                       blkdev_dequeue_request(pcd_req);
                }
 
                if (rq_data_dir(pcd_req) == READ) {
index d2ca3f5520610d7fa0cccbebf60dddc25c7f3c10..bf5955b3d873511d25e31c162d7ee4280a6cc14c 100644 (file)
@@ -412,11 +412,9 @@ static void run_fsm(void)
                                spin_lock_irqsave(&pd_lock, saved_flags);
                                if (!__blk_end_request_cur(pd_req,
                                                res == Ok ? 0 : -EIO)) {
-                                       pd_req = elv_next_request(pd_queue);
+                                       pd_req = blk_fetch_request(pd_queue);
                                        if (!pd_req)
                                                stop = 1;
-                                       else
-                                               blkdev_dequeue_request(pd_req);
                                }
                                spin_unlock_irqrestore(&pd_lock, saved_flags);
                                if (stop)
@@ -706,10 +704,9 @@ static void do_pd_request(struct request_queue * q)
 {
        if (pd_req)
                return;
-       pd_req = elv_next_request(q);
+       pd_req = blk_fetch_request(q);
        if (!pd_req)
                return;
-       blkdev_dequeue_request(pd_req);
 
        schedule_fsm();
 }
index d6f7bd84ed392a2fa0ea34d75d7a8ac3c4d2994f..68a90834e99388c366874be2fe4ea554e266831f 100644 (file)
@@ -762,10 +762,9 @@ static void do_pf_request(struct request_queue * q)
                return;
 repeat:
        if (!pf_req) {
-               pf_req = elv_next_request(q);
+               pf_req = blk_fetch_request(q);
                if (!pf_req)
                        return;
-               blkdev_dequeue_request(pf_req);
        }
 
        pf_current = pf_req->rq_disk->private_data;
index f4d8db944e7d7f7a24e4221ac70d4e3d63e23f78..338cee4cc0ba4cf4c9222203a6cc52fe85e228cd 100644 (file)
@@ -194,9 +194,7 @@ static void ps3disk_do_request(struct ps3_storage_device *dev,
 
        dev_dbg(&dev->sbd.core, "%s:%u\n", __func__, __LINE__);
 
-       while ((req = elv_next_request(q))) {
-               blkdev_dequeue_request(req);
-
+       while ((req = blk_fetch_request(q))) {
                if (blk_fs_request(req)) {
                        if (ps3disk_submit_request_sg(dev, req))
                                break;
index 9f351bfa15ea8d5fa5a440514f0d85288e95765e..cbfd9c0aef034ffd2778aaac37eec3fd4d33a61e 100644 (file)
@@ -441,12 +441,11 @@ out:
 static void do_vdc_request(struct request_queue *q)
 {
        while (1) {
-               struct request *req = elv_next_request(q);
+               struct request *req = blk_fetch_request(q);
 
                if (!req)
                        break;
 
-               blkdev_dequeue_request(req);
                if (__send_request(req) < 0)
                        __blk_end_request_all(req, -EIO);
        }
index dedd4893f5ea515177b30838c4d04fdcc5b7c962..cf7877fb8a7d721b0ddbff0c0cced731e8c3e9fc 100644 (file)
@@ -528,10 +528,7 @@ static void redo_fd_request(struct request_queue *q)
        struct request *req;
        struct floppy_state *fs;
 
-       req = elv_next_request(q);
-       if (req)
-               blkdev_dequeue_request(req);
-
+       req = blk_fetch_request(q);
        while (req) {
                int err = -EIO;
 
@@ -554,11 +551,8 @@ static void redo_fd_request(struct request_queue *q)
                        break;
                }
        done:
-               if (!__blk_end_request_cur(req, err)) {
-                       req = elv_next_request(q);
-                       if (req)
-                               blkdev_dequeue_request(req);
-               }
+               if (!__blk_end_request_cur(req, err))
+                       req = blk_fetch_request(q);
        }
 }
 
index f48c6dd47e04d1910a3f74b85997e3e6089917a3..80df93e3cdd05f0d9c219b6d18bbf8b7a6de517d 100644 (file)
@@ -326,10 +326,9 @@ static void start_request(struct floppy_state *fs)
        }
        while (fs->state == idle) {
                if (!fd_req) {
-                       fd_req = elv_next_request(swim3_queue);
+                       fd_req = blk_fetch_request(swim3_queue);
                        if (!fd_req)
                                break;
-                       blkdev_dequeue_request(fd_req);
                }
                req = fd_req;
 #if 0
index 087c94c8b2dab8559020466c548cb85edae6a46e..da403b6a7f434525a694fb139d58950d65769586 100644 (file)
@@ -810,12 +810,10 @@ static void carm_oob_rq_fn(struct request_queue *q)
 
        while (1) {
                DPRINTK("get req\n");
-               rq = elv_next_request(q);
+               rq = blk_fetch_request(q);
                if (!rq)
                        break;
 
-               blkdev_dequeue_request(rq);
-
                crq = rq->special;
                assert(crq != NULL);
                assert(crq->rq == rq);
@@ -846,7 +844,7 @@ static void carm_rq_fn(struct request_queue *q)
 
 queue_one_request:
        VPRINTK("get req\n");
-       rq = elv_next_request(q);
+       rq = blk_peek_request(q);
        if (!rq)
                return;
 
@@ -857,7 +855,7 @@ queue_one_request:
        }
        crq->rq = rq;
 
-       blkdev_dequeue_request(rq);
+       blk_start_request(rq);
 
        if (rq_data_dir(rq) == WRITE) {
                writing = 1;
index 40d03cf63f2ecd5300ad56a20808d515e0ee951e..178f459a50ed8cbf40811f342ea7f63b51e9e20f 100644 (file)
@@ -627,7 +627,7 @@ static void ub_request_fn(struct request_queue *q)
        struct ub_lun *lun = q->queuedata;
        struct request *rq;
 
-       while ((rq = elv_next_request(q)) != NULL) {
+       while ((rq = blk_peek_request(q)) != NULL) {
                if (ub_request_fn_1(lun, rq) != 0) {
                        blk_stop_queue(q);
                        break;
@@ -643,13 +643,13 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
        int n_elem;
 
        if (atomic_read(&sc->poison)) {
-               blkdev_dequeue_request(rq);
+               blk_start_request(rq);
                ub_end_rq(rq, DID_NO_CONNECT << 16, blk_rq_bytes(rq));
                return 0;
        }
 
        if (lun->changed && !blk_pc_request(rq)) {
-               blkdev_dequeue_request(rq);
+               blk_start_request(rq);
                ub_end_rq(rq, SAM_STAT_CHECK_CONDITION, blk_rq_bytes(rq));
                return 0;
        }
@@ -660,7 +660,7 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
                return -1;
        memset(cmd, 0, sizeof(struct ub_scsi_cmd));
 
-       blkdev_dequeue_request(rq);
+       blk_start_request(rq);
 
        urq = &lun->urq;
        memset(urq, 0, sizeof(struct ub_request));
index 2086cb12d3ec76957333728edb9447ae16ad0ce6..390d69bb7c482ad1a79a09a42192575b692b4980 100644 (file)
@@ -361,11 +361,9 @@ static void do_viodasd_request(struct request_queue *q)
         * back later.
         */
        while (num_req_outstanding < VIOMAXREQ) {
-               req = elv_next_request(q);
+               req = blk_fetch_request(q);
                if (req == NULL)
                        return;
-               /* dequeue the current request from the queue */
-               blkdev_dequeue_request(req);
                /* check that request contains a valid command */
                if (!blk_fs_request(req)) {
                        viodasd_end_request(req, -EIO, blk_rq_sectors(req));
index 1980ab45635691832a6e1f9563ec7569db0ca5cc..29a9daf48621f23711b0d01b954580aa482c823d 100644 (file)
@@ -128,7 +128,7 @@ static void do_virtblk_request(struct request_queue *q)
        struct request *req;
        unsigned int issued = 0;
 
-       while ((req = elv_next_request(q)) != NULL) {
+       while ((req = blk_peek_request(q)) != NULL) {
                vblk = req->rq_disk->private_data;
                BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems);
 
@@ -138,7 +138,7 @@ static void do_virtblk_request(struct request_queue *q)
                        blk_stop_queue(q);
                        break;
                }
-               blkdev_dequeue_request(req);
+               blk_start_request(req);
                issued++;
        }
 
index d4c4352354b559076002509e26422c1d63e6f973..ce2429219925597edddb597ed88c09ff37c48b75 100644 (file)
@@ -305,10 +305,7 @@ static void do_xd_request (struct request_queue * q)
        if (xdc_busy)
                return;
 
-       req = elv_next_request(q);
-       if (req)
-               blkdev_dequeue_request(req);
-
+       req = blk_fetch_request(q);
        while (req) {
                unsigned block = blk_rq_pos(req);
                unsigned count = blk_rq_cur_sectors(req);
@@ -325,11 +322,8 @@ static void do_xd_request (struct request_queue * q)
                                           block, count);
        done:
                /* wrap up, 0 = success, -errno = fail */
-               if (!__blk_end_request_cur(req, res)) {
-                       req = elv_next_request(q);
-                       if (req)
-                               blkdev_dequeue_request(req);
-               }
+               if (!__blk_end_request_cur(req, res))
+                       req = blk_fetch_request(q);
        }
 }
 
index 66f834571b88c3a59ef4a37e7172715e19153860..6d4ac76c2806a02cc8fc8ce844b4b2ffd62df0ae 100644 (file)
@@ -299,13 +299,13 @@ static void do_blkif_request(struct request_queue *rq)
 
        queued = 0;
 
-       while ((req = elv_next_request(rq)) != NULL) {
+       while ((req = blk_peek_request(rq)) != NULL) {
                info = req->rq_disk->private_data;
 
                if (RING_FULL(&info->ring))
                        goto wait;
 
-               blkdev_dequeue_request(req);
+               blk_start_request(req);
 
                if (!blk_fs_request(req)) {
                        __blk_end_request_all(req, -EIO);
index edf137b6c37947040cb3137d0943efc127f2c68e..3a4397edab71a25b2de8216a17ce9cbc7232add8 100644 (file)
@@ -463,10 +463,10 @@ struct request *ace_get_next_request(struct request_queue * q)
 {
        struct request *req;
 
-       while ((req = elv_next_request(q)) != NULL) {
+       while ((req = blk_peek_request(q)) != NULL) {
                if (blk_fs_request(req))
                        break;
-               blkdev_dequeue_request(req);
+               blk_start_request(req);
                __blk_end_request_all(req, -EIO);
        }
        return req;
@@ -498,10 +498,8 @@ static void ace_fsm_dostate(struct ace_device *ace)
                        __blk_end_request_all(ace->req, -EIO);
                        ace->req = NULL;
                }
-               while ((req = elv_next_request(ace->queue)) != NULL) {
-                       blkdev_dequeue_request(req);
+               while ((req = blk_fetch_request(ace->queue)) != NULL)
                        __blk_end_request_all(req, -EIO);
-               }
 
                /* Drop back to IDLE state and notify waiters */
                ace->fsm_state = ACE_FSM_STATE_IDLE;
@@ -649,7 +647,7 @@ static void ace_fsm_dostate(struct ace_device *ace)
                        ace->fsm_state = ACE_FSM_STATE_IDLE;
                        break;
                }
-               blkdev_dequeue_request(req);
+               blk_start_request(req);
 
                /* Okay, it's a data request, set it up for transfer */
                dev_dbg(ace->dev,
index c909c1a3f6507cf0817ef6f63a44d972bc8b3e2a..4575171e5beb1bd754e0fe0ba11600b0fce4ea3f 100644 (file)
@@ -71,10 +71,7 @@ static void do_z2_request(struct request_queue *q)
 {
        struct request *req;
 
-       req = elv_next_request(q);
-       if (req)
-               blkdev_dequeue_request(req);
-
+       req = blk_fetch_request(q);
        while (req) {
                unsigned long start = blk_rq_pos(req) << 9;
                unsigned long len  = blk_rq_cur_bytes(req);
@@ -100,11 +97,8 @@ static void do_z2_request(struct request_queue *q)
                        len -= size;
                }
        done:
-               if (!__blk_end_request_cur(req, err)) {
-                       req = elv_next_request(q);
-                       if (req)
-                               blkdev_dequeue_request(req);
-               }
+               if (!__blk_end_request_cur(req, err))
+                       req = blk_fetch_request(q);
        }
 }
 
index 3cc02bfe828dde005c28f2cb44ea135d694913da..1e366ad8f68069b8c15fc2d0c66fee2d09074bf7 100644 (file)
@@ -642,9 +642,7 @@ static void gdrom_request(struct request_queue *rq)
 {
        struct request *req;
 
-       while ((req = elv_next_request(rq)) != NULL) {
-               blkdev_dequeue_request(req);
-
+       while ((req = blk_fetch_request(rq)) != NULL) {
                if (!blk_fs_request(req)) {
                        printk(KERN_DEBUG "GDROM: Non-fs request ignored\n");
                        __blk_end_request_all(req, -EIO);
index bbe9f08673475b4c3ac1733ae7f268f68216994f..ca741c21e4aaa4fa93af33e6ae8e4ef6af4b038c 100644 (file)
@@ -297,9 +297,7 @@ static void do_viocd_request(struct request_queue *q)
 {
        struct request *req;
 
-       while ((rwreq == 0) && ((req = elv_next_request(q)) != NULL)) {
-               blkdev_dequeue_request(req);
-
+       while ((rwreq == 0) && ((req = blk_fetch_request(q)) != NULL)) {
                if (!blk_fs_request(req))
                        __blk_end_request_all(req, -EIO);
                else if (send_request(req) < 0) {
index 2874c3d703a920b127fc9edf9abda3437268d716..8a894fa37b530d2841e77f6db60c7104a660d7e8 100644 (file)
@@ -269,7 +269,7 @@ void ide_retry_pc(ide_drive_t *drive)
        blk_requeue_request(failed_rq->q, failed_rq);
        drive->hwif->rq = NULL;
        if (ide_queue_sense_rq(drive, pc)) {
-               blkdev_dequeue_request(failed_rq);
+               blk_start_request(failed_rq);
                ide_complete_rq(drive, -EIO, blk_rq_bytes(failed_rq));
        }
 }
index abda7337b3f49fab704c58a8b1f8183e41fc681f..e4e3a0e3201e5516700b60184bfc7ebe03d308bd 100644 (file)
@@ -519,11 +519,8 @@ repeat:
                 * we know that the queue isn't empty, but this can happen
                 * if the q->prep_rq_fn() decides to kill a request
                 */
-               if (!rq) {
-                       rq = elv_next_request(drive->queue);
-                       if (rq)
-                               blkdev_dequeue_request(rq);
-               }
+               if (!rq)
+                       rq = blk_fetch_request(drive->queue);
 
                spin_unlock_irq(q->queue_lock);
                spin_lock_irq(&hwif->lock);
@@ -536,7 +533,7 @@ repeat:
                /*
                 * Sanity: don't accept a request that isn't a PM request
                 * if we are currently power managed. This is very important as
-                * blk_stop_queue() doesn't prevent the elv_next_request()
+                * blk_stop_queue() doesn't prevent the blk_fetch_request()
                 * above to return us whatever is in the queue. Since we call
                 * ide_do_request() ourselves, we end up taking requests while
                 * the queue is blocked...
index 58f5be8cd69e0e419a4b19cd7f918889612d5871..c0bebc6a2f2ccbb1cab1298f0fdfd396316928b0 100644 (file)
@@ -704,13 +704,12 @@ try_again:
                return 0;
        }
 
-       dev_dbg(&card->dev, "elv_next\n");
-       msb->block_req = elv_next_request(msb->queue);
+       dev_dbg(&card->dev, "blk_fetch\n");
+       msb->block_req = blk_fetch_request(msb->queue);
        if (!msb->block_req) {
                dev_dbg(&card->dev, "issue end\n");
                return -EAGAIN;
        }
-       blkdev_dequeue_request(msb->block_req);
 
        dev_dbg(&card->dev, "trying again\n");
        chunk = 1;
@@ -825,10 +824,8 @@ static void mspro_block_submit_req(struct request_queue *q)
                return;
 
        if (msb->eject) {
-               while ((req = elv_next_request(q)) != NULL) {
-                       blkdev_dequeue_request(req);
+               while ((req = blk_fetch_request(q)) != NULL)
                        __blk_end_request_all(req, -ENODEV);
-               }
 
                return;
        }
index 8b5cbfc3ba97da40082d40b2f6ad824de542feb3..6573ef4408f1dc66141acbc4c6038fd84b08acbd 100644 (file)
@@ -877,7 +877,7 @@ static void i2o_block_request_fn(struct request_queue *q)
        struct request *req;
 
        while (!blk_queue_plugged(q)) {
-               req = elv_next_request(q);
+               req = blk_peek_request(q);
                if (!req)
                        break;
 
@@ -890,7 +890,7 @@ static void i2o_block_request_fn(struct request_queue *q)
 
                        if (queue_depth < I2O_BLOCK_MAX_OPEN_REQUESTS) {
                                if (!i2o_block_transfer(req)) {
-                                       blkdev_dequeue_request(req);
+                                       blk_start_request(req);
                                        continue;
                                } else
                                        osm_info("transfer error\n");
@@ -917,7 +917,7 @@ static void i2o_block_request_fn(struct request_queue *q)
                                break;
                        }
                } else {
-                       blkdev_dequeue_request(req);
+                       blk_start_request(req);
                        __blk_end_request_all(req, -EIO);
                }
        }
index 4b70f1e28347cb96911ea4113d6d21f1bf684bbe..49e582356c65ab34bc17b1db1bbae002bc5faaff 100644 (file)
@@ -54,11 +54,8 @@ static int mmc_queue_thread(void *d)
 
                spin_lock_irq(q->queue_lock);
                set_current_state(TASK_INTERRUPTIBLE);
-               if (!blk_queue_plugged(q)) {
-                       req = elv_next_request(q);
-                       if (req)
-                               blkdev_dequeue_request(req);
-               }
+               if (!blk_queue_plugged(q))
+                       req = blk_fetch_request(q);
                mq->req = req;
                spin_unlock_irq(q->queue_lock);
 
@@ -94,10 +91,8 @@ static void mmc_request(struct request_queue *q)
 
        if (!mq) {
                printk(KERN_ERR "MMC: killing requests for dead queue\n");
-               while ((req = elv_next_request(q)) != NULL) {
-                       blkdev_dequeue_request(req);
+               while ((req = blk_fetch_request(q)) != NULL)
                        __blk_end_request_all(req, -EIO);
-               }
                return;
        }
 
index 3e10442615d17274a8fcacc12a190dc68ca5b9fd..502622f628bc0dfb8e988a86833bc10dc5710c58 100644 (file)
@@ -100,12 +100,7 @@ static int mtd_blktrans_thread(void *arg)
                struct mtd_blktrans_dev *dev;
                int res;
 
-               if (!req) {
-                       req = elv_next_request(rq);
-                       if (req)
-                               blkdev_dequeue_request(req);
-               }
-               if (!req) {
+               if (!req && !(req = blk_fetch_request(rq))) {
                        set_current_state(TASK_INTERRUPTIBLE);
                        spin_unlock_irq(rq->queue_lock);
                        schedule();
index 7df03c7aea0d3b5929775ac5c787dfd81742ee99..e64f62d5e0fc503f2fe7533c741778be1a5092d1 100644 (file)
@@ -1656,17 +1656,13 @@ static void __dasd_process_request_queue(struct dasd_block *block)
        if (basedev->state < DASD_STATE_READY)
                return;
        /* Now we try to fetch requests from the request queue */
-       while (!blk_queue_plugged(queue) &&
-              elv_next_request(queue)) {
-
-               req = elv_next_request(queue);
-
+       while (!blk_queue_plugged(queue) && (req = blk_peek_request(queue))) {
                if (basedev->features & DASD_FEATURE_READONLY &&
                    rq_data_dir(req) == WRITE) {
                        DBF_DEV_EVENT(DBF_ERR, basedev,
                                      "Rejecting write request %p",
                                      req);
-                       blkdev_dequeue_request(req);
+                       blk_start_request(req);
                        __blk_end_request_all(req, -EIO);
                        continue;
                }
@@ -1695,7 +1691,7 @@ static void __dasd_process_request_queue(struct dasd_block *block)
                                      "CCW creation failed (rc=%ld) "
                                      "on request %p",
                                      PTR_ERR(cqr), req);
-                       blkdev_dequeue_request(req);
+                       blk_start_request(req);
                        __blk_end_request_all(req, -EIO);
                        continue;
                }
@@ -1705,7 +1701,7 @@ static void __dasd_process_request_queue(struct dasd_block *block)
                 */
                cqr->callback_data = (void *) req;
                cqr->status = DASD_CQR_FILLED;
-               blkdev_dequeue_request(req);
+               blk_start_request(req);
                list_add_tail(&cqr->blocklist, &block->ccw_queue);
                dasd_profile_start(block, cqr, req);
        }
@@ -2029,10 +2025,8 @@ static void dasd_flush_request_queue(struct dasd_block *block)
                return;
 
        spin_lock_irq(&block->request_queue_lock);
-       while ((req = elv_next_request(block->request_queue))) {
-               blkdev_dequeue_request(req);
+       while ((req = blk_fetch_request(block->request_queue)))
                __blk_end_request_all(req, -EIO);
-       }
        spin_unlock_irq(&block->request_queue_lock);
 }
 
index 5d035e4939dc0df81f4c3a7ce0dc8d8ae6d3b54d..1e796767598056616ed6b3265ed27855fd77d40a 100644 (file)
@@ -93,7 +93,7 @@ __tapeblock_end_request(struct tape_request *ccw_req, void *data)
                device->blk_data.block_position = -1;
        device->discipline->free_bread(ccw_req);
        if (!list_empty(&device->req_queue) ||
-           elv_next_request(device->blk_data.request_queue))
+           blk_peek_request(device->blk_data.request_queue))
                tapeblock_trigger_requeue(device);
 }
 
@@ -162,19 +162,16 @@ tapeblock_requeue(struct work_struct *work) {
        spin_lock_irq(&device->blk_data.request_queue_lock);
        while (
                !blk_queue_plugged(queue) &&
-               elv_next_request(queue)   &&
+               (req = blk_fetch_request(queue)) &&
                nr_queued < TAPEBLOCK_MIN_REQUEUE
        ) {
-               req = elv_next_request(queue);
                if (rq_data_dir(req) == WRITE) {
                        DBF_EVENT(1, "TBLOCK: Rejecting write request\n");
-                       blkdev_dequeue_request(req);
                        spin_unlock_irq(&device->blk_data.request_queue_lock);
                        blk_end_request_all(req, -EIO);
                        spin_lock_irq(&device->blk_data.request_queue_lock);
                        continue;
                }
-               blkdev_dequeue_request(req);
                nr_queued++;
                spin_unlock_irq(&device->blk_data.request_queue_lock);
                rc = tapeblock_start_request(device, req);
index f572a4a1d1419ed650176dde8df5768885c0f0a7..6d46516846884515bd56b35a9f0d28b342df1b03 100644 (file)
@@ -186,10 +186,7 @@ static void jsfd_do_request(struct request_queue *q)
 {
        struct request *req;
 
-       req = elv_next_request(q);
-       if (req)
-               blkdev_dequeue_request(req);
-
+       req = blk_fetch_request(q);
        while (req) {
                struct jsfd_part *jdp = req->rq_disk->private_data;
                unsigned long offset = blk_rq_pos(req) << 9;
@@ -212,11 +209,8 @@ static void jsfd_do_request(struct request_queue *q)
                jsfd_read(req->buffer, jdp->dbase + offset, len);
                err = 0;
        end:
-               if (!__blk_end_request_cur(req, err)) {
-                       req = elv_next_request(q);
-                       if (req)
-                               blkdev_dequeue_request(req);
-               }
+               if (!__blk_end_request_cur(req, err))
+                       req = blk_fetch_request(q);
        }
 }
 
index ee308f6f7982c98c11652b10a70ac440b7497219..b12750f82169f37ad3ed6968752dbb0e91e87839 100644 (file)
@@ -1207,7 +1207,7 @@ int scsi_prep_return(struct request_queue *q, struct request *req, int ret)
                break;
        case BLKPREP_DEFER:
                /*
-                * If we defer, the elv_next_request() returns NULL, but the
+                * If we defer, the blk_peek_request() returns NULL, but the
                 * queue must be restarted, so we plug here if no returning
                 * command will automatically do that.
                 */
@@ -1385,7 +1385,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
        struct scsi_target *starget = scsi_target(sdev);
        struct Scsi_Host *shost = sdev->host;
 
-       blkdev_dequeue_request(req);
+       blk_start_request(req);
 
        if (unlikely(cmd == NULL)) {
                printk(KERN_CRIT "impossible request in %s.\n",
@@ -1477,7 +1477,7 @@ static void scsi_request_fn(struct request_queue *q)
 
        if (!sdev) {
                printk("scsi: killing requests for dead queue\n");
-               while ((req = elv_next_request(q)) != NULL)
+               while ((req = blk_peek_request(q)) != NULL)
                        scsi_kill_request(req, q);
                return;
        }
@@ -1498,7 +1498,7 @@ static void scsi_request_fn(struct request_queue *q)
                 * that the request is fully prepared even if we cannot 
                 * accept it.
                 */
-               req = elv_next_request(q);
+               req = blk_peek_request(q);
                if (!req || !scsi_dev_queue_ready(q, sdev))
                        break;
 
@@ -1514,7 +1514,7 @@ static void scsi_request_fn(struct request_queue *q)
                 * Remove the request from the request list.
                 */
                if (!(blk_queue_tagged(q) && !blk_queue_start_tag(q, req)))
-                       blkdev_dequeue_request(req);
+                       blk_start_request(req);
                sdev->device_busy++;
 
                spin_unlock(q->queue_lock);
index 50988cbf7b2df90a1cc23d07e423c920b428e2ba..d606452297cf3fdc82747b279067fb67613f8779 100644 (file)
@@ -163,12 +163,10 @@ static void sas_smp_request(struct request_queue *q, struct Scsi_Host *shost,
        int (*handler)(struct Scsi_Host *, struct sas_rphy *, struct request *);
 
        while (!blk_queue_plugged(q)) {
-               req = elv_next_request(q);
+               req = blk_fetch_request(q);
                if (!req)
                        break;
 
-               blkdev_dequeue_request(req);
-
                spin_unlock_irq(q->queue_lock);
 
                handler = to_sas_internal(shost->transportt)->f->smp_handler;
index c75580345700f46faa8ec61fe084836765c82b5f..6e59d3b92ff2a3127db23f429207ae0710a5cc01 100644 (file)
@@ -818,8 +818,6 @@ static inline void blk_run_address_space(struct address_space *mapping)
                blk_run_backing_dev(mapping->backing_dev_info, NULL);
 }
 
-extern void blkdev_dequeue_request(struct request *req);
-
 /*
  * blk_rq_pos()                : the current sector
  * blk_rq_bytes()      : bytes left in the entire request
@@ -852,6 +850,13 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq)
        return blk_rq_cur_bytes(rq) >> 9;
 }
 
+/*
+ * Request issue related functions.
+ */
+extern struct request *blk_peek_request(struct request_queue *q);
+extern void blk_start_request(struct request *rq);
+extern struct request *blk_fetch_request(struct request_queue *q);
+
 /*
  * Request completion related functions.
  *
index 4e462878c9ca31f965a660ec249412dc2afb63e9..1cb3372e65d89521886a8deb0f08f46c31dfe813 100644 (file)
@@ -103,10 +103,8 @@ extern int elv_merge(struct request_queue *, struct request **, struct bio *);
 extern void elv_merge_requests(struct request_queue *, struct request *,
                               struct request *);
 extern void elv_merged_request(struct request_queue *, struct request *, int);
-extern void elv_dequeue_request(struct request_queue *, struct request *);
 extern void elv_requeue_request(struct request_queue *, struct request *);
 extern int elv_queue_empty(struct request_queue *);
-extern struct request *elv_next_request(struct request_queue *q);
 extern struct request *elv_former_request(struct request_queue *, struct request *);
 extern struct request *elv_latter_request(struct request_queue *, struct request *);
 extern int elv_register_queue(struct request_queue *q);