linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sg: add SG_FLAG_Q_AT_TAIL flag
@ 2014-06-04  1:36 Douglas Gilbert
  2014-06-04  8:58 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Douglas Gilbert @ 2014-06-04  1:36 UTC (permalink / raw)
  To: SCSI development list, Christoph Hellwig, James Bottomley; +Cc: openosd

[-- Attachment #1: Type: text/plain, Size: 714 bytes --]

When the SG_IO ioctl was copied into the block layer and
later into the bsg driver, subtle differences emerged.

One difference is the way injected commands are queued through
the block layer (i.e. this is not SCSI device queueing nor SATA
NCQ). Summarizing:
   - SG_IO in the block layer: blk_exec*(at_head=false)
   - sg SG_IO: at_head=true
   - bsg SG_IO: at_head=true

Some time ago Boaz Harrosh introduced a sg v4 flag called
BSG_FLAG_Q_AT_TAIL to override the bsg driver default.
This patch does the equivalent for the sg driver.

ChangeLog:
	Introduce SG_FLAG_Q_AT_TAIL flag to cause commands
	to be injected into the block layer with
	at_head=false.

Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>

[-- Attachment #2: sg_q_at_tail.patch --]
[-- Type: text/x-patch, Size: 1328 bytes --]

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 177f755..1b7d4f6 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -740,7 +740,7 @@ static int
 sg_common_write(Sg_fd * sfp, Sg_request * srp,
 		unsigned char *cmnd, int timeout, int blocking)
 {
-	int k, data_dir;
+	int k, data_dir, at_head;
 	Sg_device *sdp = sfp->parentdp;
 	sg_io_hdr_t *hp = &srp->header;
 
@@ -784,11 +784,12 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
 		break;
 	}
 	hp->duration = jiffies_to_msecs(jiffies);
+	at_head = !(hp->interface_id && (SG_FLAG_Q_AT_TAIL & hp->flags));
 
 	srp->rq->timeout = timeout;
 	kref_get(&sfp->f_ref); /* sg_rq_end_io() does kref_put(). */
 	blk_execute_rq_nowait(sdp->device->request_queue, sdp->disk,
-			      srp->rq, 1, sg_rq_end_io);
+			      srp->rq, at_head, sg_rq_end_io);
 	return 0;
 }
 
diff --git a/include/scsi/sg.h b/include/scsi/sg.h
index d8c0c43..9859355 100644
--- a/include/scsi/sg.h
+++ b/include/scsi/sg.h
@@ -86,6 +86,7 @@ typedef struct sg_io_hdr
 #define SG_FLAG_MMAP_IO 4       /* request memory mapped IO */
 #define SG_FLAG_NO_DXFER 0x10000 /* no transfer of kernel buffers to/from */
 				/* user space (debug indirect IO) */
+#define SG_FLAG_Q_AT_TAIL 0x10  /* default is Q_AT_HEAD */
 
 /* following 'info' values are "or"-ed together */
 #define SG_INFO_OK_MASK 0x1

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

* Re: [PATCH] sg: add SG_FLAG_Q_AT_TAIL flag
  2014-06-04  1:36 [PATCH] sg: add SG_FLAG_Q_AT_TAIL flag Douglas Gilbert
@ 2014-06-04  8:58 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2014-06-04  8:58 UTC (permalink / raw)
  To: Douglas Gilbert
  Cc: SCSI development list, Christoph Hellwig, James Bottomley,
	openosd

On Tue, Jun 03, 2014 at 09:36:56PM -0400, Douglas Gilbert wrote:
> When the SG_IO ioctl was copied into the block layer and
> later into the bsg driver, subtle differences emerged.
> 
> One difference is the way injected commands are queued through
> the block layer (i.e. this is not SCSI device queueing nor SATA
> NCQ). Summarizing:
>   - SG_IO in the block layer: blk_exec*(at_head=false)
>   - sg SG_IO: at_head=true
>   - bsg SG_IO: at_head=true
> 
> Some time ago Boaz Harrosh introduced a sg v4 flag called
> BSG_FLAG_Q_AT_TAIL to override the bsg driver default.
> This patch does the equivalent for the sg driver.
> 
> ChangeLog:
> 	Introduce SG_FLAG_Q_AT_TAIL flag to cause commands
> 	to be injected into the block layer with
> 	at_head=false.
> 
> Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>

> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
> index 177f755..1b7d4f6 100644
> --- a/drivers/scsi/sg.c
> +++ b/drivers/scsi/sg.c
> @@ -740,7 +740,7 @@ static int
>  sg_common_write(Sg_fd * sfp, Sg_request * srp,
>  		unsigned char *cmnd, int timeout, int blocking)
>  {
> -	int k, data_dir;
> +	int k, data_dir, at_head;
>  	Sg_device *sdp = sfp->parentdp;
>  	sg_io_hdr_t *hp = &srp->header;
>  
> @@ -784,11 +784,12 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
>  		break;
>  	}
>  	hp->duration = jiffies_to_msecs(jiffies);
> +	at_head = !(hp->interface_id && (SG_FLAG_Q_AT_TAIL & hp->flags));

It seems like all other occurances of ->interface_id compare to either
'\0' or 'S', so this looks odd.  Also I think this would really benefit
from beeing untangled into and if/else as it took me literally two
minutes to parse..


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

end of thread, other threads:[~2014-06-04  8:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-04  1:36 [PATCH] sg: add SG_FLAG_Q_AT_TAIL flag Douglas Gilbert
2014-06-04  8:58 ` Christoph Hellwig

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