mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: tj@kernel.org, stable@gnu.org,
	"James E.J. Bottomley" <JBottomley@parallels.com>,
	linux-scsi@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Subject: [PATCH v3 part1 2/4] sg_io: prepare to introduce per-class command filters
Date: Thu, 23 May 2013 15:58:21 +0200	[thread overview]
Message-ID: <1369317503-4095-3-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1369317503-4095-1-git-send-email-pbonzini@redhat.com>

To prepare for the next patches, abstract setting of an entry in the
command filter behind a macro.

The next patch will change the implementation of the macro.

Cc: stable@gnu.org
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 | 148 +++++++++++++++++++++++++++--------------------------
 1 file changed, 76 insertions(+), 72 deletions(-)

diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 96cab50..21ddf17 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -116,85 +116,89 @@ static int sg_emulated_host(struct request_queue *q, int __user *p)
 
 static void blk_set_cmd_filter_defaults(struct blk_cmd_filter *filter)
 {
+#define sgio_bitmap_set(cmd, rw) \
+	__set_bit((cmd), filter->rw##_ok)
+
 	/* Basic read-only commands */
-	__set_bit(TEST_UNIT_READY, filter->read_ok);
-	__set_bit(REQUEST_SENSE, filter->read_ok);
-	__set_bit(READ_6, filter->read_ok);
-	__set_bit(READ_10, filter->read_ok);
-	__set_bit(READ_12, filter->read_ok);
-	__set_bit(READ_16, filter->read_ok);
-	__set_bit(READ_BUFFER, filter->read_ok);
-	__set_bit(READ_DEFECT_DATA, filter->read_ok);
-	__set_bit(READ_CAPACITY, filter->read_ok);
-	__set_bit(READ_LONG, filter->read_ok);
-	__set_bit(INQUIRY, filter->read_ok);
-	__set_bit(MODE_SENSE, filter->read_ok);
-	__set_bit(MODE_SENSE_10, filter->read_ok);
-	__set_bit(LOG_SENSE, filter->read_ok);
-	__set_bit(START_STOP, filter->read_ok);
-	__set_bit(GPCMD_VERIFY_10, filter->read_ok);
-	__set_bit(VERIFY_16, filter->read_ok);
-	__set_bit(REPORT_LUNS, filter->read_ok);
-	__set_bit(SERVICE_ACTION_IN, filter->read_ok);
-	__set_bit(RECEIVE_DIAGNOSTIC, filter->read_ok);
-	__set_bit(MAINTENANCE_IN, filter->read_ok);
-	__set_bit(GPCMD_READ_BUFFER_CAPACITY, filter->read_ok);
+	sgio_bitmap_set(TEST_UNIT_READY, read);
+	sgio_bitmap_set(REQUEST_SENSE, read);
+	sgio_bitmap_set(READ_6, read);
+	sgio_bitmap_set(READ_10, read);
+	sgio_bitmap_set(READ_12, read);
+	sgio_bitmap_set(READ_16, read);
+	sgio_bitmap_set(READ_BUFFER, read);
+	sgio_bitmap_set(READ_DEFECT_DATA, read);
+	sgio_bitmap_set(READ_CAPACITY, read);
+	sgio_bitmap_set(READ_LONG, read);
+	sgio_bitmap_set(INQUIRY, read);
+	sgio_bitmap_set(MODE_SENSE, read);
+	sgio_bitmap_set(MODE_SENSE_10, read);
+	sgio_bitmap_set(LOG_SENSE, read);
+	sgio_bitmap_set(START_STOP, read);
+	sgio_bitmap_set(GPCMD_VERIFY_10, read);
+	sgio_bitmap_set(VERIFY_16, read);
+	sgio_bitmap_set(REPORT_LUNS, read);
+	sgio_bitmap_set(SERVICE_ACTION_IN, read);
+	sgio_bitmap_set(RECEIVE_DIAGNOSTIC, read);
+	sgio_bitmap_set(MAINTENANCE_IN, read);
+	sgio_bitmap_set(GPCMD_READ_BUFFER_CAPACITY, read);
 
 	/* Audio CD commands */
-	__set_bit(GPCMD_PLAY_CD, filter->read_ok);
-	__set_bit(GPCMD_PLAY_AUDIO_10, filter->read_ok);
-	__set_bit(GPCMD_PLAY_AUDIO_MSF, filter->read_ok);
-	__set_bit(GPCMD_PLAY_AUDIO_TI, filter->read_ok);
-	__set_bit(GPCMD_PAUSE_RESUME, filter->read_ok);
+	sgio_bitmap_set(GPCMD_PLAY_CD, read);
+	sgio_bitmap_set(GPCMD_PLAY_AUDIO_10, read);
+	sgio_bitmap_set(GPCMD_PLAY_AUDIO_MSF, read);
+	sgio_bitmap_set(GPCMD_PLAY_AUDIO_TI, read);
+	sgio_bitmap_set(GPCMD_PAUSE_RESUME, read);
 
 	/* CD/DVD data reading */
-	__set_bit(GPCMD_READ_CD, filter->read_ok);
-	__set_bit(GPCMD_READ_CD_MSF, filter->read_ok);
-	__set_bit(GPCMD_READ_DISC_INFO, filter->read_ok);
-	__set_bit(GPCMD_READ_CDVD_CAPACITY, filter->read_ok);
-	__set_bit(GPCMD_READ_DVD_STRUCTURE, filter->read_ok);
-	__set_bit(GPCMD_READ_HEADER, filter->read_ok);
-	__set_bit(GPCMD_READ_TRACK_RZONE_INFO, filter->read_ok);
-	__set_bit(GPCMD_READ_SUBCHANNEL, filter->read_ok);
-	__set_bit(GPCMD_READ_TOC_PMA_ATIP, filter->read_ok);
-	__set_bit(GPCMD_REPORT_KEY, filter->read_ok);
-	__set_bit(GPCMD_SCAN, filter->read_ok);
-	__set_bit(GPCMD_GET_CONFIGURATION, filter->read_ok);
-	__set_bit(GPCMD_READ_FORMAT_CAPACITIES, filter->read_ok);
-	__set_bit(GPCMD_GET_EVENT_STATUS_NOTIFICATION, filter->read_ok);
-	__set_bit(GPCMD_GET_PERFORMANCE, filter->read_ok);
-	__set_bit(GPCMD_SEEK, filter->read_ok);
-	__set_bit(GPCMD_STOP_PLAY_SCAN, filter->read_ok);
+	sgio_bitmap_set(GPCMD_READ_CD, read);
+	sgio_bitmap_set(GPCMD_READ_CD_MSF, read);
+	sgio_bitmap_set(GPCMD_READ_DISC_INFO, read);
+	sgio_bitmap_set(GPCMD_READ_CDVD_CAPACITY, read);
+	sgio_bitmap_set(GPCMD_READ_DVD_STRUCTURE, read);
+	sgio_bitmap_set(GPCMD_READ_HEADER, read);
+	sgio_bitmap_set(GPCMD_READ_TRACK_RZONE_INFO, read);
+	sgio_bitmap_set(GPCMD_READ_SUBCHANNEL, read);
+	sgio_bitmap_set(GPCMD_READ_TOC_PMA_ATIP, read);
+	sgio_bitmap_set(GPCMD_REPORT_KEY, read);
+	sgio_bitmap_set(GPCMD_SCAN, read);
+	sgio_bitmap_set(GPCMD_GET_CONFIGURATION, read);
+	sgio_bitmap_set(GPCMD_READ_FORMAT_CAPACITIES, read);
+	sgio_bitmap_set(GPCMD_GET_EVENT_STATUS_NOTIFICATION, read);
+	sgio_bitmap_set(GPCMD_GET_PERFORMANCE, read);
+	sgio_bitmap_set(GPCMD_SEEK, read);
+	sgio_bitmap_set(GPCMD_STOP_PLAY_SCAN, read);
 
 	/* Basic writing commands */
-	__set_bit(WRITE_6, filter->write_ok);
-	__set_bit(WRITE_10, filter->write_ok);
-	__set_bit(WRITE_VERIFY, filter->write_ok);
-	__set_bit(WRITE_12, filter->write_ok);
-	__set_bit(WRITE_VERIFY_12, filter->write_ok);
-	__set_bit(WRITE_16, filter->write_ok);
-	__set_bit(WRITE_LONG, filter->write_ok);
-	__set_bit(WRITE_LONG_2, filter->write_ok);
-	__set_bit(ERASE, filter->write_ok);
-	__set_bit(GPCMD_MODE_SELECT_10, filter->write_ok);
-	__set_bit(MODE_SELECT, filter->write_ok);
-	__set_bit(LOG_SELECT, filter->write_ok);
-	__set_bit(GPCMD_BLANK, filter->write_ok);
-	__set_bit(GPCMD_CLOSE_TRACK, filter->write_ok);
-	__set_bit(GPCMD_FLUSH_CACHE, filter->write_ok);
-	__set_bit(GPCMD_FORMAT_UNIT, filter->write_ok);
-	__set_bit(GPCMD_REPAIR_RZONE_TRACK, filter->write_ok);
-	__set_bit(GPCMD_RESERVE_RZONE_TRACK, filter->write_ok);
-	__set_bit(GPCMD_SEND_DVD_STRUCTURE, filter->write_ok);
-	__set_bit(GPCMD_SEND_EVENT, filter->write_ok);
-	__set_bit(GPCMD_SEND_KEY, filter->write_ok);
-	__set_bit(GPCMD_SEND_OPC, filter->write_ok);
-	__set_bit(GPCMD_SEND_CUE_SHEET, filter->write_ok);
-	__set_bit(GPCMD_SET_SPEED, filter->write_ok);
-	__set_bit(GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL, filter->write_ok);
-	__set_bit(GPCMD_LOAD_UNLOAD, filter->write_ok);
-	__set_bit(GPCMD_SET_STREAMING, filter->write_ok);
-	__set_bit(GPCMD_SET_READ_AHEAD, filter->write_ok);
+	sgio_bitmap_set(WRITE_6, write);
+	sgio_bitmap_set(WRITE_10, write);
+	sgio_bitmap_set(WRITE_VERIFY, write);
+	sgio_bitmap_set(WRITE_12, write);
+	sgio_bitmap_set(WRITE_VERIFY_12, write);
+	sgio_bitmap_set(WRITE_16, write);
+	sgio_bitmap_set(WRITE_LONG, write);
+	sgio_bitmap_set(WRITE_LONG_2, write);
+	sgio_bitmap_set(ERASE, write);
+	sgio_bitmap_set(GPCMD_MODE_SELECT_10, write);
+	sgio_bitmap_set(MODE_SELECT, write);
+	sgio_bitmap_set(LOG_SELECT, write);
+	sgio_bitmap_set(GPCMD_BLANK, write);
+	sgio_bitmap_set(GPCMD_CLOSE_TRACK, write);
+	sgio_bitmap_set(GPCMD_FLUSH_CACHE, write);
+	sgio_bitmap_set(GPCMD_FORMAT_UNIT, write);
+	sgio_bitmap_set(GPCMD_REPAIR_RZONE_TRACK, write);
+	sgio_bitmap_set(GPCMD_RESERVE_RZONE_TRACK, write);
+	sgio_bitmap_set(GPCMD_SEND_DVD_STRUCTURE, write);
+	sgio_bitmap_set(GPCMD_SEND_EVENT, write);
+	sgio_bitmap_set(GPCMD_SEND_KEY, write);
+	sgio_bitmap_set(GPCMD_SEND_OPC, write);
+	sgio_bitmap_set(GPCMD_SEND_CUE_SHEET, write);
+	sgio_bitmap_set(GPCMD_SET_SPEED, write);
+	sgio_bitmap_set(GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL, write);
+	sgio_bitmap_set(GPCMD_LOAD_UNLOAD, write);
+	sgio_bitmap_set(GPCMD_SET_STREAMING, write);
+	sgio_bitmap_set(GPCMD_SET_READ_AHEAD, write);
+#undef sgio_bitmap_set
 }
 
 int blk_verify_command(struct request_queue *q,
-- 
1.8.1.4



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

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-23 13:58 [PATCH v3 part1 0/4] Fix SG_IO ambiguity between READ SUBCHANNEL and UNMAP (and other similar cases) Paolo Bonzini
2013-05-23 13:58 ` [PATCH v3 part1 1/4] sg_io: pass request_queue to blk_verify_command Paolo Bonzini
2013-05-24  7:36   ` James Bottomley
2013-05-24  7:43     ` Paolo Bonzini
2013-05-24  7:50       ` James Bottomley
2013-05-24  7:53         ` Paolo Bonzini
2013-05-24  8:03           ` James Bottomley
2013-05-24  8:32             ` Paolo Bonzini
2013-05-24 21:41               ` Paolo Bonzini
2013-05-25  4:14               ` James Bottomley
2013-05-25  6:18                 ` Paolo Bonzini
2013-05-23 13:58 ` Paolo Bonzini [this message]
2013-05-23 13:58 ` [PATCH v3 part1 3/4] sg_io: use different default filters for each device class Paolo Bonzini
2013-05-23 13:58 ` [PATCH v3 part1 4/4] sg_io: resolve conflicts between commands assigned to multiple classes (CVE-2012-4542) Paolo Bonzini
2014-08-27  9:34 ` [PATCH v3 part1 0/4] Fix SG_IO ambiguity between READ SUBCHANNEL and UNMAP (and other similar cases) Luis Henriques
2014-08-27 10:09   ` Paolo Bonzini
2014-08-27 12:08     ` Luis Henriques
2014-08-27 17:47       ` Christoph Hellwig

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=1369317503-4095-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=stable@gnu.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

all inboxes | Powered by JetHome®