Whamcloud - gitweb
LU-2729 mgs: fix cleanup of nonexistant MGSSELF_NAME proc file
[fs/lustre-release.git] / lustre / mgs / lproc_mgs.c
index 06b8396..65513fd 100644 (file)
@@ -154,8 +154,8 @@ int lproc_mgs_setup(struct mgs_device *mgs, char *osd_name)
 
         rc = lprocfs_obd_seq_create(obd, "filesystems", 0444,
                                     &mgs_fs_fops, obd);
-        rc = lprocfs_obd_seq_create(obd, "srpc_rules", 0600,
-                                    &mgsself_srpc_fops, obd);
+       rc = lprocfs_obd_seq_create(obd, "srpc_rules", 0400,
+                                   &mgsself_srpc_fops, obd);
 
         mgs->mgs_proc_live = lprocfs_register("live", obd->obd_proc_entry,
                                               NULL, NULL);
@@ -198,12 +198,12 @@ int lproc_mgs_setup(struct mgs_device *mgs, char *osd_name)
        return rc;
 }
 
-int lproc_mgs_cleanup(struct mgs_device *mgs)
+void lproc_mgs_cleanup(struct mgs_device *mgs)
 {
        struct obd_device *obd = mgs->mgs_obd;
 
-        if (!obd)
-                return -EINVAL;
+       if (obd == NULL)
+               return;
 
        if (mgs->mgs_proc_osd != NULL)
                lprocfs_remove(&mgs->mgs_proc_osd);
@@ -220,10 +220,9 @@ int lproc_mgs_cleanup(struct mgs_device *mgs)
                 mgs->mgs_proc_live = NULL;
         }
         lprocfs_free_per_client_stats(obd);
+       lprocfs_obd_cleanup(obd);
         lprocfs_free_obd_stats(obd);
         lprocfs_free_md_stats(obd);
-
-        return lprocfs_obd_cleanup(obd);
 }
 
 static int mgs_live_seq_show(struct seq_file *seq, void *v)
@@ -282,8 +281,8 @@ int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb)
 
         if (!mgs->mgs_proc_live)
                 return 0;
-        rc = lprocfs_seq_create(mgs->mgs_proc_live, fsdb->fsdb_name, 0444,
-                                &mgs_live_fops, fsdb);
+       rc = lprocfs_seq_create(mgs->mgs_proc_live, fsdb->fsdb_name, 0644,
+                               &mgs_live_fops, fsdb);
 
         return 0;
 }
@@ -293,7 +292,9 @@ int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb)
         if (!mgs->mgs_proc_live)
                 return 0;
 
-        lprocfs_remove_proc_entry(fsdb->fsdb_name, mgs->mgs_proc_live);
+       /* didn't create the proc file for MGSSELF_NAME */
+       if (!test_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags))
+               lprocfs_remove_proc_entry(fsdb->fsdb_name, mgs->mgs_proc_live);
         return 0;
 }