Skip to contentSkip to conversation

RFC] [PATCH] helper function for retrieving scsi_cmd given host based block layer tag

PATCH Applied David C Somayajulu 3 participants 10 messages Sep 19, 2006 – Oct 4, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

This was necessitated by the need for a function to get back to a scsi_cmnd, when an hba the posts its (corresponding) completion interrupt with a block layer tag as its reference.

---

 block/ll_rw_blk.c       |    7 +------
 include/linux/blkdev.h  |    8 ++++++++
 include/scsi/scsi_tcq.h |   20 ++++++++++++++++++++
 3 files changed, 29 insertions(+), 6 deletions(-)

39a4a2005c490d22a3e5c4430e5e71375615de73

block/ll_rw_blk.c +1 -6
index 556a3d3..4aea565 100644
@@ -837,12 +837,7 @@ EXPORT_SYMBOL(blk_queue_dma_alignment);
  **/
 struct request *blk_queue_find_tag(request_queue_t *q, int tag)
 {
-       struct blk_queue_tag *bqt = q->queue_tags;
-
-       if (unlikely(bqt == NULL || tag >= bqt->real_max_depth))
-               return NULL;
-
-       return bqt->tag_index[tag];
+       return blk_map_queue_find_tag(q->queue_tags, tag);
 }
 
 EXPORT_SYMBOL(blk_queue_find_tag);
include/linux/blkdev.h +8 -0
index 427b0d6..dd16ce9 100644
@@ -749,6 +749,14 @@ extern long blk_congestion_wait(int rw, 
 extern struct blk_queue_tag *blk_init_tags(int);
 extern void blk_free_tags(struct blk_queue_tag *);
 
+static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt, 
+                                               int tag)
+{
+       if (unlikely(bqt == NULL || tag >= bqt->real_max_depth))
+               return NULL;
+       return bqt->tag_index[tag];
+}
+
 extern void blk_rq_bio_prep(request_queue_t *, struct request *, struct bio *);
 extern int blkdev_issue_flush(struct block_device *, sector_t *);
 
include/scsi/scsi_tcq.h +20 -0
index d04d05a..1215ffe 100644
@@ -144,4 +144,24 @@ static inline int scsi_init_shared_tag_m
        return shost->bqt ? 0 : -ENOMEM;
 }
 
+/**
+ * scsi_host_find_tag - find the tagged command by host
+ * @shost: pointer to scsi host
+ * @tag: tag of the scsi_cmnd
+ *
+ * Notes:
+ *     Only works with tags allocated by the generic blk layer.
+ */
+static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost,
+                                               int tag)
+{
+        struct request *req;
+
+        if (tag != SCSI_NO_TAG) {
+               req = blk_map_queue_find_tag(shost->bqt, tag);
+               return req ? (struct scsi_cmnd *)req->special : NULL;
+       }
+       return NULL;
+}
+
 #endif /* _SCSI_SCSI_TCQ_H */
#1 lore raw

Re: [RFC] [PATCH] helper function for retrieving scsi_cmd given host based block layer tag

Quoted 3 lines · David C Somayajulu

This was necessitated by the need for a function to get back to a scsi_cmnd, when an hba the posts its (corresponding) completion interrupt with a block layer tag as its reference.

Regenerated the patch with reference to
git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-2.6-block.git
Also fixed tabs.

Here is the link to the same patch with reference scsi-misc just in case
( ftp://ftp.qlogic.com/outgoing/linux/iSCSI/upstream/5.00.05b10-k/blk_tag_helper_patch.txt )

---

 block/ll_rw_blk.c       |    7 +------
 include/linux/blkdev.h  |    8 ++++++++
 include/scsi/scsi_tcq.h |   20 ++++++++++++++++++++
 3 files changed, 29 insertions(+), 6 deletions(-)

f07bce89f5707f53a502543b47a95fea1b041084

block/ll_rw_blk.c +1 -6
index ddd9253..6c55467 100644
@@ -837,12 +837,7 @@ EXPORT_SYMBOL(blk_queue_dma_alignment);
  **/
 struct request *blk_queue_find_tag(request_queue_t *q, int tag)
 {
-	struct blk_queue_tag *bqt = q->queue_tags;
-
-	if (unlikely(bqt == NULL || tag >= bqt->real_max_depth))
-		return NULL;
-
-	return bqt->tag_index[tag];
+	return blk_map_queue_find_tag(q->queue_tags, tag);
 }
 
 EXPORT_SYMBOL(blk_queue_find_tag);
include/linux/blkdev.h +8 -0
index aafe827..924d05e 100644
@@ -747,6 +747,14 @@ extern int blk_queue_resize_tags(request
 extern void blk_queue_invalidate_tags(request_queue_t *);
 extern long blk_congestion_wait(int rw, long timeout);
 
+static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt, 
+						int tag)
+{
+	if (unlikely(bqt == NULL || tag >= bqt->real_max_depth))
+		return NULL;
+	return bqt->tag_index[tag];
+}
+
 extern void blk_rq_bio_prep(request_queue_t *, struct request *, struct bio *);
 extern int blkdev_issue_flush(struct block_device *, sector_t *);
 
include/scsi/scsi_tcq.h +20 -0
index e47e36a..1733b4d 100644
@@ -131,4 +131,24 @@ static inline struct scsi_cmnd *scsi_fin
 	return sdev->current_cmnd;
 }
 
