- * Create the specified orphan MDT-object on remote MDT.
- *
- * The LFSCK instance on this MDT will send LFSCK RPC to remote MDT to
- * ask the remote LFSCK instance to create the specified orphan object
- * under .lustre/lost+found/MDTxxxx/ directory with the name:
- * ${FID}-P-${conflict_version}.
- *
- * \param[in] env pointer to the thread context
- * \param[in] com pointer to the lfsck component
- * \param[in] orphan pointer to the orphan MDT-object
- * \param[in] type the orphan's type to be created
- *
- * type "P": The orphan object to be created was a parent directory
- * of some MDT-object which linkEA shows that the @orphan
- * object is missing.
- *
- * \see lfsck_layout_recreate_parent() for more types.
- *
- * \param[in] lmv pointer to master LMV EA that will be set to the orphan
- *
- * \retval positive number for repaired cases
- * \retval 0 if needs to repair nothing
- * \retval negative error number on failure
- */
-static int lfsck_namespace_create_orphan_remote(const struct lu_env *env,
- struct lfsck_component *com,
- struct dt_object *orphan,
- __u32 type,
- struct lmv_mds_md_v1 *lmv)
-{
- struct lfsck_thread_info *info = lfsck_env_info(env);
- struct lfsck_request *lr = &info->lti_lr;
- struct lu_seq_range *range = &info->lti_range;
- const struct lu_fid *fid = lfsck_dto2fid(orphan);
- struct lfsck_namespace *ns = com->lc_file_ram;
- struct lfsck_instance *lfsck = com->lc_lfsck;
- struct seq_server_site *ss =
- lu_site2seq(lfsck->li_bottom->dd_lu_dev.ld_site);
- struct lfsck_tgt_desc *ltd = NULL;
- struct ptlrpc_request *req = NULL;
- int rc;
- ENTRY;
-
- if (lfsck->li_bookmark_ram.lb_param & LPF_DRYRUN)
- GOTO(out, rc = 1);
-
- fld_range_set_mdt(range);
- rc = fld_server_lookup(env, ss->ss_server_fld, fid_seq(fid), range);
- if (rc != 0)
- GOTO(out, rc);
-
- ltd = lfsck_tgt_get(&lfsck->li_mdt_descs, range->lsr_index);
- if (ltd == NULL) {
- ns->ln_flags |= LF_INCOMPLETE;
-
- GOTO(out, rc = -ENODEV);
- }
-
- req = ptlrpc_request_alloc(class_exp2cliimp(ltd->ltd_exp),
- &RQF_LFSCK_NOTIFY);
- if (req == NULL)
- GOTO(out, rc = -ENOMEM);
-
- rc = ptlrpc_request_pack(req, LUSTRE_OBD_VERSION, LFSCK_NOTIFY);
- if (rc != 0) {
- ptlrpc_request_free(req);
-
- GOTO(out, rc);
- }
-
- lr = req_capsule_client_get(&req->rq_pill, &RMF_LFSCK_REQUEST);
- memset(lr, 0, sizeof(*lr));
- lr->lr_event = LE_CREATE_ORPHAN;
- lr->lr_index = lfsck_dev_idx(lfsck->li_bottom);
- lr->lr_active = LFSCK_TYPE_NAMESPACE;
- lr->lr_fid = *fid;
- lr->lr_type = type;
- if (lmv != NULL) {
- lr->lr_hash_type = lmv->lmv_hash_type;
- lr->lr_stripe_count = lmv->lmv_stripe_count;
- lr->lr_layout_version = lmv->lmv_layout_version;
- memcpy(lr->lr_pool_name, lmv->lmv_pool_name,
- sizeof(lr->lr_pool_name));
- }
-
- ptlrpc_request_set_replen(req);
- rc = ptlrpc_queue_wait(req);
- ptlrpc_req_finished(req);
-
- if (rc == 0) {
- orphan->do_lu.lo_header->loh_attr |= LOHA_EXISTS;
- rc = 1;
- } else if (rc == -EEXIST) {
- orphan->do_lu.lo_header->loh_attr |= LOHA_EXISTS;
- rc = 0;
- }
-
- GOTO(out, rc);
-
-out:
- CDEBUG(D_LFSCK, "%s: namespace LFSCK create object "
- DFID" on the MDT %x remotely: rc = %d\n",
- lfsck_lfsck2name(lfsck), PFID(fid),
- ltd != NULL ? ltd->ltd_index : -1, rc);
-
- if (ltd != NULL)
- lfsck_tgt_put(ltd);
-
- return rc;
-}
-
-/**
- * Create the specified orphan MDT-object locally.