From: shadow Date: Fri, 17 Jul 2009 05:25:33 +0000 (+0000) Subject: move handling CATALOGS file at osc layer and forbid access to llog X-Git-Tag: v1_9_220~5 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=a928591d58b5d0dbbcc9a7f534dca2b6df22da9e move handling CATALOGS file at osc layer and forbid access to llog context before init. Branch HEAD b=18800 i=rread i=wangdi --- diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 1c2fd25..fa75769 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -14,6 +14,13 @@ tbd Sun Microsystems, Inc. * File join has been disabled in this release, refer to Bugzilla 16929. Severity : normal +Frequency : rare +Bugzilla : 18800 +Description: access to llog context before init. +Details : move handling CATALOGS file at osc layer and forbid access to llog + context before init. + +Severity : normal Bugzilla : 19529 Description: Avoid deadlock for local client writes Details : Use new OBD_BRW_MEMALLOC flag to notify OST about writes in the diff --git a/lustre/include/lustre_log.h b/lustre/include/lustre_log.h index e5f5cad..05d85ab 100644 --- a/lustre/include/lustre_log.h +++ b/lustre/include/lustre_log.h @@ -193,11 +193,8 @@ int llog_obd_origin_add(struct llog_ctxt *ctxt, struct llog_rec_hdr *rec, struct lov_stripe_md *lsm, struct llog_cookie *logcookies, int numcookies); -int llog_cat_initialize(struct obd_device *obd, struct obd_llog_group *olg, - int idx, struct obd_uuid *uuid); int obd_llog_init(struct obd_device *obd, struct obd_llog_group *olg, - struct obd_device *disk_obd, int count, - struct llog_catid *logid, struct obd_uuid *uuid); + struct obd_device *disk_obd, int *idx); int obd_llog_finish(struct obd_device *obd, int count); @@ -256,13 +253,15 @@ struct llog_operations { /* llog_lvfs.c */ extern struct llog_operations llog_lvfs_ops; -int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd, +int llog_get_cat_list(struct obd_device *disk_obd, char *name, int idx, int count, struct llog_catid *idarray); -int llog_put_cat_list(struct obd_device *obd, struct obd_device *disk_obd, +int llog_put_cat_list(struct obd_device *disk_obd, char *name, int idx, int count, struct llog_catid *idarray); +#define LLOG_CTXT_FLAG_UNINITIALIZED 0x00000001 + struct llog_ctxt { int loc_idx; /* my index the obd array of ctxt's */ struct llog_gen loc_gen; @@ -278,6 +277,7 @@ struct llog_ctxt { struct semaphore loc_sem; /* protects loc_llcd and loc_imp */ atomic_t loc_refcount; void *llog_proc_cb; + long loc_flags; /* flags, see above defines */ }; #define LCM_NAME_SIZE 64 diff --git a/lustre/include/obd.h b/lustre/include/obd.h index dbfd961..55b8c27 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -1385,8 +1385,7 @@ struct obd_ops { /* llog related obd_methods */ int (*o_llog_init)(struct obd_device *obd, struct obd_llog_group *grp, - struct obd_device *disk_obd, int count, - struct llog_catid *logid, struct obd_uuid *uuid); + struct obd_device *disk_obd, int *idx); int (*o_llog_finish)(struct obd_device *obd, int count); int (*o_llog_connect)(struct obd_export *, struct llogd_conn_body *); diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 643f5b3..3e7dfc8 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -521,7 +521,7 @@ int lmv_add_target(struct obd_device *obd, struct obd_uuid *tgt_uuid) RETURN(-EINVAL); } - rc = obd_llog_init(obd, &obd->obd_olg, mdc_obd, 0, NULL, tgt_uuid); + rc = obd_llog_init(obd, &obd->obd_olg, mdc_obd, NULL); if (rc) { lmv_init_unlock(lmv); CERROR("lmv failed to setup llogging subsystems\n"); diff --git a/lustre/lov/lov_internal.h b/lustre/lov/lov_internal.h index 8f32543..3c8ede2 100644 --- a/lustre/lov/lov_internal.h +++ b/lustre/lov/lov_internal.h @@ -260,8 +260,7 @@ int lov_del_target(struct obd_device *obd, __u32 index, struct obd_uuid *uuidp, int gen); /* lov_log.c */ int lov_llog_init(struct obd_device *obd, struct obd_llog_group *olg, - struct obd_device *tgt, int count, struct llog_catid *logid, - struct obd_uuid *uuid); + struct obd_device *tgt, int *idx); int lov_llog_finish(struct obd_device *obd, int count); /* lov_pack.c */ diff --git a/lustre/lov/lov_log.c b/lustre/lov/lov_log.c index 81a0e00..23441a8 100644 --- a/lustre/lov/lov_log.c +++ b/lustre/lov/lov_log.c @@ -204,24 +204,20 @@ static struct llog_operations lov_size_repl_logops = { }; int lov_llog_init(struct obd_device *obd, struct obd_llog_group *olg, - struct obd_device *tgt, int count, struct llog_catid *logid, - struct obd_uuid *uuid) + struct obd_device *disk_obd, int *index) { struct lov_obd *lov = &obd->u.lov; struct obd_device *child; int i, rc = 0; ENTRY; - /* allow init only one target at one time */ - LASSERT(uuid); - LASSERT(olg == &obd->obd_olg); - rc = llog_setup(obd, olg, LLOG_MDS_OST_ORIG_CTXT, tgt, 0, NULL, + 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(obd, olg, LLOG_SIZE_REPL_CTXT, tgt, 0, NULL, + rc = llog_setup(obd, olg, LLOG_SIZE_REPL_CTXT, disk_obd, 0, NULL, &lov_size_repl_logops); if (rc) GOTO(err_cleanup, rc); @@ -229,19 +225,19 @@ int lov_llog_init(struct obd_device *obd, struct obd_llog_group *olg, obd_getref(obd); /* count may not match lov->desc.ld_tgt_count during dynamic ost add */ for (i = 0; i < lov->desc.ld_tgt_count; i++) { - if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_active) + if (!lov->lov_tgts[i]) continue; - if (!obd_uuid_equals(uuid, &lov->lov_tgts[i]->ltd_uuid)) + + if (index && i != *index) continue; - LASSERT(lov->lov_tgts[i]->ltd_exp); - child = lov->lov_tgts[i]->ltd_exp->exp_obd; - rc = obd_llog_init(child, &child->obd_olg, tgt, 1, logid, uuid); + child = lov->lov_tgts[i]->ltd_obd; + rc = obd_llog_init(child, &child->obd_olg, disk_obd, &i); if (rc) CERROR("error osc_llog_init idx %d osc '%s' tgt '%s' " - "(rc=%d)\n", i, child->obd_name, tgt->obd_name, - rc); - break; + "(rc=%d)\n", i, child->obd_name, + disk_obd->obd_name, rc); + rc = 0; } obd_putref(obd); GOTO(err_cleanup, rc); diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 7d4d41b..40f5f53 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1629,7 +1629,7 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); - rc = obd_llog_init(obd, &obd->obd_olg, obd, 0, NULL, NULL); + rc = obd_llog_init(obd, &obd->obd_olg, obd, NULL); if (rc) { mdc_cleanup(obd); CERROR("failed to setup llogging subsystems\n"); @@ -1715,8 +1715,7 @@ 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 count, - struct llog_catid *logid, struct obd_uuid *uuid) + struct obd_device *tgt, int *index) { struct llog_ctxt *ctxt; int rc; @@ -1728,6 +1727,7 @@ static int mdc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, &llog_client_ops); if (rc) RETURN(rc); + ctxt = llog_get_context(obd, LLOG_LOVEA_REPL_CTXT); llog_initiator_connect(ctxt); llog_ctxt_put(ctxt); diff --git a/lustre/mds/mds_internal.h b/lustre/mds/mds_internal.h index 4c3ec94..309a48e 100644 --- a/lustre/mds/mds_internal.h +++ b/lustre/mds/mds_internal.h @@ -45,8 +45,7 @@ int mds_cleanup_pending(struct obd_device *obd); /* mds/mds_log.c */ int mds_llog_init(struct obd_device *obd, struct obd_llog_group *olg, - struct obd_device *tgt, int count, - struct llog_catid *logid, struct obd_uuid *uuid); + struct obd_device *tgt, int *index); int mds_llog_finish(struct obd_device *obd, int count); int mds_changelog_llog_init(struct obd_device *obd, struct obd_device *tgt); diff --git a/lustre/mds/mds_log.c b/lustre/mds/mds_log.c index dd7a7ca..0a305b2 100644 --- a/lustre/mds/mds_log.c +++ b/lustre/mds/mds_log.c @@ -196,8 +196,7 @@ int mds_changelog_llog_init(struct obd_device *obd, struct obd_device *tgt) EXPORT_SYMBOL(mds_changelog_llog_init); int mds_llog_init(struct obd_device *obd, struct obd_llog_group *olg, - struct obd_device *tgt, int count, struct llog_catid *logid, - struct obd_uuid *uuid) + struct obd_device *disk_obd, int *index) { struct obd_device *lov_obd = obd->u.mds.mds_osc_obd; struct llog_ctxt *ctxt; @@ -205,17 +204,17 @@ 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, tgt, + 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(obd, &obd->obd_olg, LLOG_SIZE_REPL_CTXT, tgt, + rc = llog_setup(obd, &obd->obd_olg, LLOG_SIZE_REPL_CTXT, disk_obd, 0, NULL, &mds_size_repl_logops); if (rc) GOTO(err_llog, rc); - rc = obd_llog_init(lov_obd, &lov_obd->obd_olg, tgt, count, logid, uuid); + rc = obd_llog_init(lov_obd, &lov_obd->obd_olg, disk_obd, index); if (rc) { CERROR("lov_llog_init err %d\n", rc); GOTO(err_cleanup, rc); diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index dd903df..507d4a4 100644 --- a/lustre/mds/mds_lov.c +++ b/lustre/mds/mds_lov.c @@ -537,7 +537,7 @@ static int mds_lov_update_desc(struct obd_device *obd, int idx, /* If we added a target we have to reconnect the llogs */ /* We only _need_ to do this at first add (idx), or the first time after recovery. However, it should now be safe to call anytime. */ - rc = llog_cat_initialize(obd, &obd->obd_olg, idx, uuid); + rc = obd_llog_init(obd, &obd->obd_olg, obd, &idx); if (rc) GOTO(out, rc); @@ -644,11 +644,17 @@ int mds_lov_connect(struct obd_device *obd, char * lov_name) GOTO(err_exit, rc); } + /* try init too early */ + rc = obd_llog_init(obd, &obd->obd_olg, obd, NULL); + if (rc) + GOTO(err_exit, rc); + mds->mds_osc_obd->u.lov.lov_sp_me = LUSTRE_SP_MDT; OBD_ALLOC(data, sizeof(*data)); if (data == NULL) - RETURN(-ENOMEM); + GOTO(err_exit, rc = -ENOMEM); + data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_INDEX | OBD_CONNECT_REQPORTAL | OBD_CONNECT_QUOTA64 | OBD_CONNECT_OSS_CAPA | OBD_CONNECT_FID | diff --git a/lustre/mgc/libmgc.c b/lustre/mgc/libmgc.c index 3c242e3..f799cd5 100644 --- a/lustre/mgc/libmgc.c +++ b/lustre/mgc/libmgc.c @@ -70,7 +70,7 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) /* liblustre only support null flavor to MGS */ obd->u.cli.cl_flvr_mgc.sf_rpc = SPTLRPC_FLVR_NULL; - rc = obd_llog_init(obd, &obd->obd_olg, obd, 0, NULL, NULL); + rc = obd_llog_init(obd, &obd->obd_olg, obd, NULL); if (rc) { CERROR("failed to setup llogging subsystems\n"); GOTO(err_cleanup, rc); @@ -116,8 +116,7 @@ static int mgc_cleanup(struct obd_device *obd) } static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, - struct obd_device *tgt, int count, - struct llog_catid *logid, struct obd_uuid *uuid) + struct obd_device *tgt, int *index) { struct llog_ctxt *ctxt; int rc; diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 270de52..c28488e 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -678,7 +678,7 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) if (rc) GOTO(err_decref, rc); - rc = obd_llog_init(obd, &obd->obd_olg, obd, 0, NULL, NULL); + rc = obd_llog_init(obd, &obd->obd_olg, obd, NULL); if (rc) { CERROR("failed to setup llogging subsystems\n"); GOTO(err_cleanup, rc); @@ -1108,8 +1108,7 @@ static int mgc_import_event(struct obd_device *obd, } static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, - struct obd_device *tgt, int count, - struct llog_catid *logid, struct obd_uuid *uuid) + struct obd_device *tgt, int *index) { struct llog_ctxt *ctxt; int rc; diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 394fcb4..cb0ff23 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -163,8 +163,7 @@ static int mgs_cleanup(struct obd_device *obd); 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 count, - struct llog_catid *logid, struct obd_uuid *uuid) + struct obd_device *tgt, int *index) { int rc; ENTRY; @@ -235,7 +234,7 @@ static int mgs_setup(struct obd_device *obd, struct lustre_cfg *lcfg) GOTO(err_ns, rc); } - rc = obd_llog_init(obd, &obd->obd_olg, obd, 0, NULL, NULL); + rc = obd_llog_init(obd, &obd->obd_olg, obd, NULL); if (rc) GOTO(err_fs, rc); diff --git a/lustre/obdclass/llog_internal.h b/lustre/obdclass/llog_internal.h index 4c31016..d83733e 100644 --- a/lustre/obdclass/llog_internal.h +++ b/lustre/obdclass/llog_internal.h @@ -48,10 +48,6 @@ struct llog_process_info { struct completion lpi_completion; }; -int llog_put_cat_list(struct obd_device *obd, struct obd_device *disk_obd, - char *name, int idx, int count, - struct llog_catid *idarray); - int llog_cat_id2handle(struct llog_handle *cathandle, struct llog_handle **res, struct llog_logid *logid); int class_config_dump_handler(struct llog_handle * handle, diff --git a/lustre/obdclass/llog_ioctl.c b/lustre/obdclass/llog_ioctl.c index f6b4b17..8d57e18 100644 --- a/lustre/obdclass/llog_ioctl.c +++ b/lustre/obdclass/llog_ioctl.c @@ -437,7 +437,7 @@ int llog_catalog_list(struct obd_device *obd, int count, RETURN(-ENOMEM); mutex_down(&obd->obd_olg.olg_cat_processing); - rc = llog_get_cat_list(obd, obd, name, 0, count, idarray); + rc = llog_get_cat_list(obd, name, 0, count, idarray); if (rc) GOTO(out, rc); diff --git a/lustre/obdclass/llog_lvfs.c b/lustre/obdclass/llog_lvfs.c index 4f0e45b..7cab899 100644 --- a/lustre/obdclass/llog_lvfs.c +++ b/lustre/obdclass/llog_lvfs.c @@ -754,7 +754,7 @@ static int llog_lvfs_destroy(struct llog_handle *handle) } /* reads the catalog list */ -int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd, +int llog_get_cat_list(struct obd_device *disk_obd, char *name, int idx, int count, struct llog_catid *idarray) { struct lvfs_run_ctxt saved; @@ -767,7 +767,7 @@ int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd, if (!count) RETURN(0); - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); + push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); file = filp_open(name, O_RDWR | O_CREAT | O_LARGEFILE, 0700); if (!file || IS_ERR(file)) { rc = PTR_ERR(file); @@ -798,7 +798,7 @@ int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd, EXIT; out: - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); + pop_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); if (file && !IS_ERR(file)) rc1 = filp_close(file, 0); if (rc == 0) @@ -808,7 +808,7 @@ int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd, EXPORT_SYMBOL(llog_get_cat_list); /* writes the cat list */ -int llog_put_cat_list(struct obd_device *obd, struct obd_device *disk_obd, +int llog_put_cat_list(struct obd_device *disk_obd, char *name, int idx, int count, struct llog_catid *idarray) { struct lvfs_run_ctxt saved; @@ -820,7 +820,7 @@ int llog_put_cat_list(struct obd_device *obd, struct obd_device *disk_obd, if (!count) GOTO(out1, rc = 0); - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); + push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); file = filp_open(name, O_RDWR | O_CREAT | O_LARGEFILE, 0700); if (!file || IS_ERR(file)) { rc = PTR_ERR(file); @@ -843,7 +843,7 @@ int llog_put_cat_list(struct obd_device *obd, struct obd_device *disk_obd, } out: - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); + pop_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); if (file && !IS_ERR(file)) rc1 = filp_close(file, 0); @@ -918,14 +918,14 @@ static int llog_lvfs_destroy(struct llog_handle *handle) return 0; } -int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd, +int llog_get_cat_list(struct obd_device *disk_obd, char *name, int idx, int count, struct llog_catid *idarray) { LBUG(); return 0; } -int llog_put_cat_list(struct obd_device *obd, struct obd_device *disk_obd, +int llog_put_cat_list(struct obd_device *disk_obd, char *name, int idx, int count, struct llog_catid *idarray) { LBUG(); diff --git a/lustre/obdclass/llog_obd.c b/lustre/obdclass/llog_obd.c index 4453be1..0f10503 100644 --- a/lustre/obdclass/llog_obd.c +++ b/lustre/obdclass/llog_obd.c @@ -178,6 +178,7 @@ int llog_setup_named(struct obd_device *obd, struct obd_llog_group *olg, ctxt->loc_logops = op; sema_init(&ctxt->loc_sem, 1); ctxt->loc_exp = class_export_get(disk_obd->obd_self_export); + ctxt->loc_flags = LLOG_CTXT_FLAG_UNINITIALIZED; rc = llog_group_set_ctxt(olg, ctxt, index); if (rc) { @@ -185,7 +186,7 @@ int llog_setup_named(struct obd_device *obd, struct obd_llog_group *olg, if (rc == -EEXIST) { ctxt = llog_group_get_ctxt(olg, index); if (ctxt) { - /* + /* * mds_lov_update_desc() might call here multiple * times. So if the llog is already set up then * don't to do it again. @@ -215,6 +216,10 @@ int llog_setup_named(struct obd_device *obd, struct obd_llog_group *olg, CERROR("obd %s ctxt %d lop_setup=%p failed %d\n", obd->obd_name, index, op->lop_setup, rc); llog_ctxt_put(ctxt); + } else { + CDEBUG(D_CONFIG, "obd %s ctxt %d is initialized\n", + obd->obd_name, index); + ctxt->loc_flags &= ~LLOG_CTXT_FLAG_UNINITIALIZED; } RETURN(rc); @@ -256,6 +261,10 @@ int llog_add(struct llog_ctxt *ctxt, struct llog_rec_hdr *rec, RETURN(-ENODEV); } + if (ctxt->loc_flags & LLOG_CTXT_FLAG_UNINITIALIZED) + RETURN(-ENXIO); + + CTXT_CHECK_OP(ctxt, add, -EOPNOTSUPP); raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE); if (!raised) @@ -441,54 +450,15 @@ int llog_obd_origin_add(struct llog_ctxt *ctxt, } EXPORT_SYMBOL(llog_obd_origin_add); -int llog_cat_initialize(struct obd_device *obd, struct obd_llog_group *olg, - int idx, struct obd_uuid *uuid) -{ - char name[32] = CATLIST; - struct llog_catid idarray; - int rc; - ENTRY; - - mutex_down(&olg->olg_cat_processing); - rc = llog_get_cat_list(obd, obd, name, idx, 1, &idarray); - if (rc) { - CERROR("rc: %d\n", rc); - GOTO(out, rc); - } - - CDEBUG(D_INFO, "%s: Init llog for %s/%d - catid "LPX64"/"LPX64":%x\n", - obd->obd_name, uuid->uuid, idx, idarray.lci_logid.lgl_oid, - idarray.lci_logid.lgl_ogr, idarray.lci_logid.lgl_ogen); - - rc = obd_llog_init(obd, olg, obd, 1, &idarray, uuid); - if (rc) { - CERROR("rc: %d\n", rc); - GOTO(out, rc); - } - - rc = llog_put_cat_list(obd, obd, name, idx, 1, &idarray); - if (rc) { - CERROR("rc: %d\n", rc); - GOTO(out, rc); - } - - out: - mutex_up(&olg->olg_cat_processing); - - RETURN(rc); -} -EXPORT_SYMBOL(llog_cat_initialize); - int obd_llog_init(struct obd_device *obd, struct obd_llog_group *olg, - struct obd_device *disk_obd, int count, - struct llog_catid *logid, struct obd_uuid *uuid) + struct obd_device *disk_obd, int *index) { int rc; ENTRY; OBD_CHECK_DT_OP(obd, llog_init, 0); OBD_COUNTER_INCREMENT(obd, llog_init); - rc = OBP(obd, llog_init)(obd, olg, disk_obd, count, logid, uuid); + rc = OBP(obd, llog_init)(obd, olg, disk_obd, index); RETURN(rc); } EXPORT_SYMBOL(obd_llog_init); diff --git a/lustre/obdclass/llog_test.c b/lustre/obdclass/llog_test.c index 9f35232..6d467ce 100644 --- a/lustre/obdclass/llog_test.c +++ b/lustre/obdclass/llog_test.c @@ -658,8 +658,7 @@ static int llog_run_tests(struct obd_device *obd) static int llog_test_llog_init(struct obd_device *obd, struct obd_llog_group *olg, - struct obd_device *tgt, int count, - struct llog_catid *logid, struct obd_uuid *uuid) + struct obd_device *tgt, int *index) { int rc; ENTRY; @@ -715,6 +714,7 @@ static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) RETURN(-EINVAL); } + /* disk obd */ tgt = class_name2obd(lustre_cfg_string(lcfg, 1)); if (!tgt || !tgt->obd_attached || !tgt->obd_set_up) { CERROR("target device not attached or not set up (%s)\n", @@ -722,7 +722,7 @@ static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) RETURN(-EINVAL); } - rc = obd_llog_init(obd, NULL, tgt, 0, NULL, NULL); + rc = obd_llog_init(obd, NULL, tgt, NULL); if (rc) RETURN(rc); diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 7fabcb4..507e8d8 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -2146,7 +2146,7 @@ int filter_common_setup(struct obd_device *obd, struct lustre_cfg* lcfg, ptlrpc_init_client(LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL, "filter_ldlm_cb_client", &obd->obd_ldlm_client); - rc = obd_llog_init(obd, &obd->obd_olg, obd, 1, NULL, NULL); + rc = obd_llog_init(obd, &obd->obd_olg, obd, NULL); if (rc) { CERROR("failed to setup llogging subsystems\n"); GOTO(err_post, rc); @@ -2399,8 +2399,7 @@ cleanup_lcm: static int filter_llog_init(struct obd_device *obd, struct obd_llog_group *olg, - struct obd_device *tgt, int count, struct llog_catid *catid, - struct obd_uuid *uuid) + struct obd_device *tgt, int *index) { struct filter_obd *filter = &obd->u.filter; struct llog_ctxt *ctxt; @@ -2535,7 +2534,7 @@ struct obd_llog_group *filter_find_create_olg(struct obd_device *obd, int group) olg->olg_initializing = 1; spin_unlock(&filter->fo_llog_list_lock); - rc = llog_cat_initialize(obd, olg, 1, NULL); + rc = obd_llog_init(obd, olg, obd, NULL); if (rc) { spin_lock(&filter->fo_llog_list_lock); list_del(&olg->olg_list); diff --git a/lustre/osc/osc_create.c b/lustre/osc/osc_create.c index d422453..a8578e6 100644 --- a/lustre/osc/osc_create.c +++ b/lustre/osc/osc_create.c @@ -451,7 +451,8 @@ int osc_create_async(struct obd_export *exp, struct obd_info *oinfo, struct obdo *oa = oinfo->oi_oa; ENTRY; - if ((oa->o_valid & OBD_MD_FLGROUP) && (oa->o_gr != 0)){ + if ((oa->o_valid & OBD_MD_FLGROUP) && + (oa->o_gr == FILTER_GROUP_ECHO || oa->o_gr == FILTER_GROUP_LLOG)){ rc = osc_real_create(exp, oinfo->oi_oa, ea, oti); rc = oinfo->oi_cb_up(oinfo, rc); RETURN(rc); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index e48a181..a1c16a8 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -3977,32 +3977,21 @@ 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, int count, - struct llog_catid *catid, struct obd_uuid *uuid) + +static int __osc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, + struct obd_device *tgt, struct llog_catid *catid) { int rc; ENTRY; - LASSERT(olg == &obd->obd_olg); - spin_lock(&obd->obd_dev_lock); - if (osc_mds_ost_orig_logops.lop_setup != llog_obd_origin_setup) { - 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_add = llog_obd_origin_add; - osc_mds_ost_orig_logops.lop_connect = llog_origin_connect; - } - spin_unlock(&obd->obd_dev_lock); - - rc = llog_setup(obd, &obd->obd_olg, LLOG_MDS_OST_ORIG_CTXT, tgt, count, + 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); } - rc = llog_setup(obd, &obd->obd_olg, LLOG_SIZE_REPL_CTXT, tgt, count, + rc = llog_setup(obd, &obd->obd_olg, LLOG_SIZE_REPL_CTXT, tgt, 1, NULL, &osc_size_repl_logops); if (rc) { struct llog_ctxt *ctxt = @@ -4014,14 +4003,53 @@ static int osc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, GOTO(out, rc); out: if (rc) { - CERROR("osc '%s' tgt '%s' cnt %d catid %p rc=%d\n", - obd->obd_name, tgt->obd_name, count, catid, 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; } +static int osc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, + struct obd_device *disk_obd, int *index) +{ + struct llog_catid catid; + static char name[32] = CATLIST; + int rc; + ENTRY; + + LASSERT(olg == &obd->obd_olg); + + mutex_down(&olg->olg_cat_processing); + rc = llog_get_cat_list(disk_obd, name, *index, 1, &catid); + if (rc) { + CERROR("rc: %d\n", rc); + GOTO(out, rc); + } + + CDEBUG(D_INFO, "%s: Init llog for %d - catid "LPX64"/"LPX64":%x\n", + obd->obd_name, *index, catid.lci_logid.lgl_oid, + catid.lci_logid.lgl_ogr, catid.lci_logid.lgl_ogen); + + rc = __osc_llog_init(obd, olg, disk_obd, &catid); + if (rc) { + CERROR("rc: %d\n", rc); + GOTO(out, rc); + } + + rc = llog_put_cat_list(disk_obd, name, *index, 1, &catid); + if (rc) { + CERROR("rc: %d\n", rc); + GOTO(out, rc); + } + + out: + mutex_up(&olg->olg_cat_processing); + + return rc; +} + static int osc_llog_finish(struct obd_device *obd, int count) { struct llog_ctxt *ctxt; @@ -4398,6 +4426,12 @@ int __init osc_init(void) spin_lock_init(&osc_ast_guard); 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_add = llog_obd_origin_add; + osc_mds_ost_orig_logops.lop_connect = llog_origin_connect; + RETURN(rc); } diff --git a/lustre/ptlrpc/llog_server.c b/lustre/ptlrpc/llog_server.c index fd88361..b81b32d 100644 --- a/lustre/ptlrpc/llog_server.c +++ b/lustre/ptlrpc/llog_server.c @@ -606,7 +606,7 @@ static int llog_catinfo_deletions(struct obd_device *obd, char *buf, GOTO(release_ctxt, rc = -ENOMEM); mutex_down(&obd->obd_olg.olg_cat_processing); - rc = llog_get_cat_list(obd, obd, name, 0, count, idarray); + rc = llog_get_cat_list(obd, name, 0, count, idarray); if (rc) GOTO(out_free, rc);