-static struct llog_operations osc_size_repl_logops = {
- lop_cancel: llog_obd_repl_cancel
-};
-
-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 llog_ctxt *ctxt = NULL;
- struct llog_handle *lgh;
- int rc;
-
- ENTRY;
-
- 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:
- 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;
-}
-