+ pop_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL);
+ llog_ctxt_put(ctxt);
+ RETURN(rc);
+}
+
+int llog_origin_handle_destroy(struct ptlrpc_request *req)
+{
+ struct obd_export *exp = req->rq_export;
+ struct obd_device *obd = exp->exp_obd;
+ struct obd_device *disk_obd;
+ struct llog_handle *loghandle;
+ struct llogd_body *body;
+ struct lvfs_run_ctxt saved;
+ struct llog_logid *logid = NULL;
+ struct llog_ctxt *ctxt;
+ __u32 flags;
+ int rc;
+ ENTRY;
+
+ body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY);
+ if (body == NULL)
+ RETURN(-EFAULT);
+
+ if (body->lgd_logid.lgl_oid > 0)
+ logid = &body->lgd_logid;
+
+ ctxt = llog_get_context(obd, body->lgd_ctxt_idx);
+ if (ctxt == NULL)
+ RETURN(-EINVAL);
+
+ disk_obd = ctxt->loc_exp->exp_obd;
+ push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL);
+
+ rc = llog_create(ctxt, &loghandle, logid, NULL);
+ if (rc)
+ GOTO(out_pop, rc);
+
+ rc = req_capsule_server_pack(&req->rq_pill);
+ if (rc)
+ GOTO(out_close, rc = -ENOMEM);
+
+ body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY);
+ body->lgd_logid = loghandle->lgh_id;
+ flags = body->lgd_llh_flags;
+ rc = llog_init_handle(loghandle, LLOG_F_IS_PLAIN, NULL);
+ if (rc)
+ GOTO(out_close, rc);
+ rc = llog_destroy(loghandle);
+ if (rc)
+ GOTO(out_close, rc);
+ llog_free_handle(loghandle);
+
+out_close:
+ if (rc)
+ llog_close(loghandle);
+out_pop:
+ pop_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL);
+ llog_ctxt_put(ctxt);