- struct obd_device *obd = req->rq_export->exp_obd;
- struct obd_device *disk_obd;
- struct llog_cookie *logcookies;
- struct llog_ctxt *ctxt = NULL;
- int num_cookies, rc = 0, err, i;
- struct lvfs_run_ctxt saved;
- struct llog_handle *cathandle;
- struct inode *inode;
- void *handle;
- ENTRY;
-
- logcookies = req_capsule_client_get(&req->rq_pill, &RMF_LOGCOOKIES);
- num_cookies = req_capsule_get_size(&req->rq_pill, &RMF_LOGCOOKIES,
- RCL_CLIENT) / sizeof(*logcookies);
- if (logcookies == NULL || num_cookies == 0) {
- DEBUG_REQ(D_HA, req, "no cookies sent");
- RETURN(-EFAULT);
- }
-
- ctxt = llog_get_context(obd, logcookies->lgc_subsys);
- if (ctxt == NULL) {
- CWARN("llog subsys not setup or already cleanup\n");
- RETURN(-ENOENT);
- }
-
- disk_obd = ctxt->loc_exp->exp_obd;
- push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL);
- for (i = 0; i < num_cookies; i++, logcookies++) {
- cathandle = ctxt->loc_handle;
- LASSERT(cathandle != NULL);
- inode = cathandle->lgh_file->f_dentry->d_inode;
-
- handle = fsfilt_start_log(disk_obd, inode,
- FSFILT_OP_CANCEL_UNLINK, NULL, 1);
- if (IS_ERR(handle)) {
- CERROR("fsfilt_start failed: %ld\n", PTR_ERR(handle));
- GOTO(pop_ctxt, rc = PTR_ERR(handle));
- }
-
- rc = llog_cat_cancel_records(cathandle, 1, logcookies);
-
- err = fsfilt_commit(disk_obd, inode, handle, 0);
- if (err) {
- CERROR("error committing transaction: %d\n", err);
- if (!rc)
- rc = err;
- GOTO(pop_ctxt, rc);
- }
- }
-pop_ctxt:
- pop_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL);
- if (rc)
- CERROR("cancel %d llog-records failed: %d\n", num_cookies, rc);
- else
- CDEBUG(D_RPCTRACE, "cancel %d llog-records\n", num_cookies);
-
- llog_ctxt_put(ctxt);
- RETURN(rc);
+ 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;