From 99d06f1b64a7f2e42013aa19518c10dc38203ad2 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 22 Jun 2006 22:44:46 +0000 Subject: [PATCH] Branch b1_5 b=6221 6221 didn't apply cleanly to b1_5 --- lustre/obdclass/class_obd.c | 6 ++-- lustre/obdclass/linux/linux-module.c | 66 ++++++++++++++++++++---------------- 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 1e80cb6..0144c70 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -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) diff --git a/lustre/obdclass/linux/linux-module.c b/lustre/obdclass/linux/linux-module.c index ee68551..6eb062b 100644 --- a/lustre/obdclass/linux/linux-module.c +++ b/lustre/obdclass/linux/linux-module.c @@ -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) -- 1.8.3.1