int orph_declare_index_delete(const struct lu_env *env, struct mdd_object *obj, struct thandle *th) { struct mdd_device *mdd = mdo2mdd(&obj->mod_obj); struct dt_key *key; int rc; key = orph_key_fill(env, mdo2fid(obj), ORPH_OP_UNLINK); rc = dt_declare_delete(env, mdd->mdd_orphans, key, th); if (rc) return rc; rc = mdo_declare_ref_del(env, obj, th); if (rc) return rc; if (S_ISDIR(mdd_object_type(obj))) { rc = mdo_declare_ref_del(env, obj, th); if (rc) return rc; rc = dt_declare_ref_del(env, mdd->mdd_orphans, th); } return rc; }
static inline int mdd_orphan_insert_obj(const struct lu_env *env, struct mdd_device *mdd, struct mdd_object *obj, __u32 op, struct thandle *th) { struct dt_insert_rec *rec = &mdd_env_info(env)->mti_dt_rec; struct dt_object *dor = mdd->mdd_orphans; const struct lu_fid *lf = mdo2fid(obj); struct dt_key *key = orph_key_fill(env, lf, op); rec->rec_fid = lf; rec->rec_type = mdd_object_type(obj); return dt_insert(env, dor, (const struct dt_rec *)rec, key, th, 1); }
static inline int mdd_orphan_insert_obj(const struct lu_env *env, struct mdd_device *mdd, struct mdd_object *obj, __u32 op, struct thandle *th) { struct dt_object *dor = mdd->mdd_orphans; const struct lu_fid *lf = mdo2fid(obj); struct dt_key *key = orph_key_fill(env, lf, op); ENTRY; return dor->do_index_ops->dio_insert(env, dor, (struct dt_rec *)lf, key, th, BYPASS_CAPA, 1); }
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); }
int orph_declare_index_insert(const struct lu_env *env, struct mdd_object *obj, umode_t mode, struct thandle *th) { struct dt_insert_rec *rec = &mdd_env_info(env)->mti_dt_rec; struct mdd_device *mdd = mdo2mdd(&obj->mod_obj); struct dt_key *key; int rc; key = orph_key_fill(env, mdo2fid(obj), ORPH_OP_UNLINK); rec->rec_fid = mdo2fid(obj); rec->rec_type = mode; rc = dt_declare_insert(env, mdd->mdd_orphans, (const struct dt_rec *)rec, key, th); if (rc != 0) return rc; rc = mdo_declare_ref_add(env, obj, th); if (rc) return rc; if (!S_ISDIR(mode)) return 0; rc = mdo_declare_ref_add(env, obj, th); if (rc) return rc; rc = dt_declare_ref_add(env, mdd->mdd_orphans, th); if (rc) return rc; rc = mdo_declare_index_delete(env, obj, dotdot, th); if (rc) return rc; rc = mdo_declare_index_insert(env, obj, lu_object_fid(&mdd->mdd_orphans->do_lu), S_IFDIR, dotdot, th); return rc; }
int orph_declare_index_insert(const struct lu_env *env, struct mdd_object *obj, cfs_umode_t mode, struct thandle *th) { struct mdd_device *mdd = mdo2mdd(&obj->mod_obj); struct dt_key *key; int rc; key = orph_key_fill(env, mdo2fid(obj), ORPH_OP_UNLINK); rc = dt_declare_insert(env, mdd->mdd_orphans, NULL, key, th); if (rc) return rc; rc = mdo_declare_ref_add(env, obj, th); if (rc) return rc; if (!S_ISDIR(mode)) return 0; rc = mdo_declare_ref_add(env, obj, th); if (rc) return rc; rc = dt_declare_ref_add(env, mdd->mdd_orphans, th); if (rc) return rc; rc = mdo_declare_index_delete(env, obj, dotdot, th); if (rc) return rc; rc = mdo_declare_index_insert(env, obj, NULL, dotdot, th); return rc; }