public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [Patch 2/4] aacraid: expanded expose physical device code
@ 2007-01-23 22:59 Mark Haverkamp
  2007-01-24  5:49 ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Haverkamp @ 2007-01-23 22:59 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, Mark Salyzyn

Received from Mark Salyzyn,

Take the expose_physicals flag and allow the user to select default (physicals
available via /dev/sg), exposed (physicals available via /dev/sd for
experimental reasons) and hidden (physicals blocked from all access). This
expands the functionality of the previous expose_physicals insmod parameter
which was added to support some experimental configurations.

Signed-off-by Mark Haverkamp <markh@linux-foundation.org>
---

--- scsi-misc-aac.orig/drivers/scsi/aacraid/aachba.c	2007-01-18 10:06:55.000000000 -0800
+++ scsi-misc-aac/drivers/scsi/aacraid/aachba.c	2007-01-18 10:11:26.000000000 -0800
@@ -170,9 +170,9 @@
 module_param(acbsize, int, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(acbsize, "Request a specific adapter control block (FIB) size. Valid values are 512, 2048, 4096 and 8192. Default is to use suggestion from Firmware.");
 
-int expose_physicals = 0;
+int expose_physicals = -1;
 module_param(expose_physicals, int, S_IRUGO|S_IWUSR);
-MODULE_PARM_DESC(expose_physicals, "Expose physical components of the arrays. 0=off, 1=on");
+MODULE_PARM_DESC(expose_physicals, "Expose physical components of the arrays. -1=protect 0=off, 1=on");
 /**
  *	aac_get_config_status	-	check the adapter configuration
  *	@common: adapter to query
@@ -1973,7 +1973,41 @@
 	case SRB_STATUS_ERROR_RECOVERY:
 	case SRB_STATUS_PENDING:
 	case SRB_STATUS_SUCCESS:
-		scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
+		if ((scsicmd->cmnd[0] == INQUIRY) && (expose_physicals <= 0)) {
+			u8 b;
+			u8 b1;
+			/* We can't expose disk devices because we can't
+			 * tell whether they are the raw container drives
+			 * or stand alone drives.  If they have the removable
+			 * bit set then we should expose them though.
+			 */
+			b = (*(u8*)scsicmd->request_buffer)&0x1f;
+			b1 = ((u8*)scsicmd->request_buffer)[1];
+			if (b == TYPE_TAPE || b == TYPE_WORM ||
+			    b == TYPE_ROM || b==TYPE_MOD ||
+			    b == TYPE_MEDIUM_CHANGER ||
+			    (b == TYPE_DISK && (b1 & 0x80))) {
+				scsicmd->result = DID_OK << 16 |
+					COMMAND_COMPLETE << 8;
+			/*
+			 * We will allow disk devices if in RAID/SCSI mode and
+			 * the channel is 2
+			 */
+			} else if ((dev->raid_scsi_mode) &&
+					(scmd_channel(scsicmd) == 2)) {
+				scsicmd->result = DID_OK << 16 |
+						COMMAND_COMPLETE << 8;
+			} else if (expose_physicals) {
+				scsicmd->device->no_uld_attach = 1;
+				scsicmd->result = DID_OK << 16 |
+						COMMAND_COMPLETE << 8;
+			} else {
+				scsicmd->result = DID_NO_CONNECT << 16 |
+						COMMAND_COMPLETE << 8;
+			}
+		} else {
+			scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
+		}
 		break;
 	case SRB_STATUS_DATA_OVERRUN:
 		switch(scsicmd->cmnd[0]){
@@ -1993,7 +2027,41 @@
 			scsicmd->result = DID_ERROR << 16 | COMMAND_COMPLETE << 8;
 			break;
 		case INQUIRY: {
+		if (expose_physicals <= 0) {
+			u8 b;
+			u8 b1;
+			/* We can't expose disk devices because we can't tell
+			 * whether they are the raw container drives or
+			 * stand alone drives
+			 */
+			b = (*(u8*)scsicmd->request_buffer)&0x0f;
+			b1 = ((u8*)scsicmd->request_buffer)[1];
+			if (b == TYPE_TAPE || b == TYPE_WORM ||
+			    b == TYPE_ROM || b == TYPE_MOD ||
+			    b == TYPE_MEDIUM_CHANGER ||
+			    (b == TYPE_DISK && (b1&0x80))) {
+				scsicmd->result = DID_OK << 16 |
+					COMMAND_COMPLETE << 8;
+			/*
+			 * We will allow disk devices if in RAID/SCSI mode and
+			 * the channel is 2
+			 */
+			} else if (((dev->raid_scsi_mode) &&
+					(scmd_channel(scsicmd) == 2)) ||
+					(expose_physicals == 1)) {
+				scsicmd->result = DID_OK << 16 |
+						COMMAND_COMPLETE << 8;
+			} else if (expose_physicals) {
+				scsicmd->device->no_uld_attach = 1;
+				scsicmd->result = DID_OK << 16 |
+						COMMAND_COMPLETE << 8;
+			} else {
+				scsicmd->result = DID_NO_CONNECT << 16 |
+						COMMAND_COMPLETE << 8;
+			}
+		} else {
 			scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8;
+		}
 			break;
 		}
 		default:
--- scsi-misc-aac.orig/drivers/scsi/aacraid/linit.c	2007-01-18 10:06:55.000000000 -0800
+++ scsi-misc-aac/drivers/scsi/aacraid/linit.c	2007-01-18 10:11:26.000000000 -0800
@@ -396,7 +396,7 @@
 		sdev->skip_ms_page_3f = 1;
 	}
 	if ((sdev->type == TYPE_DISK) &&
-			!expose_physicals &&
+			(expose_physicals < 0) &&
 			(sdev_channel(sdev) != CONTAINER_CHANNEL)) {
 		struct aac_dev *aac = (struct aac_dev *)sdev->host->hostdata;
 		if (!aac->raid_scsi_mode || (sdev_channel(sdev) != 2))

-- 
Mark Haverkamp <markh@linux-foundation.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch 2/4] aacraid: expanded expose physical device code
  2007-01-23 22:59 [Patch 2/4] aacraid: expanded expose physical device code Mark Haverkamp
