+static int llog_client_prev_block(struct llog_handle *loghandle,
+ int prev_idx, void *buf, int len)
+{
+ struct obd_import *imp = loghandle->lgh_ctxt->loc_imp;
+ struct ptlrpc_request *req = NULL;
+ struct llogd_body *body;
+ void * ptr;
+ int size = sizeof(*body);
+ int repsize[2] = {sizeof (*body)};
+ int rc;
+ ENTRY;
+
+ req = ptlrpc_prep_req(imp, LLOG_ORIGIN_HANDLE_PREV_BLOCK, 1,&size,NULL);
+ if (!req)
+ GOTO(out, rc = -ENOMEM);
+
+ body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof (*body));
+ body->lgd_logid = loghandle->lgh_id;
+ body->lgd_ctxt_idx = loghandle->lgh_ctxt->loc_idx - 1;
+ body->lgd_llh_flags = loghandle->lgh_hdr->llh_flags;
+ body->lgd_index = prev_idx;
+ body->lgd_len = len;
+ repsize[1] = len;
+
+ req->rq_replen = lustre_msg_size(2, repsize);
+ rc = ptlrpc_queue_wait(req);
+ if (rc)
+ GOTO(out, rc);
+
+ body = lustre_swab_repbuf(req, 0, sizeof(*body),
+ lustre_swab_llogd_body);
+ if (body == NULL) {
+ CERROR ("Can't unpack llogd_body\n");
+ GOTO(out, rc =-EFAULT);
+ }
+
+ ptr = lustre_msg_buf(req->rq_repmsg, 1, len);
+ if (ptr == NULL) {
+ CERROR ("Can't unpack bitmap\n");
+ GOTO(out, rc =-EFAULT);
+ }
+
+ memcpy(buf, ptr, len);
+
+out:
+ if (req)
+ ptlrpc_req_finished(req);
+ RETURN(rc);
+}