* [PATCH] SCSI: Add SG_GET_SG_MAX_SEGMENT_SIZE ioctl to sg device
@ 2012-07-02 9:20 Cong Meng
2012-07-02 11:18 ` James Bottomley
0 siblings, 1 reply; 4+ messages in thread
From: Cong Meng @ 2012-07-02 9:20 UTC (permalink / raw)
To: James E.J. Bottomley
Cc: stefanha, linuxram, linux-kernel, linux-scsi, senwang, Cong Meng
Add a new ioctl cmd to get the max segment size. It's useful in
virtualization environment for guest to know the queue limits, so
that the guest kicks off legal scsi command to a sg device.
Signed-off-by: Cong Meng <mc@linux.vnet.ibm.com>
---
drivers/scsi/sg.c | 2 ++
include/scsi/sg.h | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index eacd46b..bdcdc9d 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -913,6 +913,8 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
return put_user(val, ip);
case SG_GET_SG_TABLESIZE:
return put_user(sdp->sg_tablesize, ip);
+ case SG_GET_SG_MAX_SEGMENT_SIZE:
+ return put_user(queue_max_segment_size(sdp->device->request_queue), ip);
case SG_SET_RESERVED_SIZE:
result = get_user(val, ip);
if (result)
diff --git a/include/scsi/sg.h b/include/scsi/sg.h
index a9f3c6f..76d94c1 100644
--- a/include/scsi/sg.h
+++ b/include/scsi/sg.h
@@ -200,6 +200,9 @@ typedef struct sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
/* Yields max scatter gather tablesize allowed by current host adapter */
#define SG_GET_SG_TABLESIZE 0x227F /* 0 implies can't do scatter gather */
+/* Yidld max size of scatter gather element by current host adapter */
+#define SG_GET_SG_MAX_SEGMENT_SIZE 0x2280
+
#define SG_GET_VERSION_NUM 0x2282 /* Example: version 2.1.34 yields 20134 */
/* Returns -EBUSY if occupied. 3rd argument pointer to int (see next) */
--
1.7.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] SCSI: Add SG_GET_SG_MAX_SEGMENT_SIZE ioctl to sg device
2012-07-02 9:20 [PATCH] SCSI: Add SG_GET_SG_MAX_SEGMENT_SIZE ioctl to sg device Cong Meng
@ 2012-07-02 11:18 ` James Bottomley
2012-07-03 7:53 ` Cong Meng
0 siblings, 1 reply; 4+ messages in thread
From: James Bottomley @ 2012-07-02 11:18 UTC (permalink / raw)
To: Cong Meng; +Cc: stefanha, linuxram, linux-kernel, linux-scsi, senwang
On Mon, 2012-07-02 at 17:20 +0800, Cong Meng wrote:
> Add a new ioctl cmd to get the max segment size. It's useful in
> virtualization environment for guest to know the queue limits, so
> that the guest kicks off legal scsi command to a sg device.
What's wrong with simply looking in the /sys for this? Plus, if you can
come up with a justifiable reason, this needs to be in block as well so
we can send it to all SCSI devices regardless of what ULD people use.
James
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] SCSI: Add SG_GET_SG_MAX_SEGMENT_SIZE ioctl to sg device
2012-07-02 11:18 ` James Bottomley
@ 2012-07-03 7:53 ` Cong Meng
2012-07-03 8:01 ` James Bottomley
0 siblings, 1 reply; 4+ messages in thread
From: Cong Meng @ 2012-07-03 7:53 UTC (permalink / raw)
To: James Bottomley; +Cc: stefanha, linuxram, linux-kernel, linux-scsi, senwang
On Mon, 2012-07-02 at 12:18 +0100, James Bottomley wrote:
> On Mon, 2012-07-02 at 17:20 +0800, Cong Meng wrote:
> > Add a new ioctl cmd to get the max segment size. It's useful in
> > virtualization environment for guest to know the queue limits, so
> > that the guest kicks off legal scsi command to a sg device.
>
> What's wrong with simply looking in the /sys for this? Plus, if you can
Adding this ioctl is a big convenience for the programs, qemu
in my case, to which parameter that likes '/dev/sgX' is given.
With this ioctl, those programs only need to issue an ioctl to
get the queue limit. Otherwise, 'dev/sgX' is needed to convert
to /sys path, then open and read it.
In addition, the potential variation and exceptional situation
of sys FS, EX mount path, are needed to consider as well.
Is my justification acceptable?
> come up with a justifiable reason, this needs to be in block as well so
> we can send it to all SCSI devices regardless of what ULD people use.
I can do it.
Thanks.
Cong.
>
> James
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] SCSI: Add SG_GET_SG_MAX_SEGMENT_SIZE ioctl to sg device
2012-07-03 7:53 ` Cong Meng
@ 2012-07-03 8:01 ` James Bottomley
0 siblings, 0 replies; 4+ messages in thread
From: James Bottomley @ 2012-07-03 8:01 UTC (permalink / raw)
To: mc; +Cc: stefanha, linuxram, linux-kernel, linux-scsi, senwang
On Tue, 2012-07-03 at 15:53 +0800, Cong Meng wrote:
> On Mon, 2012-07-02 at 12:18 +0100, James Bottomley wrote:
> > On Mon, 2012-07-02 at 17:20 +0800, Cong Meng wrote:
> > > Add a new ioctl cmd to get the max segment size. It's useful in
> > > virtualization environment for guest to know the queue limits, so
> > > that the guest kicks off legal scsi command to a sg device.
> >
> > What's wrong with simply looking in the /sys for this? Plus, if you can
>
> Adding this ioctl is a big convenience for the programs, qemu
> in my case, to which parameter that likes '/dev/sgX' is given.
> With this ioctl, those programs only need to issue an ioctl to
> get the queue limit.
I don't need to know why you need the information, I accept that it's
useful
> Otherwise, 'dev/sgX' is needed to convert
> to /sys path, then open and read it.
Well, yes, what's the problem?
> In addition, the potential variation and exceptional situation
> of sys FS, EX mount path, are needed to consider as well.
> Is my justification acceptable?
No. I need to know why you can't get it out of sysfs. We put a whole
lot of stuff into sysfs to avoid the need to add extra ioctls. There
need to be a really good reason why /sys doesn't work.
James
> > come up with a justifiable reason, this needs to be in block as well so
> > we can send it to all SCSI devices regardless of what ULD people use.
> I can do it.
>
> Thanks.
> Cong.
> >
> > James
> >
> >
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-07-03 8:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-02 9:20 [PATCH] SCSI: Add SG_GET_SG_MAX_SEGMENT_SIZE ioctl to sg device Cong Meng
2012-07-02 11:18 ` James Bottomley
2012-07-03 7:53 ` Cong Meng
2012-07-03 8:01 ` James Bottomley
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).