From patchwork Fri Apr 24 16:51:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Raghavan X-Patchwork-Id: 11508647 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AEE0815AB for ; Fri, 24 Apr 2020 16:52:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90C172098B for ; Fri, 24 Apr 2020 16:52:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="miMLd12a" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728643AbgDXQwO (ORCPT ); Fri, 24 Apr 2020 12:52:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728019AbgDXQwO (ORCPT ); Fri, 24 Apr 2020 12:52:14 -0400 Received: from mail-oo1-xc43.google.com (mail-oo1-xc43.google.com [IPv6:2607:f8b0:4864:20::c43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B19FDC09B046 for ; Fri, 24 Apr 2020 09:52:13 -0700 (PDT) Received: by mail-oo1-xc43.google.com with SMTP id r1so2241089oog.7 for ; Fri, 24 Apr 2020 09:52:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Xue2LdLI/D0JAHJ767TD8KkMFnfnppMokVLpkjqQChk=; b=miMLd12aJF7iVyFohDDgq2/UqrW2UvaSFuKGhmP4N2FmB9H3m0bwWlFEWA005H4uFu 4E6cu47mZeQVM30q2T1a77hqHU18pNo0Nj4d78/EPGo//Ea4VrCGDZaKbA18H6uL9u+x 9ntbMM+4Ve66ZjsCjkNsW3cqECmpTBL0jAGqaR8zCNt4uCjaEIzmh5KOWwkNwxrHbdwN OJhvPYarw7rjDUEv1h9LTYwbOzQV0gSul9CjuMRAo9iFifoHiC8LAr1/zdANpmldRulK uc57e3hL7q7k/Rgb08RtFihJBylNxLU0gljd84/Kb5ADqb4/OQfGzQWtJqlvYkdF8/cz aeoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Xue2LdLI/D0JAHJ767TD8KkMFnfnppMokVLpkjqQChk=; b=aqVcL+LzhopHa2dPBOwD0kbKVtmGd6raCHk8duoCekRPWf6j5HAHu2/y13jfUwUtfr c3AJYU5QUfHcHbxETHoA2zKBu6HQrDtN36TDfSKze5v0Gbyt9Qjv+fo7EhkxgKTmgNvm eJ9ArLRYBll30S4bQ/cTXMEFzo5zqgxiVxdGRC3PEg2Cvsx3iR7+UMuPABxbfclFwEbL PDZM+ywj3SwfM0Rij/WHrkgSCv3nVd3ZPeKfCWWb23EVB6ZkYdQAfgRJIpQYLTKcw2pE oqrFagUofd6bmFksog0sKtgx7Bi27r752O4x1nn5iuTdv/9C9WL/cZLdMY+HG5RvLxV8 MlIw== X-Gm-Message-State: AGi0PuaHOuTo/0aWBksL1xsbGDzuqsi7nKPnMRnHF6BGDIiuQd+6Q6Rf yYkewgigvrvTG8ZKx9mTwEROuken2Q== X-Google-Smtp-Source: APiQypJoEAmvuYGeijFTAv+0qclK4PwR5W2CPf1p+VcOkRxRm1xDu+dQF723JrXj6KyI7P0JriBvGg== X-Received: by 2002:a4a:e60d:: with SMTP id f13mr8621914oot.6.1587747132676; Fri, 24 Apr 2020 09:52:12 -0700 (PDT) Received: from localhost.localdomain (cpe-70-114-159-174.austin.res.rr.com. [70.114.159.174]) by smtp.gmail.com with ESMTPSA id 60sm1623806ott.17.2020.04.24.09.52.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 09:52:12 -0700 (PDT) From: Arvind Raghavan To: fstests@vger.kernel.org Cc: amir73il@gmail.com, jayashree2912@gmail.com, vijay@cs.utexas.edu, Arvind Raghavan Subject: [PATCH] fstest: Crashmonkey rename tests ported to xfstest Date: Fri, 24 Apr 2020 12:51:17 -0400 Message-Id: <20200424165117.6433-1-raghavan.arvind@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org This patch aims to add tests to the xfstest suite to check whether renamed files recover after a crash. These test cases were generated by CrashMonkey, a crash-consistency testing framework built at the SASLab at UT Austin. This patch batches 37 tests into a single test, each of which creates a file, renames it, syncs one of the files/parent directories, and ensures that the synced file/dir is equivalent before and after a crash. This test takes around 12-15 seconds to run locally and is thus placed in the 'quick' group. Signed-off-by: Arvind Raghavan --- tests/generic/484 | 179 ++++++++++++++++++++++++++++++++++++++++++ tests/generic/484.out | 2 + tests/generic/group | 1 + 3 files changed, 182 insertions(+) create mode 100755 tests/generic/484 create mode 100644 tests/generic/484.out diff --git a/tests/generic/484 b/tests/generic/484 new file mode 100755 index 00000000..b27d828d --- /dev/null +++ b/tests/generic/484 @@ -0,0 +1,179 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 The University of Texas at Austin. All Rights Reserved. +# +# FS QA Test 484 +# +# Test case created by CrashMonkey +# +# Test if we create a rename a file and persist it that the +# appropriate files exist. +# +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.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/dmflakey + +# 256MB in byte +fssize=$((2**20 * 256)) + +# 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_sized $fssize >> $seqres.full 2>&1 +_require_metadata_journaling $SCRATCH_DEV +_init_flakey + +stat_opt='-c %n - blocks: %b size: %s inode: %i links: %h' + +# Usage: general_stat [--data-only] file1 [--data-only] [file2] .. +# If the --data-only flag precedes a file, then only that file's +# data will be printed. If a file is synced, then general_stat +# should provide identical output before and after a crash. +general_stat() { + local data_only="false" + while (( "$#" )); do + case $1 in + --data-only) + data_only="true" + ;; + *) + local path="$1" + echo "-- $path --" + if [ ! -e "$path" ]; then + echo "Doesn't exist!" + elif [ "$data_only" = "true" ] && [ -d "$path" ]; then + echo "Directory Data" + [ -z "$(ls -A $path)" ] || ls -1 "$path" | sort + elif [ "$data_only" = "true" ]; then + echo "File Data" + od "$path" + elif [ -d "$path" ]; then + echo "Directory Metadata" + stat "$stat_opt" "$path" + echo "Directory Data" + [ -z "$(ls -A $path)" ] || ls -1 "$path" | sort + else + echo "File Metadata" + stat "$stat_opt" "$path" + echo "File Data" + od "$path" + fi + data_only="false" + ;; + esac + shift + done +} + +check_consistency() +{ + before=$(general_stat "$@") + _flakey_drop_and_remount + after=$(general_stat "$@") + + if [ "$before" != "$after" ]; then + echo -e "Before:\n$before" + echo -e "After:\n$after" + fi + + # Using _unmount_flakey nondeterministically fails here with + # "target is busy". Calling 'sync' doesn't fix the issue. Lazy + # unmount waits for lingering processes to exit. + $UMOUNT_PROG -l $SCRATCH_MNT + _check_scratch_fs $FLAKEY_DEV +} + +clean_dir() +{ + _mount_flakey + rm -rf $(find $SCRATCH_MNT/* | grep -v "lost+found") + $UMOUNT_PROG -l $SCRATCH_MNT +} + +do_fsync_check() { + local file="$1" + local sync_op="$2" + + if [ $sync_op == "fdatasync" ]; then + $XFS_IO_PROG -c "fdatasync" $file + check_consistency --data-only $file + else + $XFS_IO_PROG -c "fsync" $file + check_consistency $file + fi +} + +# Wraps mv, deletes dest dir if exists. +rename() { + [ -d $1 ] && [ -d $2 ] && rm -rf $2 + mv $1 $2 +} + +function rename_template() { + local file1="$1" + local file2="$2" + local fsync_file="$3" + local fsync_command="$4" + + _mount_flakey + mkdir -p $(dirname $file1) + touch $file1 + mkdir -p $(dirname $file2) + rename $file1 $file2 + do_fsync_check $fsync_file $fsync_command + clean_dir +} + +file1_options=( + "$SCRATCH_MNT/A/C/bar" + "$SCRATCH_MNT/A/bar" + "$SCRATCH_MNT/A/foo" + "$SCRATCH_MNT/foo" +) +file2_options=( + "$SCRATCH_MNT/A/C/bar" + "$SCRATCH_MNT/A/bar" + "$SCRATCH_MNT/bar" +) + +for file1 in ${file1_options[@]}; do + for file2 in ${file2_options[@]}; do + [ "$file1" == "$file2" ] && continue + to_sync=("$(dirname $file1)" "$(dirname $file2)") + uniques=($(for v in ${to_sync[@]}; do echo $v; done | sort -u)) + for fsync_file in ${uniques[@]}; do + for fsync_command in fsync fdatasync; do + rename_template $file1 $file2 $fsync_file $fsync_command + done + done + done +done + +# Success, all done +echo "Silence is golden" +status=0 +exit diff --git a/tests/generic/484.out b/tests/generic/484.out new file mode 100644 index 00000000..94f2f0bd --- /dev/null +++ b/tests/generic/484.out @@ -0,0 +1,2 @@ +QA output created by 484 +Silence is golden diff --git a/tests/generic/group b/tests/generic/group index 718575ba..987ad2a0 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -486,6 +486,7 @@ 481 auto quick log metadata 482 auto metadata replay thin 483 auto quick log metadata +484 auto quick log metadata 485 auto quick insert 486 auto quick attr 487 auto quick eio