+/**
+ * scsi_host_find_tag - find the tagged command by host
+ * @shost: pointer to scsi_host
+ * @tag: tag of the scsi_cmnd
+ *
+ * Notes:
+ *	Only works with tags allocated by the generic blk layer.
+ **/
+static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost,
+						int tag)
+{
+	struct request *req;
+
+	if (tag != SCSI_NO_TAG) {
+		req = blk_map_queue_find_tag(shost->bqt, tag);
+		return req ? (struct scsi_cmnd *)req->special : NULL;
+	}
+	return NULL;
+}
+
 #endif /* _SCSI_SCSI_TCQ_H */
maintainer
#2 lore raw

Re: [RFC] [PATCH] helper function for retrieving scsi_cmd given host based block layer tag

Quoted 8 lines · David C Somayajulu
Quoted 3 lines · David C Somayajulu

This was necessitated by the need for a function to get back to a scsi_cmnd, when an hba the posts its (corresponding) completion interrupt with a block layer tag as its reference.

Regenerated the patch with reference to
git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-2.6-block.git
Also fixed tabs.

Quoted 5 lines

Here is the link to the same patch with reference scsi-misc just in case
( ftp://ftp.qlogic.com/outgoing/linux/iSCSI/upstream/5.00.05b10-k/blk_tag_helper_patch.txt )

It still fails for me:

axboe@nelson:/src/linux-2.6-block.git $ patch -p1 --dry-run < ~/1 patching file block/ll_rw_blk.c
Hunk #1 succeeded at 840 (offset 3 lines).
patching file include/linux/blkdev.h
Hunk #1 succeeded at 766 (offset 19 lines).
patching file include/scsi/scsi_tcq.h
Hunk #1 FAILED at 131.
1 out of 1 hunk FAILED -- saving rejects to file include/scsi/scsi_tcq.h.rej

I wonder if you are using the 'block' branch, not just the master branch? It seems to apply perfectly there, but that is just the same as Linus' tree. So when you have cloned the block git repo, there are a number of branches you can work against. The main branch with current changes is the 'block' branch, that is what you want to be making patches against.

I'll be away for the entire next week, so no rush on my end.

Signature · 1 line
Jens Axboe
#3 lore raw

Re: [RFC] [PATCH] helper function for retrieving scsi_cmd given host based block layer tag

Quoted 27 lines · Jens Axboe
Quoted 8 lines · David C Somayajulu
Quoted 3 lines · David C Somayajulu

This was necessitated by the need for a function to get back to a scsi_cmnd, when an hba the posts its (corresponding) completion interrupt with a block layer tag as its reference.

Regenerated the patch with reference to
git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-2.6-block.git
Also fixed tabs.

Quoted 5 lines

Here is the link to the same patch with reference scsi-misc just in case
( ftp://ftp.qlogic.com/outgoing/linux/iSCSI/upstream/5.00.05b10-k/blk_tag_helper_patch.txt )

It still fails for me:

axboe@nelson:/src/linux-2.6-block.git $ patch -p1 --dry-run < ~/1 patching file block/ll_rw_blk.c
Hunk #1 succeeded at 840 (offset 3 lines).
patching file include/linux/blkdev.h
Hunk #1 succeeded at 766 (offset 19 lines).
patching file include/scsi/scsi_tcq.h
Hunk #1 FAILED at 131.
1 out of 1 hunk FAILED -- saving rejects to file include/scsi/scsi_tcq.h.rej

Quoted 9 lines

I wonder if you are using the 'block' branch, not just the master branch? It seems to apply perfectly there, but that is just the same as Linus' tree. So when you have cloned the block git repo, there are a number of branches you can work against. The main branch with current changes is the 'block' branch, that is what you want to be making patches against.

I'll be away for the entire next week, so no rush on my end.

I think I got it right this time. Here it is.
Thanks
David Somayajulu

---

block/ll_rw_blk.c +1 -6
index 4475fa4..a4a72bd 100644
@@ -840,12 +840,7 @@ EXPORT_SYMBOL(blk_queue_dma_alignment);
  **/
 struct request *blk_queue_find_tag(request_queue_t *q, int tag)
 {
-	struct blk_queue_tag *bqt = q->queue_tags;
-
-	if (unlikely(bqt == NULL || tag >= bqt->real_max_depth))
-		return NULL;
-
-	return bqt->tag_index[tag];
+	return blk_map_queue_find_tag(q->queue_tags, tag);
 }
 
 EXPORT_SYMBOL(blk_queue_find_tag);
include/linux/blkdev.h +8 -0
index c55d470..10fd39d 100644
@@ -766,6 +766,14 @@ extern int blk_queue_resize_tags(request
 extern void blk_queue_invalidate_tags(request_queue_t *);
 extern long blk_congestion_wait(int rw, long timeout);
 
+static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt,
+						int tag)
+{
+	if (unlikely(bqt == NULL || tag >= bqt->real_max_depth))
+		return NULL;
+	return bqt->tag_index[tag];
+}
+
 extern void blk_rq_bio_prep(request_queue_t *, struct request *, struct bio *);
 extern int blkdev_issue_flush(struct block_device *, sector_t *);
 
include/scsi/scsi_tcq.h +20 -0
index d1d9b10..01b7481 100644
@@ -131,5 +131,25 @@ static inline struct scsi_cmnd *scsi_fin
 	return sdev->current_cmnd;
 }
 
+/**
+ * scsi_host_find_tag - find the tagged command by host
+ * @shost:	pointer to scsi_host
+ * @tag:	tag of the scsi_cmnd
+ *
+ * Notes:
+ *	Only works with tags allocated by the generic blk layer.
+ **/
+static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost,
+						int tag)
+{
+	struct request *req;
+
+	if (tag != SCSI_NO_TAG) {
+		req = blk_map_queue_find_tag(shost->bqt, tag);
+		return req ? (struct scsi_cmnd *)req->special : NULL;
+	}
+	return NULL;
+}
+
 #endif /* CONFIG_BLOCK */
 #endif /* _SCSI_SCSI_TCQ_H */

