+ 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;
+
+ /* 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(ctxt, &lur->lur_hdr, lsm, logcookie, cookies);
+ llog_ctxt_put(ctxt);
+
+ OBD_FREE_PTR(lur);
+ RETURN(rc);
+}
+
+int mds_log_op_unlink(struct obd_device *obd,
+ struct lov_mds_md *lmm, int lmm_size,
+ struct llog_cookie *logcookies, int cookies_size)
+{
+ struct mds_obd *mds = &obd->u.mds;
+ struct lov_stripe_md *lsm = NULL;