From owner-svn-src-projects@freebsd.org Wed Dec 16 21:05:46 2015 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3A2E0A4A3F3 for ; Wed, 16 Dec 2015 21:05:46 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 13B5B1A00; Wed, 16 Dec 2015 21:05:46 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tBGL5jG4075411; Wed, 16 Dec 2015 21:05:45 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tBGL5jIk075409; Wed, 16 Dec 2015 21:05:45 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201512162105.tBGL5jIk075409@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Wed, 16 Dec 2015 21:05:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r292369 - in projects/zfsd/head/tests/sys/cddl/zfs: include tests/redundancy X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Dec 2015 21:05:46 -0000 Author: asomers Date: Wed Dec 16 21:05:44 2015 New Revision: 292369 URL: https://svnweb.freebsd.org/changeset/base/292369 Log: Add a function that syncs to stable storage, not just the ZIL. Use it to try to stamp out intermittent failures in the ZFS test suite's redundancy tests. tests/sys/cddl/zfs/include/libtest.kshlib: - Add force_sync_path(), which (ab)uses the fact that 'zpool history' always does a txg_wait_synced() for its first ioctl call. sync(8) doesn't have the flexibility to handle this type of call, and there isn't a better option available that does not mutate the pool. - Leave a XXX comment to flag this implementation as a hack. - Some history: Previously, I had changed zfs_sync(), ZFS's VFS_SYNC(9), so that it would call txg_wait_synced(), as a workaround for a performance drop off issue. gibbs later fixed this by changing zfs_sync() to ignore syncer(4)'s periodic requests to sync to stable storage, and reverted the txg_wait_synced() call back to zil_commit(). tests/sys/cddl/zfs/tests/redundancy/redundancy.kshlib: - Use foce_sync_path instead of $SYNC for the redundancy test suite, which relies on the data actually getting written to the target devices so they can be corrupted directly. These may not be the only place this would be useful, but this is somewhat of an experiment to determine whether the intermittent failures stop. Submitted by: Will Sponsored by: Spectra Logic Corp Modified: projects/zfsd/head/tests/sys/cddl/zfs/include/libtest.kshlib projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy.kshlib Modified: projects/zfsd/head/tests/sys/cddl/zfs/include/libtest.kshlib ============================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/include/libtest.kshlib Wed Dec 16 21:03:52 2015 (r292368) +++ projects/zfsd/head/tests/sys/cddl/zfs/include/libtest.kshlib Wed Dec 16 21:05:44 2015 (r292369) @@ -2696,6 +2696,25 @@ function gen_dataset_name } # +# Ensure that a given path has been synced, not just ZIL committed. +# +# XXX The implementation currently requires calling 'zpool history'. On +# FreeBSD, the sync(8) command (via $SYNC) calls zfs_sync() which just +# does a zil_commit(), as opposed to a txg_wait_synced(). For things that +# require writing to their final destination (e.g. for intentional +# corruption purposes), zil_commit() is not good enough. +# +function force_sync_path # path +{ + typeset path="$1" + + zfspath=$($DF $path 2>/dev/null | tail -1 | cut -d" " -f1 | cut -d/ -f1) + [ -z "$zfspath" ] && return false + log_note "Force syncing ${zfspath} for ${path} ..." + $ZPOOL history $zfspath >/dev/null 2>&1 +} + +# # Get cksum tuple of dataset # $1 dataset name # Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy.kshlib ============================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy.kshlib Wed Dec 16 21:03:52 2015 (r292368) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/redundancy/redundancy.kshlib Wed Dec 16 21:05:44 2015 (r292369) @@ -95,7 +95,7 @@ function setup_test_env typeset file=$TESTDIR/file log_must $FILE_WRITE -o create -f $file -b $BLOCKSZ -c $NUM_WRITES - log_must $SYNC $TESTDIR + log_must force_sync_path $TESTDIR record_data $TESTPOOL $PRE_RECORD_FILE } @@ -139,8 +139,7 @@ function sync_pool #pool { typeset pool=$1 - log_must $SYNC - log_must $SLEEP 2 + log_must force_sync_path $pool # If the OS has detected corruption on the pool, it will have # automatically initiated a scrub. In that case, our "zpool scrub"