From 702754812e7221102deb41aaeed4715a734a75f0 Mon Sep 17 00:00:00 2001 From: wangdi Date: Fri, 16 Nov 2012 11:16:29 -0800 Subject: [PATCH 1/1] LU-2349 osp: Move log ops init to module init. 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 Change-Id: I1e46d2163c2431c43c369adb7b3c16e664260a4e Reviewed-on: http://review.whamcloud.com/4608 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Mike Pershin Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- lustre/mdd/mdd_device.c | 11 +++++------ lustre/osp/osp_dev.c | 8 ++++++++ lustre/osp/osp_internal.h | 1 + lustre/osp/osp_sync.c | 5 ----- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index e95c691..104d2b5 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -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); diff --git a/lustre/osp/osp_dev.c b/lustre/osp/osp_dev.c index 18ac9a8..7d5cb30 100644 --- a/lustre/osp/osp_dev.c +++ b/lustre/osp/osp_dev.c @@ -48,6 +48,7 @@ #include #include +#include #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, diff --git a/lustre/osp/osp_internal.h b/lustre/osp/osp_internal.h index 990915e..1815a0c 100644 --- a/lustre/osp/osp_internal.h +++ b/lustre/osp/osp_internal.h @@ -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); diff --git a/lustre/osp/osp_sync.c b/lustre/osp/osp_sync.c index a6c3de0..0616e87 100644 --- a/lustre/osp/osp_sync.c +++ b/lustre/osp/osp_sync.c @@ -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) -- 1.8.3.1