From patchwork Fri Nov 2 21:29:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10666207 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA35513B5 for ; Fri, 2 Nov 2018 21:30:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD0242B4F1 for ; Fri, 2 Nov 2018 21:30:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C166D2B51A; Fri, 2 Nov 2018 21:30:14 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 64EDD2B5C1 for ; Fri, 2 Nov 2018 21:30:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728265AbeKCGjA (ORCPT ); Sat, 3 Nov 2018 02:39:00 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:40608 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728271AbeKCGjA (ORCPT ); Sat, 3 Nov 2018 02:39:00 -0400 Received: by mail-it1-f195.google.com with SMTP id e11so1798373itl.5 for ; Fri, 02 Nov 2018 14:30:13 -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 :mime-version:content-transfer-encoding; bh=gjAp51U3ifmg7JidLZjofYnOVIERTT3c+O16DBDrf0o=; b=J0jh2ZCOaUtghrsSdyyeE3/taEK5VVjiNqgcTWboUZCLEUjezqnPASvTCDw4qahvtH hnYfH0169xpE7/77kAJjPLp118ym5eptgAetkVNOdp1Z2btrJVoZHWDicgAEEYOAr8LG aIwHyMzpkH3RktRtr0TcOmtaVh1+/fk7Ez+zl8orEiSxrrpbP+PFaPtHWee0slMsyEBD 5xyN1lwoS2HPh943ZExr+RU70jzac+IpavUPDYoCJC4lB1U00f9r1O0iADOXpOe4D6qP HyQP9g2Uhd6RszY5kgrGB84e1nc1e17mmtpH9FHEt1ifVcY+z6OdMy8/INMadMXB9RVb jEYw== 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:mime-version:content-transfer-encoding; bh=gjAp51U3ifmg7JidLZjofYnOVIERTT3c+O16DBDrf0o=; b=jr6AAOLeJhaQiJflisO/a44b85bjr7Pt7sVR47UQGYSLC75mSKCNoUzNAgRbbWDKfE QyVMMwRrWX388H21UGnv31EC7PeRzvj48YDa7O/en4YqpVsAfCOQr++W4YwRDPg/s4TE tLzADKCY7OBoSNP8gaEpSFfBiGbcalraXYsMGOIJIaPieU7ZB9zECMOvttt5hVMV/cOA aVuCoGotEzveQt1HSWxJg8yqzLHM/fMsaPdsT6/2kGY/WsEvGl7YbfprkJU4p+YQEj7C RqqkArW3aoYtOwxyNJktESLyNTWYoTZhn/7/NXKKggPFcrhH7T8XBydsa+4osz9Txmgx Zi9Q== X-Gm-Message-State: AGRZ1gKbt+U84PbeUm7uYfiju5VKWyEkZGqvm6XUPNOwpp/HXmiRSpBL +MgGyHwo81RSBJnn9zzMoY1LH0vRIU4= X-Google-Smtp-Source: AJdET5dGuckXyhnDFdOYsNPE3hwpvpg6laqhCPgseJ+50pWta0afgjy3oQB9jEa3qMMfFSiFHvCZfQ== X-Received: by 2002:a05:660c:611:: with SMTP id i17mr270580itk.117.1541194212701; Fri, 02 Nov 2018 14:30:12 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::4:e24f]) by smtp.gmail.com with ESMTPSA id n130-v6sm929419itb.36.2018.11.02.14.30.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Nov 2018 14:30:12 -0700 (PDT) From: Omar Sandoval To: fstests@vger.kernel.org Cc: kernel-team@fb.com, linux-btrfs@vger.kernel.org Subject: [PATCH 3/7] btrfs: test swap file activation restrictions Date: Fri, 2 Nov 2018 14:29:38 -0700 Message-Id: <9eeea2eecff0b9fad27f49c082e987232edb40c0.1541193856.git.osandov@fb.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 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 Swap files on Btrfs have some restrictions not applicable to other filesystems. Signed-off-by: Omar Sandoval --- tests/btrfs/173 | 55 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/173.out | 5 +++++ tests/btrfs/group | 1 + 3 files changed, 61 insertions(+) create mode 100755 tests/btrfs/173 create mode 100644 tests/btrfs/173.out diff --git a/tests/btrfs/173 b/tests/btrfs/173 new file mode 100755 index 00000000..665bec39 --- /dev/null +++ b/tests/btrfs/173 @@ -0,0 +1,55 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2018 Facebook. All Rights Reserved. +# +# FS QA Test 173 +# +# Test swap file activation restrictions specific to Btrfs. +# +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.* +} + +. ./common/rc +. ./common/filter + +rm -f $seqres.full + +_supported_fs generic +_supported_os Linux +_require_scratch_swapfile + +_scratch_mkfs >> $seqres.full 2>&1 +_scratch_mount + +echo "COW file" +# We can't use _format_swapfile because we don't want chattr +C, and we can't +# unset it after the swap file has been created. +rm -f "$SCRATCH_MNT/swap" +touch "$SCRATCH_MNT/swap" +chmod 0600 "$SCRATCH_MNT/swap" +_pwrite_byte 0x61 0 $(($(get_page_size) * 10)) "$SCRATCH_MNT/swap" >> $seqres.full +mkswap "$SCRATCH_MNT/swap" >> $seqres.full +swapon "$SCRATCH_MNT/swap" 2>&1 | _filter_scratch +swapoff "$SCRATCH_MNT/swap" >/dev/null 2>&1 + +echo "Compressed file" +rm -f "$SCRATCH_MNT/swap" +_format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10)) +$CHATTR_PROG +c "$SCRATCH_MNT/swap" +swapon "$SCRATCH_MNT/swap" 2>&1 | _filter_scratch +swapoff "$SCRATCH_MNT/swap" >/dev/null 2>&1 + +status=0 +exit diff --git a/tests/btrfs/173.out b/tests/btrfs/173.out new file mode 100644 index 00000000..6d7856bf --- /dev/null +++ b/tests/btrfs/173.out @@ -0,0 +1,5 @@ +QA output created by 173 +COW file +swapon: SCRATCH_MNT/swap: swapon failed: Invalid argument +Compressed file +swapon: SCRATCH_MNT/swap: swapon failed: Invalid argument diff --git a/tests/btrfs/group b/tests/btrfs/group index a490d7eb..3525014f 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -175,3 +175,4 @@ 170 auto quick snapshot 171 auto quick qgroup 172 auto quick punch +173 auto quick swap