From eb80e37f023b85ef0e610ab65cee1d8ee07235fc Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Fri, 8 May 2020 19:22:59 -0600 Subject: [PATCH] LU-13187 tests: improve sanity test_129 checking When running sanity test_129 repeatedly, it may fail to print the warning/error messages to the console due to throttling. Fix the test to only warn if the messages were not printed, so long as the size limit is correct. Always reset max_dir_limit on exit, and delete the test files. Fix test_129 to use mcreate instead of multiop to be faster, and fix mcreate to return the actual error code returned by the syscall. Fix the console error messages to be complete strings, rather than being dynamically generated, so that they can be more easily found. To compensate, don't have separate messages for with/without FID. Test-Parameters: trivial testlist=sanity env=ONLY=129,ONLY_REPEAT=100 Signed-off-by: Andreas Dilger Change-Id: I06593441151fa508ef2db7a3e68be34cc0ce7057 Reviewed-on: https://review.whamcloud.com/38550 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Li Dongyang Reviewed-by: James Nunez Reviewed-by: Oleg Drokin --- lustre/osd-ldiskfs/osd_handler.c | 24 ++++++++++---------- lustre/tests/mcreate.c | 6 +++-- lustre/tests/sanity.sh | 48 ++++++++++++++++++---------------------- 3 files changed, 37 insertions(+), 41 deletions(-) diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 099510d..8771715 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -477,6 +477,7 @@ int osd_ldiskfs_add_entry(struct osd_thread_info *info, struct osd_device *osd, struct lustre_ost_attrs *loa = &info->oti_ost_attrs; struct inode *parent = child->d_parent->d_inode; struct lu_fid *fid = NULL; + char fidstr[FID_LEN + 1] = "unknown"; rc2 = osd_get_lma(info, parent, child->d_parent, loa); if (!rc2) { @@ -493,19 +494,18 @@ int osd_ldiskfs_add_entry(struct osd_thread_info *info, struct osd_device *osd, } if (fid != NULL) - /* below message is checked in sanity.sh test_129 */ - CWARN("%s: directory (inode: %lu, FID: "DFID") %s maximum entry limit\n", - osd_name(osd), parent->i_ino, PFID(fid), - rc == -ENOSPC ? "has reached" : "is approaching"); - else - /* below message is checked in sanity.sh test_129 */ - CWARN("%s: directory (inode: %lu, FID: unknown) %s maximum entry limit\n", - osd_name(osd), parent->i_ino, - rc == -ENOSPC ? "has reached" : "is approaching"); + snprintf(fidstr, sizeof(fidstr), DFID, PFID(fid)); + + /* below message is checked in sanity.sh test_129 */ + if (rc == -ENOSPC) { + CWARN("%s: directory (inode: %lu, FID: %s) has reached max size limit\n", + osd_name(osd), parent->i_ino, fidstr); + } else { + rc = 0; /* ignore such error now */ + CWARN("%s: directory (inode: %lu, FID: %s) is approaching max size limit\n", + osd_name(osd), parent->i_ino, fidstr); + } - /* ignore such error now */ - if (rc == -ENOBUFS) - rc = 0; } return rc; diff --git a/lustre/tests/mcreate.c b/lustre/tests/mcreate.c index 1ea4d6a..39ddba5 100644 --- a/lustre/tests/mcreate.c +++ b/lustre/tests/mcreate.c @@ -101,9 +101,11 @@ int main(int argc, char **argv) else rc = mknod(path, mode, dev); - if (rc) + if (rc) { + rc = errno; fprintf(stderr, "%s: cannot create `%s' with mode %#o: %s\n", - argv[0], path, mode, strerror(errno)); + argv[0], path, mode, strerror(rc)); + } return rc; } diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index c6bbc40..56cc51d 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -12119,7 +12119,7 @@ set_dir_limits () { check_mds_dmesg() { local facets=$(get_facets MDS) for facet in ${facets//,/ }; do - do_facet $facet "dmesg | tail -3 | grep -q $1" && return 0 + do_facet $facet "dmesg | tail -3 | grep $1" && return 0 done return 1 } @@ -12134,55 +12134,49 @@ test_129() { remote_mds_nodsh && skip "remote MDS with nodsh" local ENOSPC=28 - local EFBIG=27 local has_warning=false rm -rf $DIR/$tdir mkdir -p $DIR/$tdir # block size of mds1 - local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 5)) - set_dir_limits $maxsize $maxsize + local maxsize=$(($($LCTL get_param -n mdc.*MDT0000*.blocksize) * 8)) + set_dir_limits $maxsize $((maxsize * 6 / 8)) + stack_trap "set_dir_limits 0 0" + stack_trap "unlinkmany $DIR/$tdir/file_base_ 2000 || true" local dirsize=$(stat -c%s "$DIR/$tdir") local nfiles=0 - while [[ $dirsize -le $maxsize ]]; do - $MULTIOP $DIR/$tdir/file_base_$nfiles Oc + while (( $dirsize <= $maxsize )); do + $MCREATE $DIR/$tdir/file_base_$nfiles rc=$? - if ! $has_warning; then - check_mds_dmesg '"is approaching"' && has_warning=true - fi # check two errors: - # ENOSPC for new ext4 max_dir_size (kernel commit df981d03ee) - # EFBIG for previous versions included in ldiskfs series - if [ $rc -eq $EFBIG ] || [ $rc -eq $ENOSPC ]; then + # ENOSPC for ext4 max_dir_size, which has been used since + # kernel v3.6-rc1-8-gdf981d03ee, lustre v2_4_50_0-79-gaed82035c0 + if (( rc == ENOSPC )); then set_dir_limits 0 0 - echo "return code $rc received as expected" + echo "rc=$rc returned as expected after $nfiles files" createmany -o $DIR/$tdir/file_extra_$nfiles. 5 || - error_exit "create failed w/o dir size limit" - - check_mds_dmesg '"has reached"' || - error_exit "reached message should be output" + error "create failed w/o dir size limit" - [ $has_warning = "false" ] && - error_exit "warning message should be output" + # messages may be rate limited if test is run repeatedly + check_mds_dmesg '"is approaching max"' || + echo "warning message should be output" + check_mds_dmesg '"has reached max"' || + echo "reached message should be output" dirsize=$(stat -c%s "$DIR/$tdir") [[ $dirsize -ge $maxsize ]] && return 0 - error_exit "current dir size $dirsize, " \ - "previous limit $maxsize" - elif [ $rc -ne 0 ]; then - set_dir_limits 0 0 - error_exit "return $rc received instead of expected " \ - "$EFBIG or $ENOSPC, files in dir $dirsize" + error "dirsize $dirsize < $maxsize after $nfiles files" + elif (( rc != 0 )); then + break fi nfiles=$((nfiles + 1)) dirsize=$(stat -c%s "$DIR/$tdir") done - set_dir_limits 0 0 - error "exceeded dir size limit $maxsize($MDSCOUNT) : $dirsize bytes" + error "rc=$rc, size=$dirsize/$maxsize, mdt=$MDSCOUNT, nfiles=$nfiles" } run_test 129 "test directory size limit ========================" -- 1.8.3.1