From: Mike Christie <michaelc@cs.wisc.edu>
To: dm-devel@redhat.com, linux-scsi@vger.kernel.org, axboe@suse.de
Subject: [PATCH RFC 3/4] convert scsi-ioctl to use blk_rq_map_kern
Date: Fri, 03 Jun 2005 18:32:01 -0700 [thread overview]
Message-ID: <1117848721.23706.8.camel@mina> (raw)
convert old sg_scsi_ioctl to use blk_rq_map_kern when there is data so
all SG IO paths use bio backed requests. This simplifies scsi and
is a step twords scatter gather io always being used (just need
to convert the "special" request path.
This patch was made against 2.6.12-rc5, and works with scsi-misc.
--- linux-2.6.12-rc5.orig/drivers/block/scsi_ioctl.c 2005-06-03 03:23:46.000000000 -0700
+++ linux-2.6.12-rc5/drivers/block/scsi_ioctl.c 2005-06-03 14:55:36.000000000 -0700
@@ -334,7 +334,7 @@ static int sg_scsi_ioctl(struct file *fi
struct gendisk *bd_disk, Scsi_Ioctl_Command __user *sic)
{
struct request *rq;
- int err;
+ int err, write;
unsigned int in_len, out_len, bytes, opcode, cmdlen;
char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
@@ -350,16 +350,23 @@ static int sg_scsi_ioctl(struct file *fi
if (get_user(opcode, sic->data))
return -EFAULT;
+ write = in_len ? WRITE : READ;
bytes = max(in_len, out_len);
if (bytes) {
buffer = kmalloc(bytes, q->bounce_gfp | GFP_USER| __GFP_NOWARN);
if (!buffer)
return -ENOMEM;
-
memset(buffer, 0, bytes);
- }
- rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_WAIT);
+ rq = blk_rq_map_kern(bd_disk->queue, write, buffer, bytes,
+ __GFP_WAIT);
+ } else
+ rq = blk_get_request(q, write, __GFP_WAIT);
+
+ if (IS_ERR(rq)) {
+ err = PTR_ERR(rq);
+ goto free_buffer;
+ }
cmdlen = COMMAND_SIZE(opcode);
@@ -369,14 +376,14 @@ static int sg_scsi_ioctl(struct file *fi
err = -EFAULT;
rq->cmd_len = cmdlen;
if (copy_from_user(rq->cmd, sic->data, cmdlen))
- goto error;
+ goto free_request;
if (copy_from_user(buffer, sic->data + cmdlen, in_len))
- goto error;
+ goto free_request;
err = verify_command(file, rq->cmd);
if (err)
- goto error;
+ goto free_request;
switch (opcode) {
case SEND_DIAGNOSTIC:
@@ -421,10 +428,11 @@ static int sg_scsi_ioctl(struct file *fi
if (copy_to_user(sic->data, buffer, out_len))
err = -EFAULT;
}
-
-error:
- kfree(buffer);
+
+free_request:
blk_put_request(rq);
+free_buffer:
+ kfree(buffer);
return err;
}
reply other threads:[~2005-06-04 1:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1117848721.23706.8.camel@mina \
--to=michaelc@cs.wisc.edu \
--cc=axboe@suse.de \
--cc=dm-devel@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox