Whamcloud - gitweb
LU-1940 test: use default resend count for 118c
[fs/lustre-release.git] / lustre / osp / osp_object.c
index 81fa936..2426be1 100644 (file)
@@ -253,6 +253,13 @@ static int osp_object_create(const struct lu_env *env, struct dt_object *dt,
 
        CDEBUG(D_INODE, "fid for osp_obj %p is "DFID"!\n", osp_obj, PFID(fid));
 
+       /* If the precreate ends, it means it will be ready to rollover to
+        * the new sequence soon, all the creation should be synchronized,
+        * otherwise during replay, the replay fid will be inconsistent with
+        * last_used/create fid */
+       if (osp_precreate_end_seq(env, d) && osp_is_fid_client(d))
+               th->th_sync = 1;
+
        /*
         * it's OK if the import is inactive by this moment - id was created
         * by OST earlier, we just need to maintain it consistently on the disk
@@ -341,14 +348,40 @@ struct dt_object_operations osp_obj_ops = {
        .do_destroy             = osp_object_destroy,
 };
 
-static int osp_object_init(const struct lu_env *env, struct lu_object *o,
-                          const struct lu_object_conf *unused)
+static int is_ost_obj(struct lu_object *lo)
 {
-       struct osp_object *po = lu2osp_obj(o);
+       struct osp_device  *osp  = lu2osp_dev(lo->lo_dev);
 
-       po->opo_obj.do_ops = &osp_obj_ops;
+       return !osp->opd_connect_mdt;
+}
 
-       return 0;
+static int osp_object_init(const struct lu_env *env, struct lu_object *o,
+                          const struct lu_object_conf *conf)
+{
+       struct osp_object       *po = lu2osp_obj(o);
+       int                     rc = 0;
+       ENTRY;
+
+       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;
+               po->opo_obj.do_lock_ops = &osp_md_lock_ops;
+               /* 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);
 }
 
 static void osp_object_free(const struct lu_env *env, struct lu_object *o)