- * Create ".lustre" directory.
- */
-static int create_dot_lustre_dir(const struct lu_env *env, struct mdd_device *m)
-{
- struct lu_fid *fid = &mdd_env_info(env)->mti_fid;
- struct md_object *mdo;
- int rc;
-
- memcpy(fid, &LU_DOT_LUSTRE_FID, sizeof(struct lu_fid));
- mdo = llo_store_create_index(env, &m->mdd_md_dev, m->mdd_child,
- mdd_root_dir_name, dot_lustre_name,
- fid, &dt_directory_features);
- /* .lustre dir may be already present */
- if (IS_ERR(mdo) && PTR_ERR(mdo) != -EEXIST) {
- rc = PTR_ERR(mdo);
- CERROR("creating obj [%s] fid = "DFID" rc = %d\n",
- dot_lustre_name, PFID(fid), rc);
- RETURN(rc);
- }
-
- if (!IS_ERR(mdo))
- lu_object_put(env, &mdo->mo_lu);
-
- return 0;
-}
-
-static int dot_lustre_attr_get(const struct lu_env *env, struct md_object *obj,
- struct md_attr *ma)
-{
- struct mdd_object *mdd_obj = md2mdd_obj(obj);
-
- return mdd_attr_get_internal_locked(env, mdd_obj, ma);
-}
-
-static int dot_lustre_attr_set(const struct lu_env *env, struct md_object *obj,
- const struct md_attr *ma)
-{
- return -EPERM;
-}
-
-static int dot_lustre_xattr_get(const struct lu_env *env,
- struct md_object *obj, struct lu_buf *buf,
- const char *name)
-{
- return 0;
-}
-
-static int dot_lustre_mdd_open(const struct lu_env *env, struct md_object *obj,
- int flags)
-{
- struct mdd_object *mdd_obj = md2mdd_obj(obj);
-
- mdd_write_lock(env, mdd_obj, MOR_TGT_CHILD);
- mdd_obj->mod_count++;
- mdd_write_unlock(env, mdd_obj);
-
- return 0;
-}
-
-static int dot_lustre_path(const struct lu_env *env, struct md_object *obj,
- char *path, int pathlen, __u64 *recno, int *linkno)
-{
- return -ENOSYS;
-}
-
-static int dot_lustre_close(const struct lu_env *env, struct md_object *obj,
- struct md_attr *ma)
-{
- struct mdd_object *mdd_obj = md2mdd_obj(obj);
-
- mdd_write_lock(env, mdd_obj, MOR_TGT_CHILD);
- mdd_obj->mod_count--;
- mdd_write_unlock(env, mdd_obj);
-
- return 0;
-}
-
-static dt_obj_version_t dot_lustre_version_get(const struct lu_env *env,
- struct md_object *obj)
-{
- return 0;
-}
-
-static void dot_lustre_version_set(const struct lu_env *env,
- struct md_object *obj,
- dt_obj_version_t version)
-{
- return;
-}
-
-
-static struct md_object_operations mdd_dot_lustre_obj_ops = {
- .moo_attr_get = dot_lustre_attr_get,
- .moo_attr_set = dot_lustre_attr_set,
- .moo_xattr_get = dot_lustre_xattr_get,
- .moo_open = dot_lustre_mdd_open,
- .moo_close = dot_lustre_close,
- .moo_readpage = mdd_readpage,
- .moo_version_get = dot_lustre_version_get,
- .moo_version_set = dot_lustre_version_set,
- .moo_path = dot_lustre_path
-};
-
-static int dot_lustre_lookup(const struct lu_env *env, struct md_object *p,
- const struct lu_name *lname, struct lu_fid *f,
- struct md_op_spec *spec)
-{
- if (strcmp(lname->ln_name, mdd_obf_dir_name) == 0)
- *f = LU_OBF_FID;
- else
- return -ENOENT;
-
- return 0;
-}
-
-static int dot_lustre_create(const struct lu_env *env, struct md_object *pobj,
- const struct lu_name *lname,
- struct md_object *child, struct md_op_spec *spec,
- struct md_attr* ma)
-{
- return -EPERM;
-}
-
-static int dot_lustre_rename(const struct lu_env *env,
- struct md_object *src_pobj,
- struct md_object *tgt_pobj,
- const struct lu_fid *lf,
- const struct lu_name *lsname,
- struct md_object *tobj,
- const struct lu_name *ltname, struct md_attr *ma)
-{
- return -EPERM;
-}
-
-static int dot_lustre_link(const struct lu_env *env, struct md_object *tgt_obj,
- struct md_object *src_obj,
- const struct lu_name *lname, struct md_attr *ma)
-{
- return -EPERM;
-}
-
-static int dot_lustre_unlink(const struct lu_env *env, struct md_object *pobj,
- struct md_object *cobj, const struct lu_name *lname,
- struct md_attr *ma)
-{
- return -EPERM;
-}
-
-static struct md_dir_operations mdd_dot_lustre_dir_ops = {
- .mdo_lookup = dot_lustre_lookup,
- .mdo_create = dot_lustre_create,
- .mdo_rename = dot_lustre_rename,
- .mdo_link = dot_lustre_link,
- .mdo_unlink = dot_lustre_unlink,
-};
-
-static int obf_attr_get(const struct lu_env *env, struct md_object *obj,
- struct md_attr *ma)
-{
- int rc = 0;
-
- if (ma->ma_need & MA_INODE) {
- struct mdd_device *mdd = mdo2mdd(obj);
-
- /* "fid" is a virtual object and hence does not have any "real"
- * attributes. So we reuse attributes of .lustre for "fid" dir */
- ma->ma_need |= MA_INODE;
- rc = dot_lustre_attr_get(env, &mdd->mdd_dot_lustre->mod_obj, ma);
- if (rc)
- return rc;
- ma->ma_valid |= MA_INODE;
- }
-
- /* "fid" directory does not have any striping information. */
- if (ma->ma_need & MA_LOV) {
- struct mdd_object *mdd_obj = md2mdd_obj(obj);
-
- if (ma->ma_valid & MA_LOV)
- return 0;
-
- if (!(S_ISREG(mdd_object_type(mdd_obj)) ||
- S_ISDIR(mdd_object_type(mdd_obj))))
- return 0;
-
- if (ma->ma_need & MA_LOV_DEF) {
- rc = mdd_get_default_md(mdd_obj, ma->ma_lmm,
- &ma->ma_lmm_size);
- if (rc > 0) {
- ma->ma_valid |= MA_LOV;
- rc = 0;
- }
- }
- }
-
- return rc;
-}
-
-static int obf_attr_set(const struct lu_env *env, struct md_object *obj,
- const struct md_attr *ma)
-{
- return -EPERM;
-}
-
-static int obf_xattr_get(const struct lu_env *env,
- struct md_object *obj, struct lu_buf *buf,
- const char *name)
-{
- return 0;
-}
-
-static int obf_mdd_open(const struct lu_env *env, struct md_object *obj,
- int flags)
-{
- struct mdd_object *mdd_obj = md2mdd_obj(obj);
-
- mdd_write_lock(env, mdd_obj, MOR_TGT_CHILD);
- mdd_obj->mod_count++;
- mdd_write_unlock(env, mdd_obj);
-
- return 0;
-}
-
-static int obf_mdd_close(const struct lu_env *env, struct md_object *obj,
- struct md_attr *ma)
-{
- struct mdd_object *mdd_obj = md2mdd_obj(obj);
-
- mdd_write_lock(env, mdd_obj, MOR_TGT_CHILD);
- mdd_obj->mod_count--;
- mdd_write_unlock(env, mdd_obj);
-
- return 0;
-}
-
-/** Nothing to list in "fid" directory */
-static int obf_mdd_readpage(const struct lu_env *env, struct md_object *obj,
- const struct lu_rdpg *rdpg)
-{
- return -EPERM;
-}
-
-static int obf_path(const struct lu_env *env, struct md_object *obj,
- char *path, int pathlen, __u64 *recno, int *linkno)
-{
- return -ENOSYS;
-}
-
-static struct md_object_operations mdd_obf_obj_ops = {
- .moo_attr_get = obf_attr_get,
- .moo_attr_set = obf_attr_set,
- .moo_xattr_get = obf_xattr_get,
- .moo_open = obf_mdd_open,
- .moo_close = obf_mdd_close,
- .moo_readpage = obf_mdd_readpage,
- .moo_path = obf_path
-};
-
-/**