From patchwork Sun May 28 16:32:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 9754793 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 C8B1A602BF for ; Tue, 30 May 2017 15:30:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9EEC223B3 for ; Tue, 30 May 2017 15:30:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AEDA3283F2; Tue, 30 May 2017 15:30:29 +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=-5.6 required=2.0 tests=BAYES_00, DATE_IN_PAST_24_48, 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 4EEA0274A3 for ; Tue, 30 May 2017 15:30:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750930AbdE3Pa1 (ORCPT ); Tue, 30 May 2017 11:30:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:46150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750796AbdE3Pa1 (ORCPT ); Tue, 30 May 2017 11:30:27 -0400 Received: from debian3.lan (bl12-226-64.dsl.telepac.pt [85.245.226.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8BEAD239EA; Tue, 30 May 2017 15:30:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8BEAD239EA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=fdmanana@kernel.org From: fdmanana@kernel.org To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH] generic: test for hole punching beyond eof followed by buffered writes Date: Sun, 28 May 2017 17:32:43 +0100 Message-Id: <20170528163243.32018-1-fdmanana@kernel.org> X-Mailer: git-send-email 2.11.0 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 From: Filipe Manana Test that if we punch a hole in a file that goes beyond the file's size and that if after we do some buffered write operations that cover different parts of the hole, no warnings are emmitted in syslog/dmesg and the file's content is correct after remounting the filesystem. This test is motivated by a bug in btrfs that is manifested in kernel 4.12-rc1 onwards (the bug existed long time ago but was not so easy to expose before 4.12-rc1). The btrfs patch that fixes the issue is titled: "Btrfs: fix invalid extent maps due to hole punching". Signed-off-by: Filipe Manana --- tests/generic/438 | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/438.out | 15 +++++++++++ tests/generic/group | 1 + 3 files changed, 86 insertions(+) create mode 100755 tests/generic/438 create mode 100644 tests/generic/438.out diff --git a/tests/generic/438 b/tests/generic/438 new file mode 100755 index 00000000..f1cbec7e --- /dev/null +++ b/tests/generic/438 @@ -0,0 +1,70 @@ +#! /bin/bash +# FS QA Test No. generic/438 +# +# Test that if we punch a hole in a file that goes beyond the file's size and +# that if after we do some buffered write operations that cover different parts +# of the hole, no warnings are emmitted in syslog/dmesg and the file's content +# is correct after remounting the filesystem. +# +#----------------------------------------------------------------------- +# +# Copyright (C) 2017 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() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_fs generic +_supported_os Linux +_require_test +_require_scratch +_require_xfs_io_command "fpunch" + +rm -f $seqres.full + +_scratch_mkfs >>$seqres.full 2>&1 +_scratch_mount + +$XFS_IO_PROG -f -c "pwrite -S 0xaa 0 100K" $SCRATCH_MNT/f | _filter_xfs_io +$XFS_IO_PROG -c "fpunch 60K 90K" $SCRATCH_MNT/f +$XFS_IO_PROG -c "pwrite -S 0xbb -b 100K 50K 100K" $SCRATCH_MNT/f | _filter_xfs_io +$XFS_IO_PROG -c "pwrite -S 0xcc -b 50K 100K 50K" $SCRATCH_MNT/f | _filter_xfs_io + +_scratch_cycle_mount + +echo "File contents after remounting filesystem:" +od -t x1 $SCRATCH_MNT/f + +status=0 +exit diff --git a/tests/generic/438.out b/tests/generic/438.out new file mode 100644 index 00000000..9712a872 --- /dev/null +++ b/tests/generic/438.out @@ -0,0 +1,15 @@ +QA output created by 438 +wrote 102400/102400 bytes at offset 0 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 102400/102400 bytes at offset 51200 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 51200/51200 bytes at offset 102400 +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +File contents after remounting filesystem: +0000000 aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa +* +0144000 bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb +* +0310000 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc +* +0454000 diff --git a/tests/generic/group b/tests/generic/group index 438c2990..34f176a9 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -440,3 +440,4 @@ 435 auto encrypt 436 auto quick rw 437 auto quick +438 auto quick punch