From 755fdc6678836652302cea51f838e4894f2a7efc Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Thu, 24 Mar 2022 16:19:31 +0800 Subject: [PATCH] LU-15683 ofd: proper initialize filter_fid in ofd fallocate Intialize filter_fid buffer and call xattr set XATTR_NAME_FID properly in ofd_object_fallocate(). Signed-off-by: Bobi Jam Change-Id: Ied573c39dde77f935622e9fbedb2d71eb3bd8f5d Reviewed-on: https://review.whamcloud.com/46919 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Arshad Hussain Reviewed-by: Oleg Drokin --- lustre/ofd/ofd_objects.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lustre/ofd/ofd_objects.c b/lustre/ofd/ofd_objects.c index 41fe74b..9fd41e8 100644 --- a/lustre/ofd/ofd_objects.c +++ b/lustre/ofd/ofd_objects.c @@ -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,6 +810,16 @@ 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); -- 1.8.3.1