linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: tj@kernel.org, "James E.J. Bottomley" <JBottomley@parallels.com>,
	linux-scsi@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Subject: [PATCH v3 part3 2/7] sg_io: create separate entries for conflicting commands
Date: Thu, 23 May 2013 15:59:30 +0200	[thread overview]
Message-ID: <1369317575-4236-3-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1369317575-4236-1-git-send-email-pbonzini@redhat.com>

Some SCSI commands were special cased at the end of the table because
they overlapped across SCSI device classes, with different meanings for
different classes.

Instead of hacking the bits manually, use separate entries in the table.
The 0xA4 opcode is blocked for non-MMC devices, even when open read-write.
The other four conflicting commands have their bitmap entries split in
two parts, one read-only for MMC and one read-write for the other classes.

Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: linux-scsi@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block/scsi_ioctl.c | 40 +++++++++-------------------------------
 1 file changed, 9 insertions(+), 31 deletions(-)

diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 5d2143f..8f0344f 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -179,29 +179,33 @@ static void blk_set_cmd_filter_defaults(struct blk_cmd_filter *filter)
 	sgio_bitmap_set(0x2E, D|      W|R|O|      B|K      , write); /* WRITE AND VERIFY(10) */
 	sgio_bitmap_set(0x35, D|      W|R|O|      B|K      , write); /* SYNCHRONIZE CACHE(10) */
 	sgio_bitmap_set(0x3F, D|      W|  O                , write); /* WRITE LONG(10) */
+	sgio_bitmap_set(0x42, D                            , write); /* UNMAP */
+	sgio_bitmap_set(0x48, D|                  B        , write); /* SANITIZE */
+	sgio_bitmap_set(0x51, D                            , write); /* XPWRITE(10) */
 	sgio_bitmap_set(0x8A, D|T|    W|  O|      B        , write); /* WRITE(16) */
 	sgio_bitmap_set(0xAA, D|      W|R|O|              C, write); /* WRITE(12) */
+	sgio_bitmap_set(0xAC,             O                , write); /* ERASE(12) */
 	sgio_bitmap_set(0xAE, D|      W|  O                , write); /* WRITE AND VERIFY(12) */
 	sgio_bitmap_set(0xEA, D|      W|  O                , write); /* WRITE_LONG_2 ?? */
 
 	/* MMC */
 
 	sgio_bitmap_set(0x23,           R                  , read);  /* READ FORMAT CAPACITIES */
-	sgio_bitmap_set(0x42, D|        R                  , read);  /* READ SUB-CHANNEL / UNMAP !! */
+	sgio_bitmap_set(0x42,           R                  , read);  /* READ SUB-CHANNEL */
 	sgio_bitmap_set(0x43,           R                  , read);  /* READ TOC/PMA/ATIP */
 	sgio_bitmap_set(0x44,   T|      R                  , read);  /* READ HEADER */
 	sgio_bitmap_set(0x45,           R                  , read);  /* PLAY AUDIO(10) */
 	sgio_bitmap_set(0x46,           R                  , read);  /* GET CONFIGURATION */
 	sgio_bitmap_set(0x47,           R                  , read);  /* PLAY AUDIO MSF */
-	sgio_bitmap_set(0x48, D|        R|        B        , read);  /* PLAY AUDIO TI / SANITIZE !! */
+	sgio_bitmap_set(0x48,           R                  , read);  /* PLAY AUDIO TI */
 	sgio_bitmap_set(0x4A,           R                  , read);  /* GET EVENT STATUS NOTIFICATION */
 	sgio_bitmap_set(0x4B,           R                  , read);  /* PAUSE/RESUME */
 	sgio_bitmap_set(0x4E,           R                  , read);  /* STOP PLAY/SCAN */
-	sgio_bitmap_set(0x51, D|        R                  , read);  /* READ DISC INFORMATION / XPWRITE(10) !! */
+	sgio_bitmap_set(0x51,           R                  , read);  /* READ DISC INFORMATION */
 	sgio_bitmap_set(0x52,           R                  , read);  /* READ TRACK INFORMATION */
 	sgio_bitmap_set(0x5C,           R                  , read);  /* READ BUFFER CAPACITY */
