From: Dave Chinner <david@fromorbit.com>
To: Jayashree Mohan <jayashree2912@gmail.com>
Cc: Eryu Guan <guaneryu@gmail.com>, fstests <fstests@vger.kernel.org>,
Vijaychidambaram Velayudhan Pillai <vijay@cs.utexas.edu>,
Theodore Ts'o <tytso@mit.edu>,
Amir Goldstein <amir73il@gmail.com>,
Filipe Manana <fdmanana@gmail.com>
Subject: Re: [PATCH] fstest: CrashMonkey tests ported to xfstest
Date: Mon, 5 Nov 2018 16:22:17 +1100 [thread overview]
Message-ID: <20181105052217.GT6311@dastard> (raw)
In-Reply-To: <1B22AFA2-FAF3-45AA-9910-CDBE4AEBFB09@gmail.com>
On Sun, Nov 04, 2018 at 02:21:21PM -0600, Jayashree Mohan wrote:
> Hi Eryu and Filipe,
>
> I have incorporated the coding style suggested, and renamed the cleanup function. However, creating a clean fs image after each sub test is resulting in about 10-15s of additional overhead overall. I instead clean up the working directory and unmount. The time for the tests varies between 12-15 seconds.
>
> Please find the patch below
>
> —
>
> diff --git a/tests/generic/517-link b/tests/generic/517-link
> new file mode 100755
> index 0000000..ea5c5b7
> --- /dev/null
> +++ b/tests/generic/517-link
> @@ -0,0 +1,164 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2018 The University of Texas at Austin. All Rights Reserved.
> +#
> +# FS QA Test 517-link
> +#
> +# Test case created by CrashMonkey
> +#
> +# Test if we create a hard link to a file and persist either of the files, all the names persist.
> +#
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +echo "QA output created by $seq"
> +
> +here=`pwd`
> +tmp=/tmp/$$
> +status=1 # failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> + _cleanup_flakey
> + cd /
> + rm -f $tmp.*
> +}
> +
> +init_start_time=$(date +%s.%N)
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/dmflakey
> +
> +# remove previous $seqres.full before test
> +rm -f $seqres.full
> +
> +# real QA test starts here
> +_supported_fs generic
> +_supported_os Linux
> +_require_scratch_nocheck
> +_require_dm_target flakey
> +
> +# initialize scratch device
> +_scratch_mkfs >> $seqres.full 2>&1
> +_require_metadata_journaling $SCRATCH_DEV
> +_init_flakey
> +init_end_time=$(date +%s.%N)
> +init_time_elapsed=$(echo "$init_end_time - $init_start_time" | bc)
> +echo "Initialization time = $init_time_elapsed" >> $seqres.full
No timing inside the test, please. The harness times the test
execution.
> +stat_opt='-c "blocks: %b size: %s inode: %i links: %h"'
> +test_num=0
Don't number tests. If we add an extra test, it will completely
break the golden output.
> +total_time=0
> +
> +_clean_dir()
> +{
> + _mount_flakey
> + rm -rf $SCRATCH_MNT/*
> + sync
> + _unmount_flakey
> +}
Why not just _scratch_mkfs?
> +
> +# create a hard link $2 to file $1, and fsync $3, followed by power-cut
> +test_link()
> +{
> + test_num=$((test_num + 1))
> + local start_time=$(date +%s.%N)
> + local sibling=0
> + local before=""
> + local after=""
> + echo -ne "\n=== Test $test_num : link $1 $2 " | _filter_scratch
> + _mount_flakey
> +
Still whitespace damaged.
> + # now execute the workload
> + mkdir -p "${1%/*}" && mkdir -p "${2%/*}" && touch "$1"
One line each.
> + ln $1 $2
No checks for failure?
> +
> + if [ -z "$3" ]; then
> + echo -ne " with sync ===\n"
> + sync
> + before=`stat "$stat_opt" $1`
> + else
> + echo " with fsync $3 ===" | _filter_scratch
> +
> + # If the file being persisted is a sibling, create it first
> + if [ ! -f $3 ]; then
> + sibling=1
> + touch $3
> + fi
> +
> + $XFS_IO_PROG -c "fsync" $3
> +
> + if [ $sibling -ne 1 ]; then
> + before=`stat "$stat_opt" $1`
> + fi
> + fi
To tell the truth, I'd consider these two separate functions -
test_link_sync() and test_link_fsync(). More below.
> +
> + _flakey_drop_and_remount | tee -a $seqres.full
> +
> + if [ -f $1 ]; then
> + after=`stat "$stat_opt" $1`
> + fi
> +
> + if [ "$before" != "$after" ] && [ $sibling -ne 1 ]; then
> + echo "Before: $before" | tee -a $seqres.full
> + echo "After: $after" | tee -a $seqres.full
> + fi
Why tee all the output to $seqres.full? Once the timing info is
removed, it dones't contain anything extra that the normal output
file...
> +
> + _unmount_flakey
> + _check_scratch_fs $FLAKEY_DEV
> + [ $? -ne 0 ] && _fatal "fsck failed"
> + end_time=$(date +%s.%N)
> + time_elapsed=$(echo "$end_time - $start_time" | bc)
> + echo " Elapsed time : $time_elapsed" >> $seqres.full
> + total_time=$(echo "$total_time + $time_elapsed" | bc)
> + echo " Total time : $total_time" >> $seqres.full
> + _clean_dir
> +}
> +
> +# run the link test for different combinations
> +
> +test_start_time=$(date +%s.%N)
> +# Group 1: Both files within root directory
> +for file_name in $SCRATCH_MNT $SCRATCH_MNT/foo $SCRATCH_MNT/bar; do
> + test_link $SCRATCH_MNT/foo $SCRATCH_MNT/bar $file_name
> +done
> +test_link $SCRATCH_MNT/foo $SCRATCH_MNT/bar
> +
> +# Group 2: Create hard link in a sub directory
> +for file_name in $SCRATCH_MNT $SCRATCH_MNT/foo $SCRATCH_MNT/bar $SCRATCH_MNT/A $SCRATCH_MNT/A/bar $SCRATCH_MNT/A/foo; do
> + test_link $SCRATCH_MNT/foo $SCRATCH_MNT/A/bar $file_name
> +done
> +test_link $SCRATCH_MNT/foo $SCRATCH_MNT/A/bar
Lines too long.
Basically, this is a two dimensional array of filenames.
Make test_link_fsync() do:
src=$SCRATCH_MNT/$1
dst=$SCRATCH_MNT/$2
fsync=$SCRATCH_MNT/$3
And define your fsync filenames and link destinations names like so
(can't remember bash array notation, so paraphrasing):
# group 1: Both files within root directory
fnames[1]="./ foo bar"
dnames[1]="foo bar"
# group 2: Create hard link in a sub directory
fnames[2]="./ foo bar A A/bar A/foo"
dnames[2]="foo A/bar"
#g3
fnames[3]="./ foo bar A A/bar A/foo"
dnames[3]="A/foo bar"
#g4
fnames[4]="./ A A/bar A/foo"
dnames[4]="A/foo A/bar"
#g5
fnames[5]="./ foo bar A A/bar A/foo"
dnames[5]="bar A/bar"
#g6
fnames[6]="./ foo bar A A/bar A/foo"
dnames[6]="A/bar bar"
for ((i=1; i<=6; i++)); do
for f in $fnames[$i]; do
test_link_fsync $dnames[$i] $f
done
test_link_sync $dnames[1]
done
And all this shouty, shouty noise goes away. Much easier to read,
much simpler to maintain.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2018-11-05 14:40 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-29 16:50 [PATCH] fstest: CrashMonkey tests ported to xfstest Jayashree Mohan
2018-10-30 13:05 ` Filipe Manana
2018-11-02 20:39 ` Jayashree Mohan
2018-11-04 16:27 ` Eryu Guan
2018-11-04 16:38 ` Eryu Guan
2018-11-04 20:21 ` Jayashree Mohan
2018-11-05 5:22 ` Dave Chinner [this message]
2018-11-05 20:16 ` Jayashree Mohan
2018-11-06 22:57 ` Dave Chinner
2018-11-06 23:15 ` Theodore Y. Ts'o
2018-11-06 23:39 ` Dave Chinner
[not found] ` <CA+EzBbDwdi26MCswz0iQ8hUTcGixATUXayxMOmEw5gekYvmMuw@mail.gmail.com>
[not found] ` <5be228d2.1c69fb81.3ad08.5e76.GMR@mx.google.com>
2018-11-06 23:54 ` Delivery Status Notification (Failure) Jayashree Mohan
2018-11-07 2:09 ` [PATCH] fstest: CrashMonkey tests ported to xfstest Dave Chinner
2018-11-07 4:04 ` Theodore Y. Ts'o
2018-11-08 1:41 ` Jayashree Mohan
2018-11-08 9:10 ` Dave Chinner
2018-11-08 14:46 ` Jayashree Mohan
2018-11-08 9:40 ` Dave Chinner
2018-11-08 15:35 ` Vijaychidambaram Velayudhan Pillai
2018-11-09 3:12 ` Dave Chinner
2018-11-09 16:39 ` Vijaychidambaram Velayudhan Pillai
2018-11-09 19:17 ` Theodore Y. Ts'o
2018-11-09 20:47 ` Vijaychidambaram Velayudhan Pillai
2018-11-08 16:10 ` Theodore Y. Ts'o
2018-11-07 0:24 ` Jayashree Mohan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181105052217.GT6311@dastard \
--to=david@fromorbit.com \
--cc=amir73il@gmail.com \
--cc=fdmanana@gmail.com \
--cc=fstests@vger.kernel.org \
--cc=guaneryu@gmail.com \
--cc=jayashree2912@gmail.com \
--cc=tytso@mit.edu \
--cc=vijay@cs.utexas.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox