From patchwork Tue May 22 23:33: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: 10419737 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 16FE06016C for ; Tue, 22 May 2018 23:34:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05FB828EB3 for ; Tue, 22 May 2018 23:34:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EEB4F28EBB; Tue, 22 May 2018 23:34:25 +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=unavailable 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 9451428EC6 for ; Tue, 22 May 2018 23:34:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753516AbeEVXeW (ORCPT ); Tue, 22 May 2018 19:34:22 -0400 Received: from mail-pf0-f182.google.com ([209.85.192.182]:35897 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753507AbeEVXeS (ORCPT ); Tue, 22 May 2018 19:34:18 -0400 Received: by mail-pf0-f182.google.com with SMTP id w129-v6so9512575pfd.3 for ; Tue, 22 May 2018 16:34:18 -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=/YVldN/cCuN3ppx46UzqZsHTQ9lz05Uyi2KzHDpdKck=; b=CkTyrWCJshDfAu2S8Gpabg+IXb4DaDSsc2McPnNE4U7iNtayPk5PAaK9RxJcy09AL3 RgfIIdavqJW2lQ+PAESEzJ1hfS9pFniLBsl41AMLBBqLE2aSryr7Zu57cDqPPHrs+PYX VNKdWv3zOzP1g6eFAgpcvUkhf6AYeEnFcMx969srMo3hzTEnpNSbcaeo/Fy7CkEcJrV/ TglP2nL9Kjz+ELQt9+wR7zoRaCrhR+3FKT/BA7yV5nL8I6gTlvWcC1hP4DDj6BlJb5V8 yoAXaTEp4uiPXPHAOjOttdj6BhUfn3yJxUxvU65AbYPrxjubeV8l+5F0O8B6AgIYJh7s Ibwg== 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=/YVldN/cCuN3ppx46UzqZsHTQ9lz05Uyi2KzHDpdKck=; b=Szzd4PYmqSAhDy93i1fEjKEOO1fhdATODmwrm8cGmOXeW4lVqiRziaASZ+F1wSgbhq vPE/R5I7jWVuqgxyG4FXYpTiKR5Z2CBmDqiKlapkgmWZGOCZvL3k/AkWG+uUasVBmYNB hbi6wvkGl96ch0R+P4IHPkuD8T0FB7mYymiuqLZhq24UlBSWpTnJe48j9+PQI6qrihzC mkL1bxvrRzpbKKGjaFbAbiNSOxULfuOGLiMKEgWOw4FXaJNcQEHecgJ4Dh0KVmFkm8Xq F8pWsyVnNBeDDaCH/EFSHeSsRLTxy8Qs7JB1/e4rwoIYeVaPbwyHLGAacZYYeBqgSkGs 45QA== X-Gm-Message-State: ALKqPweqRfuG9flhgvUHFGN84TYDoonSijzjcmV7Fz6vyMoSDCLQA/gX z1CdvmLnCao+JIopy2S9wrl9LQDWN+A= X-Google-Smtp-Source: AB8JxZrxzfyhLroHEm1cM22D0mR6jKPuh0M2k+NJi9FzSqbTjNDOPm5laW7pYSyP+xzcL3r1fsFRMw== X-Received: by 2002:a63:4207:: with SMTP id p7-v6mr383112pga.163.1527032057759; Tue, 22 May 2018 16:34:17 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::7:5b87]) by smtp.gmail.com with ESMTPSA id t28-v6sm35522928pfk.161.2018.05.22.16.34.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 16:34:16 -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 v3 4/5] generic: add test for truncate/fpunch of an active swapfile Date: Tue, 22 May 2018 16:33:59 -0700 Message-Id: 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/493 | 73 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/493.out | 8 +++++ tests/generic/group | 1 + 3 files changed, 82 insertions(+) create mode 100755 tests/generic/493 create mode 100644 tests/generic/493.out diff --git a/tests/generic/493 b/tests/generic/493 new file mode 100755 index 00000000..eba62dcb --- /dev/null +++ b/tests/generic/493 @@ -0,0 +1,73 @@ +#! /bin/bash +# FS QA Test 493 +# +# 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" +_format_swapfile "$testdir/file1" $((blocks * blksz)) +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/493.out b/tests/generic/493.out new file mode 100644 index 00000000..929a76b6 --- /dev/null +++ b/tests/generic/493.out @@ -0,0 +1,8 @@ +QA output created by 493 +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 dc5adf04..9778930a 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -495,3 +495,4 @@ 490 auto quick rw 491 auto quick freeze mount 492 auto quick swap +493 auto quick swap