From patchwork Wed Apr 5 03:13:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9662897 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 84A2B60352 for ; Wed, 5 Apr 2017 03:13:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76C9628338 for ; Wed, 5 Apr 2017 03:13:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B453283F4; Wed, 5 Apr 2017 03:13:30 +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 autolearn=unavailable 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 F0A0E28338 for ; Wed, 5 Apr 2017 03:13:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752158AbdDEDNZ (ORCPT ); Tue, 4 Apr 2017 23:13:25 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:41587 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751843AbdDEDNY (ORCPT ); Tue, 4 Apr 2017 23:13:24 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="17360874" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 05 Apr 2017 11:13:21 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 9D1AA49FD51E; Wed, 5 Apr 2017 11:13:21 +0800 (CST) Received: from localhost.localdomain (10.167.226.34) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 5 Apr 2017 11:13:20 +0800 From: Qu Wenruo To: , , Subject: [PATCH v2] fstests: generic: Check if cycle mount and sleep can affect fiemap result Date: Wed, 5 Apr 2017 11:13:19 +0800 Message-ID: <20170405031319.21413-1-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.12.1 MIME-Version: 1.0 X-Originating-IP: [10.167.226.34] X-yoursite-MailScanner-ID: 9D1AA49FD51E.AE323 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: quwenruo@cn.fujitsu.com Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As long as we don't modify the on-disk data, fiemap result should always be constant. Operation like cycle mount and sleep should not affect fiemap result. While unfortunately, btrfs doesn't follow that behavior. Btrfs fiemap sometimes return merged result, while after cycle mount, it returns split result. Furthermore after a snap, btrfs returns merged result again. Signed-off-by: Qu Wenruo --- v2: Add require_fiemap Remove IRIX support Fix whilespace issues Remove _scratch_mkfs_sized, as the needed space is so small that no sane tester would put a so small fs as SCRATCH_DEV. --- tests/generic/422 | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/422.out | 2 + tests/generic/group | 1 + 3 files changed, 130 insertions(+) create mode 100755 tests/generic/422 create mode 100644 tests/generic/422.out diff --git a/tests/generic/422 b/tests/generic/422 new file mode 100755 index 0000000..f0a990f --- /dev/null +++ b/tests/generic/422 @@ -0,0 +1,127 @@ +#! /bin/bash +# FS QA Test 422 +# +# Test if a file system returns constant fiemap result after remount and +# fiemap. +# Unfortunately, btrfs doesn't follow this behavior. +# +#----------------------------------------------------------------------- +# Copyright (c) 2017 Fujitsu. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +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() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +_require_scratch +_require_fiemap + +block_size=$((64 * 1024)) +block_count=32 +dst=$SCRATCH_MNT/file +sleeptime=3 + +# It's almost 100% for btrfs to trigger inconstant fiemap result +# just in case +loop_counts=$((2 * $LOAD_FACTOR)) + +# record fiemap as checkpoint, and output the hash of fiemap result +# to stdout +fiemap_checkpoint() +{ + local number=$1 + local message=$2 + + echo "=== $message ===" >> $seqres.full + $XFS_IO_PROG -c "fiemap -v" $dst > ${tmp}.cp$number + cat ${tmp}.cp${number} >> $seqres.full + + md5sum ${tmp}.cp${number} | cut -d ' ' -f 1 +} + +do_test() +{ + local number=$1 + + # Use 16 times of file size to ensure we have enough space + _scratch_mkfs > /dev/null 2>&1 + _scratch_mount + + echo "====== Loop $number ======" >> $seqres.full + touch $dst + # Xfsprogs 4.9.0 still has a bug that xfs_io "open" with O_SYNC command + # doesn't work well with "pwrite", although it gets fixed in v4.10.0, + # use dd here to avoid it, non-xfs developers will be happy with it. + dd if=/dev/zero of=$dst bs=$block_size count=$block_count oflag=dsync \ + status=none 2>&1 + + hash1=$(fiemap_checkpoint 1 "Fiemap just after dsync write") + + # Sleep should not modify fiemap result + sleep $sleeptime + + hash2=$(fiemap_checkpoint 2 "Fiemap after dsync write and sleep") + + # cycle mount should not modify fiemap result + _scratch_cycle_mount + + hash3=$(fiemap_checkpoint 3 "Fiemap after cycle mount") + + # Sleep should not modify fiemap result + sleep $sleeptime + + hash4=$(fiemap_checkpoint 4 "Fiemap after cycle mount and sleep") + + _scratch_unmount + + if [ $hash1 != $hash2 -o $hash2 != $hash3 -o $hash3 != $hash4 ]; then + echo "Inconstant fiemap result detected" + fi + echo >> $seqres.full +} + +for i in $(seq 1 $loop_counts); do + do_test $i +done + +echo "Silence is golden" +# success, all done +status=0 +exit diff --git a/tests/generic/422.out b/tests/generic/422.out new file mode 100644 index 0000000..f70693f --- /dev/null +++ b/tests/generic/422.out @@ -0,0 +1,2 @@ +QA output created by 422 +Silence is golden diff --git a/tests/generic/group b/tests/generic/group index 3c7c5e4..86d2325 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -424,3 +424,4 @@ 419 auto quick encrypt 420 auto quick punch 421 auto quick encrypt dangerous +422 auto