Skip to content

Commit 16070cc

Browse files
doug-gilbertChristoph Hellwig
authored andcommitted
sg: add SG_FLAG_Q_AT_TAIL flag
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> Reviewed-by: Mike Christie <michaelc@cs.wisc.edu> Reviewed-by: Ewan D. Milne <emilne@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 65c26a0 commit 16070cc

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎drivers/scsi/sg.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ static int
741741
sg_common_write(Sg_fd * sfp, Sg_request * srp,
742742
unsigned char *cmnd, int timeout, int blocking)
743743
{
744-
int k, data_dir;
744+
int k, data_dir, at_head;
745745
Sg_device *sdp = sfp->parentdp;
746746
sg_io_hdr_t *hp = &srp->header;
747747

@@ -785,11 +785,16 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
785785
break;
786786
}
787787
hp->duration = jiffies_to_msecs(jiffies);
788+
if (hp->interface_id != '\0' && /* v3 (or later) interface */
789+
(SG_FLAG_Q_AT_TAIL & hp->flags))
790+
at_head = 0;
791+
else
792+
at_head = 1;
788793

789794
srp->rq->timeout = timeout;
790795
kref_get(&sfp->f_ref); /* sg_rq_end_io() does kref_put(). */
791796
blk_execute_rq_nowait(sdp->device->request_queue, sdp->disk,
792-
srp->rq, 1, sg_rq_end_io);
797+
srp->rq, at_head, sg_rq_end_io);
793798
return 0;
794799
}
795800

‎include/scsi/sg.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ typedef struct sg_io_hdr
8686
#define SG_FLAG_MMAP_IO 4 /* request memory mapped IO */
8787
#define SG_FLAG_NO_DXFER 0x10000 /* no transfer of kernel buffers to/from */
8888
/* user space (debug indirect IO) */
89+
#define SG_FLAG_Q_AT_TAIL 0x10 /* default is Q_AT_HEAD */
8990

9091
/* following 'info' values are "or"-ed together */
9192
#define SG_INFO_OK_MASK 0x1

0 commit comments

Comments
 (0)