From patchwork Sun Dec 11 21:52:57 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: 9469901 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 6C54860760 for ; Sun, 11 Dec 2016 21:54:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B97628210 for ; Sun, 11 Dec 2016 21:54:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E50628305; Sun, 11 Dec 2016 21:54:41 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B379628210 for ; Sun, 11 Dec 2016 21:54:40 +0000 (UTC) Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uBBLs5B3001225 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 11 Dec 2016 21:54:06 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id uBBLs5df004043 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 11 Dec 2016 21:54:05 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1cGC4L-00025R-Da; Sun, 11 Dec 2016 13:54:05 -0800 Received: from userv0021.oracle.com ([156.151.31.71]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1cGC3I-0001n8-9T for ocfs2-devel@oss.oracle.com; Sun, 11 Dec 2016 13:53:00 -0800 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id uBBLqxib009879 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 11 Dec 2016 21:52:59 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id uBBLqw9j007024; Sun, 11 Dec 2016 21:52:59 GMT Received: from localhost (/24.21.211.40) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 11 Dec 2016 13:52:58 -0800 From: "Darrick J. Wong" To: eguan@redhat.com, darrick.wong@oracle.com Date: Sun, 11 Dec 2016 13:52:57 -0800 Message-ID: <148149317758.31093.14955725683270205488.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 Cc: fstests@vger.kernel.org, ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH 2/7] ocfs2/reflink: fix file block size reporting X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-Virus-Scanned: ClamAV using ClamSMTP Some of the reflink tests try to require a specific filesystem block size so that they can test file block manipulation functions. That's straightforward for most filesystems but ocfs2 throws in the additional twist that data fork block mappings are stored in units of clusters, not blocks, which causes these reflink tests to fail. Therefore, introduce a new helper that retrieves the file minimum block size and adapt the reflink tests to use that instead. Signed-off-by: Darrick J. Wong --- common/rc | 21 +++++++++++++++++++-- tests/generic/205 | 2 +- tests/generic/206 | 2 +- tests/generic/216 | 2 +- tests/generic/217 | 2 +- tests/generic/218 | 2 +- tests/generic/220 | 2 +- tests/generic/222 | 2 +- tests/generic/227 | 2 +- tests/generic/229 | 2 +- tests/generic/238 | 2 +- 11 files changed, 29 insertions(+), 12 deletions(-) diff --git a/common/rc b/common/rc index 2639fbd..30111d4 100644 --- a/common/rc +++ b/common/rc @@ -925,7 +925,7 @@ _scratch_mkfs_blocksized() ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV ;; ocfs2) - yes | ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV + yes | ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize -C $blocksize $SCRATCH_DEV ;; *) _notrun "Filesystem $FSTYP not supported in _scratch_mkfs_blocksized" @@ -3029,13 +3029,30 @@ _sysfs_dev() echo /sys/dev/block/$_maj:$_min } +# Get the minimum block size of a file. Usually this is the +# minimum fs block size, but some filesystems (ocfs2) do block +# mappings in larger units. +get_file_block_size() +{ + if [ -z $1 ] || [ ! -d $1 ]; then + echo "Missing mount point argument for get_file_block_size" + exit 1 + fi + if [ "$FSTYP" = "ocfs2" ]; then + stat -c '%o' $1 + else + stat -f -c '%S' $1 + fi +} + +# Get the minimum block size of an fs. get_block_size() { if [ -z $1 ] || [ ! -d $1 ]; then echo "Missing mount point argument for get_block_size" exit 1 fi - echo `stat -f -c %S $1` + stat -f -c %S $1 } get_page_size() diff --git a/tests/generic/205 b/tests/generic/205 index cfda8c3..7889ca4 100755 --- a/tests/generic/205 +++ b/tests/generic/205 @@ -60,7 +60,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." echo "Create the original files" diff --git a/tests/generic/206 b/tests/generic/206 index 909956f..f82e146 100755 --- a/tests/generic/206 +++ b/tests/generic/206 @@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." echo "Create the original files" diff --git a/tests/generic/216 b/tests/generic/216 index d9b868a..cbff75f 100755 --- a/tests/generic/216 +++ b/tests/generic/216 @@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." echo "Create the original files" diff --git a/tests/generic/217 b/tests/generic/217 index 65113d9..5f59fd8 100755 --- a/tests/generic/217 +++ b/tests/generic/217 @@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." echo "Create the original files" diff --git a/tests/generic/218 b/tests/generic/218 index 21029ef..bdce367 100755 --- a/tests/generic/218 +++ b/tests/generic/218 @@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." echo "Create the original files" diff --git a/tests/generic/220 b/tests/generic/220 index c54bf06..29d2f04 100755 --- a/tests/generic/220 +++ b/tests/generic/220 @@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." echo "Create the original files" diff --git a/tests/generic/222 b/tests/generic/222 index d7ee57e..3052a22 100755 --- a/tests/generic/222 +++ b/tests/generic/222 @@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." echo "Create the original files" diff --git a/tests/generic/227 b/tests/generic/227 index fa6a33e..18441cf 100755 --- a/tests/generic/227 +++ b/tests/generic/227 @@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." echo "Create the original files" diff --git a/tests/generic/229 b/tests/generic/229 index 3e2c6f4..99eb774 100755 --- a/tests/generic/229 +++ b/tests/generic/229 @@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." runtest() { diff --git a/tests/generic/238 b/tests/generic/238 index a2f44e8..5419a30 100755 --- a/tests/generic/238 +++ b/tests/generic/238 @@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." runtest() {