From patchwork Wed May 16 20:38:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10404831 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 29C28601C8 for ; Wed, 16 May 2018 20:39:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 180CF26E96 for ; Wed, 16 May 2018 20:39:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C95D2870D; Wed, 16 May 2018 20:39:27 +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_SIGNED, 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 8E6B426E96 for ; Wed, 16 May 2018 20:39:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751293AbeEPUj0 (ORCPT ); Wed, 16 May 2018 16:39:26 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:34183 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751259AbeEPUi6 (ORCPT ); Wed, 16 May 2018 16:38:58 -0400 Received: by mail-pf0-f194.google.com with SMTP id a14-v6so935892pfi.1 for ; Wed, 16 May 2018 13:38:58 -0700 (PDT) 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=gxbrkBFbXo+Bjz+VncgRkV7Je+1RgyVVxoGO+f1QjPM=; b=IqXPfoa5gmZSefX0x7nhb3ztNOVptA5ZLIX7INW7uTGHuj2yJk+BsoRLnM/E8DB3nX S0dohHbGbYWuMrjgJckJ8fHIAxFmAdgssiERuSJV1Jw9O3SHvxyJ5+hhrHXKBrlYSs9e GSH5uvseg4I1+oa7eSMxqMehG8vgwok5PqLXbruIXQrMdtf1zYuAHRR/FG10kW+g5nfz VhTh875fBCo7fZxBKz2TBfCWLvtAERFvJjYWCnX+C06Ba4SYVD+RYFAGrhdwPKH+36Yj L/FzXK35ZeQbP4gYKzYcpjHFsdWQDaFtGu805MzrZELK2VN+zjtyfZvdwHc/JbzupVRa +x5w== 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=gxbrkBFbXo+Bjz+VncgRkV7Je+1RgyVVxoGO+f1QjPM=; b=Z9XLvfNCAop9Zj2DWWTYRpJWnLtPEX/bO7JxkQtR2Ep8XOLrFODMJjlF8QmId3qYUg jbPKTD6AHDj6UbqI58rwKQ7F4e3rMtF5Locwb2Zbh3fdVqOc6jjlG8MqWdPBFS6NxBvG NwglF7G4NCA3m0JwbvUCgx+9SvrvnAIALZ7uFQn4KLWX1sU1DOU2zbk0W9qpfXUbBXU3 UA+g148V0Hbf7efepVv/8NEydCGhV2qQIXg11Woj28n6oIcyovX3M8vC8hJi/0xhh4uM MgIvfbpAvKbcnHHGKgTyv6w4+m9N6hg98MIOUhJnmwjHQoVY3SL+eQfap9GBpTtwELJ1 20hA== X-Gm-Message-State: ALKqPwfU8NkWBXKc+c648ANgA0h9x0hEmz0Sxk+TFm+XbXyd0Wvh+9/+ qa2pRIhi4D3Szm/zPeMUGiQ/4VcHBlA= X-Google-Smtp-Source: AB8JxZpPHympc+e9LNWG3omr2vx5Tb+yYT4R0P0C/4sK5i/APsFAOcAkyhgcnkuKgWGOFzFJX06YVA== X-Received: by 2002:a62:190f:: with SMTP id 15-v6mr2455410pfz.42.1526503137106; Wed, 16 May 2018 13:38:57 -0700 (PDT) Received: from vader.hsd1.wa.comcast.net ([2601:602:8800:a9a9:e6a7:a0ff:fe0b:c9a8]) by smtp.gmail.com with ESMTPSA id k8-v6sm3858768pga.94.2018.05.16.13.38.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 May 2018 13:38:56 -0700 (PDT) From: Omar Sandoval To: fstests@vger.kernel.org Cc: "Darrick J . Wong" , Eryu Guan , linux-btrfs@vger.kernel.org, linux-xfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 2/5] generic: enable swapfile tests on Btrfs Date: Wed, 16 May 2018 13:38:46 -0700 Message-Id: <80a5002310ab7f06efd9fed76cf268673e631335.1526503000.git.osandov@fb.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval Commit 8c96cfbfe530 ("generic/35[67]: disable swapfile tests on Btrfs") disabled the swapfile tests on Btrfs because it did not support swapfiles at the time. Now that we're adding support, we want these tests to run, but they don't. _require_scratch_swapfile always fails for Btrfs because swapfiles on Btrfs must be set to nocow. After fixing that, generic/356 and generic/357 fail for the same reason. After fixing _that_, both tests still fail because we don't allow reflinking a non-checksummed extent (which nocow implies) to a checksummed extent. Add a helper for formatting a swap file which does the chattr, and chattr the second file, which gets these tests running on kernels supporting Btrfs swapfiles. Signed-off-by: Omar Sandoval --- common/rc | 15 ++++++++++++--- tests/generic/356 | 7 ++++--- tests/generic/357 | 6 +++--- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/common/rc b/common/rc index ffe53236..814b8b5c 100644 --- a/common/rc +++ b/common/rc @@ -2222,6 +2222,17 @@ _require_odirect() rm -f $testfile 2>&1 > /dev/null } +_format_swapfile() { + local fname="$1" + local sz="$2" + + touch "$fname" + chmod 0600 "$fname" + $CHATTR_PROG +C "$fname" > /dev/null 2>&1 + _pwrite_byte 0x61 0 "$sz" "$fname" >> $seqres.full + mkswap -U 27376b42-ff65-42ca-919f-6c9b62292a5c "$fname" >> $seqres.full +} + # Check that the filesystem supports swapfiles _require_scratch_swapfile() { @@ -2231,10 +2242,8 @@ _require_scratch_swapfile() _scratch_mount # Minimum size for mkswap is 10 pages - local size=$(($(get_page_size) * 10)) + _format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10)) - _pwrite_byte 0x61 0 "$size" "$SCRATCH_MNT/swap" >/dev/null 2>&1 - mkswap "$SCRATCH_MNT/swap" >/dev/null 2>&1 if ! swapon "$SCRATCH_MNT/swap" >/dev/null 2>&1; then _scratch_unmount _notrun "swapfiles are not supported" diff --git a/tests/generic/356 b/tests/generic/356 index 51eeb652..b4a38f84 100755 --- a/tests/generic/356 +++ b/tests/generic/356 @@ -59,11 +59,12 @@ blocks=160 blksz=65536 echo "Initialize file" -echo >> $seqres.full -_pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file1 >> $seqres.full -mkswap -U 27376b42-ff65-42ca-919f-6c9b62292a5c $testdir/file1 >> $seqres.full +_format_swapfile "$testdir/file1" $((blocks * blksz)) swapon $testdir/file1 +touch "$testdir/file2" +$CHATTR_PROG +C "$testdir/file2" >/dev/null 2>&1 + echo "Try to reflink" _cp_reflink $testdir/file1 $testdir/file2 2>&1 | _filter_scratch diff --git a/tests/generic/357 b/tests/generic/357 index 0dd0c10f..9a83a283 100755 --- a/tests/generic/357 +++ b/tests/generic/357 @@ -59,9 +59,9 @@ blocks=160 blksz=65536 echo "Initialize file" -echo >> $seqres.full -_pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file1 >> $seqres.full -mkswap -U 27376b42-ff65-42ca-919f-6c9b62292a5c $testdir/file1 >> $seqres.full +_format_swapfile "$testdir/file1" $((blocks * blksz)) +touch "$testdir/file2" +$CHATTR_PROG +C "$testdir/file2" >/dev/null 2>&1 _cp_reflink $testdir/file1 $testdir/file2 2>&1 | _filter_scratch echo "Try to swapon"