From patchwork Fri Feb 17 06:54:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9578901 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 04E5760586 for ; Fri, 17 Feb 2017 06:55:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB063286A1 for ; Fri, 17 Feb 2017 06:55:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAC72286AA; Fri, 17 Feb 2017 06:55:47 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, 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 68C38286A7 for ; Fri, 17 Feb 2017 06:55:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755628AbdBQGzm (ORCPT ); Fri, 17 Feb 2017 01:55:42 -0500 Received: from mail-pg0-f41.google.com ([74.125.83.41]:33900 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755588AbdBQGzk (ORCPT ); Fri, 17 Feb 2017 01:55:40 -0500 Received: by mail-pg0-f41.google.com with SMTP id z67so13182080pgb.1 for ; Thu, 16 Feb 2017 22:55:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=k2rKaiX9yJLspa30V9NB3StZyOuxe83lLKuoA+mUwUk=; b=yeE6VOn1AF7UXSeadkmp1aSLwJJu1rIqa6zqcS1KGieD/9GgFoHyNHFJRVpbxHRLhZ usOIHh7Al1HQeYf9b1me32ufSOh8y6qdljbRbPx9IBz4CNyps4x89sUIYhylJzZdYVCj 3fsAqQyn1lBEdN33d9jVRit/9nfpv0KhiW7nSzBYBjzdVt4ZAZfxg+p69grFA2WTasfO /Voq3+cXTM+980Kq5qgk3C/+nlG0SX3Lf8uvoUpgkpxZgewTJIMVd2yhM6AfMQH6r82a Y19osqYIbVvEgZab9ySarcK8dWAaOvkZtG5A7Um/XYd3cWjCu9QjOpwBzWTB8ty0WJEE FmuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=k2rKaiX9yJLspa30V9NB3StZyOuxe83lLKuoA+mUwUk=; b=XQUaJ3/Q6CEftW+dH+szJK4o/wTvwlZxekIkLyP8J2Ic9L35Sh/SLNsJIrYLriIQj4 5H50Ro53NaURE/cqv5sHwbCyQstBYYK7O1LCUXGX8KWxb5TT5Xr1zxr5FcjfM4mgwlBv lvDexfq+O8G5/oYqfZq9AFSgDkd3IfpQDns23PktIWUUsEm6ACP7vYWftLUFWhb8lmAG Y2avwWZzr1hUiNkT4qZ1+8p91VaItYo+NS1b4PMD470eKenL+D8bCdTxH1ecciVvNnGR IvdHy9+edu10T/XZe92ykXKj5vt6G0bsda54Zu4YfpRexwDEaCji+5VKwKhyrWMsXH1K WKIw== X-Gm-Message-State: AMke39mXxmSf1WEf7NfdsNKY9uVk7pRu6eCwr1H1cvIZXlohGO42Iaq3yeN3cAoFSbnV6ZYW X-Received: by 10.99.8.133 with SMTP id 127mr8224087pgi.42.1487314539125; Thu, 16 Feb 2017 22:55:39 -0800 (PST) Received: from localhost.localdomain ([2601:602:8801:8110:e6a7:a0ff:fe0b:c9a8]) by smtp.gmail.com with ESMTPSA id t22sm17154090pfa.114.2017.02.16.22.55.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 22:55:38 -0800 (PST) From: Omar Sandoval To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 2/2] btrfs: test decompression in the middle of large extents Date: Thu, 16 Feb 2017 22:54:52 -0800 Message-Id: <8298fa62e0746a394ee26924ee3c69accd7f1841.1487314416.git.osandov@fb.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <7e55bbd20c8e6515e0b76b1ee4c348fb6066c502.1487314416.git.osandov@fb.com> References: <7e55bbd20c8e6515e0b76b1ee4c348fb6066c502.1487314416.git.osandov@fb.com> In-Reply-To: <7e55bbd20c8e6515e0b76b1ee4c348fb6066c502.1487314416.git.osandov@fb.com> References: <7e55bbd20c8e6515e0b76b1ee4c348fb6066c502.1487314416.git.osandov@fb.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 From: Omar Sandoval This is a regression test for "Btrfs: fix btrfs_decompress_buf2page()". It fails for zlib on v4.10-rc[1-7]. Signed-off-by: Omar Sandoval --- Changed from v1: - Remove from quick group - Handle compress features in sysfs generically - Require btrfs property command common/btrfs | 8 +++++ tests/btrfs/137 | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/137.out | 2 ++ tests/btrfs/group | 1 + 4 files changed, 108 insertions(+) create mode 100755 tests/btrfs/137 create mode 100644 tests/btrfs/137.out diff --git a/common/btrfs b/common/btrfs index 96c3635b..b342644c 100644 --- a/common/btrfs +++ b/common/btrfs @@ -364,3 +364,11 @@ _reload_btrfs_ko() modprobe -r btrfs || _fail "btrfs unload failed" modprobe btrfs || _fail "btrfs load failed" } + +_btrfs_compression_algos() +{ + echo zlib + for feature in /sys/fs/btrfs/features/compress_*; do + echo "${feature#/sys/fs/btrfs/features/compress_}" + done +} diff --git a/tests/btrfs/137 b/tests/btrfs/137 new file mode 100755 index 00000000..d5e4774b --- /dev/null +++ b/tests/btrfs/137 @@ -0,0 +1,97 @@ +#! /bin/bash +# FS QA Test 137 +# +# Test decompression in the middle of large extents. Regression test for Linux +# kernel commit 6e78b3f7a193 ("Btrfs: fix btrfs_decompress_buf2page()"). +# +#----------------------------------------------------------------------- +# Copyright (c) 2017 Facebook. 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 + +_supported_fs btrfs +_supported_os Linux +_require_scratch +_require_btrfs_command property + +algos=($(_btrfs_compression_algos)) + +_scratch_mkfs >>$seqres.full 2>&1 +_scratch_mount +# Need 1GB for the uncompressed file plus <1GB for each compressed file. +_require_fs_space $SCRATCH_MNT $((1024 * 1024 * (1 + ${#algos[@]}))) + +# Checksum a piece in the middle of the file. This hits the unaligned case that +# caused the original bug. +do_csum() +{ + dd if="$1" bs=4K skip=555 count=100 2>>$seqres.full| md5sum | cut -d ' ' -f 1 +} + +# Create a large, uncompressed (but compressible) file. +touch "${SCRATCH_MNT}/uncompressed" +$BTRFS_UTIL_PROG property set "${SCRATCH_MNT}/uncompressed" compression "" +_ddt of="${SCRATCH_MNT}/uncompressed" bs=1M count=1K 2>&1 | _filter_dd + +csum="$(do_csum "${SCRATCH_MNT}/uncompressed")" + +for algo in ${algos[@]}; do + echo "Testing ${algo}" >> $seqres.full + + # Copy the same data, but with compression enabled. + touch "${SCRATCH_MNT}/${algo}" + $BTRFS_UTIL_PROG property set "${SCRATCH_MNT}/${algo}" compression "${algo}" + dd if="${SCRATCH_MNT}/uncompressed" of="${SCRATCH_MNT}/${algo}" bs=1M 2>&1 | _filter_dd + + # The correct data is likely still cached. Cycle the mount to drop the + # cache and start fresh. + _scratch_cycle_mount + + # Check the checksum. + compressed_csum="$(do_csum "${SCRATCH_MNT}/${algo}")" + if [ "${compressed_csum}" != "${csum}" ]; then + echo "Checksum mismatch for ${algo} (expected ${csum}, got ${compressed_csum})" + fi +done + +echo "Silence is golden" + +status=0 +exit diff --git a/tests/btrfs/137.out b/tests/btrfs/137.out new file mode 100644 index 00000000..eb48dd21 --- /dev/null +++ b/tests/btrfs/137.out @@ -0,0 +1,2 @@ +QA output created by 137 +Silence is golden diff --git a/tests/btrfs/group b/tests/btrfs/group index ea88ba4e..a8d1851d 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -139,3 +139,4 @@ 134 auto quick send 135 auto quick send 136 auto convert +137 auto compress