---

#4 lore raw

RE: [RFC] [PATCH] helper function for retrieving scsi_cmd given host based block layer tag

Quoted 1 line

From: [email protected]

[mailto:[email protected]] On Behalf Of David C

Quoted 4 lines

Somayajulu
Sent: Friday, September 22, 2006 3:01 PM
To: Jens Axboe
Cc: James Bottomley; [email protected]; Mike Christie; Doug

Maxey; David Wagner

Quoted 2 lines
Quoted 2 lines

I wonder if you are using the 'block' branch, not just the master branch? It seems to apply perfectly there, but that is just the same

as

Quoted 2 lines
Quoted 2 lines

Linus' tree. So when you have cloned the block git repo, there are a number of branches you can work against. The main branch with

current

Quoted 8 lines
Quoted 5 lines

changes is the 'block' branch, that is what you want to be making patches against.

I'll be away for the entire next week, so no rush on my end.

I think I got it right this time. Here it is.
Thanks
David Somayajulu

Jens,
I would appreciate if you can let me know if the last post of the above patch was acceptable.
Thanks
David Somayajulu

Quoted 25 lines

---

block/ll_rw_blk.c +1 -6
index 4475fa4..a4a72bd 100644
@@ -840,12 +840,7 @@ EXPORT_SYMBOL(blk_queue_dma_alignment);
  **/
 struct request *blk_queue_find_tag(request_queue_t *q, int tag)
 {
-	struct blk_queue_tag *bqt = q->queue_tags;
-
-	if (unlikely(bqt == NULL || tag >= bqt->real_max_depth))
-		return NULL;
-
-	return bqt->tag_index[tag];
+	return blk_map_queue_find_tag(q->queue_tags, tag);
 }
 
 EXPORT_SYMBOL(blk_queue_find_tag);
include/linux/blkdev.h +0 -0
index c55d470..10fd39d 100644

