linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: [PATCH] 2.5.41, cciss, add rescan disk ioctl (6 of 5 :-)
@ 2002-10-09 16:49 Cameron, Steve
  0 siblings, 0 replies; 3+ messages in thread
From: Cameron, Steve @ 2002-10-09 16:49 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linux Kernel Mailing List, axboe


Alan Cox wrote:
> 
> On Wed, 2002-10-09 at 15:46, Stephen Cameron wrote:
> > This patch adds the CCISS_RESCANDISK ioctl which is meant 
> to be used in a 
> > configuration like Steeleye's Lifekeeper.  Two hosts 
> connect to the storage, 
> > one reserves disks.  The 2nd will not be able to read the partition 
> > information because of the reservations.  In the event the 
> 1st system fails, 
> > the 2nd can detect this, (via special hardware + software 
> typically) and then 
> > take over the storage and rescan he disks via this ioctl.
> > Applies to 2.5.41 (after applying my prior 4 patches to 2.5.4[01] )
> 
> Why not use the existing rescanning ioctls like BLKRRPART - 
> what else is
> different to need a custom ioctl?
> 

if i understand correctly, the BLKRRPART just does a rescan_partitions()
and does not do any INQUIRY and READ_CAPACITY to get the 
capacity and geometry information again, as normally, this would
already be done. 

This ioctl is meant for a failover type configuration where two hosts
have access to the storage.  Host A does a scsi reservation of the storage,
preventing the Host B from being able to talk to it.  So Host B can't do
the READ_CAPACITY successfully.  (this is on purpose).

This ioctl is used upon failover.  When Host B detects that Host A is failed,
Host B would make sure host A is_really_ dead, for example
by depriving it of power, and break the scsi reservation.  Then it uses
this ioctl to get the geometry and capacity information and rescan
the partitions.

Maybe it should use 2 ioctls?  One special one to get the geometry
and capacity info, and then the BLKRRPART ioctl to rescan partitions?

Hope that makes sense.

-- steve
 

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

* Re: [PATCH] 2.5.41, cciss, add rescan disk ioctl (6 of 5 :-)
  2002-10-09 14:46 Stephen Cameron
@ 2002-10-09 15:31 ` Alan Cox
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Cox @ 2002-10-09 15:31 UTC (permalink / raw)
  To: steve.cameron; +Cc: Linux Kernel Mailing List, axboe

On Wed, 2002-10-09 at 15:46, Stephen Cameron wrote:
> This patch adds the CCISS_RESCANDISK ioctl which is meant to be used in a 
> configuration like Steeleye's Lifekeeper.  Two hosts connect to the storage, 
> one reserves disks.  The 2nd will not be able to read the partition 
> information because of the reservations.  In the event the 1st system fails, 
> the 2nd can detect this, (via special hardware + software typically) and then 
> take over the storage and rescan he disks via this ioctl.
> Applies to 2.5.41 (after applying my prior 4 patches to 2.5.4[01] )

Why not use the existing rescanning ioctls like BLKRRPART - what else is
different to need a custom ioctl?


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

* [PATCH] 2.5.41, cciss, add rescan disk ioctl (6 of 5 :-)
@ 2002-10-09 14:46 Stephen Cameron
  2002-10-09 15:31 ` Alan Cox
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Cameron @ 2002-10-09 14:46 UTC (permalink / raw)
  To: linux-kernel; +Cc: axboe

This patch adds the CCISS_RESCANDISK ioctl which is meant to be used in a 
configuration like Steeleye's Lifekeeper.  Two hosts connect to the storage, 
one reserves disks.  The 2nd will not be able to read the partition 
information because of the reservations.  In the event the 1st system fails, 
the 2nd can detect this, (via special hardware + software typically) and then 
take over the storage and rescan he disks via this ioctl.
Applies to 2.5.41 (after applying my prior 4 patches to 2.5.4[01] )

(yes, this is patch 6 of 5, I can't seem to count this morning.
This will be the last one from me for today, I expect.) 

-- steve

diff -urN linux-2.5.41-c-factor2/drivers/block/cciss.c linux-2.5.41-rescan2/drivers/block/cciss.c
--- linux-2.5.41-c-factor2/drivers/block/cciss.c	Tue Oct  8 08:46:30 2002
+++ linux-2.5.41-rescan2/drivers/block/cciss.c	Tue Oct  8 15:27:58 2002
@@ -46,12 +46,12 @@
 #include <linux/completion.h>
 
 #define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin))
-#define DRIVER_NAME "Compaq CISS Driver (v 2.5.0)"
-#define DRIVER_VERSION CCISS_DRIVER_VERSION(2,5,0)
+#define DRIVER_NAME "Compaq CISS Driver (v 2.5.1)"
+#define DRIVER_VERSION CCISS_DRIVER_VERSION(2,5,1)
 
 /* Embedded module documentation macros - see modules.h */
 MODULE_AUTHOR("Charles M. White III - Compaq Computer Corporation");
-MODULE_DESCRIPTION("Driver for Compaq Smart Array Controller 5xxx v. 2.5.0");
+MODULE_DESCRIPTION("Driver for Compaq Smart Array Controller 5xxx v. 2.5.1");
 MODULE_LICENSE("GPL");
 
 #include "cciss_cmd.h"
