Whamcloud - gitweb
LU-18276 tests: add debugging to sanity-pfl/16b 16/59416/2
authorAndreas Dilger <adilger@whamcloud.com>
Sun, 25 May 2025 00:17:54 +0000 (18:17 -0600)
committerOleg Drokin <green@whamcloud.com>
Sat, 7 Jun 2025 23:05:59 +0000 (23:05 +0000)
Add extra debugging messages to sanity-pfl.sh test_16b to help find
what is causing this test to fail with ENOSPC intermittently.

Reduce size of overstriped PFL file layout slightly, so that two
such components can fit within the xattr size limit, which may or
may not be the cause of the ENOSPC failures.

Print a message in llapi_layout_file_open() if ENOSPC is hit, so
that we can determine the xattr size, in case it is too large.
Move layout conversion before file open() to avoid contacting
MDS needlessly if the layout is bad.

Test-Parameters: trivial testlist=sanity-pfl env=ONLY=16b,ONLY_REPEAT=100
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: Iaf347e231147041dda07277227e80f0b6f2540e5
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59416
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Emoly Liu <emoly@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity-pfl.sh
lustre/tests/test-framework.sh
lustre/utils/lfs.c
lustre/utils/liblustreapi_layout.c

index 0ae0a84..6d22085 100755 (executable)
@@ -1025,7 +1025,7 @@ test_16b() {
        local dir=$DIR/$tdir/dir
        local temp=$DIR/$tdir/template
        # We know OSTCOUNT < (LOV_MAX_STRIPE_COUNT / 2), so this is overstriping
-       local large_count=$((LOV_MAX_STRIPE_COUNT / 2 + 10))
+       local large_count=$((LOV_MAX_STRIPE_COUNT / 2))
 
        rm -rf $DIR/$tdir
        test_mkdir $DIR/$tdir
@@ -1053,8 +1053,12 @@ test_16b() {
        #                           3. PFL dir + overstriping
        # set stripe for source dir
        test_mkdir $dir
-       $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir ||
-               error "setstripe $dir failed"
+       $LFS setstripe -E1m -S 1M -o 0,0 -E2m -C $large_count -E-1 $dir || {
+               $LFS df -v $dir
+               $LFS df -i $dir
+               getfattr -d -m - -e hex $dir
+               error "setstripe -E2m -C $large_count -E-1 $dir failed" 
+       }
 
        test_mkdir $dir.copy
        echo "3. PFL dir"
index 7362a66..9e5158a 100755 (executable)
@@ -11550,17 +11550,28 @@ verify_yaml_layout() {
        local temp=$3
        local msg_prefix=$4
 
-       echo "getstripe --yaml $src"
-       $LFS getstripe --yaml $src > $temp || error "getstripe $src failed"
-       echo "setstripe --yaml=$temp $dst"
-       $LFS setstripe --yaml=$temp $dst|| error "setstripe $dst failed"
-
-       echo "compare"
-       local layout1=$(get_layout_param $src)
-       local layout2=$(get_layout_param $dst)
+       echo "$msg_prefix: getstripe --yaml $src"
+       $LFS getstripe --yaml $src > $temp ||
+               error "$msg_prefix: getstripe $src failed"
+       echo "$msg_prefix: setstripe --yaml=$temp $dst"
+       $LFS setstripe --yaml=$temp $dst || {
+               $LFS df -v $dst
+               $LFS df -i $dst
+               sed -e "s/^/$msg_prefix-yaml: /" $temp
+               getfattr -d -m - -e hex $src
+               getfattr -d -m - -e hex $dst
+               error "$msg_prefix: setstripe '$dst' failed"
+       }
+
+       echo "$msg_prefix: compare"
+       local layout_src=$(get_layout_param $src)
+       local layout_dst=$(get_layout_param $dst)
        # compare their layout info
-       [ "$layout1" == "$layout2" ] ||
-               error "$msg_prefix $src/$dst layouts are not equal"
+       [ "$layout_src" == "$layout_dst" ] || {
+               sed -e "s/^/$msg_prefix-src: /" <<< $layout_src
+               sed -e "s/^/$msg_prefix-dst: /" <<< $layout_dst
+               error "$msg_prefix: $src/$dst layouts are not equal"
+       }
 }
 
 is_project_quota_supported() {
index abe3e23..7ef588b 100644 (file)
@@ -1464,11 +1464,10 @@ static int lfs_component_create(char *fname, int open_flags, mode_t open_mode,
 
        fd = llapi_layout_file_open(fname, open_flags, open_mode, layout);
        if (fd < 0)
-               fprintf(stderr, "%s: %s '%s': %s\n", progname,
-                       S_ISDIR(st.st_mode) ?
+               llapi_error(LLAPI_MSG_ERROR, errno, "%s: %s '%s'\n",
+                           progname, S_ISDIR(st.st_mode) ?
                                "cannot set default composite layout for" :
-                               "cannot create composite file",
-                       fname, strerror(errno));
+                               "cannot create composite file", fname);
        return fd;
 }
 
index 5e8b371..c35fc72 100644 (file)
@@ -1781,13 +1781,12 @@ int llapi_layout_pool_name_set(struct llapi_layout *layout,
 int llapi_layout_file_open(const char *path, int open_flags, mode_t mode,
                           const struct llapi_layout *layout)
 {
-       int fd;
-       int rc;
-       int tmp;
-       struct lov_user_md *lum;
+       struct lov_user_md *lum = NULL;
        size_t lum_size;
        char fsname[MAX_OBD_NAME + 1] = { 0 };
        struct llapi_layout_comp *comp;
+       int fd;
+       int rc;
 
        comp = __llapi_layout_cur_comp(layout);
 
@@ -1817,24 +1816,24 @@ int llapi_layout_file_open(const char *path, int open_flags, mode_t mode,
                }
        }
 
-       /* Object creation must be postponed until after layout attributes
-        * have been applied. */
-       if (layout != NULL && (open_flags & O_CREAT))
-               open_flags |= O_LOV_DELAY_CREATE;
+       if (layout) {
+               lum = llapi_layout_to_lum(layout);
+               if (!lum) {
+                       fd = -1;
+                       goto out_errno;
+               }
+
+               /* Object creation must be postponed until after layout
+                * attributes have been applied.
+                */
+               if (open_flags & O_CREAT)
+                       open_flags |= O_LOV_DELAY_CREATE;
+       }
 
        fd = open(path, open_flags, mode);
 
        if (layout == NULL || fd < 0)
-               return fd;
-
-       lum = llapi_layout_to_lum(layout);
-
-       if (lum == NULL) {
-               tmp = errno;
-               close(fd);
-               errno = tmp;
-               return -1;
-       }
+               goto out_free;
 
        if (lum->lmm_magic == LOV_USER_MAGIC_COMP_V1)
                lum_size = ((struct lov_comp_md_v1 *)lum)->lcm_size;
@@ -1846,14 +1845,23 @@ int llapi_layout_file_open(const char *path, int open_flags, mode_t mode,
 
        rc = fsetxattr(fd, XATTR_LUSTRE_LOV, lum, lum_size, 0);
        if (rc < 0) {
-               tmp = errno;
+               int tmp = errno;
+
+               /* caller usually prints error, but doesn't know xattr size */
+               if (errno == ENOSPC)
+                       llapi_error(LLAPI_MSG_ERROR, errno,
+                                   "error setting %zd-byte layout on '%s'\n",
+                                   lum_size, path);
                close(fd);
                errno = tmp;
                fd = -1;
        }
 
+out_free:
        free(lum);
-       errno = errno == EOPNOTSUPP ? ENOTTY : errno;
+out_errno:
+       if (errno == EOPNOTSUPP)
+               errno = ENOTTY;
 
        return fd;
 }