- 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 obd_run_ctxt saved;
- struct llog_ctxt *ctxt;
- __u32 flags;
- __u8 *buf;
- void * ptr;
- int size[] = {sizeof (*body),
- LLOG_CHUNK_SIZE};
- int rc, rc2;
- ENTRY;
-
- body = lustre_swab_reqbuf(req, 0, sizeof(*body),
- lustre_swab_llogd_body);
- if (body == NULL) {
- CERROR ("Can't unpack llogd_body\n");
- GOTO(out, rc =-EFAULT);
- }
-
- OBD_ALLOC(buf, LLOG_CHUNK_SIZE);
- if (!buf)
- GOTO(out, rc = -ENOMEM);
-
- ctxt = llog_get_context(obd, body->lgd_ctxt_idx);
- LASSERT(ctxt != NULL);
- disk_obd = ctxt->loc_exp->exp_obd;
- push_ctxt(&saved, &disk_obd->obd_ctxt, NULL);
-
- rc = llog_create(ctxt, &loghandle, &body->lgd_logid, NULL);
- if (rc)
- GOTO(out_pop, rc);
-
- flags = body->lgd_llh_flags;
- rc = llog_init_handle(loghandle, flags, NULL);
- if (rc)
- GOTO(out_close, rc);
-
- memset(buf, 0, LLOG_CHUNK_SIZE);
- rc = llog_next_block(loghandle, &body->lgd_saved_index,
- body->lgd_index,
- &body->lgd_cur_offset, buf, LLOG_CHUNK_SIZE);
- if (rc)
- GOTO(out_close, rc);
-
-
- rc = lustre_pack_reply(req, 2, size, NULL);
- if (rc)
- GOTO(out_close, rc = -ENOMEM);
-
- ptr = lustre_msg_buf(req->rq_repmsg, 0, sizeof (body));
- memcpy(ptr, body, sizeof(*body));
-
- ptr = lustre_msg_buf(req->rq_repmsg, 1, LLOG_CHUNK_SIZE);
- memcpy(ptr, buf, LLOG_CHUNK_SIZE);
+ struct llog_handle *loghandle;
+ struct llogd_body *body;
+ struct llogd_body *repbody;
+ struct llog_ctxt *ctxt;
+ __u32 flags;
+ void *ptr;
+ int rc;
+
+ ENTRY;
+
+ body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY);
+ if (body == NULL)
+ RETURN(err_serious(-EFAULT));
+
+ req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_SERVER,
+ LLOG_CHUNK_SIZE);
+ rc = req_capsule_server_pack(&req->rq_pill);
+ if (rc)
+ RETURN(err_serious(-ENOMEM));
+
+ ctxt = llog_get_context(req->rq_export->exp_obd, body->lgd_ctxt_idx);
+ if (ctxt == NULL)
+ RETURN(-ENODEV);
+
+ rc = llog_open(req->rq_svc_thread->t_env, ctxt, &loghandle,
+ &body->lgd_logid, NULL, LLOG_OPEN_EXISTS);
+ if (rc)
+ GOTO(out_ctxt, rc);
+
+ flags = body->lgd_llh_flags;
+ rc = llog_init_handle(req->rq_svc_thread->t_env, loghandle, flags,
+ NULL);
+ if (rc)
+ GOTO(out_close, rc);
+
+ repbody = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY);
+ *repbody = *body;
+
+ ptr = req_capsule_server_get(&req->rq_pill, &RMF_EADATA);
+ rc = llog_next_block(req->rq_svc_thread->t_env, loghandle,
+ &repbody->lgd_saved_index, repbody->lgd_index,
+ &repbody->lgd_cur_offset, ptr, LLOG_CHUNK_SIZE);
+ if (rc)
+ GOTO(out_close, rc);
+ EXIT;
+out_close:
+ llog_origin_close(req->rq_svc_thread->t_env, loghandle);
+out_ctxt:
+ llog_ctxt_put(ctxt);
+ return rc;
+}
+EXPORT_SYMBOL(llog_origin_handle_next_block);