Whamcloud - gitweb
LU-17983 mdt: mti_big_lov and mti_big_lmv 51/55551/11
authorShaun Tancheff <shaun.tancheff@hpe.com>
Fri, 19 Jul 2024 04:00:08 +0000 (11:00 +0700)
committerOleg Drokin <green@whamcloud.com>
Fri, 16 Aug 2024 23:52:40 +0000 (23:52 +0000)
Currently mti_big_lmm can be used for LOV, LMV and as a
generic buffer in mdt_attr_get_pfid() and mdt_attr_get_pfid_name()

The LOV and LMV are not mutually exclusive and should be split
into separate buffers so one does not over write the other.

HPE-bug-id: LUS-11657
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: Icc4c5676a24d92a6448e21fe1d66a851a17de46e
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55551
Tested-by: Maloo <maloo@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Alexander Boyko <alexander.boyko@hpe.com>
Reviewed-by: Alexander Zarochentsev <alexander.zarochentsev@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_internal.h
lustre/mdt/mdt_lib.c
lustre/mdt/mdt_open.c
lustre/mdt/mdt_reint.c
lustre/mdt/mdt_som.c

index 91d1328..48131ee 100644 (file)
@@ -1013,39 +1013,58 @@ int mdt_big_xattr_get(struct mdt_thread_info *info, struct mdt_object *o,
                      const char *name)
 {
        const struct lu_env *env = info->mti_env;
-       int rc;
+       void *big_lmm;
+       int big_size, rc;
+       bool using_big_lmv;
 
        ENTRY;
 
-       LASSERT(info->mti_big_lmm_used == 0);
        rc = mo_xattr_get(env, mdt_object_child(o), &LU_BUF_NULL, name);
        if (rc < 0)
                RETURN(rc);
 
+       if (strcmp(name, XATTR_NAME_LMV) == 0) {
+               LASSERT(info->mti_big_lmv_used == 0);
+               big_size = info->mti_big_lmvsize;
+               big_lmm = info->mti_big_lmv;
+               using_big_lmv = true;
+       } else {
+               LASSERT(info->mti_big_lov_used == 0);
+               big_size = info->mti_big_lovsize;
+               big_lmm = info->mti_big_lov;
+               using_big_lmv = false;
+       }
+
        /* big_lmm may need to be grown */
-       if (info->mti_big_lmmsize < rc) {
+       if (big_size < rc) {
                int size = size_roundup_power2(rc);
 
-               if (info->mti_big_lmmsize > 0) {
+               if (big_size > 0) {
                        /* free old buffer */
-                       LASSERT(info->mti_big_lmm);
-                       OBD_FREE_LARGE(info->mti_big_lmm,
-                                      info->mti_big_lmmsize);
-                       info->mti_big_lmm = NULL;
-                       info->mti_big_lmmsize = 0;
+                       LASSERT(big_lmm);
+                       OBD_FREE_LARGE(big_lmm, big_size);
+                       big_lmm = NULL;
+                       big_size = 0;
                }
 
-               OBD_ALLOC_LARGE(info->mti_big_lmm, size);
-               if (info->mti_big_lmm == NULL)
-                       RETURN(-ENOMEM);
-               info->mti_big_lmmsize = size;
+               OBD_ALLOC_LARGE(big_lmm, size);
+               if (big_lmm == NULL)
+                       GOTO(out, rc = -ENOMEM);
+               big_size = size;
        }
-       LASSERT(info->mti_big_lmmsize >= rc);
+       LASSERT(big_size >= rc);
 
-       info->mti_buf.lb_buf = info->mti_big_lmm;
-       info->mti_buf.lb_len = info->mti_big_lmmsize;
+       info->mti_buf.lb_buf = big_lmm;
+       info->mti_buf.lb_len = big_size;
        rc = mo_xattr_get(env, mdt_object_child(o), &info->mti_buf, name);
-
+out:
+       if (using_big_lmv) {
+               info->mti_big_lmvsize = big_size;
+               info->mti_big_lmv = big_lmm;
+       } else {
+               info->mti_big_lovsize = big_size;
+               info->mti_big_lov = big_lmm;
+       }
        RETURN(rc);
 }
 
@@ -1053,12 +1072,14 @@ int __mdt_stripe_get(struct mdt_thread_info *info, struct mdt_object *o,
                     struct md_attr *ma, const char *name)
 {
        struct md_object *next = mdt_object_child(o);
-       struct lu_buf    *buf = &info->mti_buf;
+       struct lu_buf *buf = &info->mti_buf;
        int rc;
+       bool is_lov = false;
 
        if (strcmp(name, XATTR_NAME_LOV) == 0) {
                buf->lb_buf = ma->ma_lmm;
                buf->lb_len = ma->ma_lmm_size;
+               is_lov = true;
                LASSERT(!(ma->ma_valid & MA_LOV));
        } else if (strcmp(name, XATTR_NAME_LMV) == 0) {
                buf->lb_buf = ma->ma_lmv;
@@ -1086,9 +1107,6 @@ int __mdt_stripe_get(struct mdt_thread_info *info, struct mdt_object *o,
 
 got:
                if (strcmp(name, XATTR_NAME_LOV) == 0) {
-                       if (info->mti_big_lmm_used)
-                               ma->ma_lmm = info->mti_big_lmm;
-
                        /* NOT return LOV EA with hole to old client. */
                        if (unlikely(le32_to_cpu(ma->ma_lmm->lmm_pattern) &
                                     LOV_PATTERN_F_HOLE) &&
@@ -1096,12 +1114,17 @@ got:
                              OBD_CONNECT_LFSCK)) {
                                return -EIO;
                        }
+                       if (info->mti_big_lov_used) {
+                               LASSERT(info->mti_big_lovsize >= rc);
+                               ma->ma_lmm = info->mti_big_lov;
+                       }
                        ma->ma_lmm_size = rc;
                        ma->ma_valid |= MA_LOV;
                } else if (strcmp(name, XATTR_NAME_LMV) == 0) {
-                       if (info->mti_big_lmm_used)
-                               ma->ma_lmv = info->mti_big_lmm;
-
+                       if (info->mti_big_lmv_used) {
+                               LASSERT(info->mti_big_lmvsize >= rc);
+                               ma->ma_lmv = info->mti_big_lmv;
+                       }
                        ma->ma_lmv_size = rc;
                        ma->ma_valid |= MA_LMV;
                } else if (strcmp(name, XATTR_NAME_DEFAULT_LMV) == 0) {
@@ -1125,7 +1148,10 @@ got:
                        return rc;
                rc = mdt_big_xattr_get(info, o, name);
                if (rc > 0) {
-                       info->mti_big_lmm_used = 1;
+                       if (is_lov)
+                               info->mti_big_lov_used = 1;
+                       else
+                               info->mti_big_lmv_used = 1;
                        goto got;
                }
        }
@@ -1136,33 +1162,40 @@ got:
 int mdt_stripe_get(struct mdt_thread_info *info, struct mdt_object *o,
                   struct md_attr *ma, const char *name)
 {
-       int rc;
+       void *big_lmm;
+       int big_size, rc;
+       bool is_lmv;
 
-       if (!info->mti_big_lmm) {
-               OBD_ALLOC(info->mti_big_lmm, PAGE_SIZE);
-               if (!info->mti_big_lmm)
+       if (strcmp(name, XATTR_NAME_LOV) == 0) {
+               big_size = info->mti_big_lovsize;
+               big_lmm = info->mti_big_lov;
+               is_lmv = false;
+       } else if (strcmp(name, XATTR_NAME_LMV) == 0) {
+               big_size = info->mti_big_lmvsize;
+               big_lmm = info->mti_big_lmv;
+               is_lmv = true;
+       } else {
+               LBUG();
+       }
+
+       if (!big_lmm) {
+               OBD_ALLOC_LARGE(big_lmm, PAGE_SIZE);
+               if (!big_lmm)
                        return -ENOMEM;
-               info->mti_big_lmmsize = PAGE_SIZE;
+               big_size = PAGE_SIZE;
        }
 
-       if (strcmp(name, XATTR_NAME_LOV) == 0) {
-               ma->ma_lmm = info->mti_big_lmm;
-               ma->ma_lmm_size = info->mti_big_lmmsize;
-               ma->ma_valid &= ~MA_LOV;
-       } else if (strcmp(name, XATTR_NAME_LMV) == 0) {
-               ma->ma_lmv = info->mti_big_lmm;
-               ma->ma_lmv_size = info->mti_big_lmmsize;
+       if (is_lmv) {
+               info->mti_big_lmvsize = ma->ma_lmv_size = big_size;
+               info->mti_big_lmv = ma->ma_lmv = big_lmm;
                ma->ma_valid &= ~MA_LMV;
        } else {
-               LBUG();
+               info->mti_big_lovsize = ma->ma_lmm_size = big_size;
+               info->mti_big_lov = ma->ma_lmm = big_lmm;
+               ma->ma_valid &= ~MA_LOV;
        }
 
-       LASSERT(!info->mti_big_lmm_used);
        rc = __mdt_stripe_get(info, o, ma, name);
-       /* since big_lmm is always used here, clear 'used' flag to avoid
-        * assertion in mdt_big_xattr_get().
-        */
-       info->mti_big_lmm_used = 0;
 
        return rc;
 }
@@ -1177,8 +1210,8 @@ int mdt_attr_get_pfid(struct mdt_thread_info *info, struct mdt_object *o,
 
        ENTRY;
 
-       buf->lb_buf = info->mti_big_lmm;
-       buf->lb_len = info->mti_big_lmmsize;
+       buf->lb_buf = info->mti_xattr_buf;
+       buf->lb_len = sizeof(info->mti_xattr_buf);
        rc = mo_xattr_get(info->mti_env, mdt_object_child(o),
                          buf, XATTR_NAME_LINK);
        /* ignore errors, MA_PFID won't be set and it is
@@ -1186,8 +1219,8 @@ int mdt_attr_get_pfid(struct mdt_thread_info *info, struct mdt_object *o,
         */
        if (rc == -ERANGE || buf->lb_len == 0) {
                rc = mdt_big_xattr_get(info, o, XATTR_NAME_LINK);
-               buf->lb_buf = info->mti_big_lmm;
-               buf->lb_len = info->mti_big_lmmsize;
+               buf->lb_buf = info->mti_big_lov;
+               buf->lb_len = info->mti_big_lovsize;
        }
 
        if (rc < 0)
@@ -1231,8 +1264,8 @@ int mdt_attr_get_pfid_name(struct mdt_thread_info *info, struct mdt_object *o,
                          XATTR_NAME_LINK);
        if (rc == -ERANGE) {
                rc = mdt_big_xattr_get(info, o, XATTR_NAME_LINK);
-               buf->lb_buf = info->mti_big_lmm;
-               buf->lb_len = info->mti_big_lmmsize;
+               buf->lb_buf = info->mti_big_lov;
+               buf->lb_len = info->mti_big_lovsize;
        }
        if (rc < 0)
                return rc;
@@ -4498,7 +4531,8 @@ void mdt_thread_info_reset(struct mdt_thread_info *info)
        info->mti_dlm_req = NULL;
        info->mti_cross_ref = 0;
        info->mti_opdata = 0;
-       info->mti_big_lmm_used = 0;
+       info->mti_big_lov_used = 0;
+       info->mti_big_lmv_used = 0;
        info->mti_big_acl_used = 0;
        info->mti_som_strict = 0;
        info->mti_intent_lock = 0;
@@ -8105,10 +8139,16 @@ static void mdt_key_fini(const struct lu_context *ctx,
 {
        struct mdt_thread_info *info = data;
 
-       if (info->mti_big_lmm) {
-               OBD_FREE_LARGE(info->mti_big_lmm, info->mti_big_lmmsize);
-               info->mti_big_lmm = NULL;
-               info->mti_big_lmmsize = 0;
+       if (info->mti_big_lov) {
+               OBD_FREE_LARGE(info->mti_big_lov, info->mti_big_lovsize);
+               info->mti_big_lov = NULL;
+               info->mti_big_lovsize = 0;
+       }
+
+       if (info->mti_big_lmv) {
+               OBD_FREE_LARGE(info->mti_big_lmv, info->mti_big_lmvsize);
+               info->mti_big_lmv = NULL;
+               info->mti_big_lmvsize = 0;
        }
 
        if (info->mti_big_acl) {
index 34f748e..81d47b8 100644 (file)
@@ -523,7 +523,8 @@ struct mdt_thread_info {
 
        __u32                      mti_cross_ref:1,
        /* big_lmm buffer was used and must be used in reply */
-                                  mti_big_lmm_used:1,
+                                  mti_big_lov_used:1,
+                                  mti_big_lmv_used:1,
                                   mti_big_acl_used:1,
                                   mti_som_strict:1,
        /* Batch processing environment */
@@ -592,9 +593,11 @@ struct mdt_thread_info {
        struct lu_name             mti_name;
        char                       mti_filename[NAME_MAX + 1];
        /* per-thread values, can be re-used, may be vmalloc'd */
-       void                      *mti_big_lmm;
+       void                      *mti_big_lov;  /* was _lmm */
+       void                      *mti_big_lmv;
        void                      *mti_big_acl;
-       int                        mti_big_lmmsize;
+       int                        mti_big_lovsize;
+       int                        mti_big_lmvsize;
        int                        mti_big_aclsize;
        /* should be enough to fit lustre_mdt_attrs */
        char                       mti_xattr_buf[128];
index 93f0826..86c4508 100644 (file)
@@ -847,7 +847,8 @@ int mdt_fix_reply(struct mdt_thread_info *info)
 
         /* MDT_MD buffer may be bigger than packed value, let's shrink all
          * buffers before growing it */
-       if (info->mti_big_lmm_used) {
+       if (info->mti_big_lov_used || info->mti_big_lmv_used) {
+
                /* big_lmm buffer may be used even without packing the result
                 * into reply, just for internal server needs */
                if (req_capsule_has_field(pill, &RMF_MDT_MD, RCL_SERVER))
@@ -856,7 +857,8 @@ int mdt_fix_reply(struct mdt_thread_info *info)
 
                /* free big lmm if md_size is not needed */
                if (md_size == 0 || md_packed == 0) {
-                       info->mti_big_lmm_used = 0;
+                       info->mti_big_lov_used = 0;
+                       info->mti_big_lmv_used = 0;
                } else {
                        /* buffer must be allocated separately */
                        LASSERT(info->mti_attr.ma_lmm !=
@@ -902,22 +904,23 @@ int mdt_fix_reply(struct mdt_thread_info *info)
         */
 
        /* Grow MD buffer if needed finally */
-       if (info->mti_big_lmm_used) {
-                void *lmm;
-
-                LASSERT(md_size > md_packed);
-                CDEBUG(D_INFO, "Enlarge reply buffer, need extra %d bytes\n",
-                       md_size - md_packed);
-
-                rc = req_capsule_server_grow(pill, &RMF_MDT_MD, md_size);
-                if (rc) {
-                        /* we can't answer with proper LOV EA, drop flags,
-                         * the rc is also returned so this request is
-                         * considered as failed */
+       if (info->mti_big_lov_used || info->mti_big_lmv_used) {
+               void *lmm;
+
+               LASSERT(md_size > md_packed);
+               CDEBUG(D_INFO, "Enlarge reply buffer, need extra %d bytes\n",
+                      md_size - md_packed);
+
+               rc = req_capsule_server_grow(pill, &RMF_MDT_MD, md_size);
+               if (rc) {
+                       /* we can't answer with proper LOV EA, drop flags,
+                        * the rc is also returned so this request is
+                        * considered as failed
+                        */
                        body->mbo_valid &= ~(OBD_MD_FLDIREA | OBD_MD_FLEASIZE);
-                        /* don't return transno along with error */
-                        lustre_msg_set_transno(pill->rc_req->rq_repmsg, 0);
-                } else {
+                       /* don't return transno along with error */
+                       lustre_msg_set_transno(pill->rc_req->rq_repmsg, 0);
+               } else {
                        /* now we need to pack right LOV/LMV EA */
                        lmm = req_capsule_server_get(pill, &RMF_MDT_MD);
                        if (info->mti_attr.ma_valid & MA_LOV) {
@@ -939,7 +942,8 @@ int mdt_fix_reply(struct mdt_thread_info *info)
                if (info->mti_mdt->mdt_max_mdsize < info->mti_attr.ma_lmm_size)
                        info->mti_mdt->mdt_max_mdsize =
                                                info->mti_attr.ma_lmm_size;
-               info->mti_big_lmm_used = 0;
+               info->mti_big_lov_used = 0;
+               info->mti_big_lmv_used = 0;
        }
 
        if (info->mti_big_acl_used) {
index 7ae250e..bfd1769 100644 (file)
@@ -1076,7 +1076,7 @@ static int mdt_refetch_lovea(struct mdt_thread_info *info,
                return 0;
 
        ma->ma_valid &= ~MA_LOV;
-       info->mti_big_lmm_used = 0;
+       info->mti_big_lov_used = 0;
        ma->ma_lmm = req_capsule_server_get(info->mti_pill, &RMF_MDT_MD);
        ma->ma_lmm_size = req_capsule_get_size(info->mti_pill, &RMF_MDT_MD,
                                               RCL_SERVER);
index aadde45..6e06e3e 100644 (file)
@@ -985,13 +985,13 @@ static int mdt_reint_setattr(struct mdt_thread_info *info,
 
                        if (!exp_connect_flr(info->mti_exp)) {
                                if (rc > 0 &&
-                                   mdt_lmm_is_flr(info->mti_big_lmm))
+                                   mdt_lmm_is_flr(info->mti_big_lov))
                                        GOTO(out_put, rc = -EOPNOTSUPP);
                        }
 
                        if (!exp_connect_overstriping(info->mti_exp)) {
                                if (rc > 0 &&
-                                   mdt_lmm_is_overstriping(info->mti_big_lmm))
+                                   mdt_lmm_is_overstriping(info->mti_big_lov))
                                        GOTO(out_put, rc = -EOPNOTSUPP);
                        }
                }
index a7a38e5..86843c6 100644 (file)
@@ -219,10 +219,10 @@ int mdt_lsom_update(struct mdt_thread_info *info,
                RETURN(rc);
 
        /**
-        * If mti_big_lmm_used is set, it indicates that mti_big_lmm
-        * should contain valid LOV EA data, and can be used directly.
+        * If mti_big_lov_used is set, it indicates that mti_big_lov should
+        * contain valid LOV EA data, and can be used directly.
         */
-       if (!info->mti_big_lmm_used) {
+       if (!info->mti_big_lov_used) {
                rc = mdt_big_xattr_get(info, o, XATTR_NAME_LOV);
                if (rc < 0 && rc != -ENODATA)
                        RETURN(rc);
@@ -240,7 +240,7 @@ int mdt_lsom_update(struct mdt_thread_info *info,
         * MDS only updates LSOM of the file if the size or block
         * size is being increased or the file is being truncated.
         */
-       if (!mdt_lmm_dom_only(info->mti_big_lmm) &&
+       if (!mdt_lmm_dom_only(info->mti_big_lov) &&
            !(tmp_ma->ma_valid & MA_INODE && tmp_ma->ma_attr.la_nlink == 0)) {
                __u64 size;
                __u64 blocks;