include/linux/blkdev.h extern int blk_queue_resize_tags(request · line 769

Quoted 4 lines
include/linux/blkdev.h +1 -0
@@ -766,6 +766,14 @@ extern int blk_queue_resize_tags(request
 extern void blk_queue_invalidate_tags(request_queue_t *);
 extern long blk_congestion_wait(int rw, long timeout);
 
+static inline struct request *blk_map_queue_find_tag(struct

blk_queue_tag *bqt,

include/linux/blkdev.h extern int blk_queue_resize_tags(request

Quoted 8 lines
include/linux/blkdev.h +7 -0
+						int tag)
+{
+	if (unlikely(bqt == NULL || tag >= bqt->real_max_depth))
+		return NULL;
+	return bqt->tag_index[tag];
+}
+
 extern void blk_rq_bio_prep(request_queue_t *, struct request *,

struct bio *);

Quoted 9 lines
include/linux/blkdev.h +0 -0
 extern int blkdev_issue_flush(struct block_device *, sector_t *);
 
include/scsi/scsi_tcq.h +0 -0
index d1d9b10..01b7481 100644
@@ -131,5 +131,25 @@ static inline struct scsi_cmnd *scsi_fin
 	return sdev->current_cmnd;
 }

include/scsi/scsi_tcq.h static inline struct scsi_cmnd *scsi_fin · line 142

Quoted 10 lines
include/scsi/scsi_tcq.h +9 -0
 
+/**
+ * scsi_host_find_tag - find the tagged command by host
+ * @shost:	pointer to scsi_host
+ * @tag:	tag of the scsi_cmnd
+ *
+ * Notes:
+ *	Only works with tags allocated by the generic blk layer.
+ **/
+static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host

*shost,

Quoted 14 lines
include/scsi/scsi_tcq.h +11 -0
+						int tag)
+{
+	struct request *req;
+
+	if (tag != SCSI_NO_TAG) {
+		req = blk_map_queue_find_tag(shost->bqt, tag);
+		return req ? (struct scsi_cmnd *)req->special : NULL;
+	}
+	return NULL;
+}
+
 #endif /* CONFIG_BLOCK */
 #endif /* _SCSI_SCSI_TCQ_H */
#5 lore raw

Re: [RFC] [PATCH] helper function for retrieving scsi_cmd given host based block layer tag

Quoted 16 lines · David Somayajulu
Quoted 1 line

From: [email protected]

[mailto:[email protected]] On Behalf Of David C

Quoted 4 lines

Somayajulu
Sent: Friday, September 22, 2006 3:01 PM
To: Jens Axboe
Cc: James Bottomley; [email protected]; Mike Christie; Doug

Maxey; David Wagner

Quoted 2 lines
Quoted 2 lines

I wonder if you are using the 'block' branch, not just the master branch? It seems to apply perfectly there, but that is just the same

as

Quoted 2 lines
Quoted 2 lines

Linus' tree. So when you have cloned the block git repo, there are a number of branches you can work against. The main branch with

current

Quoted 3 lines
Quoted 3 lines

changes is the 'block' branch, that is what you want to be making patches against.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I'll be away for the entire next week, so no rush on my end.

I think I got it right this time. Here it is.
Thanks
David Somayajulu

Jens,
I would appreciate if you can let me know if the last post of the above patch was acceptable.

The content and indentation looks good, but it doesn't apply to the current tree. Care to rediff it?

Signature · 1 line
Jens Axboe
#6 lore raw

RE: [RFC] [PATCH] helper function for retrieving scsi_cmd given host based block layer tag

Quoted 8 lines

-----Original Message-----
From: Jens Axboe [mailto:[email protected]]
Sent: Tuesday, October 03, 2006 12:10 PM
To: David Somayajulu
Cc: [email protected]; Mike Christie; David Wagner
Subject: Re: [RFC] [PATCH] helper function for retrieving scsi_cmd

given host based block layer tag

Quoted 8 lines · David Somayajulu
Quoted 6 lines
Quoted 1 line

From: [email protected]

[mailto:[email protected]] On Behalf Of David C

Quoted 4 lines

Somayajulu
Sent: Friday, September 22, 2006 3:01 PM
To: Jens Axboe
Cc: James Bottomley; [email protected]; Mike Christie;

Doug

Quoted 2 lines
Quoted 2 lines

Maxey; David Wagner

Quoted 1 line
Quoted 1 line

I wonder if you are using the 'block' branch, not just the

master

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

branch? It seems to apply perfectly there, but that is just the

same

Quoted 2 lines
Quoted 2 lines

as

Quoted 1 line
Quoted 1 line

Linus' tree. So when you have cloned the block git repo, there

are a

Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

number of branches you can work against. The main branch with

current

Quoted 1 line
Quoted 1 line

changes is the 'block' branch, that is what you want to be

making

Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines

patches against.

I'll be away for the entire next week, so no rush on my end.

I think I got it right this time. Here it is.
Thanks
David Somayajulu

Jens,
I would appreciate if you can let me know if the last post of the

above

Quoted 4 lines
Quoted 1 line

patch was acceptable.

The content and indentation looks good, but it doesn't apply to the current tree. Care to rediff it?

Thanks Jens. I will send this ASAP.

#7 lore raw

Re: [RFC] [PATCH] helper function for retrieving scsi_cmd given host based block layer tag

In reply to Jens Axboe
Quoted 2 lines · Jens Axboe

The content and indentation looks good, but it doesn't apply to the current tree. Care to rediff it?

Here it is. Thanks.

Date: Tue Oct 3 14:52:51 2006 -0700

---

 block/ll_rw_blk.c       |    7 +------
 include/linux/blkdev.h  |    8 ++++++++
 include/scsi/scsi_tcq.h |   20 ++++++++++++++++++++
 3 files changed, 29 insertions(+), 6 deletions(-)

fd6b37cdcd6db09207461f56eeebd377bab49d01

block/ll_rw_blk.c +1 -6
index 83425fb..c847e17 100644
@@ -840,12 +840,7 @@ EXPORT_SYMBOL(blk_queue_dma_alignment);
  **/
 struct request *blk_queue_find_tag(request_queue_t *q, int tag)
 {
-	struct blk_queue_tag *bqt = q->queue_tags;
-
-	if (unlikely(bqt == NULL || tag >= bqt->real_max_depth))
-		return NULL;
-
-	return bqt->tag_index[tag];
+	return blk_map_queue_find_tag(q->queue_tags, tag);
 }
 
 EXPORT_SYMBOL(blk_queue_find_tag);
include/linux/blkdev.h +8 -0
index 1d79b8d..26f7856 100644
@@ -769,6 +769,14 @@ extern struct blk_queue_tag *blk_init_ta
 extern void blk_free_tags(struct blk_queue_tag *);
 extern void blk_congestion_end(int rw);
 
+static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt,
+						int tag)
+{
+	if (unlikely(bqt == NULL || tag >= bqt->real_max_depth))
+		return NULL;
+	return bqt->tag_index[tag];
+}
+
 extern void blk_rq_bio_prep(request_queue_t *, struct request *, struct bio *);
 extern int blkdev_issue_flush(struct block_device *, sector_t *);
 