@@ -108,6 +108,7 @@
 static int cciss_revalidate(kdev_t dev);
 static int deregister_disk(int ctlr, int logvol);
 static int register_new_disk(int cltr);
+static int cciss_rescan_disk(int cltr, int logvol);
 
 static void cciss_getgeometry(int cntl_num);
 
@@ -351,13 +352,22 @@
 		return -ENXIO;
 	/*
 	 * Root is allowed to open raw volume zero even if its not configured
-	 * so array config can still work.  I don't think I really like this,
+	 * so array config can still work.  Root is also allowed to open any
+	 * volume that has a LUN ID, so it can issue IOCTL to reread the
+	 * disk information.  I don't think I really like this,
 	 * but I'm already using way to many device nodes to claim another one
 	 * for "raw controller".
 	 */
 	if (hba[ctlr]->drv[dsk].nr_blocks == 0) {
-		if (minor(inode->i_rdev) != 0)
-			return -ENXIO;
+		if (minor(inode->i_rdev) != 0) {
+			/* if not node 0 make sure it is a partition = 0 */	
+			if (minor(inode->i_rdev) & 0x0f)
+				return -ENXIO;
+			/* if it is, make sure we have a LUN ID */
+			if (hba[ctlr]->drv[minor(inode->i_rdev)
+					>> NWD_SHIFT].LunID == 0)
+				return -ENXIO;
+		}
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
 	}
@@ -574,6 +584,9 @@
 	case CCISS_REVALIDVOLS:
                 return( revalidate_allvol(inode->i_rdev));
 
+	case CCISS_RESCANDISK:
+		return(cciss_rescan_disk(ctlr, dsk));
+
 	case CCISS_DEREGDISK:
 		return( deregister_disk(ctlr,dsk));
 
@@ -1234,6 +1247,52 @@
 	kfree(size_buff);
 	kfree(inq_buff);
 	return (logvol);
+}
+static int cciss_rescan_disk(int ctlr, int logvol)
+{
+	/* this is meant to be used in a configuration like 
+	   Steeleye's Lifekeeper.  Two hosts connect to the storage, one 
+	   reserves disks.  The 2nd will not be able to read the partition 
+	   information because of the reservations.  In the event the 1st 
+	   system fails, the 2nd can detect this, (via special hardware +
+	   software typically) and then take over the storage and rescan 
+	   the disks via this ioctl. */
+
+	struct gendisk *disk = hba[ctlr]->gendisk[logvol];
+	ReadCapdata_struct *size_buff;
+	InquiryData_struct *inq_buff;
+	unsigned int block_size;
+	unsigned int total_size;
+	kdev_t kdev;
+	struct block_device *bdev;
+
+	if (!capable(CAP_SYS_RAWIO))
+		return -EPERM;
+	if (hba[ctlr]->drv[logvol].nr_blocks != 0) {
+		/* disk is possibly on line, return just a warning */
+		return 1;
+	}
+	size_buff = kmalloc(sizeof( ReadCapdata_struct), GFP_KERNEL);
+	if (size_buff == NULL) {
+		printk(KERN_ERR "cciss: out of memory\n");
+		return -1;
+	}
+	inq_buff = kmalloc(sizeof( InquiryData_struct), GFP_KERNEL);
+	if (inq_buff == NULL) {
+		printk(KERN_ERR "cciss: out of memory\n");
+		kfree(size_buff);
+		return -1;
+	}
+	cciss_read_capacity(ctlr, logvol, size_buff, 1, &total_size, 
+				&block_size);
+	cciss_geometry_inquiry(ctlr, logvol, 1, total_size, block_size,
+			inq_buff, &hba[ctlr]->drv[logvol]); 
+	kdev = mk_kdev(MAJOR_NR + ctlr, disk->first_minor);
+	bdev = bdget(kdev_t_to_nr(kdev));
+	rescan_partitions(disk, bdev);
+	kfree(size_buff);
+	kfree(inq_buff);
+	return(0);
 }
 /*
  *   Wait polling for a command to complete.
diff -urN linux-2.5.41-c-factor2/include/linux/cciss_ioctl.h linux-2.5.41-rescan2/include/linux/cciss_ioctl.h
--- linux-2.5.41-c-factor2/include/linux/cciss_ioctl.h	Fri Sep 27 16:49:49 2002
+++ linux-2.5.41-rescan2/include/linux/cciss_ioctl.h	Tue Oct  8 13:57:48 2002
@@ -185,6 +185,7 @@
 #define CCISS_REVALIDVOLS  _IO(CCISS_IOC_MAGIC, 10)
 #define CCISS_PASSTHRU	   _IOWR(CCISS_IOC_MAGIC, 11, IOCTL_Command_struct)
 #define CCISS_DEREGDISK	   _IO(CCISS_IOC_MAGIC, 12)
+#define CCISS_RESCANDISK   _IO(CCISS_IOC_MAGIC, 16)
 
 /* no longer used... use REGNEWD instead */ 
 #define CCISS_REGNEWDISK  _IOW(CCISS_IOC_MAGIC, 13, int)

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

end of thread, other threads:[~2002-10-09 16:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-09 16:49 [PATCH] 2.5.41, cciss, add rescan disk ioctl (6 of 5 :-) Cameron, Steve
  -- strict thread matches above, loose matches on Subject: below --
2002-10-09 14:46 Stephen Cameron
2002-10-09 15:31 ` Alan Cox

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).