+static int osp_prep_unlink_update_req(const struct lu_env *env,
+ struct osp_device *osp,
+ struct llog_handle *llh,
+ struct llog_rec_hdr *h,
+ struct ptlrpc_request **reqp)
+{
+ struct llog_unlink64_rec *rec = (struct llog_unlink64_rec *)h;
+ struct dt_update_request *update = NULL;
+ struct ptlrpc_request *req;
+ const char *buf;
+ struct llog_cookie lcookie;
+ int size;
+ int rc;
+ ENTRY;
+
+ update = out_create_update_req(&osp->opd_dt_dev);
+ if (IS_ERR(update))
+ RETURN(PTR_ERR(update));
+
+ /* This can only happens for unlink slave directory, so decrease
+ * ref for ".." and "." */
+ rc = out_insert_update(env, update, OUT_REF_DEL, &rec->lur_fid, 0,
+ NULL, NULL);
+ if (rc != 0)
+ GOTO(out, rc);
+
+ rc = out_insert_update(env, update, OUT_REF_DEL, &rec->lur_fid, 0,
+ NULL, NULL);
+ if (rc != 0)
+ GOTO(out, rc);
+
+ lcookie.lgc_lgl = llh->lgh_id;
+ lcookie.lgc_subsys = LLOG_MDS_OST_ORIG_CTXT;
+ lcookie.lgc_index = h->lrh_index;
+ size = sizeof(lcookie);
+ buf = (const char *)&lcookie;
+
+ rc = out_insert_update(env, update, OUT_DESTROY, &rec->lur_fid, 1,
+ &size, &buf);
+ if (rc != 0)
+ GOTO(out, rc);
+
+ rc = out_prep_update_req(env, osp->opd_obd->u.cli.cl_import,
+ update->dur_req, &req);
+ if (rc != 0)
+ GOTO(out, rc);
+
+ INIT_LIST_HEAD(&req->rq_exp_list);
+ req->rq_svc_thread = (void *)OSP_JOB_MAGIC;
+
+ req->rq_interpret_reply = osp_sync_interpret;
+ req->rq_commit_cb = osp_sync_request_commit_cb;
+ req->rq_cb_data = osp;
+
+ ptlrpc_request_set_replen(req);
+ *reqp = req;
+out:
+ if (update != NULL)
+ out_destroy_update_req(update);
+
+ RETURN(rc);
+}
+
+static int osp_sync_new_unlink64_job(const struct lu_env *env,
+ struct osp_device *d,