From: Brian King <brking@us.ibm.com>
To: brking@us.ibm.com
Cc: Jens Axboe <axboe@suse.de>, linux-scsi@vger.kernel.org
Subject: Re: drivers/block/scsi_ioctl problem
Date: Wed, 15 Dec 2004 16:44:14 -0600 [thread overview]
Message-ID: <41C0BE3E.3060003@us.ibm.com> (raw)
In-Reply-To: <41C08CD5.10309@us.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 394 bytes --]
Brian King wrote:
>> It was added to be able to find out which opcode was rejected and thus
>> caused an application malfunction. It dumps the specific opcode only
>> once, is that such a huge problem?
>
>
> Ok. I didn't realize that it was only dumped once. That's not as bad. I
> guess it might be better if it were only dumped if the op actually failed.
How about something like this...
[-- Attachment #2: blk_scsi_ioctl_unknown_cmd.patch --]
[-- Type: text/plain, Size: 2679 bytes --]
Currently if an SG_IO ioctl is issued to a block device with an
unknown opcode, an error is logged. This error is logged regardless
the device successfully processes the command or not. This results in
an error getting logged for each unknown opcode ever issued. This patch
changes this policy and only prints the unknown opcode if the command
fails.
Signed-off-by: Brian King <brking@us.ibm.com>
---
linux-2.6.10-rc3-bk8-bjking1/drivers/block/scsi_ioctl.c | 19 +++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diff -puN drivers/block/scsi_ioctl.c~blk_scsi_ioctl_unknown_cmd drivers/block/scsi_ioctl.c
--- linux-2.6.10-rc3-bk8/drivers/block/scsi_ioctl.c~blk_scsi_ioctl_unknown_cmd 2004-12-15 14:19:34.000000000 -0600
+++ linux-2.6.10-rc3-bk8-bjking1/drivers/block/scsi_ioctl.c 2004-12-15 14:55:04.000000000 -0600
@@ -111,7 +111,7 @@ static int sg_emulated_host(request_queu
#define safe_for_read(cmd) [cmd] = CMD_READ_SAFE
#define safe_for_write(cmd) [cmd] = CMD_WRITE_SAFE
-static int verify_command(struct file *file, unsigned char *cmd)
+static int __verify_command(struct file *file, unsigned char *cmd, int logging)
{
static unsigned char cmd_type[256] = {
@@ -199,7 +199,7 @@ static int verify_command(struct file *f
return 0;
}
- if (!(type & CMD_WARNED)) {
+ if (logging && !(type & CMD_WARNED)) {
cmd_type[cmd[0]] = CMD_WARNED;
printk(KERN_WARNING "scsi: unknown opcode 0x%02x\n", cmd[0]);
}
@@ -212,6 +212,16 @@ static int verify_command(struct file *f
return -EPERM;
}
+static int verify_command(struct file *file, unsigned char *cmd)
+{
+ return __verify_command(file, cmd, 0);
+}
+
+static void log_unknown_opcode(struct file *file, unsigned char *cmd)
+{
+ __verify_command(file, cmd, 1);
+}
+
static int sg_io(struct file *file, request_queue_t *q,
struct gendisk *bd_disk, struct sg_io_hdr *hdr)
{
@@ -307,8 +317,10 @@ static int sg_io(struct file *file, requ
hdr->host_status = host_byte(rq->errors);
hdr->driver_status = driver_byte(rq->errors);
hdr->info = 0;
- if (hdr->masked_status || hdr->host_status || hdr->driver_status)
+ if (hdr->masked_status || hdr->host_status || hdr->driver_status) {
hdr->info |= SG_INFO_CHECK;
+ log_unknown_opcode(file, cmd);
+ }
hdr->resid = rq->data_len;
hdr->duration = ((jiffies - start_time) * 1000) / HZ;
hdr->sb_len_wr = 0;
@@ -415,6 +427,7 @@ static int sg_scsi_ioctl(struct file *fi
blk_execute_rq(q, bd_disk, rq);
err = rq->errors & 0xff; /* only 8 bit SCSI status */
if (err) {
+ log_unknown_opcode(file, rq->cmd);
if (rq->sense_len && rq->sense) {
bytes = (OMAX_SB_LEN > rq->sense_len) ?
rq->sense_len : OMAX_SB_LEN;
_
next prev parent reply other threads:[~2004-12-15 22:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-14 23:49 drivers/block/scsi_ioctl problem Brian King
2004-12-15 5:32 ` Douglas Gilbert
2004-12-15 7:18 ` Jens Axboe
2004-12-15 19:13 ` Brian King
2004-12-15 22:44 ` Brian King [this message]
2004-12-16 6:32 ` Jens Axboe
2004-12-16 16:31 ` Brian King
2005-10-07 14:13 ` Brian King
2005-10-07 17:41 ` Jens Axboe
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=41C0BE3E.3060003@us.ibm.com \
--to=brking@us.ibm.com \
--cc=axboe@suse.de \
--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;
as well as URLs for NNTP newsgroup(s).