From patchwork Sun Apr 8 02:07:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 10328053 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 9DF0C60327 for ; Sun, 8 Apr 2018 02:08:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DCA2291A4 for ; Sun, 8 Apr 2018 02:08:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81C132924D; Sun, 8 Apr 2018 02:08:04 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 AE9E8291A4 for ; Sun, 8 Apr 2018 02:08:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752483AbeDHCIC (ORCPT ); Sat, 7 Apr 2018 22:08:02 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:33614 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752469AbeDHCIC (ORCPT ); Sat, 7 Apr 2018 22:08:02 -0400 Received: by mail-pl0-f66.google.com with SMTP id s10-v6so2985540plp.0; Sat, 07 Apr 2018 19:08:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=mYa7DkvdN6V8fXc+1NYYNi2TzdvZW308unychC3XbeM=; b=r47EHevuhlxJwQ5mc5P6WJG9xnRRTAgXCM4CBVpmPprX1NlA85zPxJwbQ8uZTyMrzF DYZfdCQm0kIoZN2cqPPw2YAlybLXqA89n7dl9wGU/mBCSrd/95Tz958QtXc4AucBZ8w+ /Fxj/2kRFqKzV7v8Cjwh3i8Vn2l96OTR4b35iNgFb+Tq92fx6DsPjNTflTCcWMgETXKT aCXVG+W0WNTJ3hjdUAdM7zhT/9oznTacUrnx5qS0osT8t7r22tg9shtRCc/0aDys/JsJ 3a5RPgTwEOIq87UH+eecQYLlgtQ3PPGJ6Afal6Z9O1DVmqosrObW8v5k+2hSN0pc+L3K 8M0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=mYa7DkvdN6V8fXc+1NYYNi2TzdvZW308unychC3XbeM=; b=cqaA4I4rmVApqzztus4Xyx9vWWhHgbHRvWfThw7R7ies3VdrrXseVoNtQ0fHt0nFor d/SkwTgTemALYaq4xlr8C5wOa4F1gS/oh7Ck9vCOPCyg5bx78LdCZTJ/H95YpebycJig lHCV7ljN66dpi3CNIo6TAoZBxIHkxG9lp9rjWo2gZGvCQTXQwOU0wdzoMKjheIQ+hQn0 9lbl7RYTyCaPbEcCWGqvvbl1wrdemsBxOjsy57zkPKDIF3HX5EBm/ZVJFywkHcDIBvgA 1zb2URF3ZPR1H909CRz/zkKz+D5E4lcCUS+y60vZX2I0vA0da9GaCpKt7lHimC/03MN+ al2Q== X-Gm-Message-State: ALQs6tApn2ygWudKdt2Rdc4W/80VYPhLE9wHpXJeEn6j/akh2BqCPd/3 CLT1vw9vA8dxDVgY3cHeyLw= X-Google-Smtp-Source: AIpwx49m1SaHQIjXRF0jmmJhiu10fHUzjZolZSqu8q86bBIz71uZD59fhyqzQWkK31enz1cTplQzIg== X-Received: by 2002:a17:902:7793:: with SMTP id o19-v6mr90276pll.349.1523153281080; Sat, 07 Apr 2018 19:08:01 -0700 (PDT) Received: from localhost ([128.199.137.77]) by smtp.gmail.com with ESMTPSA id n7sm23876927pff.58.2018.04.07.19.07.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Apr 2018 19:08:00 -0700 (PDT) Date: Sun, 8 Apr 2018 10:07:54 +0800 From: Eryu Guan To: fdmanana@kernel.org Cc: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org, Filipe Manana Subject: Re: [PATCH] fstests: generic test for fsync after fallocate Message-ID: <20180408020754.GA2932@desktop> References: <20180405215614.611-1-fdmanana@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180405215614.611-1-fdmanana@kernel.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Apr 05, 2018 at 10:56:14PM +0100, fdmanana@kernel.org wrote: > From: Filipe Manana > > Test that fsync operations preserve extents allocated with fallocate(2) > that are placed beyond a file's size. > > This test is motivated by a bug found in btrfs where unwritten extents > beyond the inode's i_size were not preserved after a fsync and power > failure. The btrfs bug is fixed by the following patch for the linux > kernel: > > "Btrfs: fix loss of prealloc extents past i_size after fsync log replay" > > Signed-off-by: Filipe Manana Hmm, xfs fails this test, while ext4 passes. # diff -u tests/generic/483.out /root/workspace/xfstests/results//xfs_4k_crc/generic/483.out.bad I'm not sure what the problem is yet, but IMHO controlling on-disk layout of a file from userspace is hard and should be avoided if possible. Why not dumping md5sum to .out file like other dmflakey tests? I've checked the md5sum of all the three test files, and they're the same on xfs as on ext4, so the files are not corrupted on xfs. Thanks, Eryu > --- > tests/generic/482 | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++ > tests/generic/482.out | 10 +++++ > tests/generic/group | 1 + > 3 files changed, 129 insertions(+) > create mode 100755 tests/generic/482 > create mode 100644 tests/generic/482.out > > diff --git a/tests/generic/482 b/tests/generic/482 > new file mode 100755 > index 00000000..43bbc913 > --- /dev/null > +++ b/tests/generic/482 > @@ -0,0 +1,118 @@ > +#! /bin/bash > +# FSQA Test No. 482 > +# > +# Test that fsync operations preserve extents allocated with fallocate(2) that > +# are placed beyond a file's size. > +# > +#----------------------------------------------------------------------- > +# > +# Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved. > +# Author: Filipe Manana > +# > +# 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" > +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 > +. ./common/punch > + > +# real QA test starts here > +_supported_fs generic > +_supported_os Linux > +_require_scratch > +_require_dm_target flakey > +_require_xfs_io_command "falloc" "-k" > +_require_xfs_io_command "fiemap" > + > +rm -f $seqres.full > + > +_scratch_mkfs >>$seqres.full 2>&1 > +_require_metadata_journaling $SCRATCH_DEV > +_init_flakey > +_mount_flakey > + > +# Create our test files. > +$XFS_IO_PROG -f -c "pwrite -S 0xea 0 256K" $SCRATCH_MNT/foo >/dev/null > + > +# Create a file with many extents. We later want to shrink truncate it and > +# add a prealloc extent beyond its new size. > +for ((i = 1; i <= 500; i++)); do > + offset=$(((i - 1) * 4 * 1024)) > + $XFS_IO_PROG -f -s -c "pwrite -S 0xcf $offset 4K" \ > + $SCRATCH_MNT/bar >/dev/null > +done > + > +# A file which already has a prealloc extent beyond its size. > +# The fsync done on it is motivated by differences in the btrfs implementation > +# of fsync (first fsync has different logic from subsequent fsyncs). > +$XFS_IO_PROG -f -c "pwrite -S 0xf1 0 256K" \ > + -c "falloc -k 256K 768K" \ > + -c "fsync" \ > + $SCRATCH_MNT/baz >/dev/null > + > +# Make sure everything done so far is durably persisted. > +sync > + > +# Allocate an extent beyond the size of the first test file and fsync it. > +$XFS_IO_PROG -c "falloc -k 256K 1M"\ > + -c "fsync" \ > + $SCRATCH_MNT/foo > + > +# Do a shrinking truncate of our test file, add a prealloc extent to it after > +# its new size and fsync it. > +$XFS_IO_PROG -c "truncate 256K" \ > + -c "falloc -k 256K 1M"\ > + -c "fsync" \ > + $SCRATCH_MNT/bar > + > +# Allocate another extent beyond the size of file baz. > +$XFS_IO_PROG -c "falloc -k 1M 2M"\ > + -c "fsync" \ > + $SCRATCH_MNT/baz > + > +# Simulate a power failure and mount the filesystem to check that the extents > +# previously allocated were not lost. > +_flakey_drop_and_remount > + > +echo "File foo fiemap:" > +$XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/foo | _filter_fiemap > + > +echo "File bar fiemap:" > +$XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/bar | _filter_fiemap > + > +echo "File baz fiemap:" > +$XFS_IO_PROG -c "fiemap -v" $SCRATCH_MNT/baz | _filter_fiemap > + > +_unmount_flakey > +_cleanup_flakey > + > +status=0 > +exit > diff --git a/tests/generic/482.out b/tests/generic/482.out > new file mode 100644 > index 00000000..7e3ed139 > --- /dev/null > +++ b/tests/generic/482.out > @@ -0,0 +1,10 @@ > +QA output created by 482 > +File foo fiemap: > +0: [0..511]: data > +1: [512..2559]: unwritten > +File bar fiemap: > +0: [0..511]: data > +1: [512..2559]: unwritten > +File baz fiemap: > +0: [0..511]: data > +1: [512..6143]: unwritten > diff --git a/tests/generic/group b/tests/generic/group > index e8676062..58ac1f00 100644 > --- a/tests/generic/group > +++ b/tests/generic/group > @@ -484,3 +484,4 @@ > 479 auto quick metadata > 480 auto quick metadata > 481 auto quick log metadata > +482 auto quick log metadata > -- > 2.11.0 > > -- > 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 --- 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 --- tests/generic/483.out 2018-04-07 23:35:00.555555511 +0800 +++ /root/workspace/xfstests/results//xfs_4k_crc/generic/483.out.bad 2018-04-07 23:39:48.780659707 +0800 @@ -6,5 +6,5 @@ 0: [0..511]: data 1: [512..2559]: unwritten File baz fiemap: -0: [0..511]: data -1: [512..6143]: unwritten +0: [0..895]: data +1: [896..6143]: unwritten