+ 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);
+ }
+
+ RETURN(rc);
+err_cleanup:
+ ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT);
+ if (ctxt)
+ llog_cleanup(ctxt);
+err_llog:
+ ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
+ if (ctxt)
+ llog_cleanup(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);
+}
+
+static int mds_llog_add_unlink(struct obd_device *obd,
+ struct lov_stripe_md *lsm, obd_count count,
+ struct llog_cookie *logcookie, int cookies)
+{
+ struct llog_unlink_rec *lur;
+ struct llog_ctxt *ctxt;
+ int rc;
+
+ if (cookies < lsm->lsm_stripe_count)
+ RETURN(rc = -EFBIG);
+
+ /* first prepare unlink log record */
+ OBD_ALLOC_PTR(lur);
+ if (!lur)
+ RETURN(rc = -ENOMEM);
+ lur->lur_hdr.lrh_len = lur->lur_tail.lrt_len = sizeof(*lur);
+ lur->lur_hdr.lrh_type = MDS_UNLINK_REC;
+ lur->lur_count = count;
+
+ ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
+ rc = llog_add(NULL, ctxt, &lur->lur_hdr, lsm, logcookie, cookies);
+ llog_ctxt_put(ctxt);