support of sg_iovec in bsg's struct sg_io_v4
Subsystems (3)
Is below just missing or is there something I do not understand?
It looks like the conversion from struct sg_io_hdr to struct sg_io_v4 the use of sg_iovec was dropped. Even though all the members and code comments say it is the same.
This adds the support in bsg and struct sg_io_v4 exactly in the same way it was done in sg with struct sg_io_hdr.
BTW why is the ioctl SG_IO defined exactly the same for sg.c and bsg.c even though they have none compatible API/ABI? Is that because we have the protection of the first __s32 member that is 'Q' for bsg and 'S' or 0 for sg? Is that usually done with ioctl's?
Not-signed-or-tested: Boaz Harrosh <[email protected]>
---
git diff --stat -p block/bsg.c
block/bsg.c | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-)
block/bsg.c +14 -4
@@ -285,8 +285,13 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm) next_rq->cmd_type = rq->cmd_type; dxferp = (void *)(unsigned long )hdr->din_xferp; - ret =blk_rq_map_user (q, next_rq,NULL , dxferp, - hdr->din_xfer_len,GFP_KERNEL ); +if (hdr->din_iovec_count) + ret =blk_rq_map_user_iov (q, next_rq,NULL , dxferp, + hdr->din_iovec_count, + hdr->din_xfer_len,GFP_KERNEL ); +else + ret =blk_rq_map_user (q, next_rq,NULL , dxferp, + hdr->din_xfer_len,GFP_KERNEL );if (ret) goto out; }
@@ -301,8 +306,13 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm) dxfer_len =0 ;if (dxfer_len) { - ret =blk_rq_map_user (q, rq,NULL , dxferp, dxfer_len, -GFP_KERNEL ); +if (hdr->dout_iovec_count) + ret =blk_rq_map_user_iov (q, rq,NULL , dxferp, + hdr->dout_iovec_count, + dxfer_len,GFP_KERNEL ); +else + ret =blk_rq_map_user (q, rq,NULL , dxferp, dxfer_len, +GFP_KERNEL );if (ret) goto out; }
FUJITA Tomonori
maintainerQuoted 5 lines · On Wed, 14 Jan 2009 20:01:07 +0200 Boaz Harrosh <[email protected]> wrote:
Is below just missing or is there something I do not understand?
It looks like the conversion from struct
sg_io_hdrto structsg_io_v4the use ofsg_iovecwas dropped. Even though all the members and code comments say it is the same.
It's intentional. It has been discussed several times on linux-scsi.
Quoted 2 lines
This adds the support in bsg and struct
sg_io_v4exactly in the same way it was done in sg with structsg_io_hdr.
sg_io_v4 will not support sg_iovec.
Quoted 4 lines
BTW why is the ioctl
SG_IOdefined exactly the same forsg.candbsg.ceven though they have none compatible API/ABI? Is that because we have the protection of the first__s32member that is 'Q' for bsg and 'S' or 0 for sg? Is that usually done with ioctl's?
I don't know if it's common or not. But we did the same thing with sg v2 and sg v3's read/write interface.