block: unify request processing model and implement peek/fetch
Subsystems (20)
PATCH 1/1 block: unify request processing model and implement peek/fetch
Hello,
Upon ack, please pull from the following git tree.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git block-peek-fetch
Block layer has allowed two different models of request processing. elv_next_request() is used to peek at the top of the queue, after peeking, a LLD could start processing it immediately or dequeue and then start processing.
The non-dequeuing behavior is mostly useful for simpler device drivers (usually PIO based) which process requests on segment basis. By using the block layer queue tip as the current request pointer, they don't have to care about request boundaries and just process things segment-by-segment.
However, this dual mode of operations complicates and ambiguates block layer API. Block layer can't tell whether a request has begun processing or not in deterministic manner. This makes accounting inaccurate and implementing high level features in block layer difficult. For example, it isn't clear when a block layer timeout timer should be started or how queue queiscing for EH should be implemented. Even when problems can be worked aroudn, it makes the implementation fragile.
Although allowing llds ignore request boundaries makes things simpler for certain drivers, the number of drivers benefit form it aren't too many and driver stacks which are even mildly complex have to deal with request boundaries anyway. Also, the benefit itself isn't that significant. In most cases, it is just another way of doing things rather than the definitively better way. IOW, if there were no such alternative, nobody would have missed it.
This patchset converts all block layer llds to dequeuing model and then clean up API to simplify a bit and enforce dequeueing model. This patchset contains the following patches.
0001-ide-dequeue-in-flight-request.patch 0002-mg_disk-fix-queue-hang-infinite-retry-on-fs-requ.patch 0003-mg_disk-dequeue-and-track-in-flight-request.patch 0004-hd-dequeue-and-track-in-flight-request.patch 0005-ataflop-dequeue-and-track-in-flight-request.patch 0006-swim3-dequeue-in-flight-request.patch 0007-xsysace-dequeue-in-flight-request.patch 0008-paride-dequeue-in-flight-request.patch 0009-ps3disk-dequeue-in-flight-request.patch 0010-amiflop-dequeue-in-flight-request.patch 0011-swim-dequeue-in-flight-request.patch 0012-xd-dequeue-in-flight-request.patch 0013-mtd_blkdevs-dequeue-in-flight-request.patch 0014-jsflash-dequeue-in-flight-request.patch 0015-z2ram-dequeue-in-flight-request.patch 0016-gdrom-dequeue-in-flight-request.patch 0017-block-convert-to-dequeueing-model-easy-ones.patch 0018-block-implement-and-enforce-request-peek-start-fetc.patch
0001 converts ide to dequeueing model.
0002 fixes a bug in mg_disk spotted during conversion.
0003-0005 make llds which used elv_next_request() to track in-flight request to dequeue and track it themselves.
0006-0008 convert llds which already track in-flight request to dequeueing model.
0009 converts ps3disk.
0010-0015 convert llds which process requests one-by-one sequentially to dequeueing model.
0016 converts gdrom which already used dequeueing model in normal path.
0017 converts plat-omap/mailbox, floppy, viocd, mspro_block, i2o_block and mmc/card/queue which are already pretty close to dequeueing model.
0018 changes block layer issue API such that there are three functions
- blk_peek_request(), blk_start_request() and blk_fetch_request() where blk_fetch_request() is combination of the prevoius two. It also enforces dequeueing model. Trying to complete a queued request will trigger BUG.
Please note that conversions in 0001-0016 might not look optimal. They're done in such a way that 0018 can mechanically convert to blk_fetch_request() where applicable.
All changes have been compile tested. libata, ide, hd and ubd_kern are verified to work. Waiting for floppy media to test it.
This patchset is on top of
linux-2.6-block#for-2.6.31 (f68adec3c7155a8bbf32a90cb4c4d0737df045d9)
+ linux-2.6-ide#for-next (03682411b1ccd38cbde2e9a6ab43884ff34fbefc)
+ block-unify-sector-and-data-len (1df2a196e28cc8f97919dc530dc1c019e1d3a968)
and contains the following changes.
arch/arm/plat-omap/mailbox.c | 9 +- arch/um/drivers/ubd_kern.c | 3 block/blk-barrier.c | 4 - block/blk-core.c | 105 ++++++++++++++++++++++++-------- block/blk-tag.c | 2 block/blk.h | 1 drivers/block/DAC960.c | 4 - drivers/block/amiflop.c | 47 +++++++------- drivers/block/ataflop.c | 62 ++++++++++--------- drivers/block/cciss.c | 4 - drivers/block/cpqarray.c | 4 - drivers/block/floppy.c | 4 - drivers/block/hd.c | 62 ++++++++++++------- drivers/block/mg_disk.c | 115 +++++++++++++++++++----------------- drivers/block/nbd.c | 4 - drivers/block/paride/pcd.c | 17 +++-- drivers/block/paride/pd.c | 13 ++-- drivers/block/paride/pf.c | 13 +--- drivers/block/ps3disk.c | 8 +- drivers/block/sunvdc.c | 3 drivers/block/swim.c | 41 +++++------- drivers/block/swim3.c | 46 ++++++++++---- drivers/block/sx8.c | 8 -- drivers/block/ub.c | 8 +- drivers/block/viodasd.c | 4 - drivers/block/virtio_blk.c | 4 - drivers/block/xd.c | 23 +++---- drivers/block/xen-blkfront.c | 15 ++-- drivers/block/xsysace.c | 19 +++-- drivers/block/z2ram.c | 13 ++-- drivers/cdrom/gdrom.c | 28 +++----- drivers/cdrom/viocd.c | 2 drivers/ide/ide-atapi.c | 14 +++- drivers/ide/ide-cd.c | 8 -- drivers/ide/ide-io.c | 33 +++++++--- drivers/memstick/core/mspro_block.c | 9 +- drivers/message/i2o/i2o_block.c | 10 +-- drivers/mmc/card/queue.c | 11 --- drivers/mtd/mtd_blkdevs.c | 14 ++-- drivers/s390/block/dasd.c | 16 +---- drivers/s390/char/tape_block.c | 7 -- drivers/sbus/char/jsflash.c | 22 +++--- drivers/scsi/scsi_lib.c | 10 +-- drivers/scsi/scsi_transport_sas.c | 4 - include/linux/blkdev.h | 9 ++ include/linux/elevator.h | 2 46 files changed, 486 insertions(+), 378 deletions(-)
Thanks.
--
tejun
PATCH 1/18 ide: dequeue in-flight request
ide generally has single request in flight and tracks it using hwif->rq and all state handlers follow the following convention.
* ide_started is returned if the request is in flight.
* ide_stopped is returned if the queue needs to be restarted. The request might or might not have been processed fully or partially.
* hwif->rq is set to NULL, when an issued request completes.
So, dequeueing model can be implemented by dequeueing after fetch, requeueing if hwif->rq isn't NULL on ide_stopped return and doing about the same thing on completion / port unlock paths. These changes can be made in ide-io proper.
In addition to the above main changes, the following updates are necessary.
* ide-cd shouldn't dequeue a request when issuing REQUEST SENSE for it as the request is already dequeued.
* ide-atapi uses request queue as stack when issuing REQUEST SENSE to put the REQUEST SENSE in front of the failed request. This now needs to be done using requeueing.
[ Impact: dequeue in-flight request ]
--- drivers/ide/ide-atapi.c | 14 ++++++++++++-- drivers/ide/ide-cd.c | 8 -------- drivers/ide/ide-io.c | 34 +++++++++++++++++++++++++++------- 3 files changed, 39 insertions(+), 17 deletions(-)
drivers/ide/ide-atapi.c +12 -2
@@ -246,6 +246,7 @@ EXPORT_SYMBOL_GPL(ide_queue_sense_rq);*/ void ide_retry_pc (ide_drive_t *drive) { +struct request *failed_rq = drive->hwif->rq;struct request *sense_rq = &drive->sense_rq;struct ide_atapi_pc *pc = &drive->request_sense_pc;
@@ -260,8 +261,17 @@ void ide_retry_pc(ide_drive_t *drive)if (drive->media == ide_tape)set_bit (IDE_AFLAG_IGNORE_DSC , &drive->atapi_flags); -if (ide_queue_sense_rq (drive, pc)) -ide_complete_rq (drive, -EIO ,blk_rq_bytes (drive->hwif->rq)); +/* +* Push back the failed request and put request sense on top +* of it. The failed command will be retried after sense data +* is acquired. +*/ +blk_requeue_request (failed_rq->q, failed_rq); + drive->hwif->rq =NULL ; +if (ide_queue_sense_rq (drive, pc)) { +blkdev_dequeue_request (failed_rq); +ide_complete_rq (drive, -EIO ,blk_rq_bytes (failed_rq)); + } }EXPORT_SYMBOL_GPL (ide_retry_pc);
drivers/ide/ide-cd.c +0 -8
@@ -404,15 +404,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat) end_request:if (stat &ATA_ERR ) { -struct request_queue *q = drive->queue; -unsigned long flags; - -spin_lock_irqsave (q->queue_lock, flags); -blkdev_dequeue_request (rq); -spin_unlock_irqrestore (q->queue_lock, flags); - hwif->rq =NULL ; -return ide_queue_sense_rq (drive, rq) ?2 :1 ; }else return 2 ;
drivers/ide/ide-io.c +27 -7
@@ -487,10 +487,10 @@ void do_ide_request(struct request_queue *q)if (!ide_lock_port (hwif)) {ide_hwif_t *prev_port; + +WARN_ON_ONCE (hwif->rq); repeat: prev_port = hwif->host->cur_port; - hwif->rq =NULL ; -if (drive->dev_flags &IDE_DFLAG_SLEEPING &&time_after (drive->sleep, jiffies)) {ide_unlock_port (hwif);
@@ -519,7 +519,12 @@ repeat:* we know that the queue isn't empty, but this can happen * if the q->prep_rq_fn() decides to kill a request */ - rq =elv_next_request (drive->queue); +if (!rq) { + rq =elv_next_request (drive->queue); +if (rq) +blkdev_dequeue_request (rq); + } +spin_unlock_irq (q->queue_lock);spin_lock_irq (&hwif->lock);
@@ -555,8 +560,11 @@ repeat: startstop =start_request (drive, rq);spin_lock_irq (&hwif->lock); -if (startstop == ide_stopped) +if (startstop == ide_stopped) { + rq = hwif->rq; + hwif->rq =NULL ; goto repeat; + } }else goto plug_device; out:
@@ -572,18 +580,24 @@ plug_device: plug_device_2:spin_lock_irq (q->queue_lock); +if (rq) +blk_requeue_request (q, rq);if (!elv_queue_empty (q))blk_plug_device (q); } -static void ide_plug_device (ide_drive_t *drive) +static void ide_requeue_and_plug (ide_drive_t *drive,struct request *rq) {struct request_queue *q = drive->queue;unsigned long flags;spin_lock_irqsave (q->queue_lock, flags); + +if (rq) +blk_requeue_request (q, rq);if (!elv_queue_empty (q))blk_plug_device (q); +spin_unlock_irqrestore (q->queue_lock, flags); }
@@ -632,6 +646,7 @@ void ide_timer_expiry (unsigned long data)unsigned long flags;int wait =-1 ;int plug_device =0 ; +struct request *uninitialized_var (rq_in_flight );spin_lock_irqsave (&hwif->lock, flags);
@@ -693,6 +708,8 @@ void ide_timer_expiry (unsigned long data)spin_lock_irq (&hwif->lock);enable_irq (hwif->irq);if (startstop == ide_stopped) { + rq_in_flight = hwif->rq; + hwif->rq =NULL ;ide_unlock_port (hwif); plug_device =1 ; }
@@ -701,7 +718,7 @@ void ide_timer_expiry (unsigned long data)if (plug_device) {ide_unlock_host (hwif->host); -ide_plug_device (drive); +ide_requeue_and_plug (drive, rq_in_flight); } }
@@ -787,6 +804,7 @@ irqreturn_t ide_intr (int irq, void *dev_id)ide_startstop_t startstop;irqreturn_t irq_ret =IRQ_NONE ;int plug_device =0 ; +struct request *uninitialized_var (rq_in_flight );if (host->host_flags &IDE_HFLAG_SERIALIZE ) {if (hwif != host->cur_port)
@@ -866,6 +884,8 @@ irqreturn_t ide_intr (int irq, void *dev_id)*/ if (startstop == ide_stopped) {BUG_ON (hwif->handler); + rq_in_flight = hwif->rq; + hwif->rq =NULL ;ide_unlock_port (hwif); plug_device =1 ; }
@@ -875,7 +895,7 @@ out: out_early:if (plug_device) {ide_unlock_host (hwif->host); -ide_plug_device (drive); +ide_requeue_and_plug (drive, rq_in_flight); }return irq_ret;
Signature · 1 line
1.6.0.2
PATCH 2/18 mg_disk: fix queue hang / infinite retry on !fs requests
In reply to Tejun HeoBoth request functions in mg_disk simply return when they encounter a !fs request, which means the request will never be cleared from the queue causing queue hang and indefinite retry of the request. Fix it.
While at it, flatten condition checks and add unlikely to !fs tests.
[ Impact: fix possible queue hang / infinite retry of !fs requests ]
--- drivers/block/mg_disk.c | 24 +++++++++++++----------- 1 files changed, 13 insertions(+), 11 deletions(-)
drivers/block/mg_disk.c +13 -11
@@ -672,16 +672,16 @@ static void mg_request_poll(struct request_queue *q)while ((req =elv_next_request (q)) !=NULL ) { host = req->rq_disk->private_data; -if (blk_fs_request (req)) { -switch (rq_data_dir (req)) { -case READ : -mg_read (req); -break ; -case WRITE : -mg_write (req); -break ; - } + +if (unlikely (!blk_fs_request (req))) { +__blk_end_request_cur (req, -EIO ); +continue ; } + +if (rq_data_dir (req) ==READ ) +mg_read (req); +else +mg_write (req); } }
@@ -766,8 +766,10 @@ static void mg_request(struct request_queue *q)continue ; } -if (!blk_fs_request (req)) -return ; +if (unlikely (!blk_fs_request (req))) { +__blk_end_request_cur (req, -EIO ); +continue ; + }if (!mg_issue_req (req, host, sect_num, sect_cnt))return ;
Signature · 1 line
1.6.0.2
PATCH 3/18 mg_disk: dequeue and track in-flight request
In reply to Tejun Heomg_disk has at most single request in flight per device. Till now, whenever it needs to access the in-flight request it called elv_next_request(). This patch makes mg_disk track the in-flight request directly using mg_host->req and dequeue it when processing starts.
q->queuedata is set to mg_host so that mg_host can be determined without fetching request from the queue.
[ Impact: dequeue in-flight request, one elv_next_request() per request ]
--- drivers/block/mg_disk.c | 109 +++++++++++++++++++++++++--------------------- 1 files changed, 59 insertions(+), 50 deletions(-)
drivers/block/mg_disk.c +59 -50
@@ -135,6 +135,7 @@ struct mg_host {struct device *dev;struct request_queue *breq; +struct request *req;spinlock_t lock;struct gendisk *gd;
@@ -171,17 +172,27 @@ struct mg_host {static void mg_request (struct request_queue *); +static bool mg_end_request (struct mg_host *host,int err,unsigned int nr_bytes) +{ +if (__blk_end_request (host->req, err, nr_bytes)) +return true; + + host->req =NULL ; +return false; +} + +static bool mg_end_request_cur (struct mg_host *host,int err) +{ +return mg_end_request (host, err,blk_rq_cur_bytes (host->req)); +} +static void mg_dump_status (const char *msg,unsigned int stat,struct mg_host *host) {char *name =MG_DISK_NAME ; -struct request *req; -if (host->breq) { - req =elv_next_request (host->breq); -if (req) - name = req->rq_disk->disk_name; - } +if (host->req) + name = host->req->rq_disk->disk_name;printk (KERN_ERR "%s: %s: status=0x%02x { " , name, msg, stat &0xff );if (stat &ATA_BUSY )
@@ -217,13 +228,9 @@ static void mg_dump_status(const char *msg, unsigned int stat,printk ("AddrMarkNotFound " );printk ("}" );if (host->error & (ATA_BBK |ATA_UNC |ATA_IDNF |ATA_AMNF )) { -if (host->breq) { - req =elv_next_request (host->breq); -if (req) -printk (", sector=%u" , - (unsigned int )blk_rq_pos (req)); - } - +if (host->req) +printk (", sector=%u" , + (unsigned int )blk_rq_pos (host->req)); }printk ("\n" ); }
@@ -453,11 +460,10 @@ static int mg_disk_init(struct mg_host *host)static void mg_bad_rw_intr (struct mg_host *host) { -struct request *req =elv_next_request (host->breq); -if (req !=NULL ) -if (++req->errors >=MG_MAX_ERRORS || - host->error ==MG_ERR_TIMEOUT ) -__blk_end_request_cur (req, -EIO ); +if (host->req) +if (++host->req->errors >=MG_MAX_ERRORS || + host->error ==MG_ERR_TIMEOUT ) +mg_end_request_cur (host, -EIO ); } static unsigned int mg_out(struct mg_host *host,
@@ -515,7 +521,7 @@ static void mg_read(struct request *req)outb (MG_CMD_RD_CONF , (unsigned long )host->dev_base +MG_REG_COMMAND ); - }while (__blk_end_request (req,0 ,MG_SECTOR_SIZE )); + }while (mg_end_request (host,0 ,MG_SECTOR_SIZE )); }static void mg_write (struct request *req)
@@ -545,14 +551,14 @@ static void mg_write(struct request *req)outb (MG_CMD_WR_CONF , (unsigned long )host->dev_base +MG_REG_COMMAND ); - }while (__blk_end_request (req,0 ,MG_SECTOR_SIZE )); + }while (mg_end_request (host,0 ,MG_SECTOR_SIZE )); }static void mg_read_intr (struct mg_host *host) { +struct request *req = host->req;u32 i;u16 *buff; -struct request *req;/* check status */ do {
@@ -571,7 +577,6 @@ static void mg_read_intr(struct mg_host *host) ok_to_read:/* get current segment of request */ - req =elv_next_request (host->breq); buff = (u16 *)req->buffer;/* read 1 sector */
@@ -585,7 +590,7 @@ ok_to_read:/* send read confirm */ outb (MG_CMD_RD_CONF , (unsigned long )host->dev_base +MG_REG_COMMAND ); -if (__blk_end_request (req,0 ,MG_SECTOR_SIZE )) { +if (mg_end_request (host,0 ,MG_SECTOR_SIZE )) {/* set handler if read remains */ host->mg_do_intr = mg_read_intr;mod_timer (&host->timer, jiffies +3 *HZ );
@@ -595,14 +600,11 @@ ok_to_read:static void mg_write_intr (struct mg_host *host) { +struct request *req = host->req;u32 i, j;u16 *buff; -struct request *req;bool rem; -/* get current segment of request */ - req =elv_next_request (host->breq); -/* check status */ do { i = inb((unsigned long)host->dev_base + MG_REG_STATUS);
@@ -619,7 +621,7 @@ static void mg_write_intr(struct mg_host *host)return ; ok_to_write: -if ((rem =__blk_end_request (req,0 ,MG_SECTOR_SIZE ))) { +if ((rem =mg_end_request (host,0 ,MG_SECTOR_SIZE ))) {/* write 1 sector and set handler if remains */ buff = (u16 *)req->buffer;for (j =0 ; j <MG_STORAGE_BUFFER_SIZE >>1 ; j++) {
@@ -644,44 +646,47 @@ void mg_times_out(unsigned long data) {struct mg_host *host = (struct mg_host *)data;char *name; -struct request *req;spin_lock_irq (&host->lock); - req =elv_next_request (host->breq); -if (!req) +if (!host->req) goto out_unlock; host->mg_do_intr =NULL ; - name = req->rq_disk->disk_name; + name = host->req->rq_disk->disk_name;printk (KERN_DEBUG "%s: timeout\n" , name); host->error =MG_ERR_TIMEOUT ;mg_bad_rw_intr (host); -mg_request (host->breq); out_unlock: +mg_request (host->breq);spin_unlock_irq (&host->lock); }static void mg_request_poll (struct request_queue *q) { -struct request *req; -struct mg_host *host; +struct mg_host *host = q->queuedata; -while ((req =elv_next_request (q)) !=NULL ) { - host = req->rq_disk->private_data; +while (1 ) { +if (!host->req) { + host->req =elv_next_request (q); +if (host->req) +blkdev_dequeue_request (host->req); +else +break ; + } -if (unlikely (!blk_fs_request (req))) { -__blk_end_request_cur (req, -EIO ); +if (unlikely (!blk_fs_request (host->req))) { +mg_end_request_cur (host, -EIO );continue ; } -if (rq_data_dir (req) ==READ ) -mg_read (req); +if (rq_data_dir (host->req) ==READ ) +mg_read (host->req);else -mg_write (req); +mg_write (host->req); } }
@@ -733,16 +738,19 @@ static unsigned int mg_issue_req(struct request *req,/* This function also called from IRQ context */ static void mg_request (struct request_queue *q) { +struct mg_host *host = q->queuedata;struct request *req; -struct mg_host *host;u32 sect_num, sect_cnt;while (1 ) { - req =elv_next_request (q); -if (!req) -return ; - - host = req->rq_disk->private_data; +if (!host->req) { + host->req =elv_next_request (q); +if (host->req) +blkdev_dequeue_request (host->req); +else +break ; + } + req = host->req;/* check unwanted request call */ if (host->mg_do_intr)
@@ -762,12 +770,12 @@ static void mg_request(struct request_queue *q)"%s: bad access: sector=%d, count=%d\n" , req->rq_disk->disk_name, sect_num, sect_cnt); -__blk_end_request_cur (req, -EIO ); +mg_end_request_cur (host, -EIO );continue ; }if (unlikely (!blk_fs_request (req))) { -__blk_end_request_cur (req, -EIO ); +mg_end_request_cur (host, -EIO );continue ; }
@@ -981,6 +989,7 @@ static int mg_probe(struct platform_device *plat_dev) __func__, __LINE__); goto probe_err_5; } + host->breq->queuedata = host;/* mflash is random device, thanx for the noop */ elevator_exit (host->breq->elevator);
Signature · 1 line
1.6.0.2
PATCH 4/18 hd: dequeue and track in-flight request
In reply to Tejun Heohd has at most single request in flight. Till now, whenever it needs to access the in-flight request it called elv_next_request(). This patch makes hd track the in-flight request directly and dequeue it when processing starts. The added complexity is minimal and this will help future block layer changes.
[ Impact: dequeue in-flight request, one elv_next_request() per request ]
--- drivers/block/hd.c | 63 +++++++++++++++++++++++++++++++++------------------- 1 files changed, 40 insertions(+), 23 deletions(-)
drivers/block/hd.c +40 -23
@@ -98,10 +98,9 @@static DEFINE_SPINLOCK (hd_lock);static struct request_queue *hd_queue; +static struct request *hd_req;#define MAJOR_NR HD_MAJOR -#define QUEUE (hd_queue) -#define CURRENT elv_next_request(hd_queue)#define TIMEOUT_VALUE (6*HZ)#define HD_DELAY 0
@@ -195,11 +194,24 @@ static void __init hd_setup(char *str, int *ints)NR_HD = hdind+1 ; } +static bool hd_end_request (int err,unsigned int bytes) +{ +if (__blk_end_request (hd_req, err, bytes)) +return true; + hd_req =NULL ; +return false; +} + +static bool hd_end_request_cur (int err) +{ +return hd_end_request (err,blk_rq_cur_bytes (hd_req)); +} +static void dump_status (const char *msg,unsigned int stat) {char *name ="hd?" ; -if (CURRENT ) - name =CURRENT ->rq_disk->disk_name; +if (hd_req) + name = hd_req->rq_disk->disk_name;#ifdef VERBOSE_ERRORS printk ("%s: %s: status=0x%02x { " , name, msg, stat &0xff );
@@ -227,8 +239,8 @@ static void dump_status(const char *msg, unsigned int stat)if (hd_error & (BBD_ERR |ECC_ERR |ID_ERR |MARK_ERR )) {printk (", CHS=%d/%d/%d" , (inb (HD_HCYL )<<8 ) +inb (HD_LCYL ),inb (HD_CURRENT ) &0xf ,inb (HD_SECTOR )); -if (CURRENT ) -printk (", sector=%ld" ,blk_rq_pos (CURRENT )); +if (hd_req) +printk (", sector=%ld" ,blk_rq_pos (hd_req)); }printk ("\n" ); }
@@ -406,11 +418,12 @@ static void unexpected_hd_interrupt(void)*/ static void bad_rw_intr (void ) { -struct request *req =CURRENT ; +struct request *req = hd_req; +if (req !=NULL ) {struct hd_i_struct *disk = req->rq_disk->private_data;if (++req->errors >=MAX_ERRORS || (hd_error &BBD_ERR )) { -__blk_end_request_cur (req, -EIO ); +hd_end_request_cur (-EIO ); disk->special_op = disk->recalibrate =1 ; }else if (req->errors %RESET_FREQ ==0 ) reset =1 ;
@@ -454,14 +467,14 @@ static void read_intr(void)return ; ok_to_read: - req =CURRENT ; + req = hd_req;insw (HD_DATA , req->buffer,256 );#ifdef DEBUG printk ("%s: read: sector %ld, remaining = %u, buffer=%p\n" , req->rq_disk->disk_name,blk_rq_pos (req) +1 ,blk_rq_sectors (req) -1 , req->buffer+512 );#endif -if (__blk_end_request (req,0 ,512 )) { +if (hd_end_request (0 ,512 )) {SET_HANDLER (&read_intr);return ; }
@@ -475,7 +488,7 @@ ok_to_read:static void write_intr (void ) { -struct request *req =CURRENT ; +struct request *req = hd_req;int i;int retries =100000 ;
@@ -494,7 +507,7 @@ static void write_intr(void)return ; ok_to_write: -if (__blk_end_request (req,0 ,512 )) { +if (hd_end_request (0 ,512 )) {SET_HANDLER (&write_intr);outsw (HD_DATA , req->buffer,256 );return ;
@@ -525,18 +538,18 @@ static void hd_times_out(unsigned long dummy) do_hd =NULL ; -if (!CURRENT ) +if (!hd_req)return ;spin_lock_irq (hd_queue->queue_lock); reset =1 ; - name =CURRENT ->rq_disk->disk_name; + name = hd_req->rq_disk->disk_name;printk ("%s: timeout\n" , name); -if (++CURRENT ->errors >=MAX_ERRORS ) { +if (++hd_req->errors >=MAX_ERRORS ) {#ifdef DEBUG printk ("%s: too many errors\n" , name);#endif -__blk_end_request_cur (CURRENT , -EIO ); +hd_end_request_cur (-EIO ); }hd_request ();spin_unlock_irq (hd_queue->queue_lock);
@@ -551,7 +564,7 @@ static int do_special_op(struct hd_i_struct *disk, struct request *req) }if (disk->head >16 ) {printk ("%s: cannot handle device with more than 16 heads - giving up\n" , req->rq_disk->disk_name); -__blk_end_request_cur (req, -EIO ); +hd_end_request_cur (-EIO ); } disk->special_op =0 ;return 1 ;
@@ -578,11 +591,15 @@ static void hd_request(void) repeat:del_timer (&device_timer); - req =CURRENT ; -if (!req) { - do_hd =NULL ; -return ; +if (!hd_req) { + hd_req =elv_next_request (hd_queue); +if (!hd_req) { + do_hd =NULL ; +return ; + } +blkdev_dequeue_request (hd_req); } + req = hd_req;if (reset) {reset_hd ();
@@ -595,7 +612,7 @@ repeat: ((block+nsect) > get_capacity(req->rq_disk))) {printk ("%s: bad access: block=%d, count=%d\n" , req->rq_disk->disk_name, block, nsect); -__blk_end_request_cur (req, -EIO ); +hd_end_request_cur (-EIO ); goto repeat; }
@@ -635,7 +652,7 @@ repeat:break ;default :printk ("unknown hd-command\n" ); -__blk_end_request_cur (req, -EIO ); +hd_end_request_cur (-EIO );break ; } }
Signature · 1 line
1.6.0.2
PATCH 5/18 ataflop: dequeue and track in-flight request
In reply to Tejun Heoataflop has single request in flight. Till now, whenever it needs to access the in-flight request it called elv_next_request(). This patch makes ataflop track the in-flight request directly and dequeue it when processing starts. The added complexity is minimal and this will help future block layer changes.
[ Impact: dequeue in-flight request, one elv_next_request() per request ]
--- drivers/block/ataflop.c | 63 ++++++++++++++++++++++++++--------------------- 1 files changed, 35 insertions(+), 28 deletions(-)
drivers/block/ataflop.c +35 -28
@@ -79,9 +79,7 @@#undef DEBUGstatic struct request_queue *floppy_queue; - -#define QUEUE (floppy_queue) -#define CURRENT elv_next_request(floppy_queue) +static struct request *fd_request;/* Disk types: DD, HD, ED */ static struct atari_disk_type {
@@ -376,6 +374,12 @@ static DEFINE_TIMER(readtrack_timer, fd_readtrack_check, 0, 0); static DEFINE_TIMER(timeout_timer, fd_times_out, 0, 0); static DEFINE_TIMER(fd_timer, check_change, 0, 0); +static void fd_end_request_cur (int err) +{ +if (!__blk_end_request_cur (fd_request, err)) + fd_request =NULL ; +} +static inline void start_motor_off_timer (void ) {mod_timer (&motor_off_timer, jiffies +FD_MOTOR_OFF_DELAY );
@@ -606,15 +610,15 @@ static void fd_error( void )return ; } -if (!CURRENT ) +if (!fd_request)return ; -CURRENT ->errors++; -if (CURRENT ->errors >=MAX_ERRORS ) { + fd_request->errors++; +if (fd_request->errors >=MAX_ERRORS ) {printk (KERN_ERR "fd%d: too many errors.\n" , SelectedDrive ); -__blk_end_request_cur (CURRENT , -EIO ); +fd_end_request_cur (-EIO ); } -else if (CURRENT ->errors ==RECALIBRATE_ERRORS ) { +else if (fd_request->errors ==RECALIBRATE_ERRORS ) {printk (KERN_WARNING "fd%d: recalibrating\n" , SelectedDrive );if (SelectedDrive !=-1 )SUD .track =-1 ;
@@ -725,14 +729,14 @@ static void do_fd_action( int drive )if (IS_BUFFERED ( drive, ReqSide, ReqTrack )) {if (ReqCmd ==READ ) {copy_buffer (SECTOR_BUFFER (ReqSector), ReqData ); -if (++ReqCnt <blk_rq_cur_sectors (CURRENT )) { +if (++ReqCnt <blk_rq_cur_sectors (fd_request)) {/* read next sector */ setup_req_params ( drive ); goto repeat; }else {/* all sectors finished */ -__blk_end_request_cur (CURRENT ,0 ); +fd_end_request_cur (0 );redo_fd_request ();return ; }
@@ -1130,14 +1134,14 @@ static void fd_rwsec_done1(int status) } } -if (++ReqCnt <blk_rq_cur_sectors (CURRENT )) { +if (++ReqCnt <blk_rq_cur_sectors (fd_request)) {/* read next sector */ setup_req_params ( SelectedDrive );do_fd_action ( SelectedDrive ); }else {/* all sectors finished */ -__blk_end_request_cur (CURRENT ,0 ); +fd_end_request_cur (0 );redo_fd_request (); }return ;
@@ -1378,7 +1382,7 @@ static void setup_req_params( int drive ) ReqData = ReqBuffer +512 * ReqCnt;if (UseTrackbuffer) - read_track = (ReqCmd ==READ &&CURRENT ->errors ==0 ); + read_track = (ReqCmd ==READ && fd_request->errors ==0 );else read_track =0 ;
@@ -1392,25 +1396,28 @@ static void redo_fd_request(void)int drive, type;struct atari_floppy_struct *floppy; -DPRINT (("redo_fd_request: CURRENT=%p dev=%s CURRENT->sector=%ld\n" , -CURRENT ,CURRENT ?CURRENT ->rq_disk->disk_name :"" , -CURRENT ?blk_rq_pos (CURRENT ) :0 )); +DPRINT (("redo_fd_request: fd_request=%p dev=%s fd_request->sector=%ld\n" , + fd_request, fd_request ? fd_request->rq_disk->disk_name :"" , + fd_request ?blk_rq_pos (fd_request) :0 )); IsFormatting =0 ; repeat: +if (!fd_request) { + fd_request =elv_next_request (floppy_queue); +if (!fd_request) + goto the_end; +blkdev_dequeue_request (fd_request); + } -if (!CURRENT ) - goto the_end; - - floppy =CURRENT ->rq_disk->private_data; + floppy = fd_request->rq_disk->private_data; drive = floppy - unit; type = floppy->type;if (!UD .connected) {/* drive not connected */ printk (KERN_ERR "Unknown Device: fd%d\n" , drive ); -__blk_end_request_cur (CURRENT , -EIO ); +fd_end_request_cur (-EIO ); goto repeat; }
@@ -1426,12 +1433,12 @@ repeat:/* user supplied disk type */ if (--type >=NUM_DISK_MINORS ) {printk (KERN_WARNING "fd%d: invalid disk format" , drive ); -__blk_end_request_cur (CURRENT , -EIO ); +fd_end_request_cur (-EIO ); goto repeat; }if (minor2disktype[type].drive_types > DriveType) {printk (KERN_WARNING "fd%d: unsupported disk format" , drive ); -__blk_end_request_cur (CURRENT , -EIO ); +fd_end_request_cur (-EIO ); goto repeat; } type = minor2disktype[type].index;
@@ -1440,8 +1447,8 @@ repeat:UD .autoprobe =0 ; } -if (blk_rq_pos (CURRENT ) +1 >UDT ->blocks) { -__blk_end_request_cur (CURRENT , -EIO ); +if (blk_rq_pos (fd_request) +1 >UDT ->blocks) { +fd_end_request_cur (-EIO ); goto repeat; }
@@ -1449,9 +1456,9 @@ repeat:del_timer ( &motor_off_timer ); ReqCnt =0 ; - ReqCmd =rq_data_dir (CURRENT ); - ReqBlock =blk_rq_pos (CURRENT ); - ReqBuffer =CURRENT ->buffer; + ReqCmd =rq_data_dir (fd_request); + ReqBlock =blk_rq_pos (fd_request); + ReqBuffer = fd_request->buffer;setup_req_params ( drive );do_fd_action ( drive );
Signature · 1 line
1.6.0.2
PATCH 6/18 swim3: dequeue in-flight request
In reply to Tejun Heoswim3 has at most single request in flight and already tracks it using fd_req. Convert it to dequeuing model by updating request fetching and wrapping completion function.
[ Impact: dequeue in-flight request ]
--- drivers/block/swim3.c | 47 ++++++++++++++++++++++++++++++++++------------- 1 files changed, 34 insertions(+), 13 deletions(-)
drivers/block/swim3.c +34 -13
@@ -251,6 +251,20 @@ static int floppy_release(struct gendisk *disk, fmode_t mode);static int floppy_check_change (struct gendisk *disk);static int floppy_revalidate (struct gendisk *disk); +static bool swim3_end_request (int err,unsigned int nr_bytes) +{ +if (__blk_end_request (fd_req, err, nr_bytes)) +return true; + + fd_req =NULL ; +return false; +} + +static bool swim3_end_request_cur (int err) +{ +return swim3_end_request (err,blk_rq_cur_bytes (fd_req)); +} +static void swim3_select (struct floppy_state *fs,int sel) {struct swim3 __iomem *sw = fs->swim3;
@@ -310,7 +324,14 @@ static void start_request(struct floppy_state *fs)wake_up (&fs->wait);return ; } -while (fs->state == idle && (req =elv_next_request (swim3_queue))) { +while (fs->state == idle) { +if (!fd_req) { + fd_req =elv_next_request (swim3_queue); +if (!fd_req) +break ; +blkdev_dequeue_request (fd_req); + } + req = fd_req;#if 0 printk("do_fd_req: dev=%s cmd=%d sec=%ld nr_sec=%u buf=%p\n", req->rq_disk->disk_name, req->cmd,
@@ -320,11 +341,11 @@ static void start_request(struct floppy_state *fs)#endif if (blk_rq_pos (req) >= fs->total_secs) { -__blk_end_request_cur (req, -EIO ); +swim3_end_request_cur (-EIO );continue ; }if (fs->ejected) { -__blk_end_request_cur (req, -EIO ); +swim3_end_request_cur (-EIO );continue ; }
@@ -332,7 +353,7 @@ static void start_request(struct floppy_state *fs)if (fs->write_prot <0 ) fs->write_prot =swim3_readbit (fs,WRITE_PROT );if (fs->write_prot) { -__blk_end_request_cur (req, -EIO ); +swim3_end_request_cur (-EIO );continue ; } }
@@ -505,7 +526,7 @@ static void act(struct floppy_state *fs)case do_transfer:if (fs->cur_cyl != fs->req_cyl) {if (fs->retries >5 ) { -__blk_end_request_cur (fd_req, -EIO ); +swim3_end_request_cur (-EIO ); fs->state = idle;return ; }
@@ -537,7 +558,7 @@ static void scan_timeout(unsigned long data)out_8 (&sw->intr_enable,0 ); fs->cur_cyl =-1 ;if (fs->retries >5 ) { -__blk_end_request_cur (fd_req, -EIO ); +swim3_end_request_cur (-EIO ); fs->state = idle;start_request (fs); }else {
@@ -556,7 +577,7 @@ static void seek_timeout(unsigned long data)out_8 (&sw->select,RELAX );out_8 (&sw->intr_enable,0 );printk (KERN_ERR "swim3: seek timeout\n" ); -__blk_end_request_cur (fd_req, -EIO ); +swim3_end_request_cur (-EIO ); fs->state = idle;start_request (fs); }
@@ -580,7 +601,7 @@ static void settle_timeout(unsigned long data)return ; }printk (KERN_ERR "swim3: seek settle timeout\n" ); -__blk_end_request_cur (fd_req, -EIO ); +swim3_end_request_cur (-EIO ); fs->state = idle;start_request (fs); }
@@ -603,7 +624,7 @@ static void xfer_timeout(unsigned long data)printk (KERN_ERR "swim3: timeout %sing sector %ld\n" , (rq_data_dir (fd_req)==WRITE ?"writ" :"read" ), (long )blk_rq_pos (fd_req)); -__blk_end_request_cur (fd_req, -EIO ); +swim3_end_request_cur (-EIO ); fs->state = idle;start_request (fs); }
@@ -634,7 +655,7 @@ static irqreturn_t swim3_interrupt(int irq, void *dev_id)printk (KERN_ERR "swim3: seen sector but cyl=ff?\n" ); fs->cur_cyl =-1 ;if (fs->retries >5 ) { -__blk_end_request_cur (fd_req, -EIO ); +swim3_end_request_cur (-EIO ); fs->state = idle;start_request (fs); }else {
@@ -717,7 +738,7 @@ static irqreturn_t swim3_interrupt(int irq, void *dev_id)printk ("swim3: error %sing block %ld (err=%x)\n" ,rq_data_dir (fd_req) ==WRITE ?"writ" :"read" , (long )blk_rq_pos (fd_req), err); -__blk_end_request_cur (fd_req, -EIO ); +swim3_end_request_cur (-EIO ); fs->state = idle; } }else {
@@ -726,12 +747,12 @@ static irqreturn_t swim3_interrupt(int irq, void *dev_id)printk (KERN_ERR "swim3: fd dma: stat=%x resid=%d\n" , stat, resid);printk (KERN_ERR " state=%d, dir=%x, intr=%x, err=%x\n" , fs->state,rq_data_dir (fd_req), intr, err); -__blk_end_request_cur (fd_req, -EIO ); +swim3_end_request_cur (-EIO ); fs->state = idle;start_request (fs);break ; } -if (__blk_end_request (fd_req,0 , fs->scount <<9 )) { +if (swim3_end_request (0 , fs->scount <<9 )) { fs->req_sector += fs->scount;if (fs->req_sector > fs->secpertrack) { fs->req_sector -= fs->secpertrack;
Signature · 1 line
1.6.0.2
PATCH 7/18 xsysace: dequeue in-flight request
In reply to Tejun Heoxsysace already tracks in-flight request using ace->req. Converting to dequeueing model is mostly a matter of adding dequeueing call after request fetching. The only tricky part is handling CF removal which should complete both in flight and on queue requests. Convert to dequeueing model.
While at it, remove explicit blk_rq_cur_bytes() and use __blk_end_request_cur() instead.
[ Impact: dequeue in-flight request ]
--- drivers/block/xsysace.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-)
drivers/block/xsysace.c +13 -6
@@ -466,7 +466,8 @@ struct request *ace_get_next_request(struct request_queue * q)while ((req =elv_next_request (q)) !=NULL ) {if (blk_fs_request (req))break ; -__blk_end_request_cur (req, -EIO ); +blkdev_dequeue_request (req); +__blk_end_request_all (req, -EIO ); }return req; }
@@ -492,9 +493,15 @@ static void ace_fsm_dostate(struct ace_device *ace)set_capacity (ace->gd,0 );dev_info (ace->dev,"No CF in slot\n" ); -/* Drop all pending requests */ -while ((req =elv_next_request (ace->queue)) !=NULL ) -__blk_end_request_cur (req, -EIO ); +/* Drop all in-flight and pending requests */ +if (ace->req) { +__blk_end_request_all (ace->req, -EIO ); + ace->req =NULL ; + } +while ((req =elv_next_request (ace->queue)) !=NULL ) { +blkdev_dequeue_request (req); +__blk_end_request_all (req, -EIO ); + }/* Drop back to IDLE state and notify waiters */ ace->fsm_state =ACE_FSM_STATE_IDLE ;
@@ -642,6 +649,7 @@ static void ace_fsm_dostate(struct ace_device *ace) ace->fsm_state =ACE_FSM_STATE_IDLE ;break ; } +blkdev_dequeue_request (req);/* Okay, it's a data request, set it up for transfer */ dev_dbg(ace->dev,
@@ -718,8 +726,7 @@ static void ace_fsm_dostate(struct ace_device *ace) }/* bio finished; is there another one? */ -if (__blk_end_request (ace->req,0 , -blk_rq_cur_bytes (ace->req))) { +if (__blk_end_request_cur (ace->req,0 )) {/* dev_dbg(ace->dev, "next block; h=%u c=%u\n", * blk_rq_sectors(ace->req), * blk_rq_cur_sectors(ace->req));
Signature · 1 line
1.6.0.2
PATCH 8/18 paride: dequeue in-flight request
In reply to Tejun Heopd/pf/pcd have track in-flight request by pd/pf/pcd_req. They can be converted to dequeueing model by updating fetching and completion paths. Convert them.
Note that removal of elv_next_request() call from pf_next_buf() doesn't make any functional difference. The path is traveled only during partial completion of a request and elv_next_request() call must return the same request anyway.
[ Impact: dequeue in-flight request ]
--- drivers/block/paride/pcd.c | 18 ++++++++++++------ drivers/block/paride/pd.c | 14 +++++++++----- drivers/block/paride/pf.c | 14 +++++++------- 3 files changed, 28 insertions(+), 18 deletions(-)
drivers/block/paride/pcd.c +12 -6
@@ -719,9 +719,12 @@ static void do_pcd_request(struct request_queue * q)if (pcd_busy)return ;while (1 ) { - pcd_req =elv_next_request (q); -if (!pcd_req) -return ; +if (!pcd_req) { + pcd_req =elv_next_request (q); +if (!pcd_req) +return ; +blkdev_dequeue_request (pcd_req); + }if (rq_data_dir (pcd_req) ==READ ) {struct pcd_unit *cd = pcd_req->rq_disk->private_data;
@@ -734,8 +737,10 @@ static void do_pcd_request(struct request_queue * q) pcd_busy =1 ;ps_set_intr (do_pcd_read,NULL ,0 , nice);return ; - }else -__blk_end_request_cur (pcd_req, -EIO ); + }else { +__blk_end_request_all (pcd_req, -EIO ); + pcd_req =NULL ; + } } }
@@ -744,7 +749,8 @@ static inline void next_request(int err)unsigned long saved_flags;spin_lock_irqsave (&pcd_lock, saved_flags); -__blk_end_request_cur (pcd_req, err); +if (!__blk_end_request_cur (pcd_req, err)) + pcd_req =NULL ; pcd_busy =0 ;do_pcd_request (pcd_queue);spin_unlock_irqrestore (&pcd_lock, saved_flags);
drivers/block/paride/pd.c +9 -5
@@ -410,11 +410,14 @@ static void run_fsm(void) pd_claimed =0 ; phase =NULL ;spin_lock_irqsave (&pd_lock, saved_flags); -__blk_end_request_cur (pd_req, - res == Ok ?0 : -EIO ); - pd_req =elv_next_request (pd_queue); -if (!pd_req) - stop =1 ; +if (!__blk_end_request_cur (pd_req, + res == Ok ?0 : -EIO )) { + pd_req =elv_next_request (pd_queue); +if (!pd_req) + stop =1 ; +else +blkdev_dequeue_request (pd_req); + }spin_unlock_irqrestore (&pd_lock, saved_flags);if (stop)return ;
@@ -706,6 +709,7 @@ static void do_pd_request(struct request_queue * q) pd_req =elv_next_request (q);if (!pd_req)return ; +blkdev_dequeue_request (pd_req);schedule_fsm (); }
drivers/block/paride/pf.c +7 -7
@@ -752,10 +752,8 @@ static struct request_queue *pf_queue;static void pf_end_request (int err) { -if (pf_req) { -__blk_end_request_cur (pf_req, err); +if (pf_req && !__blk_end_request_cur (pf_req, err)) pf_req =NULL ; - } }static void do_pf_request (struct request_queue * q)
@@ -763,9 +761,12 @@ static void do_pf_request(struct request_queue * q)if (pf_busy)return ; repeat: - pf_req =elv_next_request (q); -if (!pf_req) -return ; +if (!pf_req) { + pf_req =elv_next_request (q); +if (!pf_req) +return ; +blkdev_dequeue_request (pf_req); + } pf_current = pf_req->rq_disk->private_data; pf_block =blk_rq_pos (pf_req);
@@ -806,7 +807,6 @@ static int pf_next_buf(void)if (!pf_count) {spin_lock_irqsave (&pf_spin_lock, saved_flags);pf_end_request (0 ); - pf_req =elv_next_request (pf_queue);spin_unlock_irqrestore (&pf_spin_lock, saved_flags);if (!pf_req)return 1 ;
Signature · 1 line
1.6.0.2
PATCH 9/18 ps3disk: dequeue in-flight request
In reply to Tejun HeoOther than in issue error paths, ps3disk always completely finishes fetched requests. With full completion on error paths, it can be easily converted to dequeueing model.
* After L1 r/w call failure, ps3disk_submit_request_sg() now fails the whole request. Issue failure isn't likely to benefit from partial retry anyway and ps3disk uses full failure in completion error path too, so I don't think this amounts to any meaningful functionality loss.
* flush completion is converted to _all for consistency. It doesn't make any functional difference.
[ Impact: dequeue in-flight request ]
--- drivers/block/ps3disk.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/block/ps3disk.c +5 -3
@@ -157,7 +157,7 @@ static int ps3disk_submit_request_sg(struct ps3_storage_device *dev,if (res) {dev_err (&dev->sbd.core,"%s:%u: %s failed %d\n" , __func__, __LINE__, op, res); -__blk_end_request_cur (req, -EIO ); +__blk_end_request_all (req, -EIO );return 0 ; }
@@ -179,7 +179,7 @@ static int ps3disk_submit_flush_request(struct ps3_storage_device *dev,if (res) {dev_err (&dev->sbd.core,"%s:%u: sync cache failed 0x%llx\n" , __func__, __LINE__, res); -__blk_end_request_cur (req, -EIO ); +__blk_end_request_all (req, -EIO );return 0 ; }
@@ -195,6 +195,8 @@ 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); +if (blk_fs_request (req)) {if (ps3disk_submit_request_sg (dev, req))break ;
@@ -204,7 +206,7 @@ static void ps3disk_do_request(struct ps3_storage_device *dev,break ; }else {blk_dump_rq_flags (req,DEVICE_NAME " bad request" ); -__blk_end_request_cur (req, -EIO ); +__blk_end_request_all (req, -EIO );continue ; } }
Signature · 1 line
1.6.0.2
PATCH 10/18 amiflop: dequeue in-flight request
In reply to Tejun HeoRequest processing in amiflop is done sequentially in redo_fd_request() proper and redo_fd_request() can easily be converted to track in-flight request. Remove CURRENT, track in-flight request directly and dequeue it when processing starts.
[ Impact: dequeue in-flight request ]
--- drivers/block/amiflop.c | 48 +++++++++++++++++++++++----------------------- 1 files changed, 24 insertions(+), 24 deletions(-)
drivers/block/amiflop.c +24 -24
@@ -112,8 +112,6 @@ module_param(fd_def_df0, ulong, 0);MODULE_LICENSE ("GPL" );static struct request_queue *floppy_queue; -#define QUEUE (floppy_queue) -#define CURRENT elv_next_request(floppy_queue)/* * Macros
@@ -1335,59 +1333,61 @@ static int get_track(int drive, int track)static void redo_fd_request (void ) { +struct request *rq;unsigned int cnt, block, track, sector;int drive;struct amiga_floppy_struct *floppy;char *data;unsigned long flags; +int err; - repeat: -if (!CURRENT ) { +next_req: + rq =elv_next_request (floppy_queue); +if (!rq) {/* Nothing left to do */ return ; } +blkdev_dequeue_request (rq); - floppy =CURRENT ->rq_disk->private_data; + floppy = rq->rq_disk->private_data; drive = floppy - unit; +next_segment:/* Here someone could investigate to be more efficient */ -for (cnt =0 ; cnt <blk_rq_cur_sectors (CURRENT ); cnt++) { +for (cnt =0 , err =0 ; cnt <blk_rq_cur_sectors (rq); cnt++) {#ifdef DEBUG printk ("fd: sector %ld + %d requested for %s\n" , -blk_rq_pos (CURRENT ), cnt, - (rq_data_dir (CURRENT ) ==READ ) ?"read" :"write" ); +blk_rq_pos (rq), cnt, + (rq_data_dir (rq) ==READ ) ?"read" :"write" );#endif - block =blk_rq_pos (CURRENT ) + cnt; + block =blk_rq_pos (rq) + cnt;if ((int )block > floppy->blocks) { -__blk_end_request_cur (CURRENT , -EIO ); - goto repeat; + err = -EIO ; +break ; } track = block / (floppy->dtype->sects * floppy->type->sect_mult); sector = block % (floppy->dtype->sects * floppy->type->sect_mult); - data =CURRENT ->buffer +512 * cnt; + data = rq->buffer +512 * cnt;#ifdef DEBUG printk ("access to track %d, sector %d, with buffer at " "0x%08lx\n" , track, sector, data);#endif if (get_track (drive, track) ==-1 ) { -__blk_end_request_cur (CURRENT , -EIO ); - goto repeat; + err = -EIO ; +break ; } -switch (rq_data_dir (CURRENT )) { -case READ : +if (rq_data_dir (rq) ==READ ) {memcpy (data, floppy->trackbuf + sector *512 ,512 ); -break ; - -case WRITE : + }else {memcpy (floppy->trackbuf + sector *512 , data,512 );/* keep the drive spinning while writes are scheduled */ if (!fd_motor_on (drive)) { -__blk_end_request_cur (CURRENT , -EIO ); - goto repeat; + err = -EIO ; +break ; }/* * setup a callback to write the track buffer
@@ -1399,12 +1399,12 @@ static void redo_fd_request(void)/* reset the timer */ mod_timer (flush_track_timer + drive, jiffies +1 );local_irq_restore (flags); -break ; } } -__blk_end_request_cur (CURRENT ,0 ); - goto repeat; +if (__blk_end_request_cur (rq, err)) + goto next_segment; + goto next_req; }static void do_fd_request (struct request_queue * q)
Signature · 1 line
1.6.0.2
PATCH 11/18 swim: dequeue in-flight request
In reply to Tejun Heoswim processes requests one-by-one synchronously and can easily be converted to dequeuing model. Convert it.
[ Impact: dequeue in-flight request ]
--- drivers/block/swim.c | 47 +++++++++++++++++++++++------------------------ 1 files changed, 23 insertions(+), 24 deletions(-)
drivers/block/swim.c +23 -24
@@ -514,7 +514,7 @@ static int floppy_read_sectors(struct floppy_state *fs, ret =swim_read_sector (fs, side, track, sector, buffer);if (try-- ==0 ) -return -1 ; +return -EIO ; }while (ret !=512 ); buffer += ret;
@@ -528,38 +528,37 @@ static void redo_fd_request(struct request_queue *q)struct request *req;struct floppy_state *fs; -while ((req =elv_next_request (q))) { + req =elv_next_request (q); +if (req) +blkdev_dequeue_request (req); + +while (req) { +int err = -EIO ; fs = req->rq_disk->private_data; -if (blk_rq_pos (req) >= fs->total_secs) { -__blk_end_request_cur (req, -EIO ); -continue ; - } -if (!fs->disk_in) { -__blk_end_request_cur (req, -EIO ); -continue ; - } -if (rq_data_dir (req) ==WRITE ) { -if (fs->write_protected) { -__blk_end_request_cur (req, -EIO ); -continue ; - } - } +if (blk_rq_pos (req) >= fs->total_secs) + goto done; +if (!fs->disk_in) + goto done; +if (rq_data_dir (req) ==WRITE && fs->write_protected) + goto done; +switch (rq_data_dir (req)) {case WRITE :/* NOT IMPLEMENTED */ -__blk_end_request_cur (req, -EIO );break ;case READ : -if (floppy_read_sectors (fs,blk_rq_pos (req), -blk_rq_cur_sectors (req), - req->buffer)) { -__blk_end_request_cur (req, -EIO ); -continue ; - } -__blk_end_request_cur (req,0 ); + err =floppy_read_sectors (fs,blk_rq_pos (req), +blk_rq_cur_sectors (req), + req->buffer);break ; } + done: +if (!__blk_end_request_cur (req, err)) { + req =elv_next_request (q); +if (req) +blkdev_dequeue_request (req); + } } }
Signature · 1 line
1.6.0.2
PATCH 12/18 xd: dequeue in-flight request
In reply to Tejun Heoxd processes requests one-by-one synchronously and can be easily converted to dequeueing model. Convert it.
While at it, use rq_cur_bytes instead of rq_bytes when checking for sector overflow. This is for for consistency and better behavior for merged requests.
[ Impact: dequeue in-flight request ]
--- drivers/block/xd.c | 29 +++++++++++++++++------------ 1 files changed, 17 insertions(+), 12 deletions(-)
drivers/block/xd.c +17 -12
@@ -305,26 +305,31 @@ static void do_xd_request (struct request_queue * q)if (xdc_busy)return ; -while ((req =elv_next_request (q)) !=NULL ) { + req =elv_next_request (q); +if (req) +blkdev_dequeue_request (req); + +while (req) {unsigned block =blk_rq_pos (req); -unsigned count =blk_rq_sectors (req); +unsigned count =blk_rq_cur_sectors (req);XD_INFO *disk = req->rq_disk->private_data; -int res =0 ; +int res = -EIO ;int retry; -if (!blk_fs_request (req)) { -__blk_end_request_cur (req, -EIO ); -continue ; - } -if (block + count >get_capacity (req->rq_disk)) { -__blk_end_request_cur (req, -EIO ); -continue ; - } +if (!blk_fs_request (req)) + goto done; +if (block + count >get_capacity (req->rq_disk)) + goto done;for (retry =0 ; (retry <XD_RETRIES ) && !res; retry++) res =xd_readwrite (rq_data_dir (req), disk, req->buffer, block, count); + done:/* wrap up, 0 = success, -errno = fail */ -__blk_end_request_cur (req, res); +if (!__blk_end_request_cur (req, res)) { + req =elv_next_request (q); +if (req) +blkdev_dequeue_request (req); + } } }
Signature · 1 line
1.6.0.2
PATCH 13/18 mtd_blkdevs: dequeue in-flight request
In reply to Tejun Heomtd_blkdevs processes requests one-by-one synchronously from a kthread and can be easily converted to dequeueing model. Convert it.
[ Impact: dequeue in-flight request ]
--- drivers/mtd/mtd_blkdevs.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-)
drivers/mtd/mtd_blkdevs.c +13 -4
@@ -89,18 +89,22 @@ static int mtd_blktrans_thread(void *arg) {struct mtd_blktrans_ops *tr = arg;struct request_queue *rq = tr->blkcore_priv->rq; +struct request *req =NULL ;/* we might get involved when memory gets low, so use PF_MEMALLOC */ current->flags |=PF_MEMALLOC ;spin_lock_irq (rq->queue_lock); +while (!kthread_should_stop ()) { -struct request *req;struct mtd_blktrans_dev *dev;int res; - req =elv_next_request (rq); - +if (!req) { + req =elv_next_request (rq); +if (req) +blkdev_dequeue_request (req); + }if (!req) {set_current_state (TASK_INTERRUPTIBLE );spin_unlock_irq (rq->queue_lock);
@@ -120,8 +124,13 @@ static int mtd_blktrans_thread(void *arg)spin_lock_irq (rq->queue_lock); -__blk_end_request_cur (req, res); +if (!__blk_end_request_cur (req, res)) + req =NULL ; } + +if (req) +__blk_end_request_all (req, -EIO ); +spin_unlock_irq (rq->queue_lock);return 0 ;
Signature · 1 line
1.6.0.2
PATCH 14/18 jsflash: dequeue in-flight request
In reply to Tejun Heojsflash processes requests one-by-one synchronously from a kthread and can be easily converted to dequeueing model. Convert it.
[ Impact: dequeue in-flight request ]
--- drivers/sbus/char/jsflash.c | 28 +++++++++++++++++----------- 1 files changed, 17 insertions(+), 11 deletions(-)
drivers/sbus/char/jsflash.c +17 -11
@@ -186,31 +186,37 @@ static void jsfd_do_request(struct request_queue *q) {struct request *req; -while ((req =elv_next_request (q)) !=NULL ) { + req =elv_next_request (q); +if (req) +blkdev_dequeue_request (req); + +while (req) {struct jsfd_part *jdp = req->rq_disk->private_data;unsigned long offset =blk_rq_pos (req) <<9 ;size_t len =blk_rq_cur_bytes (req); +int err = -EIO ; -if ((offset + len) > jdp->dsize) { -__blk_end_request_cur (req, -EIO ); -continue ; - } +if ((offset + len) > jdp->dsize) + goto end;if (rq_data_dir (req) !=READ ) {printk (KERN_ERR "jsfd: write\n" ); -__blk_end_request_cur (req, -EIO ); -continue ; + goto end; }if ((jdp->dbase &0xff000000 ) !=0x20000000 ) {printk (KERN_ERR "jsfd: bad base %x\n" , (int )jdp->dbase); -__blk_end_request_cur (req, -EIO ); -continue ; + goto end; }jsfd_read (req->buffer, jdp->dbase + offset, len); - -__blk_end_request_cur (req,0 ); + err =0 ; + end: +if (!__blk_end_request_cur (req, err)) { + req =elv_next_request (q); +if (req) +blkdev_dequeue_request (req); + } } }
Signature · 1 line
1.6.0.2
PATCH 15/18 z2ram: dequeue in-flight request
In reply to Tejun Heoz2ram processes requests one-by-one synchronously and can be easily converted to dequeueing model. Convert it.
[ Impact: dequeue in-flight request ]
--- drivers/block/z2ram.c | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-)
drivers/block/z2ram.c +15 -4
@@ -70,15 +70,21 @@ static struct gendisk *z2ram_gendisk;static void do_z2_request (struct request_queue *q) {struct request *req; -while ((req =elv_next_request (q)) !=NULL ) { + + req =elv_next_request (q); +if (req) +blkdev_dequeue_request (req); + +while (req) {unsigned long start =blk_rq_pos (req) <<9 ;unsigned long len =blk_rq_cur_bytes (req); +int err =0 ;if (start + len > z2ram_size) { printk( KERN_ERR DEVICE_NAME ": bad access: block=%lu, count=%u\n", blk_rq_pos(req), blk_rq_cur_sectors(req)); -__blk_end_request_cur (req, -EIO ); -continue ; + err = -EIO ; + goto done; }while (len) {unsigned long addr = start &Z2RAM_CHUNKMASK ;
@@ -93,7 +99,12 @@ static void do_z2_request(struct request_queue *q) start += size; len -= size; } -__blk_end_request_cur (req,0 ); + done: +if (!__blk_end_request_cur (req, err)) { + req =elv_next_request (q); +if (req) +blkdev_dequeue_request (req); + } } }
Signature · 1 line
1.6.0.2
PATCH 16/18 gdrom: dequeue in-flight request
In reply to Tejun Heogdrom already dequeues and fully completes requests on normal path and the error paths can be easily converted to do so too. Clean it up and dequeue requests on error paths too.
While at it remove superflous blk_fs_request() && !blk_rq_sectors() condition check.
[ Impact: dequeue in-flight request, cleanup ]
--- drivers/cdrom/gdrom.c | 28 +++++++++++++--------------- 1 files changed, 13 insertions(+), 15 deletions(-)
drivers/cdrom/gdrom.c +13 -15
@@ -638,33 +638,31 @@ static void gdrom_readdisk_dma(struct work_struct *work)kfree (read_command); } -static void gdrom_request_handler_dma (struct request *req) -{ -/* dequeue, add to list of deferred work -* and then schedule workqueue */ -blkdev_dequeue_request (req); -list_add_tail (&req->queuelist, &gdrom_deferred); -schedule_work (&work); -} -static void gdrom_request (struct request_queue *rq) {struct request *req;while ((req =elv_next_request (rq)) !=NULL ) { +blkdev_dequeue_request (req); +if (!blk_fs_request (req)) {printk (KERN_DEBUG "GDROM: Non-fs request ignored\n" ); -__blk_end_request_cur (req, -EIO ); +__blk_end_request_all (req, -EIO ); +continue ; }if (rq_data_dir (req) !=READ ) {printk (KERN_NOTICE "GDROM: Read only device -" );printk (" write request ignored\n" ); -__blk_end_request_cur (req, -EIO ); +__blk_end_request_all (req, -EIO ); +continue ; } -if (blk_rq_sectors (req)) -gdrom_request_handler_dma (req); -else -__blk_end_request_cur (req, -EIO ); + +/* +* Add to list of deferred work and then schedule +* workqueue. +*/ +list_add_tail (&req->queuelist, &gdrom_deferred); +schedule_work (&work); } }
Signature · 1 line
1.6.0.2
PATCH 17/18 block: convert to dequeueing model (easy ones)
In reply to Tejun Heoplat-omap/mailbox, floppy, viocd, mspro_block, i2o_block and mmc/card/queue are already pretty close to dequeueing model and can be converted with simple changes. Convert them.
While at it,
* xen-blkfront: !fs check moved downwards to share dequeue call with normal path.
* mspro_block: __blk_end_request(..., blk_rq_cur_byte()) converted to __blk_end_request_cur()
* mmc/card/queue: loop of __blk_end_request() converted to __blk_end_request_all()
[ Impact: dequeue in-flight request ]
--- arch/arm/plat-omap/mailbox.c | 9 +++++++++ drivers/block/floppy.c | 4 +++- drivers/block/xen-blkfront.c | 13 +++++++------ drivers/cdrom/viocd.c | 2 ++ drivers/memstick/core/mspro_block.c | 8 +++++--- drivers/message/i2o/i2o_block.c | 6 ++++-- drivers/mmc/card/queue.c | 12 ++++++------ 7 files changed, 36 insertions(+), 18 deletions(-)
arch/arm/plat-omap/mailbox.c +9 -0
@@ -198,6 +198,8 @@ static void mbox_tx_work(struct work_struct *work)spin_lock (q->queue_lock); rq =elv_next_request (q); +if (rq) +blkdev_dequeue_request (rq);spin_unlock (q->queue_lock);if (!rq)
@@ -208,6 +210,9 @@ static void mbox_tx_work(struct work_struct *work) ret =__mbox_msg_send (mbox, tx_data->msg, tx_data->arg);if (ret) {enable_mbox_irq (mbox,IRQ_TX ); +spin_lock (q->queue_lock); +blk_requeue_request (q, rq); +spin_unlock (q->queue_lock);return ; }
@@ -238,6 +243,8 @@ 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);spin_unlock_irqrestore (q->queue_lock, flags);if (!rq)break ;
@@ -345,6 +352,8 @@ 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);spin_unlock_irqrestore (q->queue_lock, flags);if (!rq)
drivers/block/floppy.c +3 -1
@@ -931,7 +931,7 @@ static inline void unlock_fdc(void)del_timer (&fd_timeout); cont =NULL ;clear_bit (0 , &fdc_busy); -if (elv_next_request (floppy_queue)) +if (current_req ||elv_next_request (floppy_queue))do_fd_request (floppy_queue);spin_unlock_irqrestore (&floppy_lock, flags);wake_up (&fdc_wait);
@@ -2913,6 +2913,8 @@ static void redo_fd_request(void)spin_lock_irq (floppy_queue->queue_lock); req =elv_next_request (floppy_queue); +if (req) +blkdev_dequeue_request (req);spin_unlock_irq (floppy_queue->queue_lock);if (!req) { do_floppy =NULL ;
drivers/block/xen-blkfront.c +7 -6
@@ -301,22 +301,23 @@ static void do_blkif_request(struct request_queue *rq)while ((req =elv_next_request (rq)) !=NULL ) { info = req->rq_disk->private_data; -if (!blk_fs_request (req)) { -__blk_end_request_cur (req, -EIO ); -continue ; - }if (RING_FULL (&info->ring)) goto wait; +blkdev_dequeue_request (req); + +if (!blk_fs_request (req)) { +__blk_end_request_all (req, -EIO ); +continue ; + } +pr_debug ("do_blk_req %p: cmd %p, sec %lx, " "(%u/%u) buffer:%p [%s]\n" , req, req->cmd, (unsigned long )blk_rq_pos (req),blk_rq_cur_sectors (req),blk_rq_sectors (req), req->buffer,rq_data_dir (req) ?"write" :"read" ); - -blkdev_dequeue_request (req);if (blkif_queue_request (req)) {blk_requeue_request (rq, req); wait:
drivers/cdrom/viocd.c +2 -0
@@ -298,6 +298,8 @@ 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); +if (!blk_fs_request (req))__blk_end_request_all (req, -EIO );else if (send_request (req) <0 ) {
drivers/memstick/core/mspro_block.c +5 -3
@@ -672,8 +672,7 @@ try_again: msb->req_sg);if (!msb->seg_count) { - chunk =__blk_end_request (msb->block_req, -ENOMEM , -blk_rq_cur_bytes (msb->block_req)); + chunk =__blk_end_request_cur (msb->block_req, -ENOMEM );continue ; }
@@ -711,6 +710,7 @@ try_again: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,8 +825,10 @@ static void mspro_block_submit_req(struct request_queue *q)return ;if (msb->eject) { -while ((req =elv_next_request (q)) !=NULL ) +while ((req =elv_next_request (q)) !=NULL ) { +blkdev_dequeue_request (req);__blk_end_request_all (req, -ENODEV ); + }return ; }
drivers/message/i2o/i2o_block.c +4 -2
@@ -916,8 +916,10 @@ static void i2o_block_request_fn(struct request_queue *q)blk_stop_queue (q);break ; } - }else -__blk_end_request_cur (req, -EIO ); + }else { +blkdev_dequeue_request (req); +__blk_end_request_all (req, -EIO ); + } } };
drivers/mmc/card/queue.c +6 -6
@@ -54,8 +54,11 @@ static int mmc_queue_thread(void *d)spin_lock_irq (q->queue_lock);set_current_state (TASK_INTERRUPTIBLE ); -if (!blk_queue_plugged (q)) +if (!blk_queue_plugged (q)) { req =elv_next_request (q); +if (req) +blkdev_dequeue_request (req); + } mq->req = req;spin_unlock_irq (q->queue_lock);
@@ -88,15 +91,12 @@ static void mmc_request(struct request_queue *q) {struct mmc_queue *mq = q->queuedata;struct request *req; -int ret;if (!mq) {printk (KERN_ERR "MMC: killing requests for dead queue\n" );while ((req =elv_next_request (q)) !=NULL ) { -do { - ret =__blk_end_request (req, -EIO , -blk_rq_cur_bytes (req)); - }while (ret); +blkdev_dequeue_request (req); +__blk_end_request_all (req, -EIO ); }return ; }
Signature · 1 line
1.6.0.2
PATCH 18/18 block: implement and enforce request peek/start/fetch
In reply to Tejun HeoTill 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 ]
--- arch/arm/plat-omap/mailbox.c | 12 +--- arch/um/drivers/ubd_kern.c | 3 +- block/blk-barrier.c | 4 +- block/blk-core.c | 105 +++++++++++++++++++++++++--------- block/blk-tag.c | 2 +- block/blk.h | 1 + drivers/block/DAC960.c | 4 +- drivers/block/amiflop.c | 3 +- drivers/block/ataflop.c | 3 +- drivers/block/cciss.c | 4 +- drivers/block/cpqarray.c | 4 +- drivers/block/floppy.c | 6 +- drivers/block/hd.c | 3 +- drivers/block/mg_disk.c | 12 +--- drivers/block/nbd.c | 4 +- drivers/block/paride/pcd.c | 3 +- drivers/block/paride/pd.c | 7 +-- drivers/block/paride/pf.c | 3 +- drivers/block/ps3disk.c | 4 +- drivers/block/sunvdc.c | 3 +- drivers/block/swim.c | 12 +--- drivers/block/swim3.c | 3 +- drivers/block/sx8.c | 8 +-- drivers/block/ub.c | 8 +- drivers/block/viodasd.c | 4 +- drivers/block/virtio_blk.c | 4 +- drivers/block/xd.c | 12 +--- drivers/block/xen-blkfront.c | 4 +- drivers/block/xsysace.c | 10 +-- drivers/block/z2ram.c | 12 +--- drivers/cdrom/gdrom.c | 4 +- drivers/cdrom/viocd.c | 4 +- drivers/ide/ide-atapi.c | 2 +- drivers/ide/ide-io.c | 9 +-- drivers/memstick/core/mspro_block.c | 9 +-- drivers/message/i2o/i2o_block.c | 6 +- drivers/mmc/card/queue.c | 11 +--- drivers/mtd/mtd_blkdevs.c | 7 +-- drivers/s390/block/dasd.c | 16 ++---- drivers/s390/char/tape_block.c | 7 +-- drivers/sbus/char/jsflash.c | 12 +--- drivers/scsi/scsi_lib.c | 10 ++-- drivers/scsi/scsi_transport_sas.c | 4 +- include/linux/blkdev.h | 9 ++- include/linux/elevator.h | 2 - 45 files changed, 172 insertions(+), 207 deletions(-)
arch/arm/plat-omap/mailbox.c +3 -9
@@ -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)
arch/um/drivers/ubd_kern.c +1 -2
@@ -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); }
block/blk-barrier.c +2 -2
@@ -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;
block/blk-core.c +77 -28
146 lines not on this page · raw message
block/blk-tag.c +1 -1
@@ -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 ; }
block/blk.h +1 -0
@@ -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);
drivers/block/DAC960.c +2 -2
@@ -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 */
drivers/block/amiflop.c +1 -2
@@ -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;
drivers/block/ataflop.c +1 -2
@@ -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;
drivers/block/cciss.c +2 -2
@@ -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);
drivers/block/cpqarray.c +2 -2
@@ -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;
drivers/block/floppy.c +2 -4
@@ -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 ;
drivers/block/hd.c +1 -2
@@ -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;
drivers/block/mg_disk.c +4 -8
@@ -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;
drivers/block/nbd.c +1 -3
@@ -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",
drivers/block/paride/pcd.c +1 -2
@@ -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 ) {
drivers/block/paride/pd.c +2 -5
@@ -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 (); }
drivers/block/paride/pf.c +1 -2
@@ -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;
drivers/block/ps3disk.c +1 -3
@@ -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 ;
drivers/block/sunvdc.c +1 -2
@@ -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 ); }
drivers/block/swim.c +3 -9
@@ -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); } }
drivers/block/swim3.c +1 -2
@@ -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
drivers/block/sx8.c +3 -5
@@ -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 ;
drivers/block/ub.c +4 -4
@@ -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 ));
drivers/block/viodasd.c +1 -3
@@ -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));
drivers/block/virtio_blk.c +2 -2
@@ -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++; }
drivers/block/xd.c +3 -9
@@ -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); } }
drivers/block/xen-blkfront.c +2 -2
@@ -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 );
drivers/block/xsysace.c +4 -6
@@ -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,
drivers/block/z2ram.c +3 -9
@@ -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); } }
drivers/cdrom/gdrom.c +1 -3
@@ -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 );
drivers/cdrom/viocd.c +1 -3
@@ -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 ) {
drivers/ide/ide-atapi.c +1 -1
@@ -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)); } }
drivers/ide/ide-io.c +3 -6
@@ -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...
drivers/memstick/core/mspro_block.c +3 -6
@@ -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 ; }
drivers/message/i2o/i2o_block.c +3 -3
@@ -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 ); } }
drivers/mmc/card/queue.c +3 -8
@@ -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 ; }
drivers/mtd/mtd_blkdevs.c +1 -6
@@ -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 ();
drivers/s390/block/dasd.c +5 -11
@@ -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); }
drivers/s390/char/tape_block.c +2 -5
@@ -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);
drivers/sbus/char/jsflash.c +3 -9
@@ -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); } }
drivers/scsi/scsi_lib.c +5 -5
@@ -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);
drivers/scsi/scsi_transport_sas.c +1 -3
@@ -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;
include/linux/blkdev.h +7 -2
@@ -819,8 +819,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
@@ -854,6 +852,13 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq) }/* +* 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. * * blk_update_request() completes given number of bytes and updates
include/linux/elevator.h +0 -2
@@ -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);
Signature · 1 line
1.6.0.2
Re: [PATCH 16/18] gdrom: dequeue in-flight request
In reply to Tejun HeoQuoted 4 lines · Tejun Heo
gdrom already dequeues and fully completes requests on normal path and the error paths can be easily converted to do so too. Clean it up and dequeue requests on error paths too.
Quoted 8 lines
While at it remove superflous
blk_fs_request()&& !blk_rq_sectors() condition check.[ Impact: dequeue in-flight request, cleanup ]
Signed-off-by Tejun Heo <[email protected]>Cc Adrian McMenamin <[email protected]>---
Re: [PATCH 16/18] gdrom: dequeue in-flight request
Quoted 8 lines · Adrian McMenamin
Quoted 7 lines · Tejun Heo
gdrom already dequeues and fully completes requests on normal path and the error paths can be easily converted to do so too. Clean it up and dequeue requests on error paths too.
While at it remove superflous
blk_fs_request()&& !blk_rq_sectors() condition check.
Quoted 8 lines
Quoted 5 lines
[ Impact: dequeue in-flight request, cleanup ]
Signed-off-by Tejun Heo <[email protected]>Cc Adrian McMenamin <[email protected]>---
Tested-by Adrian McMenamin <[email protected]>Acked-by Adrian McMenamin <[email protected]>
Thanks.
Signature · 1 line
tejun
Re: [PATCH 01/18] ide: dequeue in-flight request
In reply to Tejun HeoQuoted 25 lines · Tejun Heo
ide generally has single request in flight and tracks it using
hwif->rqand all state handlers follow the following convention.*
ide_startedis returned if the request is in flight.*
ide_stoppedis returned if the queue needs to be restarted. The request might or might not have been processed fully or partially.*
hwif->rqis set to NULL, when an issued request completes.So, dequeueing model can be implemented by dequeueing after fetch, requeueing if
hwif->rqisn't NULL onide_stoppedreturn and doing about the same thing on completion / port unlock paths. These changes can be made in ide-io proper.In addition to the above main changes, the following updates are necessary.
* ide-cd shouldn't dequeue a request when issuing REQUEST SENSE for it as the request is already dequeued.
* ide-atapi uses request queue as stack when issuing REQUEST SENSE to put the REQUEST SENSE in front of the failed request. This now needs to be done using requeueing.
Quoted 6 lines
[ Impact: dequeue in-flight request ]
Signed-off-by Tejun Heo <[email protected]>Cc Bartlomiej Zolnierkiewicz <[email protected]>Cc Borislav Petkov <[email protected]>Cc Sergei Shtylyov <[email protected]>
Signature · 2 lines
Regards/Gruss,
Boris.Re: [PATCH 01/18] ide: dequeue in-flight request
In reply to Tejun HeoQuoted 25 lines · On Friday 08 May 2009 04:53:59 Tejun Heo wrote:
ide generally has single request in flight and tracks it using
hwif->rqand all state handlers follow the following convention.*
ide_startedis returned if the request is in flight.*
ide_stoppedis returned if the queue needs to be restarted. The request might or might not have been processed fully or partially.*
hwif->rqis set to NULL, when an issued request completes.So, dequeueing model can be implemented by dequeueing after fetch, requeueing if
hwif->rqisn't NULL onide_stoppedreturn and doing about the same thing on completion / port unlock paths. These changes can be made in ide-io proper.In addition to the above main changes, the following updates are necessary.
* ide-cd shouldn't dequeue a request when issuing REQUEST SENSE for it as the request is already dequeued.
* ide-atapi uses request queue as stack when issuing REQUEST SENSE to put the REQUEST SENSE in front of the failed request. This now needs to be done using requeueing.
Quoted 6 lines
[ Impact: dequeue in-flight request ]
Signed-off-by Tejun Heo <[email protected]>Cc Bartlomiej Zolnierkiewicz <[email protected]>Cc Borislav Petkov <[email protected]>Cc Sergei Shtylyov <[email protected]>
Quoted 2 lines · Tejun Heo
All changes have been compile tested. libata, ide, hd and
ubd_kernare verified to work. Waiting for floppy media to test it.
Floppy verified to work.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 18/18] block: implement and enforce request peek/start/fetch
In reply to Tejun HeoQuoted 26 lines · On Friday 08 May 2009 04:54:16 Tejun Heo wrote:
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 allowselv_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()toblk_peek_request()* renaming
blkdev_dequeue_request()toblk_start_request()* adding
blk_fetch_request()which is combination of peek and start* disallowing completion of queued (not started) requests
Quoted 8 lines
* 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]>
Quoted 34 lines · Tejun Heo
Hello,
Upon ack, please pull from the following git tree.
git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.gitblock-peek-fetchBlock layer has allowed two different models of request processing.
elv_next_request()is used to peek at the top of the queue, after peeking, a LLD could start processing it immediately or dequeue and then start processing.The non-dequeuing behavior is mostly useful for simpler device drivers (usually PIO based) which process requests on segment basis. By using the block layer queue tip as the current request pointer, they don't have to care about request boundaries and just process things segment-by-segment.
However, this dual mode of operations complicates and ambiguates block layer API. Block layer can't tell whether a request has begun processing or not in deterministic manner. This makes accounting inaccurate and implementing high level features in block layer difficult. For example, it isn't clear when a block layer timeout timer should be started or how queue queiscing for EH should be implemented. Even when problems can be worked aroudn, it makes the implementation fragile.
Although allowing llds ignore request boundaries makes things simpler for certain drivers, the number of drivers benefit form it aren't too many and driver stacks which are even mildly complex have to deal with request boundaries anyway. Also, the benefit itself isn't that significant. In most cases, it is just another way of doing things rather than the definitively better way. IOW, if there were no such alternative, nobody would have missed it.
Quoted 3 lines
This patchset converts all block layer llds to dequeuing model and then clean up API to simplify a bit and enforce dequeueing model. This patchset contains the following patches.
Glad this finally got completed, thanks a lot Tejun! Applied.
Signature · 1 line
Jens Axboe
Re: [PATCH 15/18] z2ram: dequeue in-flight request
In reply to Tejun HeoHello.
Quoted 43 lines · Tejun Heo
z2ram processes requests one-by-one synchronously and can be easily converted to dequeueing model. Convert it.
[ Impact: dequeue in-flight request ]
Signed-off-by Tejun Heo <[email protected]>--- drivers/block/z2ram.c | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-)drivers/block/z2ram.c +9
-3@@ -70,15 +70,21 @@ static struct gendisk *z2ram_gendisk;static void do_z2_request (struct request_queue *q) {struct request *req; -while ((req =elv_next_request (q)) !=NULL ) { + + req =elv_next_request (q); +if (req) +blkdev_dequeue_request (req); + +while (req) {unsigned long start =blk_rq_pos (req) <<9 ;unsigned long len =blk_rq_cur_bytes (req); +int err =0 ;if (start + len > z2ram_size) { printk( KERN_ERR DEVICE_NAME ": bad access: block=%lu, count=%u\n", blk_rq_pos(req), blk_rq_cur_sectors(req)); -__blk_end_request_cur (req, -EIO ); -continue ; + err = -EIO ; + goto done; }while (len) {unsigned long addr = start &Z2RAM_CHUNKMASK ;@@ -93,7 +99,12 @@ static void do_z2_request(struct request_queue *q) start += size; len -= size; }
drivers/block/z2ram.c static void do_z2_request(struct request_queue *q) · line 110
Quoted 10 lines
drivers/block/z2ram.c +6
-1-__blk_end_request_cur (req,0 ); + done: +if (!__blk_end_request_cur (req, err)) { + req =elv_next_request (q); +if (req) +blkdev_dequeue_request (req); + } } }
I'm sure this can be made more compact and without duplication (in
many other cases as well):
@@ -70,15 +70,21 @@ static struct gendisk *z2ram_gendisk;
static void do_z2_request(struct request_queue *q)
{
struct request *req;
+
while ((req = elv_next_request(q)) != NULL) {
unsigned long start = blk_rq_pos(req) << 9;
unsigned long len = blk_rq_cur_bytes(req);+ blkdev_dequeue_request(req);
+
if (start + len > z2ram_size) {
printk( KERN_ERR DEVICE_NAME ": bad access: block=%lu, count=%u\n",
blk_rq_pos(req), blk_rq_cur_sectors(req));
- __blk_end_request_cur(req, -EIO);
- continue;
+ err = -EIO;
+ goto done;
}
while (len) {
unsigned long addr = start & Z2RAM_CHUNKMASK;
@@ -93,7 +99,12 @@ static void do_z2_request(struct request_queue *q)
start += size;
len -= size;
}
- __blk_end_request_cur(req, 0);
+ done:
+ if (__blk_end_request_cur(req, err));
+ break;
}
}MBR, Sergei
Re: [PATCH 11/18] swim: dequeue in-flight request
In reply to Tejun HeoHello.
Quoted 74 lines · Tejun Heo
swim processes requests one-by-one synchronously and can easily be converted to dequeuing model. Convert it.
[ Impact: dequeue in-flight request ]
Signed-off-by Tejun Heo <[email protected]>Cc Laurent Vivier <[email protected]>--- drivers/block/swim.c | 47 +++++++++++++++++++++++------------------------ 1 files changed, 23 insertions(+), 24 deletions(-)drivers/block/swim.c +17
-24@@ -514,7 +514,7 @@ static int floppy_read_sectors(struct floppy_state *fs, ret =swim_read_sector (fs, side, track, sector, buffer);if (try-- ==0 ) -return -1 ; +return -EIO ; }while (ret !=512 ); buffer += ret;@@ -528,38 +528,37 @@ static void redo_fd_request(struct request_queue *q)struct request *req;struct floppy_state *fs; -while ((req =elv_next_request (q))) { + req =elv_next_request (q); +if (req) +blkdev_dequeue_request (req); + +while (req) { +int err = -EIO ; fs = req->rq_disk->private_data; -if (blk_rq_pos (req) >= fs->total_secs) { -__blk_end_request_cur (req, -EIO ); -continue ; - } -if (!fs->disk_in) { -__blk_end_request_cur (req, -EIO ); -continue ; - } -if (rq_data_dir (req) ==WRITE ) { -if (fs->write_protected) { -__blk_end_request_cur (req, -EIO ); -continue ; - } - } +if (blk_rq_pos (req) >= fs->total_secs) + goto done; +if (!fs->disk_in) + goto done; +if (rq_data_dir (req) ==WRITE && fs->write_protected) + goto done; +switch (rq_data_dir (req)) {case WRITE :/* NOT IMPLEMENTED */ -__blk_end_request_cur (req, -EIO );break ;case READ : -if (floppy_read_sectors (fs,blk_rq_pos (req), -blk_rq_cur_sectors (req), - req->buffer)) { -__blk_end_request_cur (req, -EIO ); -continue ; - } -__blk_end_request_cur (req,0 ); + err =floppy_read_sectors (fs,blk_rq_pos (req), +blk_rq_cur_sectors (req), + req->buffer);
drivers/block/swim.c static void redo_fd_request(struct request_queue *q) · line 563
Quoted 10 lines
drivers/block/swim.c +6
-0break ; } + done: +if (!__blk_end_request_cur (req, err)) { + req =elv_next_request (q); +if (req) +blkdev_dequeue_request (req); + } } }
And without duplication:
@@ -528,38 +528,37 @@
static void redo_fd_request(struct request_queue *q) {
- struct request *req; struct floppy_state *fs;
- while ((req = elv_next_request(q))) {
+ while (1) {
+ struct request *req = elv_next_request(q);
+ int err;
+ + if (req == NULL)
+ break;
+ blkdev_dequeue_request(req);
+again:
+ err = -EIO; fs = req->rq_disk->private_data;
- if (blk_rq_pos(req) >= fs->total_secs) {
- __blk_end_request_cur(req, -EIO);
- continue;
- }
- if (!fs->disk_in) {
- __blk_end_request_cur(req, -EIO);
- continue;
- }
- if (rq_data_dir(req) == WRITE) {
- if (fs->write_protected) {
- __blk_end_request_cur(req, -EIO);
- continue;
- }
- }
+ if (blk_rq_pos(req) >= fs->total_secs)
+ goto done;
+ if (!fs->disk_in)
+ goto done;
+ if (rq_data_dir(req) == WRITE && fs->write_protected)
+ goto done;
+
switch (rq_data_dir(req)) {
case WRITE:
/* NOT IMPLEMENTED */
- __blk_end_request_cur(req, -EIO);
break;
case READ:- if (floppy_read_sectors(fs, blk_rq_pos(req),
- blk_rq_cur_sectors(req),
- req->buffer)) {
- __blk_end_request_cur(req, -EIO);
- continue;
- }
- __blk_end_request_cur(req, 0);
+ err = floppy_read_sectors(fs, blk_rq_pos(req),
+ blk_rq_cur_sectors(req),
+ req->buffer); break; } + done: + if (__blk_end_request_cur(req, err)) + goto again; } }
MBR, Sergei
Re: [PATCH 11/18] swim: dequeue in-flight request
Quoted 1 line · Sergei Shtylyov
And without duplication:
Similar response as the if/else one on the other thread. Is it really any significantly better? The 'duplication' here is basically one liner after the peek/fetch change and when the duplication is minimal, I usually find it clearer to put the loop condition at the while clause itself. If you think it's significantly better, please go ahead and submit the patch but to me the change you're proposing is basically cosmetic and not even a clearly better one at that.
Thanks.
Signature · 1 line
tejun
Re: [PATCH 11/18] swim: dequeue in-flight request
Hello.
Quoted 6 lines · Tejun Heo
Quoted 2 lines
And without duplication:
Similar response as the if/else one on the other thread. Is it really any significantly better? The 'duplication' here is basically one liner
Not true, it's 3-liner. I wouldn't bother with one liner.
Quoted 1 line
after the peek/fetch change
The peek/fetch code itself is duplicated. :-/
Quoted 3 lines
and when the duplication is minimal,
I usually find it clearer to put the loop condition at the while clause itself.
No problem, we could just keep an old form of *while* loop.
Quoted 1 line
If you think it's significantly better,
I do hink it avoids duplicating peek/fetch code.
Quoted 3 lines
please go ahead and submit the patch but to me the change you're proposing is basically cosmetic and not even a clearly better one at that.
Should probably look at the resulting assembly to see how much it's
differrent.
Quoted 1 line
Thanks.
WBR, Sergei
Re: [PATCH 15/18] z2ram: dequeue in-flight request
In reply to Sergei ShtylyovHello, I wrote:
Oops, sent this message only to Tejun before, so have to repost now...
Quoted 59 lines
Quoted 44 lines
z2ram processes requests one-by-one synchronously and can be easily converted to dequeueing model. Convert it.
[ Impact: dequeue in-flight request ]
Signed-off-by Tejun Heo <[email protected]>--- drivers/block/z2ram.c | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-)drivers/block/z2ram.c +9
-3@@ -70,15 +70,21 @@ static struct gendisk *z2ram_gendisk;static void do_z2_request (struct request_queue *q) {struct request *req; -while ((req =elv_next_request (q)) !=NULL ) { + + req =elv_next_request (q); +if (req) +blkdev_dequeue_request (req); + +while (req) {unsigned long start =blk_rq_pos (req) <<9 ;unsigned long len =blk_rq_cur_bytes (req); +int err =0 ;if (start + len > z2ram_size) { printk( KERN_ERR DEVICE_NAME ": bad access: block=%lu, count=%u\n", blk_rq_pos(req), blk_rq_cur_sectors(req)); -__blk_end_request_cur (req, -EIO ); -continue ; + err = -EIO ; + goto done; }while (len) {unsigned long addr = start & Z2RAM_CHUNKMASK;drivers/block/z2ram.c +0
-0@@ -93,7 +99,12 @@ static void do_z2_request(struct request_queue *q) start += size; len -= size; }drivers/block/z2ram.c static void do_z2_request(struct request_queue *q) · line 110
Quoted 10 lines
drivers/block/z2ram.c +6
-1-__blk_end_request_cur (req,0 ); + done: +if (!__blk_end_request_cur (req, err)) { + req =elv_next_request (q); +if (req) +blkdev_dequeue_request (req); + } } }I'm sure this can be made more compact and without duplication (in
many other cases as well):
drivers/block/z2ram.c static struct gendisk *z2ram_gendisk; · line 77
Quoted 8 lines
drivers/block/z2ram.c +1
-0@@ -70,15 +70,21 @@ static struct gendisk *z2ram_gendisk;static void do_z2_request (struct request_queue *q) {struct request *req; +while ((req =elv_next_request (q)) !=NULL ) {unsigned long start =blk_rq_pos (req) <<9 ;unsigned long len =blk_rq_cur_bytes (req);
Oops, missed:
+ int err;
+
drivers/block/z2ram.c static struct gendisk *z2ram_gendisk; · line 77
Quoted 3 lines
drivers/block/z2ram.c +2
-0+blkdev_dequeue_request (req); +
+again:
Quoted 12 lines
drivers/block/z2ram.c +2
-2if (start + len > z2ram_size) { printk( KERN_ERR DEVICE_NAME ": bad access: block=%lu, count=%u\n", blk_rq_pos(req), blk_rq_cur_sectors(req)); -__blk_end_request_cur (req, -EIO ); -continue ; + err = -EIO ; + goto done; }while (len) {unsigned long addr = start &Z2RAM_CHUNKMASK ;
drivers/block/z2ram.c static void do_z2_request(struct request_queue *q) · line 96
Quoted 4 lines
drivers/block/z2ram.c +0
-1@@ -93,7 +99,12 @@ static void do_z2_request(struct request_queue *q) start += size; len -= size; } -__blk_end_request_cur (req,0 );
+ err = 0;
Review static void do_z2_request(struct request_queue *q) · line 104
Quoted 3 lines
(quoted diff) +3
-0+ done: + if (__blk_end_request_cur(req, err)); + break;
Oops, should've been:
+ if (__blk_end_request_cur(req, err))
+ goto again;
Review static void do_z2_request(struct request_queue *q) · line 106
Quoted 2 lines
(quoted diff) +0
-0} }
It can also be:
@@ -70,15 +70,21 @@ static struct gendisk *z2ram_gendisk; static void do_z2_request(struct request_queue *q) {
- struct request *req;
- while ((req = elv_next_request(q)) != NULL) {
+ while (1) {
+ struct request *req = elv_next_request(q);
+ unsigned long start, len;
+ int err;+
+ if (req == NULL)
+ break;
+
+ blkdev_dequeue_request(req);
+
+again:
+ start = blk_rq_pos(req) << 9;
+ len = blk_rq_cur_bytes(req);
if (start + len > z2ram_size) {
printk( KERN_ERR DEVICE_NAME ": bad access: block=%lu,
count=%u\n",
blk_rq_pos(req), blk_rq_cur_sectors(req));
- __blk_end_request_cur(req, -EIO);
- continue;
+ err = -EIO;
+ goto done;
}
while (len) {
unsigned long addr = start & Z2RAM_CHUNKMASK;
@@ -93,7 +99,12 @@ static void do_z2_request(struct request_queue *q)
start += size;
len -= size;
}- __blk_end_request_cur(req, 0);
+ err = 0;
+ done:
+ if (__blk_end_request_cur(req, err))
+ goto again;
}
}
if you want to get rid of the assignement in the *while* statement...
MBR, Sergei
Re: [PATCH 11/18] swim: dequeue in-flight request
In reply to Sergei ShtylyovHello, Sergei.
Quoted 5 lines · Sergei Shtylyov
Quoted 3 lines
Similar response as the if/else one on the other thread. Is it really any significantly better? The 'duplication' here is basically one liner
Not true, it's 3-liner. I wouldn't bother with one liner.
The final result is...
req = blk_fetch_request(q);
while (req) {
int err = -EIO;That looks like one liner to me.
Quoted 3 lines
Quoted 1 line
after the peek/fetch change
The peek/fetch code itself is duplicated. :-/
Do you mean by inlining? Please note that blk_fetch_request() is not inlined anymore after Fujita's bidi end_request cleanup patches.
Quoted 8 lines
Quoted 3 lines
and when the duplication is minimal,
I usually find it clearer to put the loop condition at the while clause itself.No problem, we could just keep an old form of *while* loop.
Quoted 1 line
If you think it's significantly better,
Quoted 8 lines
I do hink it avoids duplicating peek/fetch code.
Quoted 3 lines
please go ahead and submit the patch but to me the change you're proposing is
basically cosmetic and not even a clearly better one at that.Should probably look at the resulting assembly to see how much it's differrent.
Do you seriously think it's worthwhile to optimize the request loop according to assembly generation? That sounds like a bad case of over (micro) optimization to me. It's not gonna make any noticeable difference and the changes you make today can be irrelevant or even deterimental tomorrow depending on any number of parameters. Please don't do it for performance reasons.
Thanks.
Signature · 1 line
tejun