From patchwork Sun Apr 8 07:46:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 10328221 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 62E7960365 for ; Sun, 8 Apr 2018 07:47:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5474F28E92 for ; Sun, 8 Apr 2018 07:47:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48BC328EE4; Sun, 8 Apr 2018 07:47:03 +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=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 A3EB72909F for ; Sun, 8 Apr 2018 07:47:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751803AbeDHHrA (ORCPT ); Sun, 8 Apr 2018 03:47:00 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:37476 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751526AbeDHHq7 (ORCPT ); Sun, 8 Apr 2018 03:46:59 -0400 Received: by mail-pf0-f193.google.com with SMTP id p6so200535pfn.4; Sun, 08 Apr 2018 00:46:59 -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=pIKbr/baon2T9jazi+zynHTZz9qwAbb3CKCoCvBddbg=; b=AZBVXJLmE86DgHMOwdnMf/7ADl5eMHl/0cbWRbGb/XKqOM/EwEDUnl5dTWXh5Br7wx le5jsItTpAb/FCqLlHS193hQX+gMLPXSHPYs2iOI8SBUK/0dy3x15YjspUNVCZsyFSo2 2tlMqAwnynhXhHx44mjIa5A7OPJhvHoc2jDCc+mgU9SNpFuYpQTifL8FhND2TBx724cF 3BbQAUtIy4Sp44gyPQwF0o3pjr1mQZPgwO++yJVqs3DtOR8lTkFE4yKViLlsmcrhKg3q ZFNacubM8t4CBLospIyGJp2CSnrUj+iynpWKvSzL76fQg3PQwisCKeCjBv1dMdlEry87 ftBw== 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=pIKbr/baon2T9jazi+zynHTZz9qwAbb3CKCoCvBddbg=; b=bYxm0/erD6DlBzDc7BXoX7ua8MqUkHi11laYnn1ArEH5Emft/BYeddXU6YS0+QtJXn YW3CRXA1twbDKVjNcEZudV9FoK/qM3+ZF40R223eHftH3LOz/bU3mUQgEbViPVCol4bB 54e4jWrclEiCfDq/DZjcn+FT4Fs2mli8ClL9KQR7GXzgilaKKRCcbOzpKkPi3Bhiyuhp Oc0ctHJ9kw2PWkNXFPrG2rDeVLl6Z5+bYUKI5WR/d//0Xqg/o+iiQk/+UlwbojzXpb43 06CNvPRqtCP9EgTHVYxm97DWDnk1edZsCc5ok65antdPwpTsQ2cgdBk3Vc7pX2r2TNgo I0jA== X-Gm-Message-State: ALQs6tDXI1m1VdRhiPBvxJeJLtyxNVKScmfPmSXs5kH2QuPuvgKlBQiC knprxpoNprz5iKY84HEuDaE= X-Google-Smtp-Source: AIpwx490ArB63TbLFUMs9hQCTOZO6CBJFu1j4bkM8GxrZyR6O5DXDj6rEMMxuozPwqdiJ/2UkLZP2A== X-Received: by 10.167.133.85 with SMTP id y21mr12256042pfn.139.1523173618634; Sun, 08 Apr 2018 00:46:58 -0700 (PDT) Received: from localhost ([128.199.137.77]) by smtp.gmail.com with ESMTPSA id d77sm29442188pfe.127.2018.04.08.00.46.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 08 Apr 2018 00:46:57 -0700 (PDT) Date: Sun, 8 Apr 2018 15:46:47 +0800 From: Eryu Guan To: fdmanana@kernel.org Cc: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org, Filipe Manana Subject: Re: [PATCH v2] fstests: test btrfs fsync after hole punching with no-holes mode Message-ID: <20180408074647.GC2932@desktop> References: <20180326225921.10096-1-fdmanana@kernel.org> <20180328115530.15563-1-fdmanana@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180328115530.15563-1-fdmanana@kernel.org> User-Agent: Mutt/1.9.2 (2017-12-15) 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 On Wed, Mar 28, 2018 at 12:55:30PM +0100, fdmanana@kernel.org wrote: > From: Filipe Manana > > Test that when we have the no-holes mode enabled and a specific metadata > layout, if we punch a hole and fsync the file, at replay time the whole > hole was preserved. > > This issue is fixed by the following btrfs patch for the linux kernel: > > "Btrfs: fix fsync after hole punching when using no-holes feature" > > Signed-off-by: Filipe Manana > --- > > V2: Made the test work when selinux is enabled, and made it use direct IO > writes to ensure 256K extents. Test fails with selinux enabled now on unpatched kernel. But I found that, in my release testing, test still fails when testing with current Linus tree (HEAD is 642e7fd23353, without selinux this time), which should contain the mentioned fix. Does that mean the bug is not fully fixed? I'll drop this patch for now. Thanks, Eryu > > tests/btrfs/159 | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > tests/btrfs/159.out | 9 ++++ > tests/btrfs/group | 1 + > 3 files changed, 125 insertions(+) > create mode 100755 tests/btrfs/159 > create mode 100644 tests/btrfs/159.out > > diff --git a/tests/btrfs/159 b/tests/btrfs/159 > new file mode 100755 > index 00000000..eb667692 > --- /dev/null > +++ b/tests/btrfs/159 > @@ -0,0 +1,115 @@ > +#! /bin/bash > +# FSQA Test No. 159 > +# > +# Test that when we have the no-holes mode enabled and a specific metadata > +# layout, if we punch a hole and fsync the file, at replay time the whole > +# hole was preserved. > +# > +#----------------------------------------------------------------------- > +# > +# 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 > + > +# real QA test starts here > +_supported_fs btrfs > +_supported_os Linux > +_require_scratch > +_require_dm_target flakey > +_require_xfs_io_command "fpunch" > +_require_odirect > + > +rm -f $seqres.full > + > +run_test() > +{ > + local punch_offset=$1 > + > + # We create the filesystem with a node size of 64Kb because we need to > + # create a specific metadata layout in order to trigger the bug we are > + # testing. At the moment the node size can not be smaller then the > + # system's page size, so given that the largest possible page size is > + # 64Kb and by default the node size is set to the system's page size > + # value, we explicitly create a filesystem with a 64Kb node size. > + _scratch_mkfs -O no-holes -n $((64 * 1024)) >>$seqres.full 2>&1 > + _require_metadata_journaling $SCRATCH_DEV > + _init_flakey > + _mount_flakey > + > + # Create our test file with 832 extents of 256Kb each. Before each > + # extent, there is a 256Kb hole (except for the first extent, which > + # starts at offset 0). This creates two leafs in the filesystem tree. > + # We use direct IO to ensure we get exactly 256K extents (with buffered > + # IO we can get writeback triggered at any time and therefore get > + # extents smaller than 256K). > + for ((i = 0; i <= 831; i++)); do > + local offset=$((i * 2 * 256 * 1024)) > + $XFS_IO_PROG -f -d -c "pwrite -S 0xab -b 256K $offset 256K" \ > + $SCRATCH_MNT/foobar >/dev/null > + done > + > + # Make sure everything done so far is durably persisted. > + sync > + > + # Now punch a hole that covers part of the extent at offset > + # "$punch_offset". > + # We want to punch a hole that starts in the middle of the last extent > + # item in the first leaf. On a system without selinux enabled that is > + # the extent that starts at offset 216530944, while on a system with it > + # enabled it is the extent that starts at offset 216006656 (because > + # selinux causes a xattr item to be added to our test file). > + $XFS_IO_PROG -c "fpunch $((punch_offset + 128 * 1024 - 4000)) 256K" \ > + -c "fsync" \ > + $SCRATCH_MNT/foobar > + > + echo "File digest before power failure:" > + md5sum $SCRATCH_MNT/foobar | _filter_scratch > + # Simulate a power failure and mount the filesystem to check that > + # replaying the fsync log/journal succeeds and our test file has the > + # expected content. > + _flakey_drop_and_remount > + echo "File digest after power failure and log replay:" > + md5sum $SCRATCH_MNT/foobar | _filter_scratch > + > + _unmount_flakey > + _cleanup_flakey > +} > + > +run_test 216006656 > +run_test 216530944 > + > +status=0 > +exit > diff --git a/tests/btrfs/159.out b/tests/btrfs/159.out > new file mode 100644 > index 00000000..a4be9182 > --- /dev/null > +++ b/tests/btrfs/159.out > @@ -0,0 +1,9 @@ > +QA output created by 159 > +File digest before power failure: > +f049865ed45b1991dc9a299b47d51dbf SCRATCH_MNT/foobar > +File digest after power failure and log replay: > +f049865ed45b1991dc9a299b47d51dbf SCRATCH_MNT/foobar > +File digest before power failure: > +c5c0a13588a639529c979c57c336f441 SCRATCH_MNT/foobar > +File digest after power failure and log replay: > +c5c0a13588a639529c979c57c336f441 SCRATCH_MNT/foobar > diff --git a/tests/btrfs/group b/tests/btrfs/group > index 8007e07e..ba766f6b 100644 > --- a/tests/btrfs/group > +++ b/tests/btrfs/group > @@ -161,3 +161,4 @@ > 156 auto quick trim > 157 auto quick raid > 158 auto quick raid scrub > +159 auto quick > -- > 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 linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- tests/btrfs/159.out 2018-04-03 18:25:41.566105514 -0700 +++ /root/xfstests/results//btrfs/159.out.bad 2018-04-08 00:28:26.921968949 -0700 @@ -6,4 +6,4 @@ File digest before power failure: c5c0a13588a639529c979c57c336f441 SCRATCH_MNT/foobar File digest after power failure and log replay: -c5c0a13588a639529c979c57c336f441 SCRATCH_MNT/foobar +c84746bbd1b97420f076d417a6a7d81c SCRATCH_MNT/foobar