-/* 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_create(env, ctxt, &handle, logid, NULL);
- } else {
- rc = llog_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)
-{
- struct llog_handle *cathandle, *n, *loghandle;
- struct llog_log_hdr *llh;
- int rc, index;
- ENTRY;
-
- if (!ctxt)
- RETURN(0);
-
- cathandle = ctxt->loc_handle;
- if (cathandle) {
- cfs_list_for_each_entry_safe(loghandle, n,
- &cathandle->u.chd.chd_head,
- u.phd.phd_entry) {
- llh = loghandle->lgh_hdr;
- if ((llh->llh_flags &
- LLOG_F_ZAP_WHEN_EMPTY) &&
- (llh->llh_count == 1)) {
- rc = llog_destroy(env, loghandle);
- if (rc)
- CERROR("failure destroying log during "
- "cleanup: %d\n", rc);
-
- index = loghandle->u.phd.phd_cookie.lgc_index;
- llog_free_handle(loghandle);
-
- LASSERT(index);
- llog_cat_set_first_idx(cathandle, index);
- rc = llog_cancel_rec(env, cathandle, index);
- if (rc == 0)
- CDEBUG(D_RPCTRACE, "cancel plain log at"
- "index %u of catalog "LPX64"\n",
- index,cathandle->lgh_id.lgl_oid);
- }
- }
- llog_cat_put(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,
- struct llog_cookie *logcookies, int numcookies)
-{
- struct llog_handle *cathandle;
- int rc;
- ENTRY;
-
- cathandle = ctxt->loc_handle;
- LASSERT(cathandle != NULL);
- rc = llog_cat_add_rec(env, cathandle, rec, logcookies, NULL);
- if (rc != 0 && rc != 1)
- CERROR("write one catalog record failed: %d\n", rc);
- RETURN(rc);
-}
-EXPORT_SYMBOL(llog_obd_origin_add);
-
-int obd_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
- 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, index);
- RETURN(rc);
-}
-EXPORT_SYMBOL(obd_llog_init);
-
-int obd_llog_finish(struct obd_device *obd, int count)
-{
- int rc;
- ENTRY;
- OBD_CHECK_DT_OP(obd, llog_finish, 0);
- OBD_COUNTER_INCREMENT(obd, llog_finish);
-
- rc = OBP(obd, llog_finish)(obd, count);
- RETURN(rc);
-}
-EXPORT_SYMBOL(obd_llog_finish);
-