2.5.41, cciss, add rescan disk ioctl (6 of 5 :-)

2.5.41, cciss, add rescan disk ioctl (6 of 5 :-)

Post by Stephen Camero » Thu, 10 Oct 2002 17:00:07



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

 #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");


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

                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;

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

        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

 #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)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

2.5.41, cciss, add rescan disk ioctl (6 of 5 :-)

Post by Alan Co » Thu, 10 Oct 2002 17:30:10



> 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?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

2.5.41, cciss, add rescan disk ioctl (6 of 5 :-)

Post by Cameron, Stev » Thu, 10 Oct 2002 19:00:08




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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/