-int llog_origin_handle_cancel(struct ptlrpc_request *req)
-{
- 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);
-}
-EXPORT_SYMBOL(llog_origin_handle_cancel);