From: Mikhail Pershin Date: Fri, 31 Aug 2012 05:18:35 +0000 (+0400) Subject: LU-1302 llog: simplify llog_setup functionality X-Git-Tag: 2.3.51~35 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=1d2bf12a7c3e954858e08134f4e7bc1fce9a5812 LU-1302 llog: simplify llog_setup functionality llog catalog used llog_obd_origin_setup as llog_setup() function It does actually setup, open and llog processing inside that makes it different from plain llog and breaks new llog API Patch does the following: - llog operations are needed for both ctxt and handler, in ctxt there are disk and network operations possible, per-handle there are plain and catalog llogs. in-handle operations are taken from ctxt at first then updated for catalogs by the caller - rework llog_setup, keep only ctxt allocation in it, remove unused parameters, remove llog_setup_named as name was never used Signed-off-by: Mikhail Pershin Change-Id: I8641e697898a1a57bbc500b649f065ba3f2d41b0 Reviewed-on: http://review.whamcloud.com/3949 Tested-by: Hudson Reviewed-by: Andreas Dilger Reviewed-by: Jinshan Xiong Tested-by: Maloo --- diff --git a/lustre/include/lustre_log.h b/lustre/include/lustre_log.h index ebd5591..a4c131b 100644 --- a/lustre/include/lustre_log.h +++ b/lustre/include/lustre_log.h @@ -184,8 +184,6 @@ struct llog_process_cat_args { void *lpca_arg; }; -int cat_cancel_cb(const struct lu_env *env, struct llog_handle *cathandle, - struct llog_rec_hdr *rec, void *data); int llog_cat_close(const struct lu_env *env, struct llog_handle *cathandle); int llog_cat_add(const struct lu_env *env, struct llog_handle *cathandle, struct llog_rec_hdr *rec, struct llog_cookie *reccookie, @@ -193,27 +191,24 @@ int llog_cat_add(const struct lu_env *env, struct llog_handle *cathandle, int llog_cat_cancel_records(const struct lu_env *env, struct llog_handle *cathandle, int count, struct llog_cookie *cookies); -int __llog_cat_process(const struct lu_env *env, struct llog_handle *cat_llh, - llog_cb_t cb, void *data, int startcat, int startidx, - int fork); +int llog_cat_process_or_fork(const struct lu_env *env, + struct llog_handle *cat_llh, llog_cb_t cb, + void *data, int startcat, int startidx, bool fork); int llog_cat_process(const struct lu_env *env, struct llog_handle *cat_llh, llog_cb_t cb, void *data, int startcat, int startidx); int llog_cat_process_thread(void *data); int llog_cat_reverse_process(const struct lu_env *env, struct llog_handle *cat_llh, llog_cb_t cb, void *data); -int llog_cat_set_first_idx(struct llog_handle *cathandle, int index); +int llog_cat_init_and_process(const struct lu_env *env, + struct llog_handle *llh); /* llog_obd.c */ -int llog_setup_named(struct obd_device *obd, struct obd_llog_group *olg, - int index, struct obd_device *disk_obd, int count, - struct llog_logid *logid, const char *logname, - struct llog_operations *op); -int llog_setup(struct obd_device *obd, struct obd_llog_group *olg, int index, - struct obd_device *disk_obd, int count, struct llog_logid *logid, - struct llog_operations *op); -int __llog_ctxt_put(struct llog_ctxt *ctxt); -int llog_cleanup(struct llog_ctxt *); +int llog_setup(const struct lu_env *env, struct obd_device *obd, + struct obd_llog_group *olg, int index, + struct obd_device *disk_obd, struct llog_operations *op); +int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt); +int llog_cleanup(const struct lu_env *env, struct llog_ctxt *); int llog_sync(struct llog_ctxt *ctxt, struct obd_export *exp, int flags); int llog_obd_add(const struct lu_env *env, struct llog_ctxt *ctxt, struct llog_rec_hdr *rec, struct lov_stripe_md *lsm, @@ -221,11 +216,6 @@ int llog_obd_add(const struct lu_env *env, struct llog_ctxt *ctxt, int llog_cancel(const struct lu_env *env, struct llog_ctxt *ctxt, struct lov_stripe_md *lsm, int count, struct llog_cookie *cookies, int flags); -int llog_obd_origin_setup(const struct lu_env *env, struct obd_device *obd, - struct obd_llog_group *olg, int index, - struct obd_device *disk_obd, int count, - struct llog_logid *logid, const char *name); -int llog_obd_origin_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt); int llog_obd_origin_add(const struct lu_env *env, struct llog_ctxt *ctxt, struct llog_rec_hdr *rec, struct lov_stripe_md *lsm, struct llog_cookie *logcookies, int numcookies); @@ -270,8 +260,7 @@ struct llog_operations { struct llog_handle *handle); int (*lop_setup)(const struct lu_env *env, struct obd_device *obd, struct obd_llog_group *olg, int ctxt_idx, - struct obd_device *disk_obd, int count, - struct llog_logid *logid, const char *name); + struct obd_device *disk_obd); int (*lop_sync)(struct llog_ctxt *ctxt, struct obd_export *exp, int flags); int (*lop_cleanup)(const struct lu_env *env, struct llog_ctxt *ctxt); @@ -545,7 +534,7 @@ static inline void llog_ctxt_put(struct llog_ctxt *ctxt) LASSERT_ATOMIC_GT_LT(&ctxt->loc_refcount, 0, LI_POISON); CDEBUG(D_INFO, "PUTting ctxt %p : new refcount %d\n", ctxt, cfs_atomic_read(&ctxt->loc_refcount) - 1); - __llog_ctxt_put(ctxt); + __llog_ctxt_put(NULL, ctxt); } static inline void llog_group_init(struct obd_llog_group *olg, int group) @@ -602,6 +591,14 @@ static inline struct llog_ctxt *llog_group_get_ctxt(struct obd_llog_group *olg, return ctxt; } +static inline void llog_group_clear_ctxt(struct obd_llog_group *olg, int index) +{ + LASSERT(index >= 0 && index < LLOG_MAX_CTXTS); + cfs_spin_lock(&olg->olg_lock); + olg->olg_ctxts[index] = NULL; + cfs_spin_unlock(&olg->olg_lock); +} + static inline struct llog_ctxt *llog_get_context(struct obd_device *obd, int index) { diff --git a/lustre/lov/lov_log.c b/lustre/lov/lov_log.c index a12cf2b..1148243 100644 --- a/lustre/lov/lov_log.c +++ b/lustre/lov/lov_log.c @@ -217,13 +217,13 @@ int lov_llog_init(struct obd_device *obd, struct obd_llog_group *olg, ENTRY; LASSERT(olg == &obd->obd_olg); - rc = llog_setup(obd, olg, LLOG_MDS_OST_ORIG_CTXT, disk_obd, 0, NULL, - &lov_mds_ost_orig_logops); - if (rc) - RETURN(rc); + rc = llog_setup(NULL, obd, olg, LLOG_MDS_OST_ORIG_CTXT, disk_obd, + &lov_mds_ost_orig_logops); + if (rc) + RETURN(rc); - rc = llog_setup(obd, olg, LLOG_SIZE_REPL_CTXT, disk_obd, 0, NULL, - &lov_size_repl_logops); + rc = llog_setup(NULL, obd, olg, LLOG_SIZE_REPL_CTXT, disk_obd, + &lov_size_repl_logops); if (rc) GOTO(err_cleanup, rc); @@ -251,32 +251,30 @@ err_cleanup: struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT); if (ctxt) - llog_cleanup(ctxt); + llog_cleanup(NULL, ctxt); ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); if (ctxt) - llog_cleanup(ctxt); + llog_cleanup(NULL, ctxt); } return rc; } int lov_llog_finish(struct obd_device *obd, int count) { - struct llog_ctxt *ctxt; - int rc = 0, rc2 = 0; - ENTRY; + struct llog_ctxt *ctxt; - /* cleanup our llogs only if the ctxts have been setup - * (client lov doesn't setup, mds lov does). */ - ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); - if (ctxt) - rc = llog_cleanup(ctxt); + ENTRY; - ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT); - if (ctxt) - rc2 = llog_cleanup(ctxt); - if (!rc) - rc = rc2; + /* cleanup our llogs only if the ctxts have been setup + * (client lov doesn't setup, mds lov does). */ + ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); + if (ctxt) + llog_cleanup(NULL, ctxt); - /* lov->tgt llogs are cleaned during osc_cleanup. */ - RETURN(rc); + ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT); + if (ctxt) + llog_cleanup(NULL, ctxt); + + /* lov->tgt llogs are cleaned during osc_cleanup. */ + RETURN(0); } diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 4dd35b6..3864f01 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -2183,47 +2183,36 @@ static int mdc_cleanup(struct obd_device *obd) static int mdc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, struct obd_device *tgt, int *index) { - struct llog_ctxt *ctxt; - int rc; - ENTRY; + struct llog_ctxt *ctxt; + int rc; - LASSERT(olg == &obd->obd_olg); + ENTRY; - rc = llog_setup(obd, olg, LLOG_LOVEA_REPL_CTXT, tgt, 0, NULL, - &llog_client_ops); - if (rc) - RETURN(rc); + LASSERT(olg == &obd->obd_olg); - ctxt = llog_get_context(obd, LLOG_LOVEA_REPL_CTXT); - llog_initiator_connect(ctxt); - llog_ctxt_put(ctxt); + rc = llog_setup(NULL, obd, olg, LLOG_CHANGELOG_REPL_CTXT, tgt, + &llog_client_ops); + if (rc) + RETURN(rc); - rc = llog_setup(obd, olg, LLOG_CHANGELOG_REPL_CTXT, tgt, 0, NULL, - &llog_client_ops); - if (rc == 0) { - ctxt = llog_group_get_ctxt(olg, LLOG_CHANGELOG_REPL_CTXT); - llog_initiator_connect(ctxt); - llog_ctxt_put(ctxt); - } + ctxt = llog_group_get_ctxt(olg, LLOG_CHANGELOG_REPL_CTXT); + llog_initiator_connect(ctxt); + llog_ctxt_put(ctxt); - RETURN(rc); + RETURN(0); } static int mdc_llog_finish(struct obd_device *obd, int count) { - struct llog_ctxt *ctxt; - int rc = 0; - ENTRY; + struct llog_ctxt *ctxt; - ctxt = llog_get_context(obd, LLOG_LOVEA_REPL_CTXT); - if (ctxt) - rc = llog_cleanup(ctxt); + ENTRY; - ctxt = llog_get_context(obd, LLOG_CHANGELOG_REPL_CTXT); - if (ctxt) - rc = llog_cleanup(ctxt); + ctxt = llog_get_context(obd, LLOG_CHANGELOG_REPL_CTXT); + if (ctxt) + llog_cleanup(NULL, ctxt); - RETURN(rc); + RETURN(0); } static int mdc_process_config(struct obd_device *obd, obd_count len, void *buf) diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index a9c0560..fac9645 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -125,16 +125,11 @@ static int mds_postsetup(struct obd_device *obd) int rc = 0; ENTRY; - rc = llog_setup(obd, &obd->obd_olg, LLOG_CONFIG_ORIG_CTXT, obd, 0, NULL, - &llog_lvfs_ops); + rc = llog_setup(NULL, obd, &obd->obd_olg, LLOG_CONFIG_ORIG_CTXT, obd, + &llog_lvfs_ops); if (rc) RETURN(rc); - rc = llog_setup(obd, &obd->obd_olg, LLOG_LOVEA_ORIG_CTXT, obd, 0, NULL, - &llog_lvfs_ops); - if (rc) - GOTO(err_llog, rc); - mds_changelog_llog_init(obd, obd); if (mds->mds_profile) { @@ -158,13 +153,9 @@ static int mds_postsetup(struct obd_device *obd) err_cleanup: mds_lov_clean(obd); - ctxt = llog_get_context(obd, LLOG_LOVEA_ORIG_CTXT); - if (ctxt) - llog_cleanup(ctxt); -err_llog: ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); if (ctxt) - llog_cleanup(ctxt); + llog_cleanup(NULL, ctxt); return rc; } @@ -225,10 +216,7 @@ static int mds_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) mds_lov_clean(obd); ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); if (ctxt) - llog_cleanup(ctxt); - ctxt = llog_get_context(obd, LLOG_LOVEA_ORIG_CTXT); - if (ctxt) - llog_cleanup(ctxt); + llog_cleanup(NULL, ctxt); rc = obd_llog_finish(obd, 0); mds->mds_lov_exp = NULL; cfs_up_write(&mds->mds_notify_lock); diff --git a/lustre/mds/mds_log.c b/lustre/mds/mds_log.c index 1b7e5ad..76a68b8 100644 --- a/lustre/mds/mds_log.c +++ b/lustre/mds/mds_log.c @@ -198,32 +198,68 @@ static int llog_changelog_cancel(const struct lu_env *env, int mds_changelog_llog_init(struct obd_device *obd, struct obd_device *tgt) { - int rc; + struct llog_ctxt *ctxt = NULL, *uctxt = NULL; + int rc; - /* see osc_llog_init */ - changelog_orig_logops = llog_lvfs_ops; - changelog_orig_logops.lop_setup = llog_obd_origin_setup; - changelog_orig_logops.lop_cleanup = llog_obd_origin_cleanup; + /* see osc_llog_init */ + changelog_orig_logops = llog_lvfs_ops; changelog_orig_logops.lop_obd_add = llog_obd_origin_add; - changelog_orig_logops.lop_cancel = llog_changelog_cancel; - - rc = llog_setup_named(obd, &obd->obd_olg, LLOG_CHANGELOG_ORIG_CTXT, - tgt, 1, NULL, CHANGELOG_CATALOG, - &changelog_orig_logops); - if (rc) { - CERROR("changelog llog setup failed %d\n", rc); - RETURN(rc); - } - - rc = llog_setup_named(obd, &obd->obd_olg, LLOG_CHANGELOG_USER_ORIG_CTXT, - tgt, 1, NULL, CHANGELOG_USERS, - &changelog_orig_logops); - if (rc) { - CERROR("changelog users llog setup failed %d\n", rc); - RETURN(rc); - } - - RETURN(rc); + changelog_orig_logops.lop_cancel = llog_changelog_cancel; + + rc = llog_setup(NULL, obd, &obd->obd_olg, LLOG_CHANGELOG_ORIG_CTXT, + tgt, &changelog_orig_logops); + if (rc) { + CERROR("%s: changelog llog setup failed: rc = %d\n", + obd->obd_name, rc); + RETURN(rc); + } + + ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT); + LASSERT(ctxt); + + rc = llog_open_create(NULL, ctxt, &ctxt->loc_handle, NULL, + CHANGELOG_CATALOG); + if (rc) + GOTO(out_cleanup, rc); + + rc = llog_cat_init_and_process(NULL, ctxt->loc_handle); + if (rc) + GOTO(out_close, rc); + + /* setup user changelog */ + rc = llog_setup(NULL, obd, &obd->obd_olg, + LLOG_CHANGELOG_USER_ORIG_CTXT, tgt, + &changelog_orig_logops); + if (rc) { + CERROR("%s: changelog users llog setup failed: rc = %d\n", + obd->obd_name, rc); + GOTO(out_close, rc); + } + + uctxt = llog_get_context(obd, LLOG_CHANGELOG_USER_ORIG_CTXT); + LASSERT(uctxt); + + rc = llog_open_create(NULL, uctxt, &uctxt->loc_handle, NULL, + CHANGELOG_USERS); + if (rc) + GOTO(out_ucleanup, rc); + + rc = llog_cat_init_and_process(NULL, uctxt->loc_handle); + if (rc) + GOTO(out_uclose, rc); + + llog_ctxt_put(ctxt); + llog_ctxt_put(uctxt); + RETURN(0); +out_uclose: + llog_cat_close(NULL, uctxt->loc_handle); +out_ucleanup: + llog_cleanup(NULL, uctxt); +out_close: + llog_cat_close(NULL, ctxt->loc_handle); +out_cleanup: + llog_cleanup(NULL, ctxt); + return rc; } EXPORT_SYMBOL(mds_changelog_llog_init); @@ -236,13 +272,13 @@ int mds_llog_init(struct obd_device *obd, struct obd_llog_group *olg, ENTRY; LASSERT(olg == &obd->obd_olg); - rc = llog_setup(obd, &obd->obd_olg, LLOG_MDS_OST_ORIG_CTXT, disk_obd, - 0, NULL, &mds_ost_orig_logops); - if (rc) - RETURN(rc); + rc = llog_setup(NULL, obd, &obd->obd_olg, LLOG_MDS_OST_ORIG_CTXT, + disk_obd, &mds_ost_orig_logops); + if (rc) + RETURN(rc); - rc = llog_setup(obd, &obd->obd_olg, LLOG_SIZE_REPL_CTXT, disk_obd, - 0, NULL, &mds_size_repl_logops); + rc = llog_setup(NULL, obd, &obd->obd_olg, LLOG_SIZE_REPL_CTXT, + disk_obd, &mds_size_repl_logops); if (rc) GOTO(err_llog, rc); @@ -254,45 +290,42 @@ int mds_llog_init(struct obd_device *obd, struct obd_llog_group *olg, RETURN(rc); err_cleanup: - ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT); - if (ctxt) - llog_cleanup(ctxt); + ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT); + if (ctxt) + llog_cleanup(NULL, ctxt); err_llog: - ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); - if (ctxt) - llog_cleanup(ctxt); - return rc; + ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); + if (ctxt) + llog_cleanup(NULL, ctxt); + return rc; } int mds_llog_finish(struct obd_device *obd, int count) { - struct llog_ctxt *ctxt; - int rc = 0, rc2 = 0; - ENTRY; - - ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); - if (ctxt) - rc = llog_cleanup(ctxt); - - ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT); - if (ctxt) - rc2 = llog_cleanup(ctxt); - if (!rc) - rc = rc2; - - ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT); - if (ctxt) - rc2 = llog_cleanup(ctxt); - if (!rc) - rc = rc2; - - ctxt = llog_get_context(obd, LLOG_CHANGELOG_USER_ORIG_CTXT); - if (ctxt) - rc2 = llog_cleanup(ctxt); - if (!rc) - rc = rc2; - - RETURN(rc); + struct llog_ctxt *ctxt; + + ENTRY; + + ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); + if (ctxt) + llog_cleanup(NULL, ctxt); + + ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT); + if (ctxt) + llog_cleanup(NULL, ctxt); + + ctxt = llog_get_context(obd, LLOG_CHANGELOG_ORIG_CTXT); + if (ctxt) { + llog_cat_close(NULL, ctxt->loc_handle); + llog_cleanup(NULL, ctxt); + } + + ctxt = llog_get_context(obd, LLOG_CHANGELOG_USER_ORIG_CTXT); + if (ctxt) { + llog_cat_close(NULL, ctxt->loc_handle); + llog_cleanup(NULL, ctxt); + } + RETURN(0); } static int mds_llog_add_unlink(struct obd_device *obd, diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index b0c86fa..f1ef253 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -4863,8 +4863,8 @@ static int mdt_obd_llog_setup(struct obd_device *obd, obd->obd_lvfs_ctxt.pwd = lsi->lsi_srv_mnt->mnt_root; obd->obd_lvfs_ctxt.fs = get_ds(); - rc = llog_setup(obd, &obd->obd_olg, LLOG_CONFIG_ORIG_CTXT, obd, - 0, NULL, &llog_lvfs_ops); + rc = llog_setup(NULL, obd, &obd->obd_olg, LLOG_CONFIG_ORIG_CTXT, obd, + &llog_lvfs_ops); if (rc) { CERROR("llog_setup() failed: %d\n", rc); fsfilt_put_ops(obd->obd_fsops); @@ -4879,7 +4879,7 @@ static void mdt_obd_llog_cleanup(struct obd_device *obd) ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); if (ctxt) - llog_cleanup(ctxt); + llog_cleanup(NULL, ctxt); if (obd->obd_fsops) { fsfilt_put_ops(obd->obd_fsops); diff --git a/lustre/mgc/libmgc.c b/lustre/mgc/libmgc.c index 42956d8..ead0a68 100644 --- a/lustre/mgc/libmgc.c +++ b/lustre/mgc/libmgc.c @@ -121,25 +121,29 @@ static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, ENTRY; LASSERT(olg == &obd->obd_olg); - rc = llog_setup(obd, olg, LLOG_CONFIG_REPL_CTXT, tgt, 0, NULL, - &llog_client_ops); - if (rc == 0) { - ctxt = llog_group_get_ctxt(olg, LLOG_CONFIG_REPL_CTXT); - llog_initiator_connect(ctxt); - llog_ctxt_put(ctxt); - } + rc = llog_setup(NULL, obd, olg, LLOG_CONFIG_REPL_CTXT, tgt, + &llog_client_ops); + if (rc < 0) + RETURN(rc); - RETURN(rc); + ctxt = llog_group_get_ctxt(olg, LLOG_CONFIG_REPL_CTXT); + llog_initiator_connect(ctxt); + llog_ctxt_put(ctxt); + + RETURN(rc); } static int mgc_llog_finish(struct obd_device *obd, int count) { - int rc; - ENTRY; + struct llog_ctxt *ctxt; - rc = llog_cleanup(llog_get_context(obd, LLOG_CONFIG_REPL_CTXT)); + ENTRY; - RETURN(rc); + ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT); + if (ctxt) + llog_cleanup(NULL, ctxt); + + RETURN(0); } struct obd_ops mgc_obd_ops = { diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 3e7dd17..8b208e7 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -1177,50 +1177,45 @@ static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, LASSERT(olg == &obd->obd_olg); - rc = llog_setup(obd, olg, LLOG_CONFIG_ORIG_CTXT, tgt, 0, NULL, - &llog_lvfs_ops); - if (rc) - RETURN(rc); + rc = llog_setup(NULL, obd, olg, LLOG_CONFIG_ORIG_CTXT, tgt, + &llog_lvfs_ops); + if (rc) + RETURN(rc); - rc = llog_setup(obd, olg, LLOG_CONFIG_REPL_CTXT, tgt, 0, NULL, - &llog_client_ops); - if (rc == 0) { - ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT); - if (!ctxt) { - ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); - if (ctxt) - llog_cleanup(ctxt); - RETURN(-ENODEV); - } - llog_initiator_connect(ctxt); - llog_ctxt_put(ctxt); - } else { - ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); - if (ctxt) - llog_cleanup(ctxt); - } + rc = llog_setup(NULL, obd, olg, LLOG_CONFIG_REPL_CTXT, tgt, + &llog_client_ops); + if (rc) + GOTO(out, rc); + ctxt = llog_group_get_ctxt(olg, LLOG_CONFIG_REPL_CTXT); + if (!ctxt) + GOTO(out, rc = -ENODEV); + + llog_initiator_connect(ctxt); + llog_ctxt_put(ctxt); + + RETURN(0); +out: + ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); + if (ctxt) + llog_cleanup(NULL, ctxt); RETURN(rc); } static int mgc_llog_finish(struct obd_device *obd, int count) { - struct llog_ctxt *ctxt; - int rc = 0, rc2 = 0; - ENTRY; + struct llog_ctxt *ctxt; - ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT); - if (ctxt) - rc = llog_cleanup(ctxt); + ENTRY; - ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); - if (ctxt) - rc2 = llog_cleanup(ctxt); + ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT); + if (ctxt) + llog_cleanup(NULL, ctxt); - if (!rc) - rc = rc2; - - RETURN(rc); + ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); + if (ctxt) + llog_cleanup(NULL, ctxt); + RETURN(0); } enum { diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 5d4a143..5b88b0c 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -145,28 +145,29 @@ static int mgs_disconnect(struct obd_export *exp) static int mgs_handle(struct ptlrpc_request *req); static int mgs_llog_init(struct obd_device *obd, struct obd_llog_group *olg, - struct obd_device *tgt, int *index) + struct obd_device *tgt, int *index) { - int rc; - ENTRY; + int rc; - LASSERT(olg == &obd->obd_olg); - rc = llog_setup(obd, olg, LLOG_CONFIG_ORIG_CTXT, obd, 0, NULL, - &llog_lvfs_ops); - RETURN(rc); + ENTRY; + + LASSERT(olg == &obd->obd_olg); + rc = llog_setup(NULL, obd, olg, LLOG_CONFIG_ORIG_CTXT, obd, + &llog_lvfs_ops); + RETURN(rc); } static int mgs_llog_finish(struct obd_device *obd, int count) { - struct llog_ctxt *ctxt; - int rc = 0; - ENTRY; + struct llog_ctxt *ctxt; + + ENTRY; - ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); - if (ctxt) - rc = llog_cleanup(ctxt); + ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); + if (ctxt) + llog_cleanup(NULL, ctxt); - RETURN(rc); + RETURN(0); } static int mgs_completion_ast_config(struct ldlm_lock *lock, int flags, diff --git a/lustre/obdclass/llog_cat.c b/lustre/obdclass/llog_cat.c index a3c5873..0f9df2e 100644 --- a/lustre/obdclass/llog_cat.c +++ b/lustre/obdclass/llog_cat.c @@ -809,7 +809,6 @@ out: RETURN(0); } -/* callback func for llog_process in llog_obd_origin_setup */ int cat_cancel_cb(const struct lu_env *env, struct llog_handle *cathandle, struct llog_rec_hdr *rec, void *data) { @@ -866,3 +865,19 @@ cat_cleanup: RETURN(rc); } + +/* helper to initialize catalog llog and process it to cancel */ +int llog_cat_init_and_process(const struct lu_env *env, + struct llog_handle *llh) +{ + int rc; + + rc = llog_init_handle(env, llh, LLOG_F_IS_CAT, NULL); + if (rc) + RETURN(rc); + + rc = llog_process(env, llh, cat_cancel_cb, NULL, NULL); + RETURN(rc); +} +EXPORT_SYMBOL(llog_cat_init_and_process); + diff --git a/lustre/obdclass/llog_internal.h b/lustre/obdclass/llog_internal.h index a599c61..524053b 100644 --- a/lustre/obdclass/llog_internal.h +++ b/lustre/obdclass/llog_internal.h @@ -84,4 +84,8 @@ int llog_cat_id2handle(const struct lu_env *env, struct llog_handle *cathandle, int class_config_dump_handler(const struct lu_env *env, struct llog_handle *handle, struct llog_rec_hdr *rec, void *data); +int llog_process_or_fork(const struct lu_env *env, + struct llog_handle *loghandle, + llog_cb_t cb, void *data, void *catdata, bool fork); +int llog_cat_set_first_idx(struct llog_handle *cathandle, int index); #endif diff --git a/lustre/obdclass/llog_lvfs.c b/lustre/obdclass/llog_lvfs.c index 9b8536d..e2fc8a3 100644 --- a/lustre/obdclass/llog_lvfs.c +++ b/lustre/obdclass/llog_lvfs.c @@ -634,7 +634,6 @@ static int llog_lvfs_open(const struct lu_env *env, struct llog_handle *handle, logid->lgl_ogen, rc); GOTO(out, rc); } - handle->lgh_id = *logid; } else if (name) { handle->lgh_file = llog_filp_open(MOUNT_CONFIGS_DIR, name, @@ -690,6 +689,7 @@ static int llog_lvfs_create(const struct lu_env *env, struct llog_ctxt *ctxt = handle->lgh_ctxt; struct obd_device *obd; struct l_dentry *dchild = NULL; + struct file *file; struct obdo *oa = NULL; int rc = 0; int open_flags = O_RDWR | O_CREAT | O_LARGEFILE; @@ -702,17 +702,16 @@ static int llog_lvfs_create(const struct lu_env *env, LASSERT(handle->lgh_file == NULL); if (handle->lgh_name) { - handle->lgh_file = llog_filp_open(MOUNT_CONFIGS_DIR, - handle->lgh_name, - open_flags, 0644); - if (IS_ERR(handle->lgh_file)) - RETURN(PTR_ERR(handle->lgh_file)); + file = llog_filp_open(MOUNT_CONFIGS_DIR, handle->lgh_name, + open_flags, 0644); + if (IS_ERR(file)) + RETURN(PTR_ERR(file)); handle->lgh_id.lgl_oseq = FID_SEQ_LLOG; - handle->lgh_id.lgl_oid = - handle->lgh_file->f_dentry->d_inode->i_ino; + handle->lgh_id.lgl_oid = file->f_dentry->d_inode->i_ino; handle->lgh_id.lgl_ogen = - handle->lgh_file->f_dentry->d_inode->i_generation; + file->f_dentry->d_inode->i_generation; + handle->lgh_file = file; } else { OBDO_ALLOC(oa); if (oa == NULL) @@ -734,14 +733,13 @@ static int llog_lvfs_create(const struct lu_env *env, if (IS_ERR(dchild)) GOTO(out, rc = PTR_ERR(dchild)); - handle->lgh_file = l_dentry_open(&obd->obd_lvfs_ctxt, dchild, - open_flags); - if (IS_ERR(handle->lgh_file)) - GOTO(out, rc = PTR_ERR(handle->lgh_file)); - + file = l_dentry_open(&obd->obd_lvfs_ctxt, dchild, open_flags); + if (IS_ERR(file)) + GOTO(out, rc = PTR_ERR(file)); handle->lgh_id.lgl_oseq = oa->o_seq; handle->lgh_id.lgl_oid = oa->o_id; handle->lgh_id.lgl_ogen = oa->o_generation; + handle->lgh_file = file; out: OBDO_FREE(oa); } diff --git a/lustre/obdclass/llog_obd.c b/lustre/obdclass/llog_obd.c index adc8203..53b3fe6 100644 --- a/lustre/obdclass/llog_obd.c +++ b/lustre/obdclass/llog_obd.c @@ -42,7 +42,6 @@ #include #include -#include #include "llog_internal.h" /* helper functions for calling the llog obd methods */ @@ -74,7 +73,7 @@ static void llog_ctxt_destroy(struct llog_ctxt *ctxt) OBD_FREE_PTR(ctxt); } -int __llog_ctxt_put(struct llog_ctxt *ctxt) +int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt) { struct obd_llog_group *olg = ctxt->loc_olg; struct obd_device *obd; @@ -105,7 +104,7 @@ int __llog_ctxt_put(struct llog_ctxt *ctxt) /* cleanup the llog ctxt here */ if (CTXTP(ctxt, cleanup)) - rc = CTXTP(ctxt, cleanup)(NULL, ctxt); + rc = CTXTP(ctxt, cleanup)(env, ctxt); llog_ctxt_destroy(ctxt); cfs_waitq_signal(&olg->olg_waitq); @@ -113,7 +112,7 @@ int __llog_ctxt_put(struct llog_ctxt *ctxt) } EXPORT_SYMBOL(__llog_ctxt_put); -int llog_cleanup(struct llog_ctxt *ctxt) +int llog_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt) { struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); struct obd_llog_group *olg; @@ -129,17 +128,17 @@ int llog_cleanup(struct llog_ctxt *ctxt) idx = ctxt->loc_idx; - /* + /* * Banlance the ctxt get when calling llog_cleanup() */ LASSERT(cfs_atomic_read(&ctxt->loc_refcount) < LI_POISON); LASSERT(cfs_atomic_read(&ctxt->loc_refcount) > 1); llog_ctxt_put(ctxt); - /* - * Try to free the ctxt. - */ - rc = __llog_ctxt_put(ctxt); + /* + * Try to free the ctxt. + */ + rc = __llog_ctxt_put(env, ctxt); if (rc) CERROR("Error %d while cleaning up ctxt %p\n", rc, ctxt); @@ -151,10 +150,9 @@ int llog_cleanup(struct llog_ctxt *ctxt) } EXPORT_SYMBOL(llog_cleanup); -int llog_setup_named(struct obd_device *obd, struct obd_llog_group *olg, - int index, struct obd_device *disk_obd, int count, - struct llog_logid *logid, const char *logname, - struct llog_operations *op) +int llog_setup(const struct lu_env *env, struct obd_device *obd, + struct obd_llog_group *olg, int index, + struct obd_device *disk_obd, struct llog_operations *op) { struct llog_ctxt *ctxt; int rc = 0; @@ -201,18 +199,18 @@ int llog_setup_named(struct obd_device *obd, struct obd_llog_group *olg, RETURN(rc); } - if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LLOG_SETUP)) { - rc = -ENOTSUPP; - } else { - if (op->lop_setup) - rc = op->lop_setup(NULL, obd, olg, index, disk_obd, - count, logid, logname); - } - - if (rc) { - CERROR("obd %s ctxt %d lop_setup=%p failed %d\n", - obd->obd_name, index, op->lop_setup, rc); - llog_ctxt_put(ctxt); + if (op->lop_setup) { + if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LLOG_SETUP)) + rc = -EOPNOTSUPP; + else + rc = op->lop_setup(env, obd, olg, index, disk_obd); + } + + if (rc) { + CERROR("%s: ctxt %d lop_setup=%p failed: rc = %d\n", + obd->obd_name, index, op->lop_setup, rc); + llog_group_clear_ctxt(olg, index); + llog_ctxt_destroy(ctxt); } else { CDEBUG(D_CONFIG, "obd %s ctxt %d is initialized\n", obd->obd_name, index); @@ -221,14 +219,6 @@ int llog_setup_named(struct obd_device *obd, struct obd_llog_group *olg, RETURN(rc); } -EXPORT_SYMBOL(llog_setup_named); - -int llog_setup(struct obd_device *obd, struct obd_llog_group *olg, - int index, struct obd_device *disk_obd, int count, - struct llog_logid *logid, struct llog_operations *op) -{ - return llog_setup_named(obd,olg,index,disk_obd,count,logid,NULL,op); -} EXPORT_SYMBOL(llog_setup); int llog_sync(struct llog_ctxt *ctxt, struct obd_export *exp, int flags) @@ -291,70 +281,6 @@ int llog_cancel(const struct lu_env *env, struct llog_ctxt *ctxt, } EXPORT_SYMBOL(llog_cancel); -/* lop_setup method for filter/osc */ -// XXX how to set exports -int llog_obd_origin_setup(const struct lu_env *env, struct obd_device *obd, - struct obd_llog_group *olg, int index, - struct obd_device *disk_obd, int count, - struct llog_logid *logid, const char *name) -{ - struct llog_ctxt *ctxt; - struct llog_handle *handle; - struct lvfs_run_ctxt saved; - int rc; - ENTRY; - - if (count == 0) - RETURN(0); - - LASSERT(count == 1); - - LASSERT(olg != NULL); - ctxt = llog_group_get_ctxt(olg, index); - if (!ctxt) - RETURN(-ENODEV); - - if (logid && logid->lgl_oid) { - rc = llog_open(env, ctxt, &handle, logid, NULL, - LLOG_OPEN_EXISTS); - } else { - rc = llog_open_create(env, ctxt, &handle, NULL, (char *)name); - if (!rc && logid) - *logid = handle->lgh_id; - } - if (rc) - GOTO(out, rc); - - ctxt->loc_handle = handle; - push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); - rc = llog_init_handle(env, handle, LLOG_F_IS_CAT, NULL); - pop_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); - if (rc) - GOTO(out, rc); - - rc = llog_process(env, handle, (llog_cb_t)cat_cancel_cb, NULL, NULL); - if (rc) - CERROR("llog_process() with cat_cancel_cb failed: %d\n", rc); - GOTO(out, rc); -out: - llog_ctxt_put(ctxt); - return rc; -} -EXPORT_SYMBOL(llog_obd_origin_setup); - -int llog_obd_origin_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt) -{ - ENTRY; - - if (!ctxt) - RETURN(0); - - if (ctxt->loc_handle) - llog_cat_close(env, ctxt->loc_handle); - RETURN(0); -} -EXPORT_SYMBOL(llog_obd_origin_cleanup); - /* add for obdfilter/sz and mds/unlink */ int llog_obd_origin_add(const struct lu_env *env, struct llog_ctxt *ctxt, struct llog_rec_hdr *rec, struct lov_stripe_md *lsm, diff --git a/lustre/obdclass/llog_test.c b/lustre/obdclass/llog_test.c index b119a83..1e41e31 100644 --- a/lustre/obdclass/llog_test.c +++ b/lustre/obdclass/llog_test.c @@ -972,7 +972,7 @@ static int llog_test_cleanup(struct obd_device *obd) { int rc; - rc = llog_cleanup(llog_get_context(obd, LLOG_TEST_ORIG_CTXT)); + rc = llog_cleanup(NULL, llog_get_context(obd, LLOG_TEST_ORIG_CTXT)); if (rc) CERROR("failed to llog_test_llog_finish: %d\n", rc); return rc; @@ -1011,7 +1011,7 @@ static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) CWARN("Setup llog-test device over %s device\n", lustre_cfg_string(lcfg, 1)); - rc = llog_setup(obd, &obd->obd_olg, LLOG_TEST_ORIG_CTXT, tgt, 0, NULL, + rc = llog_setup(&env, obd, &obd->obd_olg, LLOG_TEST_ORIG_CTXT, tgt, &llog_lvfs_ops); if (rc) GOTO(cleanup_env, rc); diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 360cf72..ef7c213 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -2342,59 +2342,58 @@ obd_cleanup: static struct llog_operations filter_mds_ost_repl_logops; -static struct llog_operations filter_size_orig_logops = { - .lop_setup = llog_obd_origin_setup, - .lop_cleanup = llog_obd_origin_cleanup, -}; +static struct llog_operations filter_size_orig_logops = {}; static int filter_olg_fini(struct obd_llog_group *olg) { - struct llog_ctxt *ctxt; - int rc = 0, rc2 = 0; - ENTRY; + struct llog_ctxt *ctxt; - ctxt = llog_group_get_ctxt(olg, LLOG_MDS_OST_REPL_CTXT); - if (ctxt) - rc = llog_cleanup(ctxt); + ENTRY; - ctxt = llog_group_get_ctxt(olg, LLOG_SIZE_ORIG_CTXT); - if (ctxt) { - rc2 = llog_cleanup(ctxt); - if (!rc) - rc = rc2; - } + ctxt = llog_group_get_ctxt(olg, LLOG_MDS_OST_REPL_CTXT); + if (ctxt) + llog_cleanup(NULL, ctxt); - ctxt = llog_group_get_ctxt(olg, LLOG_CONFIG_ORIG_CTXT); - if (ctxt) { - rc2 = llog_cleanup(ctxt); - if (!rc) - rc = rc2; - } + ctxt = llog_group_get_ctxt(olg, LLOG_SIZE_ORIG_CTXT); + if (ctxt) + llog_cleanup(NULL, ctxt); - RETURN(rc); + ctxt = llog_group_get_ctxt(olg, LLOG_CONFIG_ORIG_CTXT); + if (ctxt) + llog_cleanup(NULL, ctxt); + + RETURN(0); } static int filter_olg_init(struct obd_device *obd, struct obd_llog_group *olg, struct obd_device *tgt) { - int rc; - ENTRY; + struct llog_ctxt *ctxt = NULL; + int rc; - rc = llog_setup(obd, olg, LLOG_MDS_OST_REPL_CTXT, tgt, 0, NULL, - &filter_mds_ost_repl_logops); - if (rc) - GOTO(cleanup, rc); + ENTRY; - rc = llog_setup(obd, olg, LLOG_SIZE_ORIG_CTXT, tgt, 0, NULL, - &filter_size_orig_logops); - if (rc) - GOTO(cleanup, rc); - EXIT; -cleanup: - if (rc) - filter_olg_fini(olg); - return rc; + filter_mds_ost_repl_logops = llog_client_ops; + filter_mds_ost_repl_logops.lop_cancel = llog_obd_repl_cancel; + filter_mds_ost_repl_logops.lop_connect = llog_obd_repl_connect; + filter_mds_ost_repl_logops.lop_sync = llog_obd_repl_sync; + + rc = llog_setup(NULL, obd, olg, LLOG_MDS_OST_REPL_CTXT, tgt, + &filter_mds_ost_repl_logops); + if (rc) + RETURN(rc); + + rc = llog_setup(NULL, obd, olg, LLOG_SIZE_ORIG_CTXT, tgt, + &filter_size_orig_logops); + if (rc) + GOTO(out, rc); + + RETURN(0); +out: + ctxt = llog_group_get_ctxt(olg, LLOG_MDS_OST_REPL_CTXT); + llog_cleanup(NULL, ctxt); + return rc; } /** @@ -2413,17 +2412,12 @@ filter_default_olg_init(struct obd_device *obd, struct obd_llog_group *olg, if (!filter->fo_lcm) RETURN(-ENOMEM); - filter_mds_ost_repl_logops = llog_client_ops; - filter_mds_ost_repl_logops.lop_cancel = llog_obd_repl_cancel; - filter_mds_ost_repl_logops.lop_connect = llog_obd_repl_connect; - filter_mds_ost_repl_logops.lop_sync = llog_obd_repl_sync; - rc = filter_olg_init(obd, olg, tgt); if (rc) GOTO(cleanup_lcm, rc); - rc = llog_setup(obd, olg, LLOG_CONFIG_ORIG_CTXT, tgt, 0, NULL, - &llog_lvfs_ops); + rc = llog_setup(NULL, obd, olg, LLOG_CONFIG_ORIG_CTXT, tgt, + &llog_lvfs_ops); if (rc) GOTO(cleanup_olg, rc); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index d85d2d1..22c1eb9 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -3275,36 +3275,72 @@ static struct llog_operations osc_size_repl_logops = { static struct llog_operations osc_mds_ost_orig_logops; static int __osc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, - struct obd_device *tgt, struct llog_catid *catid) + struct obd_device *tgt, struct llog_catid *catid) { - int rc; - ENTRY; + struct llog_ctxt *ctxt = NULL; + struct llog_handle *lgh; + int rc; - rc = llog_setup(obd, &obd->obd_olg, LLOG_MDS_OST_ORIG_CTXT, tgt, 1, - &catid->lci_logid, &osc_mds_ost_orig_logops); - if (rc) { - CERROR("failed LLOG_MDS_OST_ORIG_CTXT\n"); - GOTO(out, rc); - } + ENTRY; - rc = llog_setup(obd, &obd->obd_olg, LLOG_SIZE_REPL_CTXT, tgt, 1, - NULL, &osc_size_repl_logops); - if (rc) { - struct llog_ctxt *ctxt = - llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); - if (ctxt) - llog_cleanup(ctxt); - CERROR("failed LLOG_SIZE_REPL_CTXT\n"); - } - GOTO(out, rc); + osc_mds_ost_orig_logops = llog_lvfs_ops; + osc_mds_ost_orig_logops.lop_obd_add = llog_obd_origin_add; + osc_mds_ost_orig_logops.lop_connect = llog_origin_connect; + rc = llog_setup(NULL, obd, &obd->obd_olg, LLOG_MDS_OST_ORIG_CTXT, tgt, + &osc_mds_ost_orig_logops); + if (rc) + RETURN(rc); + + ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); + LASSERT(ctxt); + + /* context might be initialized already */ + if (ctxt->loc_handle != NULL) { + /* sanity check for valid loc_handle */ + LASSERT(ctxt->loc_handle->lgh_ctxt == ctxt); + GOTO(out, rc = 0); + } + + /* first try to open existent llog by ID */ + if (likely(catid->lci_logid.lgl_oid != 0)) { + rc = llog_open(NULL, ctxt, &lgh, &catid->lci_logid, NULL, + LLOG_OPEN_EXISTS); + /* re-create llog if it is missing */ + if (rc == -ENOENT) + catid->lci_logid.lgl_oid = 0; + else if (rc < 0) + GOTO(out_cleanup, rc); + } + /* create new llog if llog ID is not specified or llog is missed */ + if (unlikely(catid->lci_logid.lgl_oid == 0)) { + rc = llog_open_create(NULL, ctxt, &lgh, NULL, NULL); + if (rc < 0) + GOTO(out_cleanup, rc); + catid->lci_logid = lgh->lgh_id; + } + + ctxt->loc_handle = lgh; + + rc = llog_cat_init_and_process(NULL, lgh); + if (rc) + GOTO(out_close, rc); + + rc = llog_setup(NULL, obd, &obd->obd_olg, LLOG_SIZE_REPL_CTXT, tgt, + &osc_size_repl_logops); + if (rc) + GOTO(out_close, rc); out: - if (rc) { - CERROR("osc '%s' tgt '%s' catid %p rc=%d\n", - obd->obd_name, tgt->obd_name, catid, rc); - CERROR("logid "LPX64":0x%x\n", - catid->lci_logid.lgl_oid, catid->lci_logid.lgl_ogen); - } - return rc; + llog_ctxt_put(ctxt); + RETURN(0); +out_close: + llog_cat_close(NULL, lgh); +out_cleanup: + llog_cleanup(NULL, ctxt); + CERROR("%s: fail to init llog #"LPX64"#"LPX64"#%08x tgt '%s': " + "rc = %d\n", obd->obd_name, catid->lci_logid.lgl_oid, + catid->lci_logid.lgl_oseq, catid->lci_logid.lgl_ogen, + tgt->obd_name, rc); + return rc; } static int osc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, @@ -3348,21 +3384,20 @@ static int osc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, static int osc_llog_finish(struct obd_device *obd, int count) { - struct llog_ctxt *ctxt; - int rc = 0, rc2 = 0; - ENTRY; + struct llog_ctxt *ctxt; - ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); - if (ctxt) - rc = llog_cleanup(ctxt); + ENTRY; - ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT); - if (ctxt) - rc2 = llog_cleanup(ctxt); - if (!rc) - rc = rc2; + ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); + if (ctxt) { + llog_cat_close(NULL, ctxt->loc_handle); + llog_cleanup(NULL, ctxt); + } - RETURN(rc); + ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT); + if (ctxt) + llog_cleanup(NULL, ctxt); + RETURN(0); } static int osc_reconnect(const struct lu_env *env, @@ -3772,12 +3807,6 @@ int __init osc_init(void) cfs_spin_lock_init(&osc_ast_guard); cfs_lockdep_set_class(&osc_ast_guard, &osc_ast_guard_class); - osc_mds_ost_orig_logops = llog_lvfs_ops; - osc_mds_ost_orig_logops.lop_setup = llog_obd_origin_setup; - osc_mds_ost_orig_logops.lop_cleanup = llog_obd_origin_cleanup; - osc_mds_ost_orig_logops.lop_obd_add = llog_obd_origin_add; - osc_mds_ost_orig_logops.lop_connect = llog_origin_connect; - RETURN(rc); }