Whamcloud - gitweb
LU-15487 mdd: print FID in mdd_dir_page_build() error
authorAndreas Dilger <adilger@whamcloud.com>
Wed, 26 Jan 2022 23:33:27 +0000 (16:33 -0700)
committerAndreas Dilger <adilger@whamcloud.com>
Wed, 9 Mar 2022 17:10:40 +0000 (17:10 +0000)
Print the MDT name and FID in mdd_dir_page_build() when an error
is hit.  Because this changes the callback function signature,
also update dt_index_page_build() to print a more useful message.

Add OBD_FAIL_MDS_DIR_PAGE_WALK to allow triggering this codepath
to see if this is the source of problems in error handling.

Lustre-change: https://review.whamcloud.com/46368
Lustre-commit: TBD

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: Ic475f4a2c775871ff5af59a47e0966ba3eed7013
Reviewed-on: https://review.whamcloud.com/46335
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/46370
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
lustre/include/dt_object.h
lustre/include/obd_support.h
lustre/mdd/mdd_object.c
lustre/obdclass/dt_object.c
lustre/ptlrpc/nodemap_storage.c

index 830a0ee..e24d3d5 100644 (file)
@@ -2263,8 +2263,8 @@ int dt_record_read(const struct lu_env *env, struct dt_object *dt,
 int dt_record_write(const struct lu_env *env, struct dt_object *dt,
                     const struct lu_buf *buf, loff_t *pos, struct thandle *th);
 typedef int (*dt_index_page_build_t)(const struct lu_env *env,
-                                    union lu_page *lp, size_t nob,
-                                    const struct dt_it_ops *iops,
+                                    struct dt_object *obj, union lu_page *lp,
+                                    size_t nob, const struct dt_it_ops *iops,
                                     struct dt_it *it, __u32 attr, void *arg);
 int dt_index_walk(const struct lu_env *env, struct dt_object *obj,
                  const struct lu_rdpg *rdpg, dt_index_page_build_t filler,
index 63381c7..41cb179 100644 (file)
@@ -246,6 +246,7 @@ extern char obd_jobid_var[];
 #define OBD_FAIL_MDS_REINT_OPEN                 0x169
 #define OBD_FAIL_MDS_REINT_OPEN2        0x16a
 #define OBD_FAIL_MDS_CHANGELOG_DEL      0x16c
+#define OBD_FAIL_MDS_DIR_PAGE_WALK             0x16f
 
 /* layout lock */
 #define OBD_FAIL_MDS_NO_LL_GETATTR      0x170
index 25849cb..8c18c37 100644 (file)
@@ -3635,8 +3635,9 @@ static int mdd_readpage_sanity_check(const struct lu_env *env,
         RETURN(rc);
 }
 
-static int mdd_dir_page_build(const struct lu_env *env, union lu_page *lp,
-                             size_t nob, const struct dt_it_ops *iops,
+static int mdd_dir_page_build(const struct lu_env *env, struct dt_object *obj,
+                             union lu_page *lp, size_t nob,
+                             const struct dt_it_ops *iops,
                              struct dt_it *it, __u32 attr, void *arg)
 {
        struct lu_dirpage       *dp = &lp->lp_dir;
@@ -3649,7 +3650,7 @@ static int mdd_dir_page_build(const struct lu_env *env, union lu_page *lp,
        int                      first = 1;
 
        if (nob < sizeof(*dp))
-               return -EINVAL;
+               GOTO(out_err, result = -EOVERFLOW);
 
         memset(area, 0, sizeof (*dp));
         area += sizeof (*dp);
@@ -3664,7 +3665,7 @@ static int mdd_dir_page_build(const struct lu_env *env, union lu_page *lp,
 
                 /* IAM iterator can return record with zero len. */
                 if (len == 0)
-                        goto next;
+                        GOTO(next, 0);
 
                 hash = iops->store(env, it);
                 if (unlikely(first)) {
@@ -3675,34 +3676,35 @@ static int mdd_dir_page_build(const struct lu_env *env, union lu_page *lp,
                 /* calculate max space required for lu_dirent */
                 recsize = lu_dirent_calc_size(len, attr);
 
-                if (nob >= recsize) {
-                        result = iops->rec(env, it, (struct dt_rec *)ent, attr);
-                        if (result == -ESTALE)
-                                goto next;
-                        if (result != 0)
-                                goto out;
+               if (nob >= recsize &&
+                   !OBD_FAIL_CHECK(OBD_FAIL_MDS_DIR_PAGE_WALK)) {
+                       result = iops->rec(env, it, (struct dt_rec *)ent, attr);
+                       if (result == -ESTALE)
+                               GOTO(next, result);
+                       if (result != 0)
+                               GOTO(out, result);
 
-                        /* osd might not able to pack all attributes,
-                         * so recheck rec length */
-                        recsize = le16_to_cpu(ent->lde_reclen);
+                       /* osd might not able to pack all attributes,
+                        * so recheck rec length */
+                       recsize = le16_to_cpu(ent->lde_reclen);
 
                        if (le32_to_cpu(ent->lde_attrs) & LUDA_FID) {
                                fid_le_to_cpu(&fid, &ent->lde_fid);
                                if (fid_is_dot_lustre(&fid))
-                                       goto next;
+                                       GOTO(next, recsize);
                        }
-                } else {
-                        result = (last != NULL) ? 0 :-EINVAL;
-                        goto out;
-                }
-                last = ent;
-                ent = (void *)ent + recsize;
-                nob -= recsize;
+               } else {
+                       result = (last != NULL) ? 0 : -EBADSLT;
+                       GOTO(out, result);
+               }
+               last = ent;
+               ent = (void *)ent + recsize;
+               nob -= recsize;
 
 next:
                 result = iops->next(env, it);
                 if (result == -ESTALE)
-                        goto next;
+                        GOTO(next, result);
         } while (result == 0);
 
 out:
@@ -3712,11 +3714,14 @@ out:
                         dp->ldp_flags |= cpu_to_le32(LDF_COLLIDE);
                 last->lde_reclen = 0; /* end mark */
         }
+out_err:
        if (result > 0)
                /* end of directory */
                dp->ldp_hash_end = cpu_to_le64(MDS_DIR_END_OFF);
        else if (result < 0)
-               CWARN("build page failed: %d!\n", result);
+               CWARN("%s: build page failed for "DFID": rc = %d\n",
+                     lu_dev_name(obj->do_lu.lo_dev),
+                     PFID(lu_object_fid(&obj->do_lu)), result);
         return result;
 }
 
index 756a3fd..bb85982 100644 (file)
@@ -693,8 +693,9 @@ static inline const struct dt_index_features *dt_index_feat_select(__u64 seq,
  * \param attr - is the index attribute to pass to iops->rec()
  * \param arg  - is a pointer to the idx_info structure
  */
-static int dt_index_page_build(const struct lu_env *env, union lu_page *lp,
-                              size_t nob, const struct dt_it_ops *iops,
+static int dt_index_page_build(const struct lu_env *env, struct dt_object *obj,
+                              union lu_page *lp, size_t nob,
+                              const struct dt_it_ops *iops,
                               struct dt_it *it, __u32 attr, void *arg)
 {
        struct idx_info *ii = (struct idx_info *)arg;
@@ -735,9 +736,13 @@ static int dt_index_page_build(const struct lu_env *env, union lu_page *lp,
                        keysize = iops->key_size(env, it);
                        if (!(ii->ii_flags & II_FL_VARKEY) &&
                            keysize != ii->ii_keysize) {
-                               CERROR("keysize mismatch %hu != %hu.\n",
-                                      keysize, ii->ii_keysize);
-                               GOTO(out, rc = -EINVAL);
+                               rc = -EINVAL;
+                               CERROR("%s: keysize mismatch %hu != %hu on "
+                                      DFID": rc = %d\n",
+                                      lu_dev_name(obj->do_lu.lo_dev),
+                                      keysize, ii->ii_keysize,
+                                      PFID(lu_object_fid(&obj->do_lu)), rc);
+                               GOTO(out, rc);
                        }
                }
 
@@ -873,7 +878,8 @@ int dt_index_walk(const struct lu_env *env, struct dt_object *obj,
 
                /* fill lu pages */
                for (i = 0; i < LU_PAGE_COUNT; i++, lp++, nob -= LU_PAGE_SIZE) {
-                       rc = filler(env, lp, min_t(size_t, nob, LU_PAGE_SIZE),
+                       rc = filler(env, obj, lp,
+                                   min_t(size_t, nob, LU_PAGE_SIZE),
                                    iops, it, rdpg->rp_attrs, arg);
                        if (rc < 0)
                                break;
index 2ecef28..ef422e0 100644 (file)
@@ -1354,8 +1354,9 @@ int nodemap_process_idx_pages(struct nodemap_config *config, union lu_page *lip,
 }
 EXPORT_SYMBOL(nodemap_process_idx_pages);
 
-static int nodemap_page_build(const struct lu_env *env, union lu_page *lp,
-                             size_t nob, const struct dt_it_ops *iops,
+static int nodemap_page_build(const struct lu_env *env, struct dt_object *obj,
+                             union lu_page *lp, size_t nob,
+                             const struct dt_it_ops *iops,
                              struct dt_it *it, __u32 attr, void *arg)
 {
        struct idx_info *ii = (struct idx_info *)arg;