Whamcloud - gitweb
LU-3331 obdclass: return errors from class_procfs_init() 35/11935/2
authorJohn L. Hammond <john.hammond@intel.com>
Tue, 16 Sep 2014 00:02:49 +0000 (19:02 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 18 Sep 2014 10:23:37 +0000 (10:23 +0000)
In class_procfs_init() if /proc/fs/lustre/ or /proc/fs/lustre/devices
cannot be created then cleanup and return an error.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: I236a4af31c44b73207d411c02873c10ee7478ca7
Reviewed-on: http://review.whamcloud.com/11935
Tested-by: Jenkins
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/obdclass/linux/linux-module.c

index 04ec8c5..56ee26c 100644 (file)
@@ -412,17 +412,35 @@ struct file_operations obd_device_list_fops = {
 
 int class_procfs_init(void)
 {
 
 int class_procfs_init(void)
 {
+       struct proc_dir_entry *entry;
        int rc;
        ENTRY;
 
        obd_sysctl_init();
        int rc;
        ENTRY;
 
        obd_sysctl_init();
-       proc_lustre_root = lprocfs_seq_register("fs/lustre", NULL,
-                                               lprocfs_base, NULL);
+
+       entry = lprocfs_seq_register("fs/lustre", NULL, lprocfs_base, NULL);
+       if (IS_ERR(entry)) {
+               rc = PTR_ERR(entry);
+               CERROR("cannot create '/proc/fs/lustre': rc = %d\n", rc);
+               RETURN(rc);
+       }
+
+       proc_lustre_root = entry;
+
        rc = lprocfs_seq_create(proc_lustre_root, "devices", 0444,
                                &obd_device_list_fops, NULL);
        rc = lprocfs_seq_create(proc_lustre_root, "devices", 0444,
                                &obd_device_list_fops, NULL);
-       if (rc)
-               CERROR("error adding /proc/fs/lustre/devices file\n");
-       RETURN(0);
+       if (rc < 0) {
+               CERROR("cannot create '/proc/fs/lustre/devices': rc = %d\n",
+                      rc);
+               GOTO(out_proc, rc);
+       }
+
+       RETURN(rc);
+
+out_proc:
+       lprocfs_remove(&proc_lustre_root);
+
+       RETURN(rc);
 }
 
 int class_procfs_clean(void)
 }
 
 int class_procfs_clean(void)