* [PATCH 6/6] bsg: add SG_IO to SG v4
@ 2006-12-20 5:43 FUJITA Tomonori
2006-12-20 10:16 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: FUJITA Tomonori @ 2006-12-20 5:43 UTC (permalink / raw)
To: linux-scsi; +Cc: jens.axboe, dougg
This adds SG_IO support to SG v4.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
block/bsg.c | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/block/bsg.c b/block/bsg.c
index 6d139d2..9dc5d36 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -945,8 +945,27 @@ bsg_ioctl(struct inode *inode, struct fi
void __user *uarg = (void __user *) arg;
return scsi_cmd_ioctl(file, bd->disk, cmd, uarg);
}
- case SG_IO:
- return -EINVAL;
+ case SG_IO: {
+ struct request *rq;
+ struct bio *bio;
+ struct sg_io_v4 hdr;
+
+ if (copy_from_user(&hdr, uarg, sizeof(hdr)))
+ return -EFAULT;
+
+ rq = bsg_map_hdr(bd, &hdr);
+ if (IS_ERR(rq))
+ return PTR_ERR(rq);
+
+ bio = rq->bio;
+ blk_execute_rq(bd->queue, bd->disk, rq, 0);
+ blk_complete_sgv4_hdr_rq(rq, &hdr, bio);
+
+ if (copy_to_user(uarg, &hdr, sizeof(hdr)))
+ return -EFAULT;
+ else
+ return 0;
+ }
/*
* block device ioctls
*/
--
1.4.3.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 6/6] bsg: add SG_IO to SG v4
2006-12-20 5:43 [PATCH 6/6] bsg: add SG_IO to SG v4 FUJITA Tomonori
@ 2006-12-20 10:16 ` Jens Axboe
2006-12-20 10:24 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2006-12-20 10:16 UTC (permalink / raw)
To: FUJITA Tomonori; +Cc: linux-scsi, dougg
On Wed, Dec 20 2006, FUJITA Tomonori wrote:
> This adds SG_IO support to SG v4.
>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> ---
> block/bsg.c | 23 +++++++++++++++++++++--
> 1 files changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/block/bsg.c b/block/bsg.c
> index 6d139d2..9dc5d36 100644
> --- a/block/bsg.c
> +++ b/block/bsg.c
> @@ -945,8 +945,27 @@ bsg_ioctl(struct inode *inode, struct fi
> void __user *uarg = (void __user *) arg;
> return scsi_cmd_ioctl(file, bd->disk, cmd, uarg);
> }
> - case SG_IO:
> - return -EINVAL;
> + case SG_IO: {
> + struct request *rq;
> + struct bio *bio;
> + struct sg_io_v4 hdr;
> +
> + if (copy_from_user(&hdr, uarg, sizeof(hdr)))
> + return -EFAULT;
> +
> + rq = bsg_map_hdr(bd, &hdr);
> + if (IS_ERR(rq))
> + return PTR_ERR(rq);
> +
> + bio = rq->bio;
Pointless assignment. In fact the bio can be completely removed.
> + blk_execute_rq(bd->queue, bd->disk, rq, 0);
> + blk_complete_sgv4_hdr_rq(rq, &hdr, bio);
> +
> + if (copy_to_user(uarg, &hdr, sizeof(hdr)))
> + return -EFAULT;
> + else
> + return 0;
Kill the else.
I'll make both changes. Applying your series as-is, and making the
changes I noted in the previous mails.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 6/6] bsg: add SG_IO to SG v4
2006-12-20 10:16 ` Jens Axboe
@ 2006-12-20 10:24 ` Jens Axboe
0 siblings, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2006-12-20 10:24 UTC (permalink / raw)
To: FUJITA Tomonori; +Cc: linux-scsi, dougg
On Wed, Dec 20 2006, Jens Axboe wrote:
> On Wed, Dec 20 2006, FUJITA Tomonori wrote:
> > This adds SG_IO support to SG v4.
> >
> > Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> > ---
> > block/bsg.c | 23 +++++++++++++++++++++--
> > 1 files changed, 21 insertions(+), 2 deletions(-)
> >
> > diff --git a/block/bsg.c b/block/bsg.c
> > index 6d139d2..9dc5d36 100644
> > --- a/block/bsg.c
> > +++ b/block/bsg.c
> > @@ -945,8 +945,27 @@ bsg_ioctl(struct inode *inode, struct fi
> > void __user *uarg = (void __user *) arg;
> > return scsi_cmd_ioctl(file, bd->disk, cmd, uarg);
> > }
> > - case SG_IO:
> > - return -EINVAL;
> > + case SG_IO: {
> > + struct request *rq;
> > + struct bio *bio;
> > + struct sg_io_v4 hdr;
> > +
> > + if (copy_from_user(&hdr, uarg, sizeof(hdr)))
> > + return -EFAULT;
> > +
> > + rq = bsg_map_hdr(bd, &hdr);
> > + if (IS_ERR(rq))
> > + return PTR_ERR(rq);
> > +
> > + bio = rq->bio;
>
> Pointless assignment. In fact the bio can be completely removed.
> > + blk_execute_rq(bd->queue, bd->disk, rq, 0);
> > + blk_complete_sgv4_hdr_rq(rq, &hdr, bio);
My mistake, the bio assignment is fine and of course needed.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-12-20 10:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-20 5:43 [PATCH 6/6] bsg: add SG_IO to SG v4 FUJITA Tomonori
2006-12-20 10:16 ` Jens Axboe
2006-12-20 10:24 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox