Whamcloud - gitweb
Branch b1_5
authornathan <nathan>
Thu, 22 Jun 2006 22:44:46 +0000 (22:44 +0000)
committernathan <nathan>
Thu, 22 Jun 2006 22:44:46 +0000 (22:44 +0000)
b=6221
6221 didn't apply cleanly to b1_5

lustre/obdclass/class_obd.c
lustre/obdclass/linux/linux-module.c

index 1e80cb6..0144c70 100644 (file)
@@ -281,10 +281,8 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
                         GOTO(out, err = -EINVAL);
                 }
                                 
-                if (index >= MAX_OBD_DEVICES)
-                        GOTO(out, err = -ENOENT);
-                obd = obd_devs[index];
-                if (!obd->obd_type)
+                obd = class_num2obd(index);
+                if (!obd)
                         GOTO(out, err = -ENOENT);
                 
                 if (obd->obd_stopping)
index ee68551..6eb062b 100644 (file)
@@ -163,37 +163,37 @@ extern struct cfs_psdev_ops          obd_psdev_ops;
 /*  opening /dev/obd */
 static int obd_class_open(struct inode * inode, struct file * file)
 {
-       if (obd_psdev_ops.p_open != NULL)
-               return obd_psdev_ops.p_open(0, NULL);
-       return -EPERM;
+        if (obd_psdev_ops.p_open != NULL)
+                return obd_psdev_ops.p_open(0, NULL);
+        return -EPERM;
 }
 
 /*  closing /dev/obd */
 static int obd_class_release(struct inode * inode, struct file * file)
 {
-       if (obd_psdev_ops.p_close != NULL)
-               return obd_psdev_ops.p_close(0, NULL);
-       return -EPERM;
+        if (obd_psdev_ops.p_close != NULL)
+                return obd_psdev_ops.p_close(0, NULL);
+        return -EPERM;
 }
 
 /* to control /dev/obd */
 static int obd_class_ioctl(struct inode *inode, struct file *filp,
-                          unsigned int cmd, unsigned long arg)
+                           unsigned int cmd, unsigned long arg)
 {
-       int err = 0;
-       ENTRY;
+        int err = 0;
+        ENTRY;
 
-       if (current->fsuid != 0)
-               RETURN(err = -EACCES);
-       if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */
-               RETURN(err = -ENOTTY);
+        if (current->fsuid != 0)
+                RETURN(err = -EACCES);
+        if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */
+                RETURN(err = -ENOTTY);
 
-       if (obd_psdev_ops.p_ioctl != NULL)
-               err = obd_psdev_ops.p_ioctl(NULL, cmd, (void *)arg);
-       else
-               err = -EPERM;
+        if (obd_psdev_ops.p_ioctl != NULL)
+                err = obd_psdev_ops.p_ioctl(NULL, cmd, (void *)arg);
+        else
+                err = -EPERM;
 
-       RETURN(err);
+        RETURN(err);
 }
 
 /* declare character device */
@@ -255,11 +255,15 @@ static int obd_proc_read_health(char *page, char **start, off_t off,
                 rc += snprintf(page + rc, count - rc, "LBUG\n");
 
         spin_lock(&obd_dev_lock);
-        for (i = 0; i < MAX_OBD_DEVICES; i++) {
+        for (i = 0; i < class_devno_max(); i++) {
                 struct obd_device *obd;
 
-                obd = obd_devs[i];
-                if (obd->obd_type == NULL)
+                obd = class_num2obd(i);
+                if (obd == NULL)
+                        continue;
+
+                LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
+                if (obd->obd_stopping)
                         continue;
 
                 class_incref(obd);
@@ -322,9 +326,10 @@ struct lprocfs_vars lprocfs_base[] = {
 #ifdef __KERNEL__
 static void *obd_device_list_seq_start(struct seq_file *p, loff_t*pos)
 {
-        if (*pos >= MAX_OBD_DEVICES)
+        if (*pos >= class_devno_max())
                 return NULL;
-        return obd_devs[*pos];
+
+        return pos;
 }
 
 static void obd_device_list_seq_stop(struct seq_file *p, void *v)
@@ -332,21 +337,24 @@ static void obd_device_list_seq_stop(struct seq_file *p, void *v)
 }
 
 static void *obd_device_list_seq_next(struct seq_file *p, void *v, loff_t *pos)
-{
+{      
         ++*pos;
-        if (*pos >= MAX_OBD_DEVICES)
+        if (*pos >= class_devno_max())
                 return NULL;
-        return obd_devs[*pos];
+
+        return pos;
 }
 
 static int obd_device_list_seq_show(struct seq_file *p, void *v)
 {
-        struct obd_device *obd = (struct obd_device *)v;
-        int index = obd - obd_devs[0];
+        int index = *(int*)v;
+        struct obd_device *obd = class_num2obd(index);
         char *status;
 
-        if (!obd->obd_type)
+        if (obd == NULL)
                 return 0;
+
+        LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
         if (obd->obd_stopping)
                 status = "ST";
         else if (obd->obd_set_up)