Whamcloud - gitweb
LU-4056 hsm: reorder MDT proc cleanup 46/7846/3
authorJohn L. Hammond <john.hammond@intel.com>
Thu, 3 Oct 2013 19:35:00 +0000 (14:35 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 7 Oct 2013 04:43:56 +0000 (04:43 +0000)
In mdt_procfs_init() remove the call to ptlrpc_lprocfs_register_obd().
The single file that this provides (../mdt/*/stats) is backed by the
MDT OBD's obd_svc_stats which are not tallied. In mdt_procfs_fini()
remove the corresponding call to ptlrpc_lprocfs_unregister_obd() and
move the call to hsm_cdt_procfs_fini() to before
lprocfs_obd_cleanup(). This prevents a use after free of the entries
in the MDT's hsm subdirectory.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: Iad6e7738047377660f0077c9368f79d96f903d02
Reviewed-on: http://review.whamcloud.com/7846
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Faccini Bruno <bruno.faccini@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdt/mdt_lproc.c
lustre/tests/sanity-sec.sh

index 6953802..4bdf984 100644 (file)
@@ -229,13 +229,13 @@ int mdt_procfs_init(struct mdt_device *mdt, const char *name)
                       mdt_obd_name(mdt), rc);
                return rc;
        }
+
        rc = hsm_cdt_procfs_init(mdt);
        if (rc) {
                CERROR("%s: cannot create hsm proc entries: rc = %d\n",
                       mdt_obd_name(mdt), rc);
                return rc;
        }
-       ptlrpc_lprocfs_register_obd(obd);
 
        obd->obd_proc_exports_entry = proc_mkdir("exports",
                                                 obd->obd_proc_entry);
@@ -263,14 +263,14 @@ void mdt_procfs_fini(struct mdt_device *mdt)
 {
        struct obd_device *obd = mdt2obd_dev(mdt);
 
-       if (obd->obd_proc_exports_entry) {
+       if (obd->obd_proc_exports_entry != NULL) {
                lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry);
                obd->obd_proc_exports_entry = NULL;
        }
+
        lprocfs_free_per_client_stats(obd);
-       lprocfs_obd_cleanup(obd);
        hsm_cdt_procfs_fini(mdt);
-       ptlrpc_lprocfs_unregister_obd(obd);
+       lprocfs_obd_cleanup(obd);
        lprocfs_free_md_stats(obd);
        lprocfs_free_obd_stats(obd);
        lprocfs_job_stats_fini(obd);
index 70e1114..03ac2cc 100644 (file)
@@ -74,7 +74,8 @@ else
        echo "without GSS support"
 fi
 
-MDT="`do_facet $SINGLEMDS "lctl get_param -N mdt.\*MDT\*.stats 2>/dev/null | cut -d"." -f2" || true`"
+MDT=$(do_facet $SINGLEMDS lctl get_param -N "mdt.\*MDT0000" |
+       cut -d. -f2 || true)
 [ -z "$MDT" ] && error "fail to get MDT device" && exit 1
 do_facet $SINGLEMDS "mkdir -p $CONFDIR"
 IDENTITY_FLUSH=mdt.$MDT.identity_flush