From patchwork Thu May 3 17:49:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10378793 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 5FA5E60541 for ; Thu, 3 May 2018 17:49:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42FE029207 for ; Thu, 3 May 2018 17:49:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3704529209; Thu, 3 May 2018 17:49:42 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 636D529207 for ; Thu, 3 May 2018 17:49:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D5456B0007; Thu, 3 May 2018 13:49:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6AB7E6B0009; Thu, 3 May 2018 13:49:40 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 572C46B000A; Thu, 3 May 2018 13:49:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f200.google.com (mail-qt0-f200.google.com [209.85.216.200]) by kanga.kvack.org (Postfix) with ESMTP id 317446B0007 for ; Thu, 3 May 2018 13:49:40 -0400 (EDT) Received: by mail-qt0-f200.google.com with SMTP id y7-v6so13952674qtn.3 for ; Thu, 03 May 2018 10:49:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:references:mime-version:content-disposition:in-reply-to :user-agent; bh=/aV9RLP2wzARH+l2RW8yqbPGuL4m+kDuR4uw9SXpArQ=; b=XcXZ2rlhp45C4hUEYDOYDwGulyEd3bOsbyv++eKkPmq6APi94GV8rV1clXpL0GTkEy LN+ar/bubg5rZDsz+vkmY0nqCfu8C2hHNVwA2+CwPt8LZtW0u+Nju/dVLUfJ7WT6XrBT Tbc33VPe9bVTtajXAKZzct59tJKn3dy1rLTAoIkzhjJCYIQYi4JZ/RpROVux/q04IfsF hU7SWCdTH3w2Fiy6+TugDQ69KNNqOeyFWZqIVn7ez18vFiGdR6zcp+uL9BoJ28WkCAd2 /3idiHEDUmm9Q1U/YCHiq2jLuWBfyHz5mbSr67pc2SgLeFyRlNmFPMAZ5KT/XYlm2bty X94Q== X-Gm-Message-State: ALQs6tAYovmBb2TKOAGB7FlV2pXmncDcuv+D8SJmQHzevbCGXNSIjgo+ M6hn/rsPCPoACqWmrKCOPGcFrAMR+6qFhy4pdfw/SGcYQOSRhZIzvlNAePPJP5F25A/Vcr3mIkR 9MkEaMvs3n86enBzHEoW/mfvH3Lnlmd1m1efWY+y1krcUvXeL0AXS/F4FmAUJVBSqVg== X-Received: by 10.55.76.74 with SMTP id z71mr15871061qka.44.1525369779918; Thu, 03 May 2018 10:49:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqwt4QGXmFfy2XtarNepRyKyrKaRB/iZD4TMmnk1v6jnhpDqhE7QI8STkSyFUdZe2/hlxjr X-Received: by 10.55.76.74 with SMTP id z71mr15871012qka.44.1525369779059; Thu, 03 May 2018 10:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525369779; cv=none; d=google.com; s=arc-20160816; b=S8u6ARllwzqYj13JM2KeW/Y1DhdzVv97qcKPmGt5/MyaidgUs0f5pcwGme2wkRkyKp EtG+mfAPnSz/Hq7Q0gOR7ktIjYB1wrXGICK20eFElRb/3X3SLZwfWYLITE3rxB3JJXm2 VhUBNHoRVxjB1hwFT00GjUq6mCcFxoGf1Z57qlMn8faWzyRNCgi/NE4RLEvPlpCkD65q M3UX/J8jv2IFXtFcUPNWCesd9sfZ8Xjfp3N4XXfCNNUPkzRnkyOuBt5eNrZP47oYotnL SgOXZXl1j5RRr2VnYgVGL8ETwSm2us3mLWXzKEemV8zYsSRDGfSsRl2UVcMsSkSG+EK6 ioiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=/aV9RLP2wzARH+l2RW8yqbPGuL4m+kDuR4uw9SXpArQ=; b=vcN5Y5XUb+OzQQV7H8BJo3VMZ2IXG0N7Jk4PLBnpoF9jx75UHJkfacsgTxLxHPviLl O0P7fgQhxSuYIq7FS9QnaBlp+14BGqfQIl4Qm/v/BNAg05xnJ25T6E2vLxsYNrDYVBfE P/li+Kgs+cUvZVjPfPzuBhUQ0MlPfkSZTUEF1IDOd/R+Y0fjRvCC9LNzlhU+M/04wJID lCUpO26OLFfl0jiGPIiiHAORGkjRAxqm8An6RMmM5S+w9hUbqNTZkyY8HLfOnFNRcAOx h0p00KQGKaC4XBVaA8r2SpjOUUDCBjjdx8f1/mPGOK9d/xN2QwsHYE6GkC0oVpE4Ya3N TRWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=WUVGsaCR; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2120.oracle.com (userp2120.oracle.com. [156.151.31.85]) by mx.google.com with ESMTPS id 62-v6si8551792qvc.255.2018.05.03.10.49.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 10:49:39 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) client-ip=156.151.31.85; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=WUVGsaCR; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w43HjnBs024907; Thu, 3 May 2018 17:49:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2017-10-26; bh=/aV9RLP2wzARH+l2RW8yqbPGuL4m+kDuR4uw9SXpArQ=; b=WUVGsaCRuFw3tfnRg++mcdEfp3U/HPFW1/vRjup/AAhpVvmkuk8xAk8a30kdC6h9tfeV d09H15y0zHOfgxOfPRAoSwvzYs2O8eITy/9bJv2QhPh1Glee4sh+mvKv7Tu589FZmyjd DP3ROijpz3POfhxqdtWdhOhfyFXMvKPpoBxLA7TMQhQ1kHKFBYta+pSJ0AO4g4OBX+kV PsQBvZsn8wPh0Iy14AURCjfW57Na1FQGeTLDfdYWiaw6zlCPvHiOggRxOzmU/Y0Hhetb 765SID4Za2TXq6UMC6EEAW4oI61qK7p2jIc11DRWvVhQnYtxWVMM6SYUH2bBbDZAImrL Ew== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2hmhmftw3q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 03 May 2018 17:49:19 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w43HnG8E010477 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 3 May 2018 17:49:18 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w43HnEmP006813; Thu, 3 May 2018 17:49:14 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 03 May 2018 10:49:13 -0700 Date: Thu, 3 May 2018 10:49:12 -0700 From: "Darrick J. Wong" To: xfs , linux-fsdevel , linux-mm@kvack.org Cc: hch@infradead.org, cyberax@amazon.com, jack@suse.cz, osandov@osandov.com, Eryu Guan , fstests Subject: [PATCH v3 2/2] generic: test swapfile creation, activation, and deactivation Message-ID: <20180503174912.GE4127@magnolia> References: <20180503174659.GD4127@magnolia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180503174659.GD4127@magnolia> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8882 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805030153 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Test swapfile activation and deactivation. Signed-off-by: Darrick J. Wong --- tests/generic/708 | 150 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/708.out | 10 +++ tests/generic/group | 1 3 files changed, 161 insertions(+) create mode 100755 tests/generic/708 create mode 100644 tests/generic/708.out diff --git a/tests/generic/708 b/tests/generic/708 new file mode 100755 index 00000000..1c576b39 --- /dev/null +++ b/tests/generic/708 @@ -0,0 +1,150 @@ +#! /bin/bash +# FS QA Test No. 708 +# +# Test various swapfile activation oddities. +# +#----------------------------------------------------------------------- +# Copyright (c) 2018 Oracle. 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" + +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $testfile +} + +# 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 generic +_supported_os Linux +_require_scratch_swapfile + +rm -f $seqres.full +_scratch_mkfs >>$seqres.full 2>&1 +_scratch_mount >>$seqres.full 2>&1 + +swapfile=$SCRATCH_MNT/swap +len=$((2 * 1048576)) + +swapfile_cycle() { + local swapfile="$1" + + mkswap $swapfile >> $seqres.full + filefrag -v $swapfile >> $seqres.full + swapon $swapfile 2>&1 | _filter_scratch + swapon -v --bytes >> $seqres.full + swapoff $swapfile 2>> $seeqres.full + rm -f $swapfile +} + +test_can_falloc_swap() { + local test_swapfile=$TEST_DIR/swapfile + + echo "can we fallocate swap?" + $XFS_IO_PROG -f -c "falloc 0 64k" $test_swapfile + test -f $test_swapfile || return 1 + mkswap $test_swapfile + swapon $test_swapfile + res=$? + swapoff $test_swapfile + rm -f $test_swapfile + return $res +} + +unset can_falloc_swap +test_can_falloc_swap >> $seqres.full 2>&1 && can_falloc_swap=yes +page_size=$(get_page_size) + +# Create a sparse swap file +echo "sparse swap" | tee -a $seqres.full +$XFS_IO_PROG -f -c "truncate $len" $swapfile >> $seqres.full +swapfile_cycle $swapfile + +# Create a regular swap file +echo "regular swap" | tee -a $seqres.full +_pwrite_byte 0x58 0 $len $swapfile >> $seqres.full +swapfile_cycle $swapfile + +# Create a fallocated swap file +echo "fallocate swap" | tee -a $seqres.full +if [ -n "$can_falloc_swap" ]; then + $XFS_IO_PROG -f -c "falloc 0 $len" $swapfile >> $seqres.full + swapfile_cycle $swapfile +fi + +# 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 + +# Create a swap file with a large discontiguous range(?) +echo "large discontig swap" | tee -a $seqres.full +_pwrite_byte 0x58 0 $((len * 2)) $swapfile >> $seqres.full +old_sz="$(stat -c '%s' $swapfile)" +$XFS_IO_PROG -c "fcollapse $((len / 2)) $len" $swapfile >> $seqres.full 2>&1 +new_sz="$(stat -c '%s' $swapfile)" +if [ $old_sz -gt $new_sz ]; then + swapfile_cycle $swapfile +fi +rm -f $swapfile + +# Create a swap file with a small discontiguous range(?) +echo "small discontig swap" | tee -a $seqres.full +_pwrite_byte 0x58 0 $((len + 1024)) $swapfile >> $seqres.full +old_sz="$(stat -c '%s' $swapfile)" +$XFS_IO_PROG -c "fcollapse 66560 1024" $swapfile >> $seqres.full 2>&1 +new_sz="$(stat -c '%s' $swapfile)" +if [ $old_sz -gt $new_sz ]; then + swapfile_cycle $swapfile +fi +rm -f $swapfile + +# Create a fallocated swap file and touch every other $PAGE_SIZE to create +# a mess of written/unwritten extent records +echo "mixed swap" | tee -a $seqres.full +if [ -n "$can_falloc_swap" ]; then + $XFS_IO_PROG -f -c "falloc 0 $len" $swapfile >> $seqres.full + seq $page_size $((page_size * 2)) $len | while read offset; do + _pwrite_byte 0x58 $offset 1 $swapfile >> $seqres.full + done + swapfile_cycle $swapfile +fi + +# Create a ridiculously small swap file; mkswap says the minimum is 40k. +echo "tiny swap" | tee -a $seqres.full +tiny_len=40960 +if [ "$page_size" -gt "$tiny_len" ]; then + tiny_len=$page_size +fi +_pwrite_byte 0x58 0 $tiny_len $swapfile >> $seqres.full +swapfile_cycle $swapfile + +status=0 +exit diff --git a/tests/generic/708.out b/tests/generic/708.out new file mode 100644 index 00000000..d6199b99 --- /dev/null +++ b/tests/generic/708.out @@ -0,0 +1,10 @@ +QA output created by 708 +sparse swap +swapon: SCRATCH_MNT/swap: skipping - it appears to have holes. +regular swap +fallocate swap +too long swap +large discontig swap +small discontig swap +mixed swap +tiny swap diff --git a/tests/generic/group b/tests/generic/group index 49f5cbe1..94cbcee9 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -489,3 +489,4 @@ 484 auto quick 600 auto quick insert 706 auto quick attr +708 auto quick swapfile