Whamcloud - gitweb
LU-8367 osp: enable replay for precreation request
[fs/lustre-release.git] / lustre / ofd / ofd_objects.c
index 8c1b21a..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);
 
@@ -784,6 +783,19 @@ int ofd_object_fallocate(const struct lu_env *env, struct ofd_object *fo,
                        ff_needed = true;
                else if (rc < 0)
                        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);
@@ -798,14 +810,28 @@ 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_write_lock(env, fo);
+       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(unlock, rc);
@@ -821,7 +847,7 @@ int ofd_object_fallocate(const struct lu_env *env, struct ofd_object *fo,
                        filter_fid_le_to_cpu(&fo->ofo_ff, ff, sizeof(*ff));
        }
 unlock:
-       ofd_write_unlock(env, fo);
+       ofd_read_unlock(env, fo);
 stop:
        ofd_trans_stop(env, ofd, th, rc);
        RETURN(rc);