From patchwork Fri Nov 2 21:29:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10666203 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 8F71717DF 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 811112B30C for ; Fri, 2 Nov 2018 21:30:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7594A2B6F5; 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 1586B2B30C for ; Fri, 2 Nov 2018 21:30:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728273AbeKCGi7 (ORCPT ); Sat, 3 Nov 2018 02:38:59 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:37622 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728265AbeKCGi7 (ORCPT ); Sat, 3 Nov 2018 02:38:59 -0400 Received: by mail-it1-f195.google.com with SMTP id e74-v6so5076067ita.2 for ; Fri, 02 Nov 2018 14:30:12 -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=m5BROwurQKxczGsj4fbck9Sm2kxpwdnTNwXP0TSnM/Q=; b=jZNu/xsrLTHV/usJ/NccmGwYetRzYCkBGMzJPRaS+RXm2kGZGjQw6KYwe654zLOBe0 2XunczJmF1qQb4fbntXHwBQgJUHTGrlEVmfdPwwNxz5dAwbSLuj1CDmAVP7P/0EH4fAb Pf1QIISgtYKhXYJcevc/EExcKWcGkHtfJeQh9+td1EacpEo2Wr55hsevElhx+dF8SpbX Q9jLY2mZS+AImdVfYhGPIkFHv7F89NHusGmApP0NF9j2Xiq4WfE0XR865U5SECAtnxvj 5QJBlSX2PTDesKvoVPgyUH9UlNjtLEHJ2fRlfJB+v//dq8YQsXlJR8ST/M92tFSEHRKE pejg== 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=m5BROwurQKxczGsj4fbck9Sm2kxpwdnTNwXP0TSnM/Q=; b=b3RzQhmwqhdZHjePLBO+9A24n9isc/H5Zt59nC2zFtCVuMMNigNxN6/LvayBAiUa7p 6bWpy5q5O9URIGtAg5sN1rFdkuknSQdGyoadXyMrSAsQhiNcg6wzriZ/vr3ffDvzF8Or ZmKKH3FrhP39i5CVpUwi0/JdBK1vchoA+TwrAnXar5LR2HOb3EBjMc5SzzLt7/EQ6mUZ Jm+uHM1DUJvIun0e2zqSGV+U2JDx6oA3I3tzFPnug3TmlLVDhBkGByMx977/T4z4D2nf 6Yvz8PmzLTme1Z+YYE/Ymf3IxWdDFrjR33YApbhOki/O08j7oy6ER5uGUoAdaxE4qucM L4yg== X-Gm-Message-State: AGRZ1gKyU6o8Y0p3+QE+dXL8DhN2DNHgmX1VSA8V9KDCSVzyWzjidA0k AnAfsFnk9yd8no0pN9WTXvQHv4NSqwg= X-Google-Smtp-Source: AJdET5eGNytvkYSuq8Z50y/lglN8O3bKKH1iGw4FRdjX433N2jtiQM7cYy4oS2JE1iQbkbt/1VgsFQ== X-Received: by 2002:a02:2b29:: with SMTP id h41-v6mr11470226jaa.12.1541194211724; Fri, 02 Nov 2018 14:30:11 -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.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Nov 2018 14:30:11 -0700 (PDT) From: Omar Sandoval To: fstests@vger.kernel.org Cc: kernel-team@fb.com, linux-btrfs@vger.kernel.org Subject: [PATCH 2/7] generic/{472,496}: fix swap file creation on Btrfs Date: Fri, 2 Nov 2018 14:29:37 -0700 Message-Id: <6da5f398715af4f7478554920470a85e8a186b50.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 The swap file must be set nocow before it is written to, otherwise it is ignored and Btrfs refuses to activate it as swap. Fixes: 25ce9740065e ("generic: test swapfile creation, activation, and deactivation") Signed-off-by: Omar Sandoval --- tests/generic/472 | 14 ++++++-------- tests/generic/496 | 6 +++--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/generic/472 b/tests/generic/472 index 04ed3e73..aba4a007 100755 --- a/tests/generic/472 +++ b/tests/generic/472 @@ -42,13 +42,15 @@ _scratch_mount >>$seqres.full 2>&1 swapfile=$SCRATCH_MNT/swap len=$((2 * 1048576)) -page_size=$(get_page_size) swapfile_cycle() { local swapfile="$1" + local len="$2" + touch $swapfile # Swap files must be nocow on Btrfs. $CHATTR_PROG +C $swapfile >> $seqres.full 2>&1 + _pwrite_byte 0x58 0 $len $swapfile >> $seqres.full "$here/src/mkswap" $swapfile >> $seqres.full "$here/src/swapon" $swapfile 2>&1 | _filter_scratch swapoff $swapfile 2>> $seqres.full @@ -57,20 +59,16 @@ swapfile_cycle() { # Create a regular swap file echo "regular swap" | tee -a $seqres.full -_pwrite_byte 0x58 0 $len $swapfile >> $seqres.full -swapfile_cycle $swapfile +swapfile_cycle $swapfile $len # Create a swap file with a little too much junk on the end echo "too long swap" | tee -a $seqres.full -_pwrite_byte 0x58 0 $((len + 3)) $swapfile >> $seqres.full -swapfile_cycle $swapfile +swapfile_cycle $swapfile $((len + 3)) # Create a ridiculously small swap file. Each swap file must have at least # two pages after the header page. echo "tiny swap" | tee -a $seqres.full -tiny_len=$((page_size * 3)) -_pwrite_byte 0x58 0 $tiny_len $swapfile >> $seqres.full -swapfile_cycle $swapfile +swapfile_cycle $swapfile $(($(get_page_size) * 3)) status=0 exit diff --git a/tests/generic/496 b/tests/generic/496 index 968b8012..3083eef0 100755 --- a/tests/generic/496 +++ b/tests/generic/496 @@ -49,8 +49,6 @@ page_size=$(get_page_size) swapfile_cycle() { local swapfile="$1" - # Swap files must be nocow on Btrfs. - $CHATTR_PROG +C $swapfile >> $seqres.full 2>&1 "$here/src/mkswap" $swapfile >> $seqres.full "$here/src/swapon" $swapfile 2>&1 | _filter_scratch swapoff $swapfile 2>> $seqres.full @@ -59,8 +57,10 @@ swapfile_cycle() { # Create a fallocated swap file echo "fallocate swap" | tee -a $seqres.full -$XFS_IO_PROG -f -c "falloc 0 $len" $swapfile >> $seqres.full +touch $swapfile +# Swap files must be nocow on Btrfs. $CHATTR_PROG +C $swapfile >> $seqres.full 2>&1 +$XFS_IO_PROG -f -c "falloc 0 $len" $swapfile >> $seqres.full "$here/src/mkswap" $swapfile "$here/src/swapon" $swapfile >> $seqres.full 2>&1 || \ _notrun "fallocated swap not supported here"