Whamcloud - gitweb
LU-8367 osp: enable replay for precreation request
[fs/lustre-release.git] / lustre / ofd / ofd_objects.c
index 5ac4b74..dd934aa 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * lustre/ofd/ofd_objects.c
  *
@@ -357,7 +356,7 @@ int ofd_precreate_objects(const struct lu_env *env, struct ofd_device *ofd,
                }
        }
 
-       rc = dt_trans_start_local(env, ofd->ofd_osd, th);
+       rc = dt_trans_start(env, ofd->ofd_osd, th);
        if (rc)
                GOTO(trans_stop, rc);
 
@@ -770,26 +769,38 @@ int ofd_object_fallocate(const struct lu_env *env, struct ofd_object *fo,
 
        ENTRY;
 
-       ofd_write_lock(env, fo);
        if (!ofd_object_exists(fo))
-               GOTO(unlock, rc = -ENOENT);
+               RETURN(-ENOENT);
 
        /* VBR: version recovery check */
        rc = ofd_version_get_check(info, fo);
        if (rc != 0)
-               GOTO(unlock, rc);
+               RETURN(rc);
 
        if (ff != NULL) {
                rc = ofd_object_ff_load(env, fo);
                if (rc == -ENODATA)
                        ff_needed = true;
                else if (rc < 0)
-                       GOTO(unlock, rc);
+                       RETURN(rc);
+
+               if (ff_needed) {
+                       if (oa->o_valid & OBD_MD_FLFID) {
+                               ff->ff_parent.f_seq = oa->o_parent_seq;
+                               ff->ff_parent.f_oid = oa->o_parent_oid;
+                               ff->ff_parent.f_ver = oa->o_stripe_idx;
+                       }
+                       if (oa->o_valid & OBD_MD_FLOSTLAYOUT)
+                               ff->ff_layout = oa->o_layout;
+                       if (oa->o_valid & OBD_MD_LAYOUT_VERSION)
+                               ff->ff_layout_version = oa->o_layout_version;
+                       filter_fid_cpu_to_le(ff, ff, sizeof(*ff));
+               }
        }
 
        th = ofd_trans_create(env, ofd);
        if (IS_ERR(th))
-               GOTO(unlock, rc = PTR_ERR(th));
+               RETURN(PTR_ERR(th));
 
        rc = dt_declare_attr_set(env, dob, la, th);
        if (rc)
@@ -799,17 +810,35 @@ int ofd_object_fallocate(const struct lu_env *env, struct ofd_object *fo,
        if (rc)
                GOTO(stop, rc);
 
+       if (ff_needed) {
+               info->fti_buf.lb_buf = ff;
+               info->fti_buf.lb_len = sizeof(*ff);
+               rc = dt_declare_xattr_set(env, ofd_object_child(fo),
+                                         &info->fti_buf, XATTR_NAME_FID, 0,
+                                         th);
+               if (rc)
+                       GOTO(stop, rc);
+       }
+
        rc = ofd_trans_start(env, ofd, fo, th);
        if (rc)
                GOTO(stop, rc);
 
+       ofd_read_lock(env, fo);
+       if (!ofd_object_exists(fo))
+               GOTO(unlock, rc = -ENOENT);
+
+       if (la->la_valid & (LA_ATIME | LA_MTIME | LA_CTIME))
+               tgt_fmd_update(info->fti_exp, &fo->ofo_header.loh_fid,
+                              info->fti_xid);
+
        rc = dt_falloc(env, dob, start, end, mode, th);
        if (rc)
-               GOTO(stop, rc);
+               GOTO(unlock, rc);
 
        rc = dt_attr_set(env, dob, la, th);
        if (rc)
-               GOTO(stop, rc);
+               GOTO(unlock, rc);
 
        if (ff_needed) {
                rc = dt_xattr_set(env, ofd_object_child(fo), &info->fti_buf,
@@ -817,10 +846,10 @@ int ofd_object_fallocate(const struct lu_env *env, struct ofd_object *fo,
                if (!rc)
                        filter_fid_le_to_cpu(&fo->ofo_ff, ff, sizeof(*ff));
        }
+unlock:
+       ofd_read_unlock(env, fo);
 stop:
        ofd_trans_stop(env, ofd, th, rc);
-unlock:
-       ofd_write_unlock(env, fo);
        RETURN(rc);
 }