Whamcloud - gitweb
LU-1187 osp: add osp_md_object for remote directory.
[fs/lustre-release.git] / lustre / osp / osp_object.c
index e5ffe31..695a31e 100644 (file)
@@ -356,15 +356,30 @@ static int is_ost_obj(struct lu_object *lo)
 }
 
 static int osp_object_init(const struct lu_env *env, struct lu_object *o,
-                          const struct lu_object_conf *unused)
+                          const struct lu_object_conf *conf)
 {
        struct osp_object       *po = lu2osp_obj(o);
        int                     rc = 0;
        ENTRY;
 
-       if (is_ost_obj(o))
+       if (is_ost_obj(o)) {
                po->opo_obj.do_ops = &osp_obj_ops;
-
+       } else {
+               struct lu_attr          *la = &osp_env_info(env)->osi_attr;
+
+               po->opo_obj.do_ops = &osp_md_obj_ops;
+               o->lo_header->loh_attr |= LOHA_REMOTE;
+               /* Do not need get attr for new object */
+               if (!(conf != NULL && (conf->loc_flags & LOC_F_NEW) != 0)) {
+                       rc = po->opo_obj.do_ops->do_attr_get(env, lu2dt_obj(o),
+                                                            la, NULL);
+                       if (rc == 0)
+                               o->lo_header->loh_attr |=
+                                       LOHA_EXISTS | (la->la_mode & S_IFMT);
+                       if (rc == -ENOENT)
+                               rc = 0;
+               }
+       }
        RETURN(rc);
 }