From patchwork Wed May 16 16:56:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10404467 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 8BC6760155 for ; Wed, 16 May 2018 16:57:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C402204BF for ; Wed, 16 May 2018 16:57:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70F35285A6; Wed, 16 May 2018 16:57:12 +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 09296204BF for ; Wed, 16 May 2018 16:57:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750846AbeEPQ5L (ORCPT ); Wed, 16 May 2018 12:57:11 -0400 Received: from mail-pl0-f46.google.com ([209.85.160.46]:32793 "EHLO mail-pl0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750775AbeEPQ5L (ORCPT ); Wed, 16 May 2018 12:57:11 -0400 Received: by mail-pl0-f46.google.com with SMTP id n10-v6so776626plp.0 for ; Wed, 16 May 2018 09:57:10 -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=y704UzZ7BUMAAnBDHVlM1p4gqBmrsJS5IADUOdKZ3TM=; b=H1uN7dRxjmOWl3As8bRb3UViCnI0zniNWFRp5nXGYYB8E8GkERMFg6HQ0boN7bwlPh RH8jwYhYTMVblHmvB9GtjlJh/RsJpz2VttaOUY/G3Bog73UEBDjPQyzXTckqbIrSeaDN bOSTMAZ44fGMlKUCwMwSsNaTZCzIpvfuQONi6uLQKVhGFSrEi/Rj2UqN5KRiiuQBJ4hR /JtIAJkpRSLGWzkk8DoKHXvmbVpKndMzd5J/jIUN/fsGxAkhg2O30XyXIx7bWwDtKge7 sFHinhoY0lLia4lutA/t+giwSow4S238cg5kxQlhK/i3tjHcs+4XX3E1KSZGhnDPVykx Yyqg== 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=y704UzZ7BUMAAnBDHVlM1p4gqBmrsJS5IADUOdKZ3TM=; b=FAOoFPIlFDXu6XYCMF4w6alh8rZVwEwQy4S8t2AYUt3IZTBNNV3cFY74m8I/iiXWL+ Th8sVwUj2yu0xlR9RBoAejAb5lNIRfPNv9a97IYeysVmphpoSImiErQh+DFsj6pqWPdN WdEei55cNUEz61foLBQOOA4AnXXpuuvGR0eh0waRmO+e/BuXomPcYnpa+Su1otxz4Go1 L6QDI5mCEDH3k88orx9Qwbn86GsaOpy10FvJejy/S3558IMLGx5UvLdrBSyWPTpQ9tBf dTOGRCuPiEUFdpL1WJ9wJE7JzWWPIT4YYcjK8H5JMUGNNii/N63ESvcgXzub2rpKAIrZ ngig== X-Gm-Message-State: ALKqPwdeHCzbgPDz1g/xJCOKPIgw9QwIOuWP/HROKVAz92Z5hP6moxwN CMIVtqflEAiHzr5xAPe0tsQn5bh9dH8= X-Google-Smtp-Source: AB8JxZpjXLfYAg5+AROey5Jzd7UxX81BYjIcqVOsLoClAna0SDbgjJ1e10aJ/zvBiuJWdkOgqA3ZyA== X-Received: by 2002:a17:902:683:: with SMTP id 3-v6mr1689711plh.291.1526489829979; Wed, 16 May 2018 09:57:09 -0700 (PDT) Received: from vader.hsd1.wa.comcast.net ([2601:602:8800:a9a9:e6a7:a0ff:fe0b:c9a8]) by smtp.gmail.com with ESMTPSA id s2-v6sm5364751pfb.127.2018.05.16.09.57.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 May 2018 09:57:09 -0700 (PDT) From: Omar Sandoval To: fstests@vger.kernel.org Cc: "Darrick J . Wong" , Eryu Guan , kernel-team@fb.com Subject: [PATCH 3/4] generic: add test for truncate/fpunch of an active swapfile Date: Wed, 16 May 2018 09:56:59 -0700 Message-Id: <010b6acf3614654416718713fdcccab192a2be4e.1526489529.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 These should not be allowed. Signed-off-by: Omar Sandoval --- tests/generic/489 | 77 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/489.out | 8 +++++ tests/generic/group | 1 + 3 files changed, 86 insertions(+) create mode 100755 tests/generic/489 create mode 100644 tests/generic/489.out diff --git a/tests/generic/489 b/tests/generic/489 new file mode 100755 index 00000000..a38f7dcb --- /dev/null +++ b/tests/generic/489 @@ -0,0 +1,77 @@ +#! /bin/bash +# FS QA Test 489 +# +# Test truncation/hole punching of an active swapfile. +# +#----------------------------------------------------------------------- +# Copyright (c) 2018 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.* +} + +. ./common/rc +. ./common/filter + +rm -f $seqres.full + +_supported_fs generic +_supported_os Linux +_require_scratch_swapfile +_require_xfs_io_command "fpunch" + +echo "Format and mount" +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +mkdir $testdir + +blocks=160 +blksz=65536 + +echo "Initialize file" +touch "$testdir/file1" +chmod 0600 "$testdir/file1" +chattr +C "$testdir/file1" >/dev/null 2>&1 +_pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file1 >> $seqres.full +mkswap -U 27376b42-ff65-42ca-919f-6c9b62292a5c $testdir/file1 >> $seqres.full +swapon $testdir/file1 + +echo "Try to truncate" +$XFS_IO_PROG -c "truncate $blksz" $testdir/file1 + +echo "Try to punch hole" +$XFS_IO_PROG -c "fpunch $blksz $((2 * blksz))" $testdir/file1 + +echo "Tear it down" +swapoff $testdir/file1 + +status=0 +exit diff --git a/tests/generic/489.out b/tests/generic/489.out new file mode 100644 index 00000000..e2ebc530 --- /dev/null +++ b/tests/generic/489.out @@ -0,0 +1,8 @@ +QA output created by 489 +Format and mount +Initialize file +Try to truncate +ftruncate: Text file busy +Try to punch hole +fallocate: Text file busy +Tear it down diff --git a/tests/generic/group b/tests/generic/group index 6266213e..daba9073 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -491,3 +491,4 @@ 486 auto quick attr 487 auto quick 488 auto quick +489 auto quick