static int orphan_object_destroy(const struct lu_env *env, struct mdd_object *obj, struct dt_key *key) { struct thandle *th = NULL; struct mdd_device *mdd = mdo2mdd(&obj->mod_obj); int rc = 0; ENTRY; mdd_txn_param_build(env, mdd, MDD_TXN_UNLINK_OP); th = mdd_trans_start(env, mdd); if (IS_ERR(th)) { CERROR("Cannot get thandle\n"); RETURN(-ENOMEM); } mdd_write_lock(env, obj, MOR_TGT_CHILD); if (likely(obj->mod_count == 0)) { mdd_orphan_write_lock(env, mdd); rc = mdd_orphan_delete_obj(env, mdd, key, th); if (!rc) orphan_object_kill(env, obj, mdd, th); else CERROR("could not delete object: rc = %d\n",rc); mdd_orphan_write_unlock(env, mdd); } mdd_write_unlock(env, obj); mdd_trans_stop(env, mdd, 0, th); RETURN(rc); }
static int orph_index_delete(const struct lu_env *env, struct mdd_object *obj, __u32 op, struct thandle *th) { struct mdd_device *mdd = mdo2mdd(&obj->mod_obj); struct dt_object *dor = mdd->mdd_orphans; struct dt_key *key; int rc; ENTRY; LASSERT(mdd_write_locked(env, obj) != 0); LASSERT(obj->mod_flags & ORPHAN_OBJ); LASSERT(obj->mod_count == 0); LASSERT(dor); key = orph_key_fill(env, mdo2fid(obj), op); mdd_orphan_write_lock(env, mdd); rc = mdd_orphan_delete_obj(env, mdd, key, th); if (rc == -ENOENT) { key = orph_key_fill_18(env, mdo2fid(obj)); rc = mdd_orphan_delete_obj(env, mdd, key, th); } if (!rc) { /* lov objects will be destroyed by caller */ mdo_ref_del(env, obj, th); if (S_ISDIR(mdd_object_type(obj))) { mdo_ref_del(env, obj, th); mdd_orphan_ref_del(env, mdd, th); } obj->mod_flags &= ~ORPHAN_OBJ; } else { CERROR("could not delete object: rc = %d\n",rc); } mdd_orphan_write_unlock(env, mdd); RETURN(rc); }
static int orphan_object_destroy(const struct lu_env *env, struct mdd_object *obj, struct dt_key *key) { struct thandle *th = NULL; struct mdd_device *mdd = mdo2mdd(&obj->mod_obj); int rc = 0; ENTRY; th = mdd_trans_create(env, mdd); if (IS_ERR(th)) { CERROR("Cannot get thandle\n"); RETURN(PTR_ERR(th)); } rc = orph_declare_index_delete(env, obj, th); if (rc) GOTO(stop, rc); rc = mdo_declare_destroy(env, obj, th); if (rc) GOTO(stop, rc); rc = mdd_trans_start(env, mdd, th); if (rc) GOTO(stop, rc); mdd_write_lock(env, obj, MOR_TGT_CHILD); if (likely(obj->mod_count == 0)) { mdd_orphan_write_lock(env, mdd); rc = mdd_orphan_delete_obj(env, mdd, key, th); if (rc == 0) { mdo_ref_del(env, obj, th); if (S_ISDIR(mdd_object_type(obj))) { mdo_ref_del(env, obj, th); mdd_orphan_ref_del(env, mdd, th); } rc = mdo_destroy(env, obj, th); } else CERROR("could not delete object: rc = %d\n", rc); mdd_orphan_write_unlock(env, mdd); } mdd_write_unlock(env, obj); stop: rc = mdd_trans_stop(env, mdd, 0, th); RETURN(rc); }