Whamcloud - gitweb
LU-8367 osp: enable replay for precreation request
[fs/lustre-release.git] / lustre / ofd / ofd_objects.c
index 41fe74b..dd934aa 100644 (file)
@@ -356,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);
 
@@ -783,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);
@@ -797,11 +810,21 @@ 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);
 
@@ -824,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);