From: Deepak Colluru <deepakrc@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] bsg : Add support for io vectors in bsg
Date: Fri, 4 Jan 2008 21:47:34 +0530 (IST) [thread overview]
Message-ID: <Pine.LNX.4.64.0801042137350.7836@localhost> (raw)
From: Deepak Colluru <deepakrc@gmail.com>
Add support for io vectors in bsg.
Signed-off-by: Deepak Colluru <deepakrc@gmail.com>
---
bsg.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 49 insertions(+), 3 deletions(-)
diff --git a/block/bsg.c b/block/bsg.c
index 8e181ab..78f47ed 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -245,7 +245,7 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr)
struct request_queue *q = bd->queue;
struct request *rq, *next_rq = NULL;
int ret, rw;
- unsigned int dxfer_len;
+ unsigned int dxfer_len, iovec_count = 0;
void *dxferp = NULL;
dprintk("map hdr %llx/%u %llx/%u\n", (unsigned long long) hdr->dout_xferp,
@@ -281,7 +281,31 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr)
rq->next_rq = next_rq;
dxferp = (void*)(unsigned long)hdr->din_xferp;
- ret = blk_rq_map_user(q, next_rq, dxferp, hdr->din_xfer_len);
+ iovec_count = hdr->din_iovec_count;
+ dxfer_len = hdr->din_xfer_len;
+
+ if (iovec_count) {
+ const int size = sizeof(struct sg_iovec) * iovec_count;
+ struct sg_iovec *iov;
+
+ iov = kmalloc(size, GFP_KERNEL);
+ if (!iov) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ if (copy_from_user(iov, dxferp, size)) {
+ kfree(iov);
+ ret = -EFAULT;
+ goto out;
+ }
+ ret = blk_rq_map_user_iov(q, rq, iov, iovec_count,
+ dxfer_len);
+ kfree(iov);
+ } else {
+ ret = blk_rq_map_user(q, rq, dxferp, dxfer_len);
+ }
+
if (ret)
goto out;
}
@@ -289,14 +313,36 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr)
if (hdr->dout_xfer_len) {
dxfer_len = hdr->dout_xfer_len;
dxferp = (void*)(unsigned long)hdr->dout_xferp;
+ iovec_count = hdr->dout_iovec_count;
} else if (hdr->din_xfer_len) {
dxfer_len = hdr->din_xfer_len;
dxferp = (void*)(unsigned long)hdr->din_xferp;
+ iovec_count = hdr->din_iovec_count;
} else
dxfer_len = 0;
if (dxfer_len) {
- ret = blk_rq_map_user(q, rq, dxferp, dxfer_len);
+ if (iovec_count) {
+ const int size = sizeof(struct sg_iovec) * iovec_count;
+ struct sg_iovec *iov;
+
+ iov = kmalloc(size, GFP_KERNEL);
+ if (!iov) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ if (copy_from_user(iov, dxferp, size)) {
+ kfree(iov);
+ ret = -EFAULT;
+ goto out;
+ }
+ ret = blk_rq_map_user_iov(q, rq, iov, iovec_count,
+ dxfer_len);
+ kfree(iov);
+ } else {
+ ret = blk_rq_map_user(q, rq, dxferp, dxfer_len);
+ }
if (ret)
goto out;
}
next reply other threads:[~2008-01-04 16:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-04 16:17 Deepak Colluru [this message]
2008-01-05 5:01 ` [PATCH] bsg : Add support for io vectors in bsg FUJITA Tomonori
2008-01-05 5:01 ` FUJITA Tomonori
2008-01-08 22:09 ` Pete Wyckoff
2008-01-09 0:11 ` FUJITA Tomonori
2008-01-10 20:43 ` Pete Wyckoff
2008-01-10 20:55 ` James Bottomley
2008-01-10 21:46 ` Pete Wyckoff
2008-01-10 21:54 ` James Bottomley
2008-01-12 0:16 ` Douglas Gilbert
2008-01-14 16:18 ` Pete Wyckoff
2008-01-10 22:33 ` Mark Rustad
2008-01-11 5:42 ` FUJITA Tomonori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0801042137350.7836@localhost \
--to=deepakrc@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.