mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
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 <[email protected]> Cc: Rusty Russell <[email protected]> Cc: James Bottomley <[email protected]> Cc: Mike Miller <[email protected]> Cc: unsik Kim <[email protected]> Cc: Paul Clements <[email protected]> Cc: Tim Waugh <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: David S. Miller <[email protected]> Cc: Laurent Vivier <[email protected]> Cc: Jeff Garzik <[email protected]> Cc: Jeremy Fitzhardinge <[email protected]> Cc: Grant Likely <[email protected]> Cc: Adrian McMenamin <[email protected]> Cc: Stephen Rothwell <[email protected]> Cc: Bartlomiej Zolnierkiewicz <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Sergei Shtylyov <[email protected]> Cc: Alex Dubov <[email protected]> Cc: Pierre Ossman <[email protected]> Cc: David Woodhouse <[email protected]> Cc: Markus Lidel <[email protected]> Cc: Stefan Weinhuber <[email protected]> Cc: Martin Schwidefsky <[email protected]> Cc: Pete Zaitcev <[email protected]> Cc: FUJITA Tomonori <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
parent
2343046826
commit
9934c8c045
45 changed files with 172 additions and 207 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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++;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue