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,
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,
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);
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);
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)
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)
{
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);
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);
}
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)
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) {
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;
}
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);
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);
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);
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,
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);
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);
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 = {
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 {
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,
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)
{
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);
+
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
logid->lgl_ogen, rc);
GOTO(out, rc);
}
-
handle->lgh_id = *logid;
} else if (name) {
handle->lgh_file = llog_filp_open(MOUNT_CONFIGS_DIR, name,
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;
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)
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);
}
#include <obd_class.h>
#include <lustre_log.h>
-#include <libcfs/list.h>
#include "llog_internal.h"
/* helper functions for calling the llog obd methods */
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;
/* 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);
}
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;
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);
}
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;
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);
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)
}
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,
{
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;
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);
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;
}
/**
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);
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,
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,
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);
}