Whamcloud - gitweb
LU-2349 osp: Move log ops init to module init.
authorwangdi <di.wang@whamcloud.com>
Fri, 16 Nov 2012 19:16:29 +0000 (11:16 -0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 18 Jan 2013 16:57:35 +0000 (11:57 -0500)
Because osp_mds_ost_orig_logops and changelog_orig_logops
will be shared by all of the llog ctxt for all OSPs/MDDs
on one node, if we keep changing that during obd_setup
process, the loc_logops might be changed, i.e. lop_add
and lop_declare_add might become zero for a while. So if
other healthy device(like another osp) tried to delcare_add
or add record during the time, it will get ENOTSUPP.(especially
for DNE). So the ops initialization should move to module init.

Signed-off-by: wang di <di.wang@intel.com>
Change-Id: I1e46d2163c2431c43c369adb7b3c16e664260a4e
Reviewed-on: http://review.whamcloud.com/4608
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdd/mdd_device.c
lustre/osp/osp_dev.c
lustre/osp/osp_internal.h
lustre/osp/osp_sync.c

index e95c691..104d2b5 100644 (file)
@@ -301,8 +301,6 @@ static int mdd_changelog_llog_init(const struct lu_env *env,
        if (rc)
                RETURN(-ENODEV);
 
-       changelog_orig_logops = llog_osd_ops;
-       changelog_orig_logops.lop_cancel = llog_changelog_cancel;
        rc = llog_setup(env, obd, &obd->obd_olg, LLOG_CHANGELOG_ORIG_CTXT,
                        obd, &changelog_orig_logops);
        if (rc) {
@@ -319,10 +317,6 @@ static int mdd_changelog_llog_init(const struct lu_env *env,
        if (rc)
                GOTO(out_cleanup, rc);
 
-       ctxt->loc_handle->lgh_logops->lop_add = llog_cat_add_rec;
-       ctxt->loc_handle->lgh_logops->lop_declare_add =
-                                       llog_cat_declare_add_rec;
-
        rc = llog_cat_init_and_process(env, ctxt->loc_handle);
        if (rc)
                GOTO(out_close, rc);
@@ -1766,6 +1760,11 @@ static int __init mdd_mod_init(void)
        if (rc)
                return rc;
 
+       changelog_orig_logops = llog_osd_ops;
+       changelog_orig_logops.lop_cancel = llog_changelog_cancel;
+       changelog_orig_logops.lop_add = llog_cat_add_rec;
+       changelog_orig_logops.lop_declare_add = llog_cat_declare_add_rec;
+
        llo_local_obj_register(&llod_capa_key);
        llo_local_obj_register(&llod_mdd_orphan);
        llo_local_obj_register(&llod_mdd_root);
index 18ac9a8..7d5cb30 100644 (file)
@@ -48,6 +48,7 @@
 
 #include <obd_class.h>
 #include <lustre_param.h>
+#include <lustre_log.h>
 
 #include "osp_internal.h"
 
@@ -971,6 +972,8 @@ static struct obd_ops osp_obd_device_ops = {
        .o_statfs       = osp_obd_statfs,
 };
 
+struct llog_operations osp_mds_ost_orig_logops;
+
 static int __init osp_mod_init(void)
 {
        struct lprocfs_static_vars       lvars;
@@ -992,6 +995,11 @@ static int __init osp_mod_init(void)
                return rc;
        }
 
+       /* Note: add_rec/delcare_add_rec will be only used by catalogs */
+       osp_mds_ost_orig_logops = llog_osd_ops;
+       osp_mds_ost_orig_logops.lop_add = llog_cat_add_rec;
+       osp_mds_ost_orig_logops.lop_declare_add = llog_cat_declare_add_rec;
+
        osc_proc_dir = lprocfs_srch(proc_lustre_root, "osc");
        if (osc_proc_dir == NULL) {
                osc_proc_dir = lprocfs_register("osc", proc_lustre_root, NULL,
index 990915e..1815a0c 100644 (file)
@@ -295,6 +295,7 @@ static inline struct dt_object *osp_object_child(struct osp_object *o)
 
 /* osp_dev.c */
 void osp_update_last_id(struct osp_device *d, obd_id objid);
+extern struct llog_operations osp_mds_ost_orig_logops;
 
 /* osp_precreate.c */
 int osp_init_precreate(struct osp_device *d);
index a6c3de0..0616e87 100644 (file)
@@ -904,8 +904,6 @@ out:
        RETURN(0);
 }
 
-static struct llog_operations osp_mds_ost_orig_logops;
-
 static int osp_sync_llog_init(const struct lu_env *env, struct osp_device *d)
 {
        struct osp_thread_info *osi = osp_env_info(env);
@@ -937,7 +935,6 @@ static int osp_sync_llog_init(const struct lu_env *env, struct osp_device *d)
               osi->osi_cid.lci_logid.lgl_oseq,
               osi->osi_cid.lci_logid.lgl_ogen);
 
-       osp_mds_ost_orig_logops = llog_osd_ops;
        rc = llog_setup(env, obd, &obd->obd_olg, LLOG_MDS_OST_ORIG_CTXT, obd,
                        &osp_mds_ost_orig_logops);
        if (rc)
@@ -964,8 +961,6 @@ static int osp_sync_llog_init(const struct lu_env *env, struct osp_device *d)
        }
 
        ctxt->loc_handle = lgh;
-       lgh->lgh_logops->lop_add = llog_cat_add_rec;
-       lgh->lgh_logops->lop_declare_add = llog_cat_declare_add_rec;
 
        rc = llog_cat_init_and_process(env, lgh);
        if (rc)