Re: Proposed changes to generic blk tag for use in SCSI (1/3)

James Bottomley
2002-06-11T16:39:50Z

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>[<<C*4K1\=%:^">Z*$1L5!>T4C9*MH=@E
M%6X7ABSA]9Q>,F<C8MQC]5RS\?;Z_+"I:7M[<-RE48==,0%[>YJ(DR$-/'Y`
M13>(HY)(:,1#)FC)C</)3'1B$&+@GZU73&([$]TA5F7BZIZN4TMG'C&LJF/-
MM4EK-^MR2(W84M_$L&NFK9V`7K*J-2!&F3AE70>=U$VKKE>*Q*H3`M+U@Y7H
MP!\&%(EV!#_7BV/-A<]'YV=P?OBIT?R"3_BAG@=M/_(`8P[M0>0*/XYV<?AV
MP`6XB2]8XE-HQXF4Z/A1!W#MD$8>+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<RUJ5,Q
M:J1BMF^,]09NTKA@7968AJ:MU;"*SFP2HE,E3J&S1A;0:=1-LT[LC>@TMXK.
MC\<?,FPF+(R'#-#O5G_`!JR%"&PE#.^YR!?`CZ!-A_$@@;B]("31+"7S!51Q
M&`3Q"&@TAFR>(@Z<*N*%*5S01&1S$--HIOX+,/WK\>*8ADTF1+<P]?O@T8"Y
M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