@ 2007-01-24  5:49 ` Christoph Hellwig
  2007-01-24 16:31   ` Mark Haverkamp
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2007-01-24  5:49 UTC (permalink / raw)
  To: Mark Haverkamp; +Cc: James Bottomley, linux-scsi, Mark Salyzyn

> +		if ((scsicmd->cmnd[0] == INQUIRY) && (expose_physicals <= 0)) {
> +			u8 b;
> +			u8 b1;
> +			/* We can't expose disk devices because we can't
> +			 * tell whether they are the raw container drives
> +			 * or stand alone drives.  If they have the removable
> +			 * bit set then we should expose them though.
> +			 */
> +			b = (*(u8*)scsicmd->request_buffer)&0x1f;
> +			b1 = ((u8*)scsicmd->request_buffer)[1];
> +			if (b == TYPE_TAPE || b == TYPE_WORM ||
> +			    b == TYPE_ROM || b==TYPE_MOD ||
> +			    b == TYPE_MEDIUM_CHANGER ||
> +			    (b == TYPE_DISK && (b1 & 0x80))) {
> +				scsicmd->result = DID_OK << 16 |
> +					COMMAND_COMPLETE << 8;

This can't work at all.  request_buffer is always a scatterlist these days.
Besides this implementation bug it's also not the wrong way to do it either.
Please just return -ENXIO in ->slave_configure if sdev->type is not to
your liking instead of failing the INQUIRY command.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch 2/4] aacraid: expanded expose physical device code
  2007-01-24  5:49 ` Christoph Hellwig
@ 2007-01-24 16:31   ` Mark Haverkamp
  2007-01-24 16:51     ` James Bottomley
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Haverkamp @ 2007-01-24 16:31 UTC (permalink / raw)
  To: Christoph Hellwig, James Bottomley; +Cc: linux-scsi, Mark Salyzyn

On Wed, 2007-01-24 at 05:49 +0000, Christoph Hellwig wrote:
> > +		if ((scsicmd->cmnd[0] == INQUIRY) && (expose_physicals <= 0)) {
> > +			u8 b;
> > +			u8 b1;
> > +			/* We can't expose disk devices because we can't
> > +			 * tell whether they are the raw container drives
> > +			 * or stand alone drives.  If they have the removable
> > +			 * bit set then we should expose them though.
> > +			 */
> > +			b = (*(u8*)scsicmd->request_buffer)&0x1f;
> > +			b1 = ((u8*)scsicmd->request_buffer)[1];
> > +			if (b == TYPE_TAPE || b == TYPE_WORM ||
> > +			    b == TYPE_ROM || b==TYPE_MOD ||
> > +			    b == TYPE_MEDIUM_CHANGER ||
> > +			    (b == TYPE_DISK && (b1 & 0x80))) {
> > +				scsicmd->result = DID_OK << 16 |
> > +					COMMAND_COMPLETE << 8;
> 
> This can't work at all.  request_buffer is always a scatterlist these days.
> Besides this implementation bug it's also not the wrong way to do it either.
> Please just return -ENXIO in ->slave_configure if sdev->type is not to
> your liking instead of failing the INQUIRY command.

Christoph,

I talked to Mark Salyzyn about this.  He wants to drop this patch for
the time being and re-think it.

James,

The other patches still apply with this one removed (One applies with
fuzz).  Is that OK or should I re-diff and resend them.

Mark.

-- 
Mark Haverkamp <markh@linux-foundation.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch 2/4] aacraid: expanded expose physical device code
  2007-01-24 16:31   ` Mark Haverkamp
@ 2007-01-24 16:51     ` James Bottomley
  0 siblings, 0 replies; 4+ messages in thread
From: James Bottomley @ 2007-01-24 16:51 UTC (permalink / raw)
  To: Mark Haverkamp; +Cc: Christoph Hellwig, linux-scsi, Mark Salyzyn

On Wed, 2007-01-24 at 08:31 -0800, Mark Haverkamp wrote:
> The other patches still apply with this one removed (One applies with
> fuzz).  Is that OK or should I re-diff and resend them.

That should be fine ... I get large numbers of patches that either apply
with fuzz or even have rejects.

James



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-01-24 16:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-23 22:59 [Patch 2/4] aacraid: expanded expose physical device code Mark Haverkamp
2007-01-24  5:49 ` Christoph Hellwig
2007-01-24 16:31   ` Mark Haverkamp
2007-01-24 16:51     ` James Bottomley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox