From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7DD5C4320E for ; Thu, 19 Aug 2021 01:43:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 28EC5610FA for ; Thu, 19 Aug 2021 01:43:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 28EC5610FA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 313078D0001; Wed, 18 Aug 2021 21:43:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C3736B0071; Wed, 18 Aug 2021 21:43:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B36C8D0001; Wed, 18 Aug 2021 21:43:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0120.hostedemail.com [216.40.44.120]) by kanga.kvack.org (Postfix) with ESMTP id F1EBD6B006C for ; Wed, 18 Aug 2021 21:43:28 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 81737807C4E9 for ; Thu, 19 Aug 2021 01:43:28 +0000 (UTC) X-FDA: 78490132896.27.466F37C Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf21.hostedemail.com (Postfix) with ESMTP id 1FF3AD00C743 for ; Thu, 19 Aug 2021 01:43:28 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 257D3610A6; Thu, 19 Aug 2021 01:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629337407; bh=GC3zQLwOCTXI1Hy8arlkjDvFnmMVXirkECLD9NWUEK8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Bhr/l2gh1DWFy643i6FLr5pk+Lfa1MGvmI3G1CV5wpNoFsP29zKcOoQVo6bz0yetv QOK6EWOvg4y1LgXvpXKj341N2p04UZ6df2EWFj02+0+lpXv29wbWy4Gz3i7qTEKeLt yD4CWmV5Xck5zmkcy8nlMSWyekzFI7gjgDz3ZrEunvLtIjPQzSvPJAL1QuHbzooS0j g7v8ZxrpodgVfmr3y2eIKWmAeQWrjr/VDJtBZ9yaHAieiBF/bzP76ZNnEZL/rdgt3B bWe2USL7Aq7ja1h5jZt9tDT0IjsGzTDDsj28KmbZ6dme8DjPeBtIePW6BP2e8iwN+B z9Lq45wygPGaQ== Date: Wed, 18 Aug 2021 18:43:26 -0700 From: "Darrick J. Wong" To: Xu Yu Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, hch@infradead.org, riteshh@linux.ibm.com, tytso@mit.edu, gavin.dg@linux.alibaba.com, fstests , linux-btrfs Subject: [PATCH] generic: add swapfile maxpages regression test Message-ID: <20210819014326.GC12597@magnolia> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Bhr/l2gh"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of djwong@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=djwong@kernel.org X-Stat-Signature: 9rmpuhfwfwycwggj9fesh684bmqkcn7h X-Rspamd-Queue-Id: 1FF3AD00C743 X-Rspamd-Server: rspam01 X-HE-Tag: 1629337408-359840 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: From: Darrick J. Wong Add regression test for "mm/swap: consider max pages in iomap_swapfile_add_extent". Cc: Gang Deng Cc: Xu Yu Signed-off-by: Darrick J. Wong --- tests/generic/727 | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/727.out | 2 ++ 2 files changed, 64 insertions(+) create mode 100755 tests/generic/727 create mode 100644 tests/generic/727.out diff --git a/tests/generic/727 b/tests/generic/727 new file mode 100755 index 00000000..a546ad51 --- /dev/null +++ b/tests/generic/727 @@ -0,0 +1,62 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Oracle. All Rights Reserved. +# +# FS QA Test 727 +# +# Regression test for "mm/swap: consider max pages in iomap_swapfile_add_extent" + +# Xu Yu found that the iomap swapfile activation code failed to constrain +# itself to activating however many swap pages that the mm asked us for. This +# is an deviation in behavior from the classic swapfile code. It also leads to +# kernel memory corruption if the swapfile is cleverly constructed. +# +. ./common/preamble +_begin_fstest auto swap + +# Override the default cleanup function. +_cleanup() +{ + cd / + rm -f $tmp.* + test -n "$swapfile" && swapoff $swapfile &> /dev/null +} + +# real QA test starts here +_supported_fs generic +_require_scratch_swapfile + +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +# Assuming we're not borrowing a FAT16 partition from Windows 3.1, we need an +# unlikely enough name that we can grep /proc/swaps for this. +swapfile=$SCRATCH_MNT/386spart.par +_format_swapfile $swapfile 1m >> $seqres.full + +swapfile_pages() { + local swapfile="$1" + + grep "$swapfile" /proc/swaps | awk '{print $3}' +} + +_swapon_file $swapfile +before_pages=$(swapfile_pages "$swapfile") +swapoff $swapfile + +# Extend the length of the swapfile but do not rewrite the header. +# The subsequent swapon should set up 1MB worth of pages, not 2MB. +$XFS_IO_PROG -f -c 'pwrite 1m 1m' $swapfile >> $seqres.full + +_swapon_file $swapfile +after_pages=$(swapfile_pages "$swapfile") +swapoff $swapfile + +# Both swapon attempts should have found the same number of pages. +test "$before_pages" -eq "$after_pages" || \ + echo "swapon added $after_pages pages, expected $before_pages" + +# success, all done +echo Silence is golden +status=0 +exit diff --git a/tests/generic/727.out b/tests/generic/727.out new file mode 100644 index 00000000..2de2b4b2 --- /dev/null +++ b/tests/generic/727.out @@ -0,0 +1,2 @@ +QA output created by 727 +Silence is golden