linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi_error: send the sense buffer down without copying
@ 2007-05-22 19:43 James Bottomley
  2007-05-23 14:51 ` Benny Halevy
  0 siblings, 1 reply; 2+ messages in thread
From: James Bottomley @ 2007-05-22 19:43 UTC (permalink / raw)
  To: linux-scsi

Now that the block submission path correctly bounces, we can simply
use the command sense_buffer to send to retrieve sense information and
junk the unnecessary page allocation.

James

Index: scsi-misc-2.6/drivers/scsi/scsi_error.c
===================================================================
--- scsi-misc-2.6.orig/drivers/scsi/scsi_error.c	2007-05-15 11:08:31.000000000 -0500
+++ scsi-misc-2.6/drivers/scsi/scsi_error.c	2007-05-22 14:38:49.000000000 -0500
@@ -18,12 +18,12 @@
 #include <linux/sched.h>
 #include <linux/timer.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/kthread.h>
 #include <linux/interrupt.h>
 #include <linux/blkdev.h>
 #include <linux/delay.h>
+#include <linux/scatterlist.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
@@ -640,16 +640,8 @@ static int scsi_send_eh_cmnd(struct scsi
 	memcpy(scmd->cmnd, cmnd, cmnd_size);
 
 	if (copy_sense) {
-		gfp_t gfp_mask = GFP_ATOMIC;
-
-		if (shost->hostt->unchecked_isa_dma)
-			gfp_mask |= __GFP_DMA;
-
-		sgl.page = alloc_page(gfp_mask);
-		if (!sgl.page)
-			return FAILED;
-		sgl.offset = 0;
-		sgl.length = 252;
+		sg_init_one(&sgl, scmd->sense_buffer,
+			    sizeof(scmd->sense_buffer));
 
 		scmd->sc_data_direction = DMA_FROM_DEVICE;
 		scmd->request_bufflen = sgl.length;
@@ -720,18 +712,6 @@ static int scsi_send_eh_cmnd(struct scsi
 
 
 	/*
-	 * Last chance to have valid sense data.
-	 */
-	if (copy_sense) {
-		if (!SCSI_SENSE_VALID(scmd)) {
-			memcpy(scmd->sense_buffer, page_address(sgl.page),
-			       sizeof(scmd->sense_buffer));
-		}
-		__free_page(sgl.page);
-	}
-
-
-	/*
 	 * Restore original data
 	 */
 	scmd->request_buffer = old_buffer;



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

* Re: [PATCH] scsi_error: send the sense buffer down without copying
  2007-05-22 19:43 [PATCH] scsi_error: send the sense buffer down without copying James Bottomley
@ 2007-05-23 14:51 ` Benny Halevy
  0 siblings, 0 replies; 2+ messages in thread
From: Benny Halevy @ 2007-05-23 14:51 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi

James Bottomley wrote:
> Now that the block submission path correctly bounces, we can simply
> use the command sense_buffer to send to retrieve sense information and
> junk the unnecessary page allocation.

Cool.  I like that :)

Benny

> 
> James
> 
> Index: scsi-misc-2.6/drivers/scsi/scsi_error.c
> ===================================================================
> --- scsi-misc-2.6.orig/drivers/scsi/scsi_error.c	2007-05-15 11:08:31.000000000 -0500
> +++ scsi-misc-2.6/drivers/scsi/scsi_error.c	2007-05-22 14:38:49.000000000 -0500
> @@ -18,12 +18,12 @@
>  #include <linux/sched.h>
>  #include <linux/timer.h>
>  #include <linux/string.h>
> -#include <linux/slab.h>
>  #include <linux/kernel.h>
>  #include <linux/kthread.h>
>  #include <linux/interrupt.h>
>  #include <linux/blkdev.h>
>  #include <linux/delay.h>
> +#include <linux/scatterlist.h>
>  
>  #include <scsi/scsi.h>
>  #include <scsi/scsi_cmnd.h>
> @@ -640,16 +640,8 @@ static int scsi_send_eh_cmnd(struct scsi
>  	memcpy(scmd->cmnd, cmnd, cmnd_size);
>  
>  	if (copy_sense) {
> -		gfp_t gfp_mask = GFP_ATOMIC;
> -
> -		if (shost->hostt->unchecked_isa_dma)
> -			gfp_mask |= __GFP_DMA;
> -
> -		sgl.page = alloc_page(gfp_mask);
> -		if (!sgl.page)
> -			return FAILED;
> -		sgl.offset = 0;
> -		sgl.length = 252;
> +		sg_init_one(&sgl, scmd->sense_buffer,
> +			    sizeof(scmd->sense_buffer));
>  
>  		scmd->sc_data_direction = DMA_FROM_DEVICE;
>  		scmd->request_bufflen = sgl.length;
> @@ -720,18 +712,6 @@ static int scsi_send_eh_cmnd(struct scsi
>  
>  
>  	/*
> -	 * Last chance to have valid sense data.
> -	 */
> -	if (copy_sense) {
> -		if (!SCSI_SENSE_VALID(scmd)) {
> -			memcpy(scmd->sense_buffer, page_address(sgl.page),
> -			       sizeof(scmd->sense_buffer));
> -		}
> -		__free_page(sgl.page);
> -	}
> -
> -
> -	/*
>  	 * Restore original data
>  	 */
>  	scmd->request_buffer = old_buffer;
> 
> 



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

end of thread, other threads:[~2007-05-23 14:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-22 19:43 [PATCH] scsi_error: send the sense buffer down without copying James Bottomley
2007-05-23 14:51 ` Benny Halevy

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).