-	sgio_bitmap_set(0xA4, D|T|L|P|W|R|O|M|A|E|B|K|V|F|C, read);  /* REPORT KEY / 0xA4 service actions !! */
-	sgio_bitmap_set(0xAC,           R|O                , read);  /* GET PERFORMANCE / ERASE !! */
+	sgio_bitmap_set(0xA4,           R                  , read);  /* REPORT KEY */
+	sgio_bitmap_set(0xAC,           R                  , read);  /* GET PERFORMANCE */
 	sgio_bitmap_set(0xAD,           R                  , read);  /* READ DVD STRUCTURE */
 	sgio_bitmap_set(0xB9,           R                  , read);  /* READ CD MSF */
 	sgio_bitmap_set(0xBA,           R                  , read);  /* SCAN */
@@ -242,32 +246,6 @@ static void blk_set_cmd_filter_defaults(struct blk_cmd_filter *filter)
 #undef V
 #undef F
 #undef sgio_bitmap_set
-
-	/*
-	 * Treat specially those commands that have a different meaning
-	 * for disks: READ SUBCHANNEL conflicts with UNMAP.
-	 */
-	filter->read_ok[GPCMD_READ_SUBCHANNEL] &= ~(1 << TYPE_DISK);
-	filter->write_ok[GPCMD_READ_SUBCHANNEL] |= (1 << TYPE_DISK);
-
-	/* PLAY AUDIO TI conflicts with SANITIZE.  */
-	filter->read_ok[GPCMD_PLAY_AUDIO_TI] &= ~((1 << TYPE_DISK) | (1 << TYPE_RBC));
-	filter->write_ok[GPCMD_PLAY_AUDIO_TI] |= (1 << TYPE_DISK) | (1 << TYPE_RBC);
-
-	/* READ DISC INFORMATION conflicts with XPWRITE.  */
-	filter->read_ok[GPCMD_READ_DISC_INFO] &= ~(1 << TYPE_DISK);
-	filter->write_ok[GPCMD_READ_DISC_INFO] |= (1 << TYPE_DISK);
-
-	/* GET PERFORMANCE conflicts with ERASE.  */
-	filter->read_ok[GPCMD_GET_PERFORMANCE] &= ~(1 << TYPE_MOD);
-	filter->write_ok[GPCMD_GET_PERFORMANCE] |= (1 << TYPE_MOD);
-
-	/*
-	 * REPORT KEY conflicts with many management commands under operation
-	 * code 0xA4, enable it only for MMC devices.
-	 */
-	filter->read_ok[GPCMD_REPORT_KEY] = (1 << TYPE_ROM);
-	filter->write_ok[GPCMD_REPORT_KEY] = (1 << TYPE_ROM);
 }
 
 int blk_verify_command(struct request_queue *q,
-- 
1.8.1.4

  parent reply	other threads:[~2013-05-23 13:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1369317575-4236-1-git-send-email-pbonzini@redhat.com>
2013-05-23 13:59 ` [PATCH v3 part3 1/7] sg_io: complete transition to per-class lists of allowed commands Paolo Bonzini
2013-05-23 13:59 ` Paolo Bonzini [this message]
2013-05-23 13:59 ` [PATCH v3 part3 3/7] sg_io: cleanup and complete whitelist for rare device types Paolo Bonzini
2013-05-23 13:59 ` [PATCH v3 part3 4/7] sg_io: whitelist another command for multimedia devices Paolo Bonzini
2013-05-23 13:59 ` [PATCH v3 part3 5/7] sg_io: cleanup and complete whitelist for media changers Paolo Bonzini
2013-05-23 13:59 ` [PATCH v3 part3 6/7] sg_io: cleanup and complete whitelist for tapes Paolo Bonzini
2013-05-23 13:59 ` [PATCH v3 part3 7/7] sg_io: cleanup and complete whitelist for disks Paolo Bonzini

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=1369317575-4236-3-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=JBottomley@parallels.com \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=tj@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).