From patchwork Wed Apr 26 00:14:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13223922 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A0AFC77B61 for ; Wed, 26 Apr 2023 00:14:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238368AbjDZAO0 (ORCPT ); Tue, 25 Apr 2023 20:14:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238067AbjDZAOZ (ORCPT ); Tue, 25 Apr 2023 20:14:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13C05769B; Tue, 25 Apr 2023 17:14:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A637F60C2B; Wed, 26 Apr 2023 00:14:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B853C433EF; Wed, 26 Apr 2023 00:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682468064; bh=ozqQR+vvGT15RDDzBtuZWl+8FdDWWed/Qud4QylpBpY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=s5DzUkQ6DNY+/T3faiNlivHghOS97Lj0yKk1xnhsGloXqSh88CzVzhMfqUVHSYOu4 dRNgHDuXf9YkkU05EsBLoOtbstBHQrrMV5KoKcD//TfbbFHJ/+A/6hsjh7FuYVl1ly 9VRYJOIhewo4/iPfG/NW6vcBJAdz0jwgiu45P0cpfSbUTznBCUC6Ooxnb9h+ur8Da/ 33zR1ZWBsnGJCstnWqfCJIbwkIvJm/EpCLmK6bl++vS7o+1oRbCrDacNObWDsjTbTd ddz1nJ+VSDNUocjWzTCh6vM5k150p4hSHGiS0EfiH2fiGB81XZAKx1la1gscRVZnNM 3laQRanTjD/sw== Subject: [PATCH 1/4] generic/476: reclassify this test as a long running soak stress test From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Tue, 25 Apr 2023 17:14:23 -0700 Message-ID: <168246806362.732186.12173643369343352453.stgit@frogsfrogsfrogs> In-Reply-To: <168246805791.732186.9294980643404649.stgit@frogsfrogsfrogs> References: <168246805791.732186.9294980643404649.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong This test is a long(ish) running stress test that uses fsstress, so alter its group membership as follows: long_rw: because this can read and write to the fs for a long period of time stress: because this test employs fsstress Signed-off-by: Darrick J. Wong --- tests/generic/476 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/generic/476 b/tests/generic/476 index 212373d17c..62908654ad 100755 --- a/tests/generic/476 +++ b/tests/generic/476 @@ -8,7 +8,7 @@ # bugs in the write path. # . ./common/preamble -_begin_fstest auto rw +_begin_fstest auto rw long_rw stress # Override the default cleanup function. _cleanup() From patchwork Wed Apr 26 00:14:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13223923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3F8EC77B7F for ; Wed, 26 Apr 2023 00:14:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238067AbjDZAOc (ORCPT ); Tue, 25 Apr 2023 20:14:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232211AbjDZAOb (ORCPT ); Tue, 25 Apr 2023 20:14:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8EF08699; Tue, 25 Apr 2023 17:14:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 588D862E29; Wed, 26 Apr 2023 00:14:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B149DC4339B; Wed, 26 Apr 2023 00:14:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682468069; bh=1OdYSRlKf/AjwCMaQJt3WpDk9qqw5MOjbOMMhVctL7o=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=q+IIULorW0qqipcUAzrVh0sVNP8nmpVYBPA5TvYdzWM/TP5qLPf7HQT6tr3j/tFuO kp1xSDdb5VBsJ8xJhqcfrXRY2deufeO1llcUzZv8kBJDgOkDE2Lh0IFr9LuagfiPfa QWz/iGGNHxZC6dDTwMycddduYRXQpcMMz6tNfdkWUxf/hJ57GmnRIFO/a+ehsINGb1 80pHGYW2Rt5CH8N93x7LNz8ma5jaBfrlLCFzaMuAuIQ1HGAAs+wZaCTHThHS4mb7wg jHvUZUJP8XzC1OvgTDIsU/oe+mR5C8mvTODvxwHfFXFDtxpM0uQ+fhHxg8/9WRxDC1 7MGj8tEiFDHQQ== Subject: [PATCH 2/4] readme: document TIME/LOAD_FACTOR From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Tue, 25 Apr 2023 17:14:29 -0700 Message-ID: <168246806922.732186.14938530606710009918.stgit@frogsfrogsfrogs> In-Reply-To: <168246805791.732186.9294980643404649.stgit@frogsfrogsfrogs> References: <168246805791.732186.9294980643404649.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Document these two variables so that we have /some/ reference for what they're supposed to do. Signed-off-by: Darrick J. Wong --- README | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README b/README index 4ee877a962..030b47d92a 100644 --- a/README +++ b/README @@ -250,6 +250,12 @@ Kernel/Modules related configuration: - Set KCONFIG_PATH to specify your preferred location of kernel config file. The config is used by tests to check if kernel feature is enabled. +Test control: + - Set LOAD_FACTOR to a nonzero positive integer to increase the amount of + load applied to the system during a test by the specified multiple. + - Set TIME_FACTOR to a nonzero positive integer to increase the amount of + time that a test runs by the specified multiple. + Misc: - If you wish to disable UDF verification test set the environment variable DISABLE_UDF_TEST to 1. From patchwork Wed Apr 26 00:14:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13223924 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33B85C77B7F for ; Wed, 26 Apr 2023 00:14:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238373AbjDZAOj (ORCPT ); Tue, 25 Apr 2023 20:14:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232211AbjDZAOi (ORCPT ); Tue, 25 Apr 2023 20:14:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 652228A73; Tue, 25 Apr 2023 17:14:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EAD6360C2B; Wed, 26 Apr 2023 00:14:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 527BFC433D2; Wed, 26 Apr 2023 00:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682468075; bh=xWc7uWYVrYC0yA1/ZMUmMB36dhWBiGBNFdvpHcuqyCw=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ZEHNFeBEMrISi35LeBx5SWkymXiyFlQISrMwf6pzjjTxWnYRiSe9sTFbRLjZhxcNk 9JdSwJEIrxpikJohxDl5pHeF/JLw+uvA+2gdxbe2jgj3KZVuyD2V6V+ZXzFoFK2Orp ro0X8PLwlYdFZBheB0ce3vXL+l4yIHqTd/IIV3JSxsd16LsMHh1S5wKqihUYyB87J7 v3rzDVUZhxXZAew0FPbtWKZke70jFNOetsbnr8FEH7Tq66xoklISGBhOUzsyr2s1Y0 s9Kx5E89yfZrANe1E3byndLi6icr6qVgk0JFGtUPIMErv7/F0zclGZNNE+60X/CjoO Vh2OpSUbk1SkA== Subject: [PATCH 3/4] misc: add duration for long soak tests From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: Andrey Albershteyn , linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Tue, 25 Apr 2023 17:14:34 -0700 Message-ID: <168246807490.732186.2632021184514655054.stgit@frogsfrogsfrogs> In-Reply-To: <168246805791.732186.9294980643404649.stgit@frogsfrogsfrogs> References: <168246805791.732186.9294980643404649.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Make it so that test runners can schedule long soak stress test programs for an exact number of seconds by setting the SOAK_DURATION config variable. Change the definition of the 'soak' test to specify that these tests can be controlled via SOAK_DURATION. Signed-off-by: Darrick J. Wong Reviewed-by: Andrey Albershteyn --- README | 5 +++ check | 12 ++++++++ common/config | 2 + common/fuzzy | 7 ++++ common/report | 1 + doc/group-names.txt | 3 +- ltp/fsstress.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++-- ltp/fsx.c | 50 +++++++++++++++++++++++++++++++ src/soak_duration.awk | 23 ++++++++++++++ tests/generic/476 | 7 +++- tests/generic/521 | 1 + tests/generic/522 | 1 + tests/generic/642 | 1 + 13 files changed, 183 insertions(+), 8 deletions(-) create mode 100644 src/soak_duration.awk diff --git a/README b/README index 030b47d92a..fd3b123633 100644 --- a/README +++ b/README @@ -255,6 +255,11 @@ Test control: load applied to the system during a test by the specified multiple. - Set TIME_FACTOR to a nonzero positive integer to increase the amount of time that a test runs by the specified multiple. + - For tests that are a member of the "soak" group, setting SOAK_DURATION + allows the test runner to specify exactly how long the test should continue + running. This setting overrides TIME_FACTOR. Floating point numbers are + allowed, and the unit suffixes m(inutes), h(ours), d(ays), and w(eeks) are + supported. Misc: - If you wish to disable UDF verification test set the environment variable diff --git a/check b/check index 1a58a2b269..3aee66f08a 100755 --- a/check +++ b/check @@ -366,6 +366,18 @@ if ! . ./common/rc; then exit 1 fi +# If the test config specified a soak test duration, see if there are any +# unit suffixes that need converting to an integer seconds count. +if [ -n "$SOAK_DURATION" ]; then + SOAK_DURATION="$(echo "$SOAK_DURATION" | \ + sed -e 's/^\([.0-9]*\)\([a-z]\)*/\1 \2/g' | \ + $AWK_PROG -f $here/src/soak_duration.awk)" + if [ $? -ne 0 ]; then + status=1 + exit 1 + fi +fi + if [ -n "$subdir_xfile" ]; then for d in $SRC_GROUPS $FSTYP; do [ -f $SRC_DIR/$d/$subdir_xfile ] || continue diff --git a/common/config b/common/config index 6c8cb3a5ba..3878e28efa 100644 --- a/common/config +++ b/common/config @@ -57,11 +57,13 @@ export SOAK_PROC=3 # -p option to fsstress export SOAK_STRESS=10000 # -n option to fsstress export SOAK_PASSES=-1 # count of repetitions of fsstress (while soaking) export EMAIL=root@localhost # where auto-qa will send its status messages + export HOST_OPTIONS=${HOST_OPTIONS:=local.config} export CHECK_OPTIONS=${CHECK_OPTIONS:="-g auto"} export BENCH_PASSES=${BENCH_PASSES:=5} export TIME_FACTOR=${TIME_FACTOR:=1} export LOAD_FACTOR=${LOAD_FACTOR:=1} +export SOAK_DURATION=${SOAK_DURATION:=} export DEBUGFS_MNT=${DEBUGFS_MNT:="/sys/kernel/debug"} # some constants for overlayfs setup diff --git a/common/fuzzy b/common/fuzzy index 961bedc717..4365e7343e 100644 --- a/common/fuzzy +++ b/common/fuzzy @@ -1351,7 +1351,12 @@ _scratch_xfs_stress_scrub() { fi local start="$(date +%s)" - local end="$((start + (30 * TIME_FACTOR) ))" + local end + if [ -n "$SOAK_DURATION" ]; then + end="$((start + SOAK_DURATION))" + else + end="$((start + (30 * TIME_FACTOR) ))" + fi local scrub_startat="$((start + scrub_delay))" test "$scrub_startat" -gt "$((end - 10))" && scrub_startat="$((end - 10))" diff --git a/common/report b/common/report index be930e0b06..9bfa09ecce 100644 --- a/common/report +++ b/common/report @@ -67,6 +67,7 @@ __generate_report_vars() { REPORT_VARS["CPUS"]="$(getconf _NPROCESSORS_ONLN 2>/dev/null)" REPORT_VARS["MEM_KB"]="$(grep MemTotal: /proc/meminfo | awk '{print $2}')" REPORT_VARS["SWAP_KB"]="$(grep SwapTotal: /proc/meminfo | awk '{print $2}')" + test -n "$SOAK_DURATION" && REPORT_VARS["SOAK_DURATION"]="$SOAK_DURATION" test -e /sys/devices/system/node/possible && \ REPORT_VARS["NUMA_NODES"]="$(cat /sys/devices/system/node/possible 2>/dev/null)" diff --git a/doc/group-names.txt b/doc/group-names.txt index a0ae6965a8..5fd8fe6773 100644 --- a/doc/group-names.txt +++ b/doc/group-names.txt @@ -118,7 +118,8 @@ send btrfs send/receive shrinkfs decreasing the size of a filesystem shutdown FS_IOC_SHUTDOWN ioctl snapshot btrfs snapshots -soak long running soak tests of any kind +soak long running soak tests whose runtime can be controlled + directly by setting the SOAK_DURATION variable spaceman xfs_spaceman functional tests splice splice system call stress fsstress filesystem exerciser diff --git a/ltp/fsstress.c b/ltp/fsstress.c index e60f2da929..6641a525fe 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -386,6 +386,8 @@ char *execute_cmd = NULL; int execute_freq = 1; struct print_string flag_str = {0}; +struct timespec deadline = { 0 }; + void add_to_flist(int, int, int, int); void append_pathname(pathname_t *, char *); int attr_list_path(pathname_t *, char *, const int); @@ -459,6 +461,34 @@ void sg_handler(int signum) } } +bool +keep_looping(int i, int loops) +{ + int ret; + + if (deadline.tv_nsec) { + struct timespec now; + + ret = clock_gettime(CLOCK_MONOTONIC, &now); + if (ret) { + perror("CLOCK_MONOTONIC"); + return false; + } + + return now.tv_sec <= deadline.tv_sec; + } + + if (!loops) + return true; + + return i < loops; +} + +static struct option longopts[] = { + {"duration", optional_argument, 0, 256}, + { } +}; + int main(int argc, char **argv) { char buf[10]; @@ -478,13 +508,14 @@ int main(int argc, char **argv) struct sigaction action; int loops = 1; const char *allopts = "cd:e:f:i:l:m:M:n:o:p:rRs:S:vVwx:X:zH"; + long long duration; errrange = errtag = 0; umask(0); nops = sizeof(ops) / sizeof(ops[0]); ops_end = &ops[nops]; myprog = argv[0]; - while ((c = getopt(argc, argv, allopts)) != -1) { + while ((c = getopt_long(argc, argv, allopts, longopts, NULL)) != -1) { switch (c) { case 'c': cleanup = 1; @@ -579,6 +610,26 @@ int main(int argc, char **argv) case 'X': execute_freq = strtoul(optarg, NULL, 0); break; + case 256: /* --duration */ + if (!optarg) { + fprintf(stderr, "Specify time with --duration=\n"); + exit(87); + } + duration = strtoll(optarg, NULL, 0); + if (duration < 1) { + fprintf(stderr, "%lld: invalid duration\n", duration); + exit(88); + } + + i = clock_gettime(CLOCK_MONOTONIC, &deadline); + if (i) { + perror("CLOCK_MONOTONIC"); + exit(89); + } + + deadline.tv_sec += duration; + deadline.tv_nsec = 1; + break; case '?': fprintf(stderr, "%s - invalid parameters\n", myprog); @@ -721,7 +772,7 @@ int main(int argc, char **argv) } } #endif - for (i = 0; !loops || (i < loops); i++) + for (i = 0; keep_looping(i, loops); i++) doproc(); #ifdef AIO if(io_destroy(io_ctx) != 0) { @@ -1121,6 +1172,26 @@ dirid_to_fent(int dirid) return NULL; } +bool +keep_running(opnum_t opno, opnum_t operations) +{ + int ret; + + if (deadline.tv_nsec) { + struct timespec now; + + ret = clock_gettime(CLOCK_MONOTONIC, &now); + if (ret) { + perror("CLOCK_MONOTONIC"); + return false; + } + + return now.tv_sec <= deadline.tv_sec; + } + + return opno < operations; +} + void doproc(void) { @@ -1149,7 +1220,7 @@ doproc(void) srandom(seed); if (namerand) namerand = random(); - for (opno = 0; opno < operations; opno++) { + for (opno = 0; keep_running(opno, operations); opno++) { if (execute_cmd && opno && opno % dividend == 0) { if (verbose) printf("%lld: execute command %s\n", opno, @@ -1935,6 +2006,7 @@ usage(void) printf(" -V specifies verifiable logging mode (omitting inode numbers)\n"); printf(" -X ncmd number of calls to the -x command (default 1)\n"); printf(" -H prints usage and exits\n"); + printf(" --duration=s ignore any -n setting and run for this many seconds\n"); } void diff --git a/ltp/fsx.c b/ltp/fsx.c index ee4b8fe45d..c76b06ca76 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -193,6 +193,8 @@ int fsx_rw(int rw, int fd, char *buf, unsigned len, unsigned offset); #define fsxread(a,b,c,d) fsx_rw(READ, a,b,c,d) #define fsxwrite(a,b,c,d) fsx_rw(WRITE, a,b,c,d) +struct timespec deadline; + const char *replayops = NULL; const char *recordops = NULL; FILE * fsxlogf = NULL; @@ -2457,6 +2459,7 @@ usage(void) -Z: O_DIRECT (use -R, -W, -r and -w too)\n\ --replay-ops opsfile: replay ops from recorded .fsxops file\n\ --record-ops[=opsfile]: dump ops file also on success. optionally specify ops file name\n\ + --duration=seconds: ignore any -N setting and run for this many seconds\n\ fname: this filename is REQUIRED (no default)\n"); exit(90); } @@ -2739,9 +2742,33 @@ __test_fallocate(int mode, const char *mode_str) #endif } +bool +keep_running(void) +{ + int ret; + + if (deadline.tv_nsec) { + struct timespec now; + + ret = clock_gettime(CLOCK_MONOTONIC, &now); + if (ret) { + perror("CLOCK_MONOTONIC"); + return false; + } + + return now.tv_sec <= deadline.tv_sec; + } + + if (numops == -1) + return true; + + return numops-- != 0; +} + static struct option longopts[] = { {"replay-ops", required_argument, 0, 256}, {"record-ops", optional_argument, 0, 255}, + {"duration", optional_argument, 0, 254}, { } }; @@ -2753,6 +2780,7 @@ main(int argc, char **argv) char logfile[PATH_MAX]; struct stat statbuf; int o_flags = O_RDWR|O_CREAT|O_TRUNC; + long long duration; logfile[0] = 0; dname[0] = 0; @@ -2950,6 +2978,26 @@ main(int argc, char **argv) o_direct = O_DIRECT; o_flags |= O_DIRECT; break; + case 254: /* --duration */ + if (!optarg) { + fprintf(stderr, "Specify time with --duration=\n"); + exit(87); + } + duration = strtoll(optarg, NULL, 0); + if (duration < 1) { + fprintf(stderr, "%lld: invalid duration\n", duration); + exit(88); + } + + i = clock_gettime(CLOCK_MONOTONIC, &deadline); + if (i) { + perror("CLOCK_MONOTONIC"); + exit(89); + } + + deadline.tv_sec += duration; + deadline.tv_nsec = 1; + break; case 255: /* --record-ops */ if (optarg) snprintf(opsfile, sizeof(opsfile), "%s", optarg); @@ -3145,7 +3193,7 @@ main(int argc, char **argv) if (xchg_range_calls) xchg_range_calls = test_xchg_range(); - while (numops == -1 || numops--) + while (keep_running()) if (!test()) break; diff --git a/src/soak_duration.awk b/src/soak_duration.awk new file mode 100644 index 0000000000..6c38d09b39 --- /dev/null +++ b/src/soak_duration.awk @@ -0,0 +1,23 @@ +#!/usr/bin/awk +# +# Convert time interval specifications with suffixes to an integer number of +# seconds. +{ + nr = $1; + if ($2 == "" || $2 ~ /s/) # seconds + ; + else if ($2 ~ /m/) # minutes + nr *= 60; + else if ($2 ~ /h/) # hours + nr *= 3600; + else if ($2 ~ /d/) # days + nr *= 86400; + else if ($2 ~ /w/) # weeks + nr *= 604800; + else { + printf("%s: unknown suffix\n", $2); + exit 1; + } + + printf("%d\n", nr); +} diff --git a/tests/generic/476 b/tests/generic/476 index 62908654ad..8e93b73457 100755 --- a/tests/generic/476 +++ b/tests/generic/476 @@ -8,7 +8,7 @@ # bugs in the write path. # . ./common/preamble -_begin_fstest auto rw long_rw stress +_begin_fstest auto rw long_rw stress soak # Override the default cleanup function. _cleanup() @@ -33,7 +33,10 @@ _scratch_mount >> $seqres.full 2>&1 nr_cpus=$((LOAD_FACTOR * 4)) nr_ops=$((25000 * nr_cpus * TIME_FACTOR)) -$FSSTRESS_PROG $FSSTRESS_AVOID -w -d $SCRATCH_MNT -n $nr_ops -p $nr_cpus >> $seqres.full +fsstress_args=(-w -d $SCRATCH_MNT -n $nr_ops -p $nr_cpus) +test -n "$SOAK_DURATION" && fsstress_args+=(--duration="$SOAK_DURATION") + +$FSSTRESS_PROG $FSSTRESS_AVOID "${fsstress_args[@]}" >> $seqres.full # success, all done status=0 diff --git a/tests/generic/521 b/tests/generic/521 index cde9d44775..22dd31a8ec 100755 --- a/tests/generic/521 +++ b/tests/generic/521 @@ -35,6 +35,7 @@ fsx_args+=(-r $min_dio_sz) fsx_args+=(-t $min_dio_sz) fsx_args+=(-w $min_dio_sz) fsx_args+=(-Z) +test -n "$SOAK_DURATION" && fsx_args+=(--duration="$SOAK_DURATION") run_fsx "${fsx_args[@]}" | sed -e '/^fsx.*/d' diff --git a/tests/generic/522 b/tests/generic/522 index ae84fe04bb..f0cbcb245c 100755 --- a/tests/generic/522 +++ b/tests/generic/522 @@ -29,6 +29,7 @@ fsx_args+=(-N $nr_ops) fsx_args+=(-p $((nr_ops / 100))) fsx_args+=(-o $op_sz) fsx_args+=(-l $file_sz) +test -n "$SOAK_DURATION" && fsx_args+=(--duration="$SOAK_DURATION") run_fsx "${fsx_args[@]}" | sed -e '/^fsx.*/d' diff --git a/tests/generic/642 b/tests/generic/642 index c0e274d843..eba90903a3 100755 --- a/tests/generic/642 +++ b/tests/generic/642 @@ -49,6 +49,7 @@ for verb in attr_remove removefattr; do done args+=('-f' "setfattr=20") args+=('-f' "attr_set=60") # sets larger xattrs +test -n "$DURATION" && args+=(--duration="$DURATION") $FSSTRESS_PROG "${args[@]}" $FSSTRESS_AVOID -d $SCRATCH_MNT -n $nr_ops -p $nr_cpus >> $seqres.full From patchwork Wed Apr 26 00:14:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13223925 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4A71C77B7F for ; Wed, 26 Apr 2023 00:14:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238372AbjDZAOq (ORCPT ); Tue, 25 Apr 2023 20:14:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232211AbjDZAOq (ORCPT ); Tue, 25 Apr 2023 20:14:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDA189EFB; Tue, 25 Apr 2023 17:14:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 879D560C2B; Wed, 26 Apr 2023 00:14:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E646DC433D2; Wed, 26 Apr 2023 00:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682468081; bh=k5LDX4RN/ia+edWJnG7eb6flYPG7sT+wlDQ/TZqpHsY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ducWBJl5fvf/2SVfoclmun5qeEMpdmeDwxpPatnNcdlHV1f7t7TyKssBuB1UzalgR bB2rudvzkPEAyzjEb0tvwoahY6Qjt6XbgeWJZTYbbwOQ8Vs5tBjo7s/omQoPM1X28I N1CSiXqMs12fE3GR9GumKk9zTyFj0U4EJu4NIVDnAJUypsT8zns3xf5OskBsvXY1xj sWAks+H7rbkQweMNmQRnlIKa6y9+dhw4pnyNqWNJmD/zb/p4JHYcG1qiq8FHPttBW3 3szgr3tOlQWgtyrDmhWvhtF/KyRpdnjNUZCAHkOSUz1wbc0aPqv1lUOk2vYWfdZ/d5 sLmlzUDoZxEpQ== Subject: [PATCH 4/4] misc: add duration for recovery loop tests From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: Andrey Albershteyn , linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Tue, 25 Apr 2023 17:14:40 -0700 Message-ID: <168246808052.732186.2436158006887650516.stgit@frogsfrogsfrogs> In-Reply-To: <168246805791.732186.9294980643404649.stgit@frogsfrogsfrogs> References: <168246805791.732186.9294980643404649.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Make it so that we can run recovery loop tests for an exact number of seconds. Signed-off-by: Darrick J. Wong Reviewed-by: Andrey Albershteyn --- common/rc | 34 ++++++++++++++++++++++++++++++++++ tests/generic/019 | 1 + tests/generic/388 | 2 +- tests/generic/475 | 2 +- tests/generic/482 | 1 + tests/generic/648 | 8 ++++---- 6 files changed, 42 insertions(+), 6 deletions(-) diff --git a/common/rc b/common/rc index e89b0a3794..090f3d4938 100644 --- a/common/rc +++ b/common/rc @@ -5078,6 +5078,40 @@ _save_coredump() $COREDUMP_COMPRESSOR -f "$out_file" } +# Decide if a soak test should continue looping. The sole parameter is the +# number of soak loops that the test wants to run by default. The actual +# loop iteration number is stored in SOAK_LOOPIDX until the loop completes. +# +# If the test runner set a SOAK_DURATION value, this predicate will keep +# looping until it has run for at least that long. +_soak_loop_running() { + local max_soak_loops="$1" + + test -z "$SOAK_LOOPIDX" && SOAK_LOOPIDX=1 + + if [ -n "$SOAK_DURATION" ]; then + if [ -z "$SOAK_DEADLINE" ]; then + SOAK_DEADLINE="$(( $(date +%s) + SOAK_DURATION))" + fi + + local now="$(date +%s)" + if [ "$now" -gt "$SOAK_DEADLINE" ]; then + unset SOAK_DEADLINE + unset SOAK_LOOPIDX + return 1 + fi + SOAK_LOOPIDX=$((SOAK_LOOPIDX + 1)) + return 0 + fi + + if [ "$SOAK_LOOPIDX" -gt "$max_soak_loops" ]; then + unset SOAK_LOOPIDX + return 1 + fi + SOAK_LOOPIDX=$((SOAK_LOOPIDX + 1)) + return 0 +} + init_rc ################################################################################ diff --git a/tests/generic/019 b/tests/generic/019 index b68dd90c0d..b81c1d17ba 100755 --- a/tests/generic/019 +++ b/tests/generic/019 @@ -30,6 +30,7 @@ _cleanup() } RUN_TIME=$((20+10*$TIME_FACTOR)) +test -n "$SOAK_DURATION" && RUN_TIME="$SOAK_DURATION" NUM_JOBS=$((4*LOAD_FACTOR)) BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV` FILE_SIZE=$((BLK_DEV_SIZE * 512)) diff --git a/tests/generic/388 b/tests/generic/388 index 9cd737e8eb..4a5be6698c 100755 --- a/tests/generic/388 +++ b/tests/generic/388 @@ -42,7 +42,7 @@ _scratch_mkfs >> $seqres.full 2>&1 _require_metadata_journaling $SCRATCH_DEV _scratch_mount -for i in $(seq 1 $((50 * TIME_FACTOR)) ); do +while _soak_loop_running $((50 * TIME_FACTOR)); do ($FSSTRESS_PROG $FSSTRESS_AVOID -d $SCRATCH_MNT -n 999999 -p 4 >> $seqres.full &) \ > /dev/null 2>&1 diff --git a/tests/generic/475 b/tests/generic/475 index c426402ede..0cbf5131c2 100755 --- a/tests/generic/475 +++ b/tests/generic/475 @@ -41,7 +41,7 @@ _require_metadata_journaling $SCRATCH_DEV _dmerror_init _dmerror_mount -for i in $(seq 1 $((50 * TIME_FACTOR)) ); do +while _soak_loop_running $((50 * TIME_FACTOR)); do ($FSSTRESS_PROG $FSSTRESS_AVOID -d $SCRATCH_MNT -n 999999 -p $((LOAD_FACTOR * 4)) >> $seqres.full &) \ > /dev/null 2>&1 diff --git a/tests/generic/482 b/tests/generic/482 index 28c83a232e..6d8396d982 100755 --- a/tests/generic/482 +++ b/tests/generic/482 @@ -64,6 +64,7 @@ if [ $nr_cpus -gt 8 ]; then fi fsstress_args=$(_scale_fsstress_args -w -d $SCRATCH_MNT -n 512 -p $nr_cpus \ $FSSTRESS_AVOID) + devsize=$((1024*1024*200 / 512)) # 200m phys/virt size csize=$((1024*64 / 512)) # 64k cluster size lowspace=$((1024*1024 / 512)) # 1m low space threshold diff --git a/tests/generic/648 b/tests/generic/648 index d7bf5697e1..3b3544ff49 100755 --- a/tests/generic/648 +++ b/tests/generic/648 @@ -74,14 +74,14 @@ snap_loop_fs() { fsstress=($FSSTRESS_PROG $FSSTRESS_AVOID -d "$loopmnt" -n 999999 -p "$((LOAD_FACTOR * 4))") -for i in $(seq 1 $((25 * TIME_FACTOR)) ); do +while _soak_loop_running $((25 * TIME_FACTOR)); do touch $scratch_aliveflag snap_loop_fs >> $seqres.full 2>&1 & if ! _mount $loopimg $loopmnt -o loop; then rm -f $scratch_aliveflag _metadump_dev $loopimg $seqres.loop.$i.md - _fail "iteration $i loopimg mount failed" + _fail "iteration $SOAK_LOOPIDX loopimg mount failed" break fi @@ -126,12 +126,12 @@ for i in $(seq 1 $((25 * TIME_FACTOR)) ); do done if [ $is_unmounted -ne 0 ];then cat $tmp.unmount.err - _fail "iteration $i scratch unmount failed" + _fail "iteration $SOAK_LOOPIDX scratch unmount failed" fi _dmerror_load_working_table if ! _dmerror_mount; then _metadump_dev $DMERROR_DEV $seqres.scratch.$i.md - _fail "iteration $i scratch mount failed" + _fail "iteration $SOAK_LOOPIDX scratch mount failed" fi done