include/scsi/scsi_tcq.h +20 -0
index c247a28..cf4c219 100644
@@ -144,5 +144,25 @@ static inline int scsi_init_shared_tag_m
 	return shost->bqt ? 0 : -ENOMEM;
 }
 
+/**
+ * scsi_host_find_tag - find the tagged command by host
+ * @shost:	pointer to scsi_host
+ * @tag:	tag of the scsi_cmnd
+ *
+ * Notes:
+ *	Only works with tags allocated by the generic blk layer.
+ **/
+static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost,
+						int tag)
+{
+	struct request *req;
+
+	if (tag != SCSI_NO_TAG) {
+		req = blk_map_queue_find_tag(shost->bqt, tag);
+		return req ? (struct scsi_cmnd *)req->special : NULL;
+	}
+	return NULL;
+}
+
 #endif /* CONFIG_BLOCK */
 #endif /* _SCSI_SCSI_TCQ_H */
Applied
#8 lore raw

Re: [RFC] [PATCH] helper function for retrieving scsi_cmd given host based block layer tag

Quoted 4 lines · David C Somayajulu
Quoted 2 lines · Jens Axboe

The content and indentation looks good, but it doesn't apply to the current tree. Care to rediff it?

Here it is. Thanks.

Thanks, applied! It'll go upstream in a day or two.

Signature · 1 line
Jens Axboe
#9 lore raw

RE: [RFC] [PATCH] helper function for retrieving scsi_cmd given host based block layer tag

Quoted 5 lines

From: Jens Axboe [mailto:[email protected]]
Sent: Tuesday, October 03, 2006 11:28 PM

Quoted 2 lines · David C Somayajulu
Quoted 1 line · Jens Axboe

The content and indentation looks good, but it doesn't apply to

the

Quoted 4 lines
Quoted 2 lines
Quoted 1 line

current tree. Care to rediff it?

Here it is. Thanks.

Thanks, applied! It'll go upstream in a day or two.

Jens, Thank you very much.
-david S.