linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 19/33] scsi_debug: support sg chaining
  2007-07-16  9:47 [PATCH 00/33] SG table chaining support Jens Axboe
@ 2007-07-16  9:47 ` Jens Axboe
  2007-09-08 14:53   ` Douglas Gilbert
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2007-07-16  9:47 UTC (permalink / raw)
  To: linux-kernel, linux-scsi; +Cc: Jens Axboe, dgilbert

Cc: dgilbert@interlog.com
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
---
 drivers/scsi/scsi_debug.c |   30 ++++++++++++++++--------------
 1 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 4cd9c58..46a3e07 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -38,6 +38,7 @@
 #include <linux/proc_fs.h>
 #include <linux/vmalloc.h>
 #include <linux/moduleparam.h>
+#include <linux/scatterlist.h>
 
 #include <linux/blkdev.h>
 #include "scsi.h"
@@ -600,7 +601,7 @@ static int fill_from_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
 	int k, req_len, act_len, len, active;
 	void * kaddr;
 	void * kaddr_off;
-	struct scatterlist * sgpnt;
+	struct scatterlist * sg;
 
 	if (0 == scp->request_bufflen)
 		return 0;
@@ -619,16 +620,16 @@ static int fill_from_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
 			scp->resid = req_len - act_len;
 		return 0;
 	}
-	sgpnt = (struct scatterlist *)scp->request_buffer;
 	active = 1;
-	for (k = 0, req_len = 0, act_len = 0; k < scp->use_sg; ++k, ++sgpnt) {
+	req_len = act_len = 0;
+	scsi_for_each_sg(scp, sg, scp->use_sg, k) {
 		if (active) {
 			kaddr = (unsigned char *)
-				kmap_atomic(sgpnt->page, KM_USER0);
+				kmap_atomic(sg->page, KM_USER0);
 			if (NULL == kaddr)
 				return (DID_ERROR << 16);
-			kaddr_off = (unsigned char *)kaddr + sgpnt->offset;
-			len = sgpnt->length;
+			kaddr_off = (unsigned char *)kaddr + sg->offset;
+			len = sg->length;
 			if ((req_len + len) > arr_len) {
 				active = 0;
 				len = arr_len - req_len;
@@ -637,7 +638,7 @@ static int fill_from_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
 			kunmap_atomic(kaddr, KM_USER0);
 			act_len += len;
 		}
-		req_len += sgpnt->length;
+		req_len += sg->length;
 	}
 	if (scp->resid)
 		scp->resid -= act_len;
@@ -653,7 +654,7 @@ static int fetch_to_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
 	int k, req_len, len, fin;
 	void * kaddr;
 	void * kaddr_off;
-	struct scatterlist * sgpnt;
+	struct scatterlist * sg;
 
 	if (0 == scp->request_bufflen)
 		return 0;
@@ -668,13 +669,14 @@ static int fetch_to_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
 		memcpy(arr, scp->request_buffer, len);
 		return len;
 	}
-	sgpnt = (struct scatterlist *)scp->request_buffer;
-	for (k = 0, req_len = 0, fin = 0; k < scp->use_sg; ++k, ++sgpnt) {
-		kaddr = (unsigned char *)kmap_atomic(sgpnt->page, KM_USER0);
+	sg = scsi_sglist(scp);
+	req_len = fin = 0;
+	for (k = 0; k < scp->use_sg; ++k, sg = sg_next(sg)) {
+		kaddr = (unsigned char *)kmap_atomic(sg->page, KM_USER0);
 		if (NULL == kaddr)
 			return -1;
-		kaddr_off = (unsigned char *)kaddr + sgpnt->offset;
-		len = sgpnt->length;
+		kaddr_off = (unsigned char *)kaddr + sg->offset;
+		len = sg->length;
 		if ((req_len + len) > max_arr_len) {
 			len = max_arr_len - req_len;
 			fin = 1;
@@ -683,7 +685,7 @@ static int fetch_to_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
 		kunmap_atomic(kaddr, KM_USER0);
 		if (fin)
 			return req_len + len;
-		req_len += sgpnt->length;
+		req_len += sg->length;
 	}
 	return req_len;
 }
-- 
1.5.3.rc0.90.gbaa79


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 19/33] scsi_debug: support sg chaining
@ 2007-07-17 13:40 Boaz Harrosh
  2007-07-17 14:11 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Boaz Harrosh @ 2007-07-17 13:40 UTC (permalink / raw)
  To: Jens Axboe, James Bottomley, FUJITA Tomonori, linux-scsi,
	dgilbert

Jens Axboe wrote ...
> Cc: dgilbert@interlog.com
> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
> ---
>  drivers/scsi/scsi_debug.c |   30 ++++++++++++++++--------------
>  1 files changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index 4cd9c58..46a3e07 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c

(Majordumo has unsubscribed me from list since yesterday)
(Don't know why. So this will appear out of order       )

Jens Hi!

I have queued for submission a: 
"convert to use the data buffer accessors and !use_sg cleanup"
for this driver Just the other day. Should we not push the 
cleanups first before this. That is what we did with other
drivers.

I have also sent patches for ide-scsi

I Have in my Q cleanup patches for:
drivers/scsi/qla1280.c
drivers/scsi/qlogicpti.c
drivers/scsi/aha1542.c
drivers/scsi/advansys.c
And more ...

And also for this one
drivers/scsi/gdth.c
But that one has a patch in Q and I should rebase.

If you want I can rebase all your driver patches above
to my patches. Than send cleanup patches to the list and
rebasing of sg-chaining if needed to you. I can send all
cleanup patches tonight, and your rebases tomorrow.

Boaz


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 19/33] scsi_debug: support sg chaining
  2007-07-17 13:40 [PATCH 19/33] scsi_debug: support sg chaining Boaz Harrosh
@ 2007-07-17 14:11 ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2007-07-17 14:11 UTC (permalink / raw)
  To: Boaz Harrosh; +Cc: James Bottomley, FUJITA Tomonori, linux-scsi, dgilbert

On Tue, Jul 17 2007, Boaz Harrosh wrote:
> Jens Axboe wrote ...
> > Cc: dgilbert@interlog.com
> > Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
> > ---
> >  drivers/scsi/scsi_debug.c |   30 ++++++++++++++++--------------
> >  1 files changed, 16 insertions(+), 14 deletions(-)
> > 
> > diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> > index 4cd9c58..46a3e07 100644
> > --- a/drivers/scsi/scsi_debug.c
> > +++ b/drivers/scsi/scsi_debug.c
> 
> (Majordumo has unsubscribed me from list since yesterday)
> (Don't know why. So this will appear out of order       )
> 
> Jens Hi!
> 
> I have queued for submission a: 
> "convert to use the data buffer accessors and !use_sg cleanup"
> for this driver Just the other day. Should we not push the 
> cleanups first before this. That is what we did with other
> drivers.
> 
> I have also sent patches for ide-scsi
> 
> I Have in my Q cleanup patches for:
> drivers/scsi/qla1280.c
> drivers/scsi/qlogicpti.c
> drivers/scsi/aha1542.c
> drivers/scsi/advansys.c
> And more ...
> 
> And also for this one
> drivers/scsi/gdth.c
> But that one has a patch in Q and I should rebase.
> 
> If you want I can rebase all your driver patches above
> to my patches. Than send cleanup patches to the list and
> rebasing of sg-chaining if needed to you. I can send all
> cleanup patches tonight, and your rebases tomorrow.

Go ahead and submit whatever driver cleanups, I'll just rebase and drop
patches from my branch as necessary! Less work for me :-)

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 19/33] scsi_debug: support sg chaining
  2007-07-16  9:47 ` [PATCH 19/33] scsi_debug: support sg chaining Jens Axboe
@ 2007-09-08 14:53   ` Douglas Gilbert
  0 siblings, 0 replies; 4+ messages in thread
From: Douglas Gilbert @ 2007-09-08 14:53 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-scsi, FUJITA Tomonori

Jens Axboe wrote:
> Cc: dgilbert@interlog.com
> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
> ---
>  drivers/scsi/scsi_debug.c |   30 ++++++++++++++++--------------
>  1 files changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index 4cd9c58..46a3e07 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -38,6 +38,7 @@
>  #include <linux/proc_fs.h>
>  #include <linux/vmalloc.h>
>  #include <linux/moduleparam.h>
> +#include <linux/scatterlist.h>
>  
>  #include <linux/blkdev.h>
>  #include "scsi.h"
> @@ -600,7 +601,7 @@ static int fill_from_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
>  	int k, req_len, act_len, len, active;
>  	void * kaddr;
>  	void * kaddr_off;
> -	struct scatterlist * sgpnt;
> +	struct scatterlist * sg;
>  
>  	if (0 == scp->request_bufflen)
>  		return 0;
> @@ -619,16 +620,16 @@ static int fill_from_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
>  			scp->resid = req_len - act_len;
>  		return 0;
>  	}
> -	sgpnt = (struct scatterlist *)scp->request_buffer;
>  	active = 1;
> -	for (k = 0, req_len = 0, act_len = 0; k < scp->use_sg; ++k, ++sgpnt) {
> +	req_len = act_len = 0;
> +	scsi_for_each_sg(scp, sg, scp->use_sg, k) {
>  		if (active) {
>  			kaddr = (unsigned char *)
> -				kmap_atomic(sgpnt->page, KM_USER0);
> +				kmap_atomic(sg->page, KM_USER0);
>  			if (NULL == kaddr)
>  				return (DID_ERROR << 16);
> -			kaddr_off = (unsigned char *)kaddr + sgpnt->offset;
> -			len = sgpnt->length;
> +			kaddr_off = (unsigned char *)kaddr + sg->offset;
> +			len = sg->length;
>  			if ((req_len + len) > arr_len) {
>  				active = 0;
>  				len = arr_len - req_len;
> @@ -637,7 +638,7 @@ static int fill_from_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
>  			kunmap_atomic(kaddr, KM_USER0);
>  			act_len += len;
>  		}
> -		req_len += sgpnt->length;
> +		req_len += sg->length;
>  	}
>  	if (scp->resid)
>  		scp->resid -= act_len;
> @@ -653,7 +654,7 @@ static int fetch_to_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
>  	int k, req_len, len, fin;
>  	void * kaddr;
>  	void * kaddr_off;
> -	struct scatterlist * sgpnt;
> +	struct scatterlist * sg;
>  
>  	if (0 == scp->request_bufflen)
>  		return 0;
> @@ -668,13 +669,14 @@ static int fetch_to_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
>  		memcpy(arr, scp->request_buffer, len);
>  		return len;
>  	}
> -	sgpnt = (struct scatterlist *)scp->request_buffer;
> -	for (k = 0, req_len = 0, fin = 0; k < scp->use_sg; ++k, ++sgpnt) {
> -		kaddr = (unsigned char *)kmap_atomic(sgpnt->page, KM_USER0);
> +	sg = scsi_sglist(scp);
> +	req_len = fin = 0;
> +	for (k = 0; k < scp->use_sg; ++k, sg = sg_next(sg)) {
> +		kaddr = (unsigned char *)kmap_atomic(sg->page, KM_USER0);
>  		if (NULL == kaddr)
>  			return -1;
> -		kaddr_off = (unsigned char *)kaddr + sgpnt->offset;
> -		len = sgpnt->length;
> +		kaddr_off = (unsigned char *)kaddr + sg->offset;
> +		len = sg->length;
>  		if ((req_len + len) > max_arr_len) {
>  			len = max_arr_len - req_len;
>  			fin = 1;
> @@ -683,7 +685,7 @@ static int fetch_to_dev_buffer(struct scsi_cmnd * scp, unsigned char * arr,
>  		kunmap_atomic(kaddr, KM_USER0);
>  		if (fin)
>  			return req_len + len;
> -		req_len += sgpnt->length;
> +		req_len += sg->length;
>  	}
>  	return req_len;
>  }

Signed-off-by: Douglas Gilbert <dougg@torque.net>


In a post titled: "Re: [PATCH 4/9] scsi_debug: convert to
                   use the data buffer accessors"
FUJITA Tomonori wrote:
> On Fri, 07 Sep 2007 15:12:06 -0400
> Douglas Gilbert <dougg@torque.net> wrote:
>
>> FUJITA Tomonori wrote:
>>> From: Boaz Harrosh <bharrosh@panasas.com>
>>>
>>> - remove the unnecessary map_single path.
>>>
>>> - convert to use the new accessors for the sg lists and the
>>> parameters.
>>>
>>> Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
>> Signed-off-by: Douglas Gilbert <dougg@torque.net>
>
> This patch is on the top of the following patch:
>
> http://git.kernel.org/?p=linux/kernel/git/axboe/linux-2.6-block.git;a=commitdiff;h=63499aaafa6ec0c107a925574c2af84a2cd86703
>
> Can we get your ACK on this too?

Done.

> Probably, it would be fine to integrate these patches.

Yes that is fine.

When the dust settles, I can send a patch of my various mode
and log pages additions to scsi_debug in my working copy.

Doug Gilbert


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-09-08 14:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-17 13:40 [PATCH 19/33] scsi_debug: support sg chaining Boaz Harrosh
2007-07-17 14:11 ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2007-07-16  9:47 [PATCH 00/33] SG table chaining support Jens Axboe
2007-07-16  9:47 ` [PATCH 19/33] scsi_debug: support sg chaining Jens Axboe
2007-09-08 14:53   ` Douglas Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).