From mboxrd@z Thu Jan 1 00:00:00 1970 From: James Bottomley Subject: Re: Proposed changes to generic blk tag for use in SCSI (1/3) Date: Tue, 11 Jun 2002 12:39:43 -0400 Sender: linux-scsi-owner@vger.kernel.org Message-ID: <200206111639.g5BGdh509698@localhost.localdomain> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: (from root@localhost) by pogo.mtv1.steeleye.com (8.9.3/8.9.3) id JAA18976 for ; Tue, 11 Jun 2002 09:39:50 -0700 In-Reply-To: Message from Jens Axboe of "Tue, 11 Jun 2002 16:45:06 +0200." <20020611144506.GI1117@suse.de> List-Id: linux-scsi@vger.kernel.org To: Jens Axboe Cc: James Bottomley , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org OK, this is the new patch with all the changes. I didn't alter the IDE blk_queue_start_tag() to check for a REQ_CMD, since you said you would do that. James You can import this changeset into BK by piping this whole message to: '| bk receive [path to repository]' or apply the patch as usual. =================================================================== ChangeSet@1.490, 2002-06-11 12:33:05-04:00, jejb@mulgrave.(none) [BLK TCQ] remove blk_queue_tag_request() in favour of blk_queue_find_tag() Allow any request type into blk_queue_start_tag() ChangeSet@1.489, 2002-06-11 10:34:17-04:00, jejb@mulgrave.(none) [BLK LAYER] add find tag function, adjust criteria for tagging commands. drivers/block/ll_rw_blk.c | 40 ++++++++++++++++++++++++++++++++++------ drivers/ide/tcq.c | 2 +- include/linux/blkdev.h | 2 +- 3 files changed, 36 insertions(+), 8 deletions(-) diff -Nru a/drivers/block/ll_rw_blk.c b/drivers/block/ll_rw_blk.c --- a/drivers/block/ll_rw_blk.c Tue Jun 11 12:38:12 2002 +++ b/drivers/block/ll_rw_blk.c Tue Jun 11 12:38:12 2002 @@ -297,6 +297,27 @@ } /** + * blk_queue_find_tag - find a request by its tag and queue + * + * @q: The request queue for the device + * @tag: The tag of the request + * + * Notes: + * Should be used when a device returns a tag and you want to match + * it with a request. + * + * no locks need be held. + **/ +struct request *blk_queue_find_tag(request_queue_t *q, int tag) +{ + struct blk_queue_tag *bqt = q->queue_tags; + + if(unlikely(bqt == NULL || bqt->max_depth < tag)) + return NULL; + + return bqt->tag_index[tag]; +} +/** * blk_queue_free_tags - release tag maintenance info * @q: the request queue for the device * @@ -429,10 +450,12 @@ * Description: * This can either be used as a stand-alone helper, or possibly be * assigned as the queue &prep_rq_fn (in which case &struct request - * automagically gets a tag assigned). Note that this function assumes - * that only REQ_CMD requests can be queued! The request will also be - * removed from the request queue, so it's the drivers responsibility to - * readd it if it should need to be restarted for some reason. + * automagically gets a tag assigned). Note that this function + * assumes that any type of request can be queued! if this is not + * true for your device, you must check the request type before + * calling this function. The request will also be removed from + * the request queue, so it's the drivers responsibility to readd + * it if it should need to be restarted for some reason. * * Notes: * queue lock must be held. @@ -443,8 +466,12 @@ unsigned long *map = bqt->tag_map; int tag = 0; - if (unlikely(!(rq->flags & REQ_CMD))) - return 1; + if (unlikely((rq->flags & REQ_QUEUED))) { + printk(KERN_ERR + "request %p for device [02%x:02%x] already tagged %d", + rq, major(rq->rq_dev), minor(rq->rq_dev), rq->tag); + BUG(); + } for (map = bqt->tag_map; *map == -1UL; map++) { tag += BLK_TAGS_PER_LONG; @@ -2027,6 +2054,7 @@ EXPORT_SYMBOL(blk_queue_prep_rq); +EXPORT_SYMBOL(blk_queue_find_tag); EXPORT_SYMBOL(blk_queue_init_tags); EXPORT_SYMBOL(blk_queue_free_tags); EXPORT_SYMBOL(blk_queue_start_tag); diff -Nru a/drivers/ide/tcq.c b/drivers/ide/tcq.c --- a/drivers/ide/tcq.c Tue Jun 11 12:38:12 2002 +++ b/drivers/ide/tcq.c Tue Jun 11 12:38:12 2002 @@ -282,7 +282,7 @@ TCQ_PRINTK("%s: stat %x, feat %x\n", __FUNCTION__, stat, feat); - rq = blk_queue_tag_request(&drive->queue, tag); + rq = blk_queue_find_tag(&drive->queue, tag); if (!rq) { printk(KERN_ERR"%s: missing request for tag %d\n", __FUNCTION__, tag); return ide_stopped; diff -Nru a/include/linux/blkdev.h b/include/linux/blkdev.h --- a/include/linux/blkdev.h Tue Jun 11 12:38:12 2002 +++ b/include/linux/blkdev.h Tue Jun 11 12:38:12 2002 @@ -328,11 +328,11 @@ /* * tag stuff */ -#define blk_queue_tag_request(q, tag) ((q)->queue_tags->tag_index[(tag)]) #define blk_queue_tag_depth(q) ((q)->queue_tags->busy) #define blk_queue_tag_queue(q) ((q)->queue_tags->busy < (q)->queue_tags-> max_depth) #define blk_rq_tagged(rq) ((rq)->flags & REQ_QUEUED) extern int blk_queue_start_tag(request_queue_t *, struct request *); +extern struct request *blk_queue_find_tag(request_queue_t *, int); extern void blk_queue_end_tag(request_queue_t *, struct request *); extern int blk_queue_init_tags(request_queue_t *, int); extern void blk_queue_free_tags(request_queue_t *); =================================================================== This BitKeeper patch contains the following changesets: 1.489..1.490 ## Wrapped with gzip_uu ## begin 664 bkpatch9679 M'XL(`'0G!CT``\U8^W/:.!#^&?\5>^VT![D`\I-'+YF\F%XF:9J29N8ZO0ZC MV`*<^`&6@#!'__=;R>892IJT=,YA@BVO5OOX]M.*EW#-65+/W;+;&^TE_!5S M4<^%@Z"3T"$KY:,X8@4<;\8QCI>[<Z*$1L5!>T4C9*MH=@E M%6X7ABSA]9Q>,FYJ(DR$-/'Y` M13>(HY)(:,1#)FC)C=U$VKKE>*Q*H3`M+U@Y7H MP!\&%(EV!#_7BV/-A<]'YV=P?OBIT?R"3_BAG@=M/_(`8P[M0>0*/XYV+VEG8%B$U+3+>?"UXA,O32.4:/N/^.HE MOL0`(B1V[\I!T$I&+41+R5WP'4VQT'>G6IM43=UT+.+JAN>XMNFL#?-C2AU= MURW3THT)L:VJ_:B-?N0&`X^5`S\:W$LL>VQ8ZBXFIV:1B648IC6YH@TMXK. MC\(@Z<*N*%*5S01&1S$--HIOX+,/WK\>*8ADTF1+>".W'&V$(!D![O1WX0V-\' MDV\!?`87P['-%"Y5\T&_8FSN5\QMX47V)P^S,.M4)%!4^T)G!-]!=W&\RT#- MD3K2]B;=5`[3SF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