Whamcloud - gitweb
- except for fixing the segfault in the documentation build, this is
[fs/lustre-release.git] / lustre / obdclass / proc_lustre.c
index 58af539..66ff902 100644 (file)
 
 #ifdef CONFIG_PROC_FS
 extern struct proc_dir_entry proc_root;
-
 static struct proc_dir_entry *proc_lustre_dir_entry = 0;
 static struct proc_dir_entry *proc_lustre_obd_dir_entry = 0;
 
-static struct proc_dir_entry *
-proc_lustre_mkdir(const char* dname, struct proc_dir_entry *parent)
-{
-       struct proc_dir_entry *child_dir_entry;
-
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,3,0) /*0x20300 */
-       child_dir_entry = proc_mkdir(dname, parent);
-#else
-       child_dir_entry = create_proc_entry(dname,
-                                           S_IFDIR | S_IRUGO | S_IXUGO,
-                                           &proc_root);
-#endif
-       if (!child_dir_entry)
-                CERROR("lustre: failed to create /proc entry %s\n", dname);
-       
-       return child_dir_entry;
-}
 
 static int read_lustre_status(char *page, char **start, off_t offset,
                              int count, int *eof, void *data)
@@ -77,57 +59,49 @@ static int read_lustre_status(char *page, char **start, off_t offset,
        struct obd_device * obddev = (struct obd_device *) data;
        int p;
 
-       p = sprintf(&page[0], "/dev/obd%d: ", obddev->obd_minor);
+       p = sprintf(&page[0], "device %d: ", obddev->obd_minor);
        
-       if (obddev->obd_refcnt==0) { 
-               /* obd is unused */
-               p += sprintf(&page[p], "open but unused\n");
-       }
-       else {  /* obd in use */
-               p += sprintf(&page[p], "refcnt(%d)", obddev->obd_refcnt);
-               
-               if  (obddev->obd_flags & OBD_ATTACHED) {
-                       p += sprintf(&page[p], ", attached(%s)", 
-                                    obddev->obd_type->typ_name);
-               }
-               
-               if  (obddev->obd_flags & OBD_SET_UP) {
-                       struct dentry   *my_dentry;
-                       struct vfsmount *root_mnt;
-                       char *path;
-                       char *pathpage;
-                       
-                       if (!(pathpage = (char*) __get_free_page(GFP_KERNEL)))
-                               return -ENOMEM;
-               
-                       my_dentry = obddev->obd_fsname.dentry;
-                       root_mnt = mntget(current->fs->rootmnt);
-                       path = d_path(my_dentry,root_mnt,pathpage,PAGE_SIZE);
-
-                       p += sprintf(&page[p], ", setup(%s)", path);
-                       
-                       free_page((unsigned long) pathpage);
-               }
-               
-               /* print connections */
-               {
-                       struct list_head * lh;
-                       struct obd_client * cli=0;
-                       
-                       lh = &obddev->obd_gen_clients;
-                       while ((lh = lh->next) != &obddev->obd_gen_clients) {
-                               p += sprintf(&page[p],
-                                            ((cli==0) ? ", connections(" : ",") );
-                               cli = list_entry(lh, struct obd_client, cli_chain);
-                               p += sprintf(&page[p], "%d", cli->cli_id);
-                       } /* while */
-                       if (cli!=0) { /* there was at least one client */
-                               p += sprintf(&page[p], ")");
-                       }
-               }
+        if  (obddev->obd_flags & OBD_ATTACHED) {
+                p += sprintf(&page[p], ", attached(%s)", 
+                             obddev->obd_type->typ_name);
+        }
+        
+        if  (obddev->obd_flags & OBD_SET_UP) {
+                struct dentry   *my_dentry;
+                struct vfsmount *root_mnt;
+                char *path;
+                char *pathpage;
+                
+                if (!(pathpage = (char*) __get_free_page(GFP_KERNEL)))
+                        return -ENOMEM;
                
-               p += sprintf(&page[p], "\n");
-       }
+                my_dentry = NULL;
+                root_mnt = mntget(current->fs->rootmnt);
+                path = d_path(my_dentry,root_mnt,pathpage,PAGE_SIZE);
+                
+                p += sprintf(&page[p], ", setup(%s)", path);
+                
+                free_page((unsigned long) pathpage);
+        }
+        
+        /* print exports */
+        {
+                struct list_head * lh;
+                struct obd_export * export=0;
+                
+                lh = &obddev->obd_exports;
+                while ((lh = lh->next) != &obddev->obd_exports) {
+                        p += sprintf(&page[p],
+                                     ((export==0) ? ", connections(" : ",") );
+                        export = list_entry(lh, struct obd_export, export_chain);
+                        p += sprintf(&page[p], "%p", export);
+                } 
+                if (export!=0) { /* there was at least one export */
+                        p += sprintf(&page[p], ")");
+                }
+        }
+        
+        p += sprintf(&page[p], "\n");
 
        /* Compute eof and return value */
 
@@ -146,21 +120,20 @@ proc_lustre_register_obd_device(struct obd_device *obd)
        struct proc_dir_entry *obd_status = 0;
 
        if (!proc_lustre_dir_entry) {
-               proc_lustre_dir_entry = 
-                       proc_lustre_mkdir("lustre", &proc_root);
-               if (!proc_lustre_dir_entry)
+               proc_lustre_dir_entry = proc_mkdir("lustre", &proc_root);
+               if (IS_ERR(proc_lustre_dir_entry))
                        return 0;
        
                proc_lustre_obd_dir_entry = 
-                       proc_lustre_mkdir("obd", proc_lustre_dir_entry);
-               if (!proc_lustre_obd_dir_entry)
+                       proc_mkdir("obd", proc_lustre_dir_entry);
+               if (IS_ERR(proc_lustre_obd_dir_entry))
                        return 0;
        }
 
        sprintf(obdname, "%d", obd->obd_minor);
 
-       obd_dir =  proc_lustre_mkdir(obdname, proc_lustre_obd_dir_entry);
-       
+
+       obd_dir =  proc_mkdir(obdname, proc_lustre_obd_dir_entry);
         if (obd_dir) 
                obd_status = create_proc_entry("status", S_IRUSR | S_IFREG, obd_dir);
 
@@ -189,14 +162,14 @@ void proc_lustre_remove_obd_entry(const char* name, struct obd_device *obd)
                        
                obd_entry = obd_dir;
                obd_dir = obd_dir->parent;
-       
-               /* If /proc/lustre/obd/XXX or /proc/lustre/obd or
-                * /proc/lustre are being removed, then reset 
+
+               /* If /proc/lustre/obd/foo or /proc/lustre/obd or
+                * /proc/lustre is being removed, then reset
                 * internal variables
                 */
-               
-               if (obd_entry == obd->obd_proc_entry) 
-                       obd->obd_proc_entry=0; /* /proc/lustre/obd/XXX */
+
+               if (obd_entry == obd->obd_proc_entry)
+                       obd->obd_proc_entry=0; /* /proc/lustre/obd/foo */
                else 
                        if (obd_entry == proc_lustre_obd_dir_entry)
                                proc_lustre_obd_dir_entry=0;