- mutex_down(&ctxt->loc_sem); \
- if (ctxt->loc_imp != imp) \
- CWARN("loc_imp has changed from %p to %p\n", \
- ctxt->loc_imp, imp); \
- class_import_put(imp); \
- mutex_up(&ctxt->loc_sem); \
-} while(0)
-
-/* This is a callback from the llog_* functions.
- * Assumes caller has already pushed us into the kernel context. */
-static int llog_client_create(struct llog_ctxt *ctxt, struct llog_handle **res,
- struct llog_logid *logid, char *name)
-{
- struct obd_import *imp;
- struct llogd_body *body;
- struct llog_handle *handle;
- struct ptlrpc_request *req = NULL;
- int rc;
- ENTRY;
-
- LLOG_CLIENT_ENTRY(ctxt, imp);
-
- handle = llog_alloc_handle();
- if (handle == NULL)
- RETURN(-ENOMEM);
- *res = handle;
-
- req = ptlrpc_request_alloc(imp, &RQF_LLOG_ORIGIN_HANDLE_CREATE);
- if (req == NULL)
- GOTO(err_free, rc = -ENOMEM);
-
- if (name)
- req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
- strlen(name) + 1);
-
- rc = ptlrpc_request_pack(req, LUSTRE_LOG_VERSION,
- LLOG_ORIGIN_HANDLE_CREATE);
- if (rc) {
- ptlrpc_request_free(req);
- req = NULL;
- GOTO(err_free, rc);
- }
- ptlrpc_request_set_replen(req);
-
- body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY);
- if (logid)
- body->lgd_logid = *logid;
- body->lgd_ctxt_idx = ctxt->loc_idx - 1;
-
- if (name) {
- char *tmp;
- tmp = req_capsule_client_sized_get(&req->rq_pill, &RMF_NAME,
- strlen(name) + 1);
- LASSERT(tmp);
- strcpy(tmp, name);
- }
-
- rc = ptlrpc_queue_wait(req);
- if (rc)
- GOTO(err_free, rc);
-
- body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY);
- if (body == NULL)
- GOTO(err_free, rc =-EFAULT);
-
- handle->lgh_id = body->lgd_logid;
- handle->lgh_ctxt = ctxt;
- EXIT;
-out:
- LLOG_CLIENT_EXIT(ctxt, imp);
- ptlrpc_req_finished(req);
- return rc;
-err_free:
- llog_free_handle(handle);
- goto out;
-}