From patchwork Sun Dec 11 21:53:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 9469891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 97B3E60760 for ; Sun, 11 Dec 2016 21:53:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8903328210 for ; Sun, 11 Dec 2016 21:53:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DDE92824F; Sun, 11 Dec 2016 21:53:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18DC328210 for ; Sun, 11 Dec 2016 21:53:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753992AbcLKVxP (ORCPT ); Sun, 11 Dec 2016 16:53:15 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:33224 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753865AbcLKVxP (ORCPT ); Sun, 11 Dec 2016 16:53:15 -0500 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uBBLrC6E029909 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 11 Dec 2016 21:53:12 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id uBBLrBUQ002863 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 11 Dec 2016 21:53:12 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id uBBLrBIZ030330; Sun, 11 Dec 2016 21:53:11 GMT Received: from localhost (/24.21.211.40) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 11 Dec 2016 13:53:11 -0800 Subject: [PATCH 4/7] reflink: fix space consumption tests From: "Darrick J. Wong" To: eguan@redhat.com, darrick.wong@oracle.com Cc: ocfs2-devel@oss.oracle.com, fstests@vger.kernel.org Date: Sun, 11 Dec 2016 13:53:10 -0800 Message-ID: <148149319048.31093.2083894591825614863.stgit@birch.djwong.org> In-Reply-To: <148149316504.31093.16129068344227450710.stgit@birch.djwong.org> References: <148149316504.31093.16129068344227450710.stgit@birch.djwong.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some of the tests try to check that we can't COW when we're out of space, but some tricky filesystems make this hard because writing N blocks doesn't increase used blocks by N.... Signed-off-by: Darrick J. Wong --- common/populate | 14 ++++++++++++++ tests/generic/171 | 5 ++--- tests/generic/173 | 5 ++--- tests/generic/174 | 5 ++--- tests/generic/282 | 3 +-- 5 files changed, 21 insertions(+), 11 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/common/populate b/common/populate index d0003c5..9811d21 100644 --- a/common/populate +++ b/common/populate @@ -30,6 +30,20 @@ _require_xfs_db_blocktrash_z_command() { $XFS_DB_PROG -x -f -c 'blocktrash -z' "${TEST_DEV}" | grep -q 'nothing on stack' || _notrun "blocktrash -z not supported" } +# Eat free space until we can't anymore. +_consume_free_space() { + dir=$1 + + old_nr_free=0 + nr_free=$(stat -f -c '%f' $dir) + x=0 + while [ $nr_free -gt 0 ] && [ $old_nr_free != $nr_free ]; do + $XFS_IO_PROG -f -c "pwrite -b 4194304 0 $((blksz * nr_free))" $dir/eat_my_space.$((x++)) + old_nr_free=$nr_free + nr_free=$(stat -f -c '%f' $dir) + done +} + # Attempt to make files of "every" format for data, dirs, attrs etc. # (with apologies to Eric Sandeen for mutating xfser.sh) diff --git a/tests/generic/171 b/tests/generic/171 index b01dbd5..d96fd17 100755 --- a/tests/generic/171 +++ b/tests/generic/171 @@ -41,6 +41,7 @@ _cleanup() . ./common/filter . ./common/attr . ./common/reflink +. ./common/populate # real QA test starts here _supported_os Linux @@ -75,9 +76,7 @@ _cp_reflink $testdir/bigfile $testdir/clonefile sync echo "Allocate the rest of the space" -nr_free=$(stat -f -c '%f' $testdir) -touch $testdir/file0 $testdir/file1 -_pwrite_byte 0x61 0 $((blksz * nr_free)) $testdir/eat_my_space >> $seqres.full 2>&1 +_consume_free_space $testdir >> $seqres.full 2>&1 sync echo "CoW the big file" diff --git a/tests/generic/173 b/tests/generic/173 index e35597f..20c6091 100755 --- a/tests/generic/173 +++ b/tests/generic/173 @@ -41,6 +41,7 @@ _cleanup() . ./common/filter . ./common/attr . ./common/reflink +. ./common/populate # real QA test starts here _supported_os Linux @@ -75,9 +76,7 @@ _cp_reflink $testdir/bigfile $testdir/clonefile sync echo "Allocate the rest of the space" -nr_free=$(stat -f -c '%f' $testdir) -touch $testdir/file0 $testdir/file1 -_pwrite_byte 0x61 0 $((blksz * nr_free)) $testdir/eat_my_space >> $seqres.full 2>&1 +_consume_free_space $testdir >> $seqres.full 2>&1 sync echo "mmap CoW the big file" diff --git a/tests/generic/174 b/tests/generic/174 index 38fad1d..d811307 100755 --- a/tests/generic/174 +++ b/tests/generic/174 @@ -41,6 +41,7 @@ _cleanup() . ./common/filter . ./common/attr . ./common/reflink +. ./common/populate # real QA test starts here _supported_os Linux @@ -76,9 +77,7 @@ _cp_reflink $testdir/bigfile $testdir/clonefile sync echo "Allocate the rest of the space" -nr_free=$(stat -f -c '%f' $testdir) -touch $testdir/file0 $testdir/file1 -_pwrite_byte 0x61 0 $((blksz * nr_free)) $testdir/eat_my_space >> $seqres.full 2>&1 +_consume_free_space $testdir >> $seqres.full 2>&1 sync echo "CoW the big file" diff --git a/tests/generic/282 b/tests/generic/282 index 6452025..8a30811 100755 --- a/tests/generic/282 +++ b/tests/generic/282 @@ -80,8 +80,7 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" sync _dmerror_load_error_table -urk=$($XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" $testdir/file2 > $TEST_DIR/mwrite.out 2>&1) -cat $TEST_DIR/mwrite.out | tee -a $seqres.full +$XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" $testdir/file2 >> $seqres.full 2>&1 _dmerror_load_working_table rm -rf $testdir/file2 >> $seqres.full 2>&1 _dmerror_unmount