From: Pete Wyckoff <pw@osc.edu>
To: Boaz Harrosh <bharrosh@panasas.com>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
Jens Axboe <jens.axboe@oracle.com>,
Mike Christie <michaelc@cs.wisc.edu>,
linux-scsi@vger.kernel.org
Subject: [PATCH 3/3] varlen bsg submit
Date: Wed, 15 Aug 2007 14:17:04 -0500 [thread overview]
Message-ID: <20070815191704.GD14977@osc.edu> (raw)
In-Reply-To: <20070815191523.GA14977@osc.edu>
Accept variable length SCSI commands through BSG.
Signed-off-by: Pete Wyckoff <pw@osc.edu>
---
block/bsg.c | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/block/bsg.c b/block/bsg.c
index eb0aaf4..c72b4f9 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -175,11 +175,22 @@ unlock:
static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
struct sg_io_v4 *hdr, int has_write_perm)
{
+ int len = hdr->request_len;
+
memset(rq->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */
if (copy_from_user(rq->cmd, (void *)(unsigned long)hdr->request,
- hdr->request_len))
+ min(len, BLK_MAX_CDB)))
return -EFAULT;
+ if (len > BLK_MAX_CDB) {
+ rq->varlen_cdb_len = len;
+ rq->varlen_cdb = kmalloc(len, GFP_KERNEL);
+ if (rq->varlen_cdb == NULL)
+ return -ENOMEM;
+ if (copy_from_user(rq->varlen_cdb,
+ (void *)(unsigned long)hdr->request, len))
+ return -EFAULT;
+ }
if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
if (blk_verify_command(rq->cmd, has_write_perm))
@@ -190,7 +201,7 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
/*
* fill in request structure
*/
- rq->cmd_len = hdr->request_len;
+ rq->cmd_len = min(len, BLK_MAX_CDB);
rq->cmd_type = REQ_TYPE_BLOCK_PC;
rq->timeout = (hdr->timeout * HZ) / 1000;
@@ -212,8 +223,6 @@ bsg_validate_sgv4_hdr(struct request_queue *q, struct sg_io_v4 *hdr, int *rw)
if (hdr->guard != 'Q')
return -EINVAL;
- if (hdr->request_len > BLK_MAX_CDB)
- return -EINVAL;
if (hdr->dout_xfer_len > (q->max_sectors << 9) ||
hdr->din_xfer_len > (q->max_sectors << 9))
return -EIO;
@@ -303,6 +312,7 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr)
}
return rq;
out:
+ kfree(rq->varlen_cdb);
blk_put_request(rq);
if (next_rq) {
blk_rq_unmap_user(next_rq->bio);
@@ -443,6 +453,7 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr,
}
blk_rq_unmap_user(bio);
+ kfree(rq->varlen_cdb);
blk_put_request(rq);
return ret;
--
1.5.2.4
prev parent reply other threads:[~2007-08-15 19:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-15 19:15 [PATCH 0/3] bsg bidirectional and variable length commands Pete Wyckoff
2007-08-15 19:16 ` [PATCH 1/3] bsg bidi block pc Pete Wyckoff
2007-08-15 19:16 ` [PATCH 2/3] iscsi tcp queue bidi Pete Wyckoff
2007-08-15 19:17 ` Pete Wyckoff [this message]
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=20070815191704.GD14977@osc.edu \
--to=pw@osc.edu \
--cc=bharrosh@panasas.com \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=jens.axboe@oracle.com \
--cc=linux-scsi@vger.kernel.org \
--cc=michaelc@cs.wisc.edu \
/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.