From patchwork Mon Jan 18 06:20:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12026615 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 A2281C433E9 for ; Mon, 18 Jan 2021 06:21:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8018F22513 for ; Mon, 18 Jan 2021 06:21:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731743AbhARGVk (ORCPT ); Mon, 18 Jan 2021 01:21:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730841AbhARGV0 (ORCPT ); Mon, 18 Jan 2021 01:21:26 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ED54C061574; Sun, 17 Jan 2021 22:20:46 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id x12so8060514plr.10; Sun, 17 Jan 2021 22:20:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tuRANglPuvCThAaGoAF4a7CUchGXxnbMIAXQeoen4YY=; b=u6KW9T/G74mpydMLG6YddGoO+q5F/lOOeOlCIJYGQSx5Jovp/YUofHU+i6/ITAeWVG 665MKqBv4J4xYPVVNKmFWgpDGcO6Xe6NIFVQ1ZBPVvZWPeQfD8Aru0TtoxVTh3GE8T+H Y8f3LDf602LDvPDc39D3QxpGvrcq16GoxHzCO+AGcaCdgmpYz8vAL/gpo/LnpT7Ja25J JV0d5vk0KUYqbgUgLuVPzq+aOrgdmbazGIGMbdLyAwvfsM3o+Gp8MhJVK/6qlBKWb9zC PeDferzpw/h9QKKFH8VtzpjmW2co82k8ilsm7SH2ZJ6XB3t6nO4rvvd6hfc34oIkxUrb C4aA== 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=tuRANglPuvCThAaGoAF4a7CUchGXxnbMIAXQeoen4YY=; b=U0tXTLF9TRRfz46lmlZQutY/UaYWLvNuLR0g68R9hrCcI6kcOrzDEvzXJsyhXAgDg0 odOIRtKy8h0SJjcA72PUe5c4KwjbVDE+yVw77GCk7z++innst2uwXS8xNDnBbT6T2rs2 3er1cIbOsvRk5LvpENHH6Lxw3fsNeCX58Gtq0sZFTiymxmK2Xz67kUsdSksAxVnEj4HP xUyKkHaweDhtSPuY5mzNZKyd990sU/cQ79eV4SJqRWis1kwM2k0B5Wxj4pLuiY7zW4nA NNNdhBrb/xN31zo11V88Twk05Bg9GWTpCByEq+7Oujr751+3DZGR9CejtLKok03z1Ri3 f99w== X-Gm-Message-State: AOAM533H8LhJ9Rt6twUJTPP/804OjzLLZU/ixPiWgC8RrpTlrpbLB2Fh CRQ4gXRixqKUZ7tZwEBsIJu5mjQmsoY= X-Google-Smtp-Source: ABdhPJyUKfwur8DwFpRj3oRIq/rY7xj9jQqCTGDOtihfCUKm+KwUd14zwpU3nRiWyPG9OZY//Q5dqA== X-Received: by 2002:a17:90a:8508:: with SMTP id l8mr23676379pjn.131.1610950845962; Sun, 17 Jan 2021 22:20:45 -0800 (PST) Received: from localhost.localdomain ([122.179.96.31]) by smtp.gmail.com with ESMTPSA id t1sm14608423pfq.154.2021.01.17.22.20.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 22:20:45 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com, djwong@kernel.org Subject: [PATCH V4 01/11] common/xfs: Add a helper to get an inode fork's extent count Date: Mon, 18 Jan 2021 11:50:12 +0530 Message-Id: <20210118062022.15069-2-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118062022.15069-1-chandanrlinux@gmail.com> References: <20210118062022.15069-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit adds the helper _scratch_get_iext_count() which returns an inode fork's extent count. Signed-off-by: Chandan Babu R --- common/xfs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/common/xfs b/common/xfs index 3f5c14ba..641d6195 100644 --- a/common/xfs +++ b/common/xfs @@ -903,6 +903,28 @@ _scratch_get_bmx_prefix() { return 1 } +_scratch_get_iext_count() +{ + ino=$1 + whichfork=$2 + + case $whichfork in + "attr") + field=core.naextents + ;; + "data") + field=core.nextents + ;; + *) + return 1 + esac + + nextents=$(_scratch_xfs_db -c "inode $ino" -c "print $field") + nextents=${nextents##${field} = } + + echo $nextents +} + # # Ensures that we don't pass any mount options incompatible with XFS v4 # From patchwork Mon Jan 18 06:20:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12026617 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 21EC3C433E6 for ; Mon, 18 Jan 2021 06:22:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E34B92256F for ; Mon, 18 Jan 2021 06:22:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730994AbhARGVm (ORCPT ); Mon, 18 Jan 2021 01:21:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731533AbhARGV3 (ORCPT ); Mon, 18 Jan 2021 01:21:29 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3EF4C061575; Sun, 17 Jan 2021 22:20:48 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id t6so8083761plq.1; Sun, 17 Jan 2021 22:20:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PiR5XrPCo/8xBvKQBroN3k2T97ViDnryhS0HS238Hls=; b=ipM311vg29EgSI2l/OoABjfl4peqVJUfi/nB6hE5azNYH4UZ5H9Ijo28RF6p4RwkQW QO2Y06tBSkwBJBCNI9oxNK2lRzG0oMhkHxWMbLPDS6NiZWwtgGaVzCvRnQecMIXHw22m Kru8li2oN6SJdQ6e1uL2BlkyuOSOmaRw+cQFVyrFmLS5yyM4TI4qmhIEEFFLnjnFrT1j fGZ68a8fEp7gKGFI7jxY6YOxPwkzWSuVCj7WoK4K7bPT8V7a6ccz2WlFpBks6TW0dmHm m5KENSXd/gGpSFfImerbzKpf61eWatDrS6AtQT7yfTJi1c1WBYJqx1jrjsaMrOhmtu3R dfbg== 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=PiR5XrPCo/8xBvKQBroN3k2T97ViDnryhS0HS238Hls=; b=CKhsAebLfnGrjKbHj6PIp+94iwZ7iWWEWQhQBM26+g0ZUHb67a6rPpRCkK4YXChw7Y CIUiPV6zNgRlf7YYskP4sPwMJw+h1imHXhlYyH4vHqpqd9IAbFkUxStuAx81IQGSjHlp oJCdLrf+U6kF6c0/QNEvmhZWlZz9ExBGX2ParXpYZx1UsvUYt/P0q6bMg6vXq1iEhU09 ngdg7IA0feCI4xJzhoadf82de6hMtI9vPVS/XC27O2E/ASQeAasZmW6bTmsWdXSvn2h5 evWZBaiFo6wDArv51tReFt5PA7VGBIep5QZcNMkr9XGs0+TOnFDf8hVFLUe2Vil91cK2 c3Vg== X-Gm-Message-State: AOAM533A9GDf/hSKAsvpavNsqd9TeSSa4LmPOpTrOY+Cyct4eXseS4BL LIb55EDPaq1HcjPUnp/cg2jI9c8tFfI= X-Google-Smtp-Source: ABdhPJyIck67e6xUi/cLcmkT6qxvBrB0v1egA4gzaSAOlmQQbYoVTc3F/LjcdwiFlLzpiE/TvMbQ1g== X-Received: by 2002:a17:90a:4cc5:: with SMTP id k63mr24412960pjh.202.1610950848316; Sun, 17 Jan 2021 22:20:48 -0800 (PST) Received: from localhost.localdomain ([122.179.96.31]) by smtp.gmail.com with ESMTPSA id t1sm14608423pfq.154.2021.01.17.22.20.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 22:20:47 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com, djwong@kernel.org Subject: [PATCH V4 02/11] xfs: Check for extent overflow when trivally adding a new extent Date: Mon, 18 Jan 2021 11:50:13 +0530 Message-Id: <20210118062022.15069-3-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118062022.15069-1-chandanrlinux@gmail.com> References: <20210118062022.15069-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This test verifies that XFS does not cause inode fork's extent count to overflow when adding a single extent while there's no possibility of splitting an existing mapping. Signed-off-by: Chandan Babu R --- tests/xfs/522 | 173 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/522.out | 20 ++++++ tests/xfs/group | 1 + 3 files changed, 194 insertions(+) create mode 100755 tests/xfs/522 create mode 100644 tests/xfs/522.out diff --git a/tests/xfs/522 b/tests/xfs/522 new file mode 100755 index 00000000..33f0591e --- /dev/null +++ b/tests/xfs/522 @@ -0,0 +1,173 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 522 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# adding a single extent while there's no possibility of splitting an existing +# mapping. + +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.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota +. ./common/inject +. ./common/populate + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_quota +_require_xfs_debug +_require_test_program "punch-alternating" +_require_xfs_io_command "falloc" +_require_xfs_io_error_injection "reduce_max_iextents" +_require_xfs_io_error_injection "bmap_alloc_minlen_extent" + +echo "Format and mount fs" +_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full +_scratch_mount -o uquota >> $seqres.full + +bsize=$(_get_file_block_size $SCRATCH_MNT) + +echo "* Delalloc to written extent conversion" + +testfile=$SCRATCH_MNT/testfile + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +nr_blks=$((15 * 2)) + +echo "Create fragmented file" +for i in $(seq 0 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -s -c "pwrite $((i * bsize)) $bsize" $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +echo "Verify \$testfile's extent count" + +nextents=$($XFS_IO_PROG -f -c 'stat' $testfile | grep -i nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm $testfile + +echo "* Fallocate unwritten extents" + +echo "Fallocate fragmented file" +for i in $(seq 0 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -c "falloc $((i * bsize)) $bsize" $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +echo "Verify \$testfile's extent count" + +nextents=$($XFS_IO_PROG -f -c 'stat' $testfile | grep -i nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm $testfile + +echo "* Directio write" + +echo "Create fragmented file via directio writes" +for i in $(seq 0 2 $((nr_blks - 1))); do + $XFS_IO_PROG -d -s -f -c "pwrite $((i * bsize)) $bsize" $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +echo "Verify \$testfile's extent count" + +nextents=$($XFS_IO_PROG -f -c 'stat' $testfile | grep -i nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm $testfile + +echo "* Extend quota inodes" + +echo "Disable reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 0 + +echo "Consume free space" +fillerdir=$SCRATCH_MNT/fillerdir +nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT) +nr_free_blks=$((nr_free_blks * 90 / 100)) + +_fill_fs $((bsize * nr_free_blks)) $fillerdir $bsize 0 >> $seqres.full 2>&1 + +echo "Create fragmented filesystem" +for dentry in $(ls -1 $fillerdir/); do + $here/src/punch-alternating $fillerdir/$dentry >> $seqres.full +done + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Inject bmap_alloc_minlen_extent error tag" +_scratch_inject_error bmap_alloc_minlen_extent 1 + +nr_blks=20 + +# This is a rough calculation; It doesn't take block headers into +# consideration. +# gdb -batch vmlinux -ex 'print sizeof(struct xfs_dqblk)' +# $1 = 136 +nr_quotas_per_block=$((bsize / 136)) +nr_quotas=$((nr_quotas_per_block * nr_blks)) + +echo "Extend uquota file" +for i in $(seq 0 $nr_quotas_per_block $nr_quotas); do + chown $i $testfile >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +_scratch_unmount >> $seqres.full + +echo "Verify uquota inode's extent count" +uquotino=$(_scratch_xfs_db -c sb -c "print uquotino") +uquotino=${uquotino##uquotino = } + +nextents=$(_scratch_get_iext_count $uquotino data || \ + _fail "Unable to obtain inode fork's extent count") +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +# success, all done +status=0 +exit diff --git a/tests/xfs/522.out b/tests/xfs/522.out new file mode 100644 index 00000000..debeb004 --- /dev/null +++ b/tests/xfs/522.out @@ -0,0 +1,20 @@ +QA output created by 522 +Format and mount fs +* Delalloc to written extent conversion +Inject reduce_max_iextents error tag +Create fragmented file +Verify $testfile's extent count +* Fallocate unwritten extents +Fallocate fragmented file +Verify $testfile's extent count +* Directio write +Create fragmented file via directio writes +Verify $testfile's extent count +* Extend quota inodes +Disable reduce_max_iextents error tag +Consume free space +Create fragmented filesystem +Inject reduce_max_iextents error tag +Inject bmap_alloc_minlen_extent error tag +Extend uquota file +Verify uquota inode's extent count diff --git a/tests/xfs/group b/tests/xfs/group index b89c0a4e..1831f0b5 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -519,3 +519,4 @@ 519 auto quick reflink 520 auto quick reflink 521 auto quick realtime growfs +522 auto quick quota From patchwork Mon Jan 18 06:20:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12026621 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 48A28C433E9 for ; Mon, 18 Jan 2021 06:22:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2621D22838 for ; Mon, 18 Jan 2021 06:22:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731683AbhARGVv (ORCPT ); Mon, 18 Jan 2021 01:21:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731648AbhARGVb (ORCPT ); Mon, 18 Jan 2021 01:21:31 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3882CC061757; Sun, 17 Jan 2021 22:20:51 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id o20so1194408pfu.0; Sun, 17 Jan 2021 22:20:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dXh8gdoNbv/TtTkdd1We3ZVSTXnfbEKXi6TBqGYv5vk=; b=WSRSwP4wMT4B8DyoOm2I3d4yRsPDYPeuPTAnVdLJK/cPKz/GaORSSQxuL9fgXR5Pcj PuloPYApHXnmF/9PxvHC3/i3JoRK9QY/9VKD/niRg6wFov8k/C0YdBMqNR1b7skxvNRq GgQqtPPFdI97AYjqzkk/NFviwjotk1RuG0AxpEzNw2xEVup5RTd6/o6AdcrUon9wpboD ZMQi+NhHzaVXJYIQ6cDlaYarxEo92m1OfbYFlea4lb8LBHwxEnNm0DNnY8Z/qoZLo53G yDx8XsusHaQLsSogGHVHEe2tUIFpxkrRm7SI/MzvvBb0+nYAp0WR/VKaJp0GY+a3twm0 2FqQ== 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=dXh8gdoNbv/TtTkdd1We3ZVSTXnfbEKXi6TBqGYv5vk=; b=RxTGxqFBOxxLdmvM0bvR1mX7NEaohV2Uwoomp5Bf02JS1WHtBFeCNHYhCxBMdiIT5l sOZXAbLvJs0wnVDuA/IgevlJ+95pQV8pLy5B7LR7ao83HJiMl5p+kQoW0+AqD7ZuXIyl kbG9XtbX+pFDMc7Q60vhkK0QPIGZR8uovGuBN1qo3Gc5iGyddCef5IiSARS7LFc456IJ pVgD+DglGyRLWFEu6+8leVBi1JpTXBf7JRguaXNPnwQK5gcPwTgTkHNGlMIo49n3WuMv 6Xjv/2v0HeYlP8/yBVs61dTocnSP28HYFsxUTKtlhIXlIUCZaP7e5i4Pp9gYIfUGoKNG MDZQ== X-Gm-Message-State: AOAM530fQfQRDOPu7kmrSUPMJLVsCWQ/0btLVvtfOPSjfGNUKewa/nLS 0/waCmmdspqqbBmNYsv2a13Q/4V64GU= X-Google-Smtp-Source: ABdhPJyySGJm195v14QJk2p1j2zjuQb+BDsXugK7xGSkcweqv0Z6nGP04peAkAMU/K1rBM8qr/dogw== X-Received: by 2002:a63:4b5c:: with SMTP id k28mr24207244pgl.294.1610950850641; Sun, 17 Jan 2021 22:20:50 -0800 (PST) Received: from localhost.localdomain ([122.179.96.31]) by smtp.gmail.com with ESMTPSA id t1sm14608423pfq.154.2021.01.17.22.20.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 22:20:50 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com, djwong@kernel.org Subject: [PATCH V4 03/11] xfs: Check for extent overflow when growing realtime bitmap/summary inodes Date: Mon, 18 Jan 2021 11:50:14 +0530 Message-Id: <20210118062022.15069-4-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118062022.15069-1-chandanrlinux@gmail.com> References: <20210118062022.15069-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Verify that XFS does not cause realtime bitmap/summary inode fork's extent count to overflow when growing the realtime volume associated with a filesystem. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- tests/xfs/523 | 119 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/523.out | 11 +++++ tests/xfs/group | 1 + 3 files changed, 131 insertions(+) create mode 100755 tests/xfs/523 create mode 100644 tests/xfs/523.out diff --git a/tests/xfs/523 b/tests/xfs/523 new file mode 100755 index 00000000..145f0ff6 --- /dev/null +++ b/tests/xfs/523 @@ -0,0 +1,119 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 523 +# +# Verify that XFS does not cause bitmap/summary inode fork's extent count to +# overflow when growing an the realtime volume of the filesystem. +# +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 / + _scratch_unmount >> $seqres.full 2>&1 + test -e "$rtdev" && losetup -d $rtdev >> $seqres.full 2>&1 + rm -f $tmp.* $TEST_DIR/$seq.rtvol +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/inject +. ./common/populate + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_test +_require_xfs_debug +_require_test_program "punch-alternating" +_require_xfs_io_error_injection "reduce_max_iextents" +_require_xfs_io_error_injection "bmap_alloc_minlen_extent" +_require_scratch_nocheck + +echo "* Test extending rt inodes" + +_scratch_mkfs | _filter_mkfs >> $seqres.full 2> $tmp.mkfs +. $tmp.mkfs + +echo "Create fake rt volume" +nr_bitmap_blks=25 +nr_bits=$((nr_bitmap_blks * dbsize * 8)) +rtextsz=$dbsize +rtdevsz=$((nr_bits * rtextsz)) +truncate -s $rtdevsz $TEST_DIR/$seq.rtvol +rtdev=$(_create_loop_device $TEST_DIR/$seq.rtvol) + +echo "Format and mount rt volume" + +export USE_EXTERNAL=yes +export SCRATCH_RTDEV=$rtdev +_scratch_mkfs -d size=$((1024 * 1024 * 1024)) \ + -r size=2M,extsize=${rtextsz} >> $seqres.full +_scratch_mount >> $seqres.full + +echo "Consume free space" +fillerdir=$SCRATCH_MNT/fillerdir +nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT) +nr_free_blks=$((nr_free_blks * 90 / 100)) + +_fill_fs $((dbsize * nr_free_blks)) $fillerdir $dbsize 0 >> $seqres.full 2>&1 + +echo "Create fragmented filesystem" +for dentry in $(ls -1 $fillerdir/); do + $here/src/punch-alternating $fillerdir/$dentry >> $seqres.full +done + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Inject bmap_alloc_minlen_extent error tag" +_scratch_inject_error bmap_alloc_minlen_extent 1 + +echo "Grow realtime volume" +$XFS_GROWFS_PROG -r $SCRATCH_MNT >> $seqres.full 2>&1 +if [[ $? == 0 ]]; then + echo "Growfs succeeded; should have failed." + exit 1 +fi + +_scratch_unmount >> $seqres.full + +echo "Verify rbmino's and rsumino's extent count" +for rtino in rbmino rsumino; do + ino=$(_scratch_xfs_db -c sb -c "print $rtino") + ino=${ino##${rtino} = } + echo "$rtino = $ino" >> $seqres.full + + nextents=$(_scratch_get_iext_count $ino data || \ + _fail "Unable to obtain inode fork's extent count") + if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 + fi +done + +echo "Check filesystem" +_check_xfs_filesystem $SCRATCH_DEV none $rtdev + +losetup -d $rtdev +rm -f $TEST_DIR/$seq.rtvol + +export USE_EXTERNAL="" +export SCRATCH_RTDEV="" + +# success, all done +status=0 +exit diff --git a/tests/xfs/523.out b/tests/xfs/523.out new file mode 100644 index 00000000..7df02970 --- /dev/null +++ b/tests/xfs/523.out @@ -0,0 +1,11 @@ +QA output created by 523 +* Test extending rt inodes +Create fake rt volume +Format and mount rt volume +Consume free space +Create fragmented filesystem +Inject reduce_max_iextents error tag +Inject bmap_alloc_minlen_extent error tag +Grow realtime volume +Verify rbmino's and rsumino's extent count +Check filesystem diff --git a/tests/xfs/group b/tests/xfs/group index 1831f0b5..018c70ef 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -520,3 +520,4 @@ 520 auto quick reflink 521 auto quick realtime growfs 522 auto quick quota +523 auto quick realtime growfs From patchwork Mon Jan 18 06:20:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12026619 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 39A5AC433DB for ; Mon, 18 Jan 2021 06:22:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 086E3227C3 for ; Mon, 18 Jan 2021 06:22:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731928AbhARGVu (ORCPT ); Mon, 18 Jan 2021 01:21:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731683AbhARGVd (ORCPT ); Mon, 18 Jan 2021 01:21:33 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B60CC0613C1; Sun, 17 Jan 2021 22:20:53 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id md11so8812383pjb.0; Sun, 17 Jan 2021 22:20:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JlURlfQZpNNMmIPVRCThz8X9YsyM5LYX1Ylt4W4EDyQ=; b=pcFugMYS3wNtzR95ji4Zbv5ID49y8ttQgdD58gB8DuACr04d0SecAk36ed4OhaSEEc D34mndn+ZSCFQi/rZtJi2c2e5TG3LK1PGHnSVp/gIs1IFgBxCLqnb6pYOzdHLrqPYkSa KCVBwKpN+pJFyJWsIDB47fuq59AEI7AduOle1ZL3tVVSyG0Hq9GE/mTh0q+gZo18ahHW VarL9Lui16le7izjmikSpRRCoqIxV04MfQE4s2fEUx5SAdiTWGw6Zv85GmtJ2AxyM44g wilT7J7bwd6MZBJo9M9tTyc6qf5fdVPdKIDrbJ1Js2GpxFt4LGeXhezm2pZtAjxdADQe E6bw== 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=JlURlfQZpNNMmIPVRCThz8X9YsyM5LYX1Ylt4W4EDyQ=; b=TrJxUAeVdPMrDl7iaXpJVLgsJ5FxUKQeNUKXKi3o46n89IIGktfZv7zzQRirjqlmsU Btex/Ng/U3GYQFwYAJWdP95vqEJAj3RMEy2U8n2krP8ISHwTnfu7vd1W72oT5JCinLvV wxbJHl5t3Da/b0nq0jy8RqR74CRBXwjdNvYDXXcxkaxwdydNjTIZ5hFsDdCi5kmViNbA 7eYY3K17AALRoxar7P6PyzZ1O5IgKN40it25F4ZYNJlSg+mu63QDcApcW+ZhKwnoXHzO R0kBQowE+w48dOUSsSTyPG8mghj0efUhV9sqTzXBwQbtpvs51OHyjtge79p2XRnQFUSD nBiA== X-Gm-Message-State: AOAM533eyYcOuLnpxgI5kcVYPIN4d88l9qwxFw5W1iZmp7tbc0rmuXBt O9eZuOlKwacKjL6yBHJNV7jpLkbw1+I= X-Google-Smtp-Source: ABdhPJxWDp5OK8xYKlQR2XMtaDMmErLCZeRB/0eMc43rM7eV7TKL859Y1R67PgZeoXJsLlXjk3lkQw== X-Received: by 2002:a17:90b:e15:: with SMTP id ge21mr23777305pjb.185.1610950852914; Sun, 17 Jan 2021 22:20:52 -0800 (PST) Received: from localhost.localdomain ([122.179.96.31]) by smtp.gmail.com with ESMTPSA id t1sm14608423pfq.154.2021.01.17.22.20.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 22:20:52 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com, djwong@kernel.org Subject: [PATCH V4 04/11] xfs: Check for extent overflow when punching a hole Date: Mon, 18 Jan 2021 11:50:15 +0530 Message-Id: <20210118062022.15069-5-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118062022.15069-1-chandanrlinux@gmail.com> References: <20210118062022.15069-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This test verifies that XFS does not cause inode fork's extent count to overflow when punching out an extent. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- tests/xfs/524 | 84 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/524.out | 19 +++++++++++ tests/xfs/group | 1 + 3 files changed, 104 insertions(+) create mode 100755 tests/xfs/524 create mode 100644 tests/xfs/524.out diff --git a/tests/xfs/524 b/tests/xfs/524 new file mode 100755 index 00000000..79fa31d8 --- /dev/null +++ b/tests/xfs/524 @@ -0,0 +1,84 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 524 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# punching out an extent. +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.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/inject + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_debug +_require_xfs_io_command "fpunch" +_require_xfs_io_command "finsert" +_require_xfs_io_command "fcollapse" +_require_xfs_io_command "fzero" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "Format and mount fs" +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_file_block_size $SCRATCH_MNT) +nr_blks=30 + +testfile=$SCRATCH_MNT/testfile + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +for op in fpunch finsert fcollapse fzero; do + echo "* $op regular file" + + echo "Create \$testfile" + $XFS_IO_PROG -f -s \ + -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + $testfile >> $seqres.full + + echo "$op alternating blocks" + for i in $(seq 1 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -c "$op $((i * bsize)) $bsize" $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break + done + + echo "Verify \$testfile's extent count" + + nextents=$($XFS_IO_PROG -f -c 'stat' $testfile | grep -i nextents) + nextents=${nextents##fsxattr.nextents = } + if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 + fi + + rm $testfile +done + +# success, all done +status=0 +exit diff --git a/tests/xfs/524.out b/tests/xfs/524.out new file mode 100644 index 00000000..a957f9c7 --- /dev/null +++ b/tests/xfs/524.out @@ -0,0 +1,19 @@ +QA output created by 524 +Format and mount fs +Inject reduce_max_iextents error tag +* fpunch regular file +Create $testfile +fpunch alternating blocks +Verify $testfile's extent count +* finsert regular file +Create $testfile +finsert alternating blocks +Verify $testfile's extent count +* fcollapse regular file +Create $testfile +fcollapse alternating blocks +Verify $testfile's extent count +* fzero regular file +Create $testfile +fzero alternating blocks +Verify $testfile's extent count diff --git a/tests/xfs/group b/tests/xfs/group index 018c70ef..3fa38c36 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -521,3 +521,4 @@ 521 auto quick realtime growfs 522 auto quick quota 523 auto quick realtime growfs +524 auto quick punch zero insert collapse From patchwork Mon Jan 18 06:20:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12026625 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 50688C433E9 for ; Mon, 18 Jan 2021 06:22:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 299A9229C4 for ; Mon, 18 Jan 2021 06:22:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732132AbhARGWQ (ORCPT ); Mon, 18 Jan 2021 01:22:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732041AbhARGWI (ORCPT ); Mon, 18 Jan 2021 01:22:08 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4B26C0613CF; Sun, 17 Jan 2021 22:20:55 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id j12so176746pjy.5; Sun, 17 Jan 2021 22:20:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AFgkXl70cbhwwIhksj5vcFlmJ2rymNpMwaLmT5JS7VI=; b=jVFW9vzeu51KMshOQY2HjHJY1V0TMNZUCtqCJlgcyTxSLSkehWQk+jncf9q72Gaw9/ /Jjf7dzBsBBul/IS+itiO631Dwq1cVG+jjWaSVN4chA9rmX9GyLxAsAU7QPyFa9kxPJm 44T9x8g3ZPXdTAtIpXuLGAfWj2Fj1fZOdYqBXl/lRsrGYPWeHiCj6Lii7iktJwBVTaga OmfVPC3pxg0OczdpndLTS/q13QqG53XENQiDyfr/0X1vGJEylwVRwmJrso24Lbwer20w pqPoSmiNC8OmqHFIkqvrGhw4jvpFhLxx3tkncmYVRagmiJfWw51cVutWTnuN9QD6RdiG 040g== 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=AFgkXl70cbhwwIhksj5vcFlmJ2rymNpMwaLmT5JS7VI=; b=A2vr3cPHeX7jzI5HH5b434Azg9hoGuL7TGiyrxhVwHUTHNIqFju/1DzIoxhb63Wy4y d5Syt0PFA2d2O9nWnjdUm8UH+/O7taTPp3dYY+scNLwf4YAcUAjf/90OHW4ckgGUuYDB F1aV9xcGY/vPXprkxnsYBgSTcK+edEgqQnaVMpG5RtAiwnFl9RCcRLIaLl4QYlrzoy2V +lT+PVeuXVNhlgoy2NI/Lu4AN83QgpS9wFh6JJzyNkaT/RV/u/frp18rAIQ05wfa25Ut f97s1cNa8rtEZJwKoVx2OT5Ycmre1eTw7AcH5Ufsrb3M58Igwijod6trYoaBhZ+MXZGQ jXqg== X-Gm-Message-State: AOAM530BEKHkj3Fv9lLO0vxGZkl6eydqhpkJQPBpUu96HOPqHAiktPQL o0c9L1snErYzXG72irt6I05jyxJ9U10= X-Google-Smtp-Source: ABdhPJxKiCmOrICSpOsjVWLm+Aaa13ByUD1GcTawPIYxF0iaOzNoTWuoGkBgOkgjoHQMcJfjiwQTfA== X-Received: by 2002:a17:90a:d70e:: with SMTP id y14mr24507766pju.9.1610950855157; Sun, 17 Jan 2021 22:20:55 -0800 (PST) Received: from localhost.localdomain ([122.179.96.31]) by smtp.gmail.com with ESMTPSA id t1sm14608423pfq.154.2021.01.17.22.20.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 22:20:54 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com, djwong@kernel.org Subject: [PATCH V4 05/11] xfs: Check for extent overflow when adding/removing xattrs Date: Mon, 18 Jan 2021 11:50:16 +0530 Message-Id: <20210118062022.15069-6-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118062022.15069-1-chandanrlinux@gmail.com> References: <20210118062022.15069-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This test verifies that XFS does not cause inode fork's extent count to overflow when adding/removing xattrs. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- tests/xfs/525 | 141 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/525.out | 18 ++++++ tests/xfs/group | 1 + 3 files changed, 160 insertions(+) create mode 100755 tests/xfs/525 create mode 100644 tests/xfs/525.out diff --git a/tests/xfs/525 b/tests/xfs/525 new file mode 100755 index 00000000..bdca846d --- /dev/null +++ b/tests/xfs/525 @@ -0,0 +1,141 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 525 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# Adding/removing xattrs. +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.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/attr +. ./common/inject +. ./common/populate + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_attrs +_require_xfs_debug +_require_test_program "punch-alternating" +_require_xfs_io_error_injection "reduce_max_iextents" +_require_xfs_io_error_injection "bmap_alloc_minlen_extent" + +echo "Format and mount fs" +_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_block_size $SCRATCH_MNT) + +attr_len=255 + +testfile=$SCRATCH_MNT/testfile + +echo "Consume free space" +fillerdir=$SCRATCH_MNT/fillerdir +nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT) +nr_free_blks=$((nr_free_blks * 90 / 100)) + +_fill_fs $((bsize * nr_free_blks)) $fillerdir $bsize 0 >> $seqres.full 2>&1 + +echo "Create fragmented filesystem" +for dentry in $(ls -1 $fillerdir/); do + $here/src/punch-alternating $fillerdir/$dentry >> $seqres.full +done + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Inject bmap_alloc_minlen_extent error tag" +_scratch_inject_error bmap_alloc_minlen_extent 1 + +echo "* Set xattrs" + +echo "Create \$testfile" +touch $testfile + +echo "Create xattrs" +nr_attrs=$((bsize * 20 / attr_len)) +for i in $(seq 1 $nr_attrs); do + attr="$(printf "trusted.%0247d" $i)" + $SETFATTR_PROG -n "$attr" $testfile >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +echo "Verify \$testfile's naextent count" + +naextents=$($XFS_IO_PROG -f -c 'stat' $testfile | grep naextents) +naextents=${naextents##fsxattr.naextents = } +if (( $naextents > 10 )); then + echo "Extent count overflow check failed: naextents = $naextents" + exit 1 +fi + +echo "Remove \$testfile" +rm $testfile + +echo "* Remove xattrs" + +echo "Create \$testfile" +touch $testfile + +echo "Disable reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 0 + +echo "Create initial xattr extents" + +naextents=0 +last="" +start=1 +nr_attrs=$((bsize / attr_len)) + +while (( $naextents < 4 )); do + end=$((start + nr_attrs - 1)) + + for i in $(seq $start $end); do + attr="$(printf "trusted.%0247d" $i)" + $SETFATTR_PROG -n $attr $testfile + done + + start=$((end + 1)) + + naextents=$($XFS_IO_PROG -f -c 'stat' $testfile | grep naextents) + naextents=${naextents##fsxattr.naextents = } +done + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Remove xattr to trigger -EFBIG" +attr="$(printf "trusted.%0247d" 1)" +$SETFATTR_PROG -x "$attr" $testfile >> $seqres.full 2>&1 +if [[ $? == 0 ]]; then + echo "Xattr removal succeeded; Should have failed " + exit 1 +fi + +rm $testfile && echo "Successfully removed \$testfile" + +# success, all done +status=0 +exit diff --git a/tests/xfs/525.out b/tests/xfs/525.out new file mode 100644 index 00000000..74b152d9 --- /dev/null +++ b/tests/xfs/525.out @@ -0,0 +1,18 @@ +QA output created by 525 +Format and mount fs +Consume free space +Create fragmented filesystem +Inject reduce_max_iextents error tag +Inject bmap_alloc_minlen_extent error tag +* Set xattrs +Create $testfile +Create xattrs +Verify $testfile's naextent count +Remove $testfile +* Remove xattrs +Create $testfile +Disable reduce_max_iextents error tag +Create initial xattr extents +Inject reduce_max_iextents error tag +Remove xattr to trigger -EFBIG +Successfully removed $testfile diff --git a/tests/xfs/group b/tests/xfs/group index 3fa38c36..bd38aff0 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -522,3 +522,4 @@ 522 auto quick quota 523 auto quick realtime growfs 524 auto quick punch zero insert collapse +525 auto quick attr From patchwork Mon Jan 18 06:20:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12026623 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 47E7AC433E0 for ; Mon, 18 Jan 2021 06:22:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 116A722581 for ; Mon, 18 Jan 2021 06:22:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732041AbhARGWR (ORCPT ); Mon, 18 Jan 2021 01:22:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732060AbhARGWI (ORCPT ); Mon, 18 Jan 2021 01:22:08 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 043F7C0613D3; Sun, 17 Jan 2021 22:20:58 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id q7so10304474pgm.5; Sun, 17 Jan 2021 22:20:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7UjqUaoiP4TTj1RVD9Zf0UWCU4yIfYnZ2LkNzeDhWlA=; b=Qva8idhimjfSZO/xYENUDfuBZQrJ2kmmwEgA5QhE7HNytN40HZcWTmn2bFLoXqP8KG kjhUHz++Tm8aXVbHgHrpw0/p9JShq45gvx5KNKpJLT9PHP7Klzd4zxXa2teFSY7o9F9q ZvO1MDgW7VJNxbc6X+sT7lSYmeNxy7hevEmCesOkcDBcwbwIF44RnW1d9w+PBFcI5ava RvLgfR5Z2FBU7Z3ZW42GkAjIqWRWtTb9H2sZZ2ChoO7gBYCWPDKLF7TQjvniwIM1FRne 850VQaFiV+LYQP3/2NOfQ2p03WaVExnj55zSU/kfH9os972PsXCLP6jq0/BVSrOVtGRB aNTw== 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=7UjqUaoiP4TTj1RVD9Zf0UWCU4yIfYnZ2LkNzeDhWlA=; b=AAe7WADsN7g4d26S5ZlYmIbL+2P5vkPwDo4Xv4jn8S4AdmlMY4H7JRmstOko/qftPE Q75zmog/B5qaC3nU6h1DVZPumcPMJcRJM+lxaxkiIPGAl/tyRcs3auYivkCscGNS8O/X zyIQgLRItgVGRE0/j17jyq9fVdl5kQ8ErhJF1LEv58RHyfLP3srUDtx+VA3QwD2Dhq0e /lAsAcaTx2QfhoEdMEFBlvI/j5pOyVEc4LNrZgb5KG6Kvk6DEd3LDpKtGmbWOj9eaz7t ygzKu7EYBh10O0CsS35sEkuOCL6FRv7CvVpbLfKQ9BVQ/HefZpgUcwUvNhmxUA0mwXOg usNQ== X-Gm-Message-State: AOAM532Iz+oDdvMeALGulOo+l2rOuapwKD4Wh0iqC3WTERiGGmSL6KT3 bL78VUItRl7vIsLTpwT4VROcbpiUpGY= X-Google-Smtp-Source: ABdhPJzuDWa4BHhOB4hi2GNK6rPZ6JQ0kLlO96I+wmM4nnqoS814YiYbAKpOoLg3u2cyOUCYfPhdxg== X-Received: by 2002:a63:ce58:: with SMTP id r24mr24610640pgi.192.1610950857418; Sun, 17 Jan 2021 22:20:57 -0800 (PST) Received: from localhost.localdomain ([122.179.96.31]) by smtp.gmail.com with ESMTPSA id t1sm14608423pfq.154.2021.01.17.22.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 22:20:57 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com, djwong@kernel.org Subject: [PATCH V4 06/11] xfs: Check for extent overflow when adding/removing dir entries Date: Mon, 18 Jan 2021 11:50:17 +0530 Message-Id: <20210118062022.15069-7-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118062022.15069-1-chandanrlinux@gmail.com> References: <20210118062022.15069-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This test verifies that XFS does not cause inode fork's extent count to overflow when adding/removing directory entries. Signed-off-by: Chandan Babu R --- tests/xfs/526 | 186 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/526.out | 17 +++++ tests/xfs/group | 1 + 3 files changed, 204 insertions(+) create mode 100755 tests/xfs/526 create mode 100644 tests/xfs/526.out diff --git a/tests/xfs/526 b/tests/xfs/526 new file mode 100755 index 00000000..5a789d61 --- /dev/null +++ b/tests/xfs/526 @@ -0,0 +1,186 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 526 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# adding/removing directory entries. +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.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/inject +. ./common/populate + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_debug +_require_test_program "punch-alternating" +_require_xfs_io_error_injection "reduce_max_iextents" +_require_xfs_io_error_injection "bmap_alloc_minlen_extent" + +_scratch_mkfs_sized $((1024 * 1024 * 1024)) | _filter_mkfs >> $seqres.full 2> $tmp.mkfs +. $tmp.mkfs + +# Filesystems with directory block size greater than one FSB will not be tested, +# since "7 (i.e. XFS_DA_NODE_MAXDEPTH + 1 data block + 1 free block) * 2 (fsb +# count) = 14" is greater than the pseudo max extent count limit of 10. +# Extending the pseudo max limit won't help either. Consider the case where 1 +# FSB is 1k in size and 1 dir block is 64k in size (i.e. fsb count = 64). In +# this case, the pseudo max limit has to be greater than 7 * 64 = 448 extents. +if (( $dbsize != $dirbsize )); then + _notrun "FSB size ($dbsize) and directory block size ($dirbsize) do not match" +fi + +echo "Format and mount fs" +_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full +_scratch_mount >> $seqres.full + +echo "Consume free space" +fillerdir=$SCRATCH_MNT/fillerdir +nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT) +nr_free_blks=$((nr_free_blks * 90 / 100)) + +_fill_fs $((dbsize * nr_free_blks)) $fillerdir $dbsize 0 >> $seqres.full 2>&1 + +echo "Create fragmented filesystem" +for dentry in $(ls -1 $fillerdir/); do + $here/src/punch-alternating $fillerdir/$dentry >> $seqres.full +done + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Inject bmap_alloc_minlen_extent error tag" +_scratch_inject_error bmap_alloc_minlen_extent 1 + +dent_len=255 + +echo "* Create directory entries" + +testdir=$SCRATCH_MNT/testdir +mkdir $testdir + +nr_dents=$((dbsize * 20 / dent_len)) +for i in $(seq 1 $nr_dents); do + dentry="$(printf "%0255d" $i)" + touch ${testdir}/$dentry >> $seqres.full 2>&1 || break +done + +echo "Verify directory's extent count" +nextents=$($XFS_IO_PROG -c 'stat' $testdir | grep nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm -rf $testdir + +echo "* Rename: Populate destination directory" + +dstdir=$SCRATCH_MNT/dstdir +mkdir $dstdir + +nr_dents=$((dirbsize * 20 / dent_len)) + +echo "Populate \$dstdir by moving new directory entries" +for i in $(seq 1 $nr_dents); do + dentry="$(printf "%0255d" $i)" + dentry=${SCRATCH_MNT}/${dentry} + touch $dentry || break + mv $dentry $dstdir >> $seqres.full 2>&1 || break +done + +rm $dentry + +echo "Verify \$dstdir's extent count" + +nextents=$($XFS_IO_PROG -c 'stat' $dstdir | grep nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm -rf $dstdir + +echo "* Create multiple hard links to a single file" + +testdir=$SCRATCH_MNT/testdir +mkdir $testdir + +testfile=$SCRATCH_MNT/testfile +touch $testfile + +nr_dents=$((dirbsize * 20 / dent_len)) + +echo "Create multiple hardlinks" +for i in $(seq 1 $nr_dents); do + dentry="$(printf "%0255d" $i)" + ln $testfile ${testdir}/${dentry} >> $seqres.full 2>&1 || break +done + +rm $testfile + +echo "Verify directory's extent count" +nextents=$($XFS_IO_PROG -c 'stat' $testdir | grep nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm -rf $testdir + +echo "* Create multiple symbolic links to a single file" + +testdir=$SCRATCH_MNT/testdir +mkdir $testdir + +testfile=$SCRATCH_MNT/testfile +touch $testfile + +nr_dents=$((dirbsize * 20 / dent_len)) + +echo "Create multiple symbolic links" +for i in $(seq 1 $nr_dents); do + dentry="$(printf "%0255d" $i)" + ln -s $testfile ${testdir}/${dentry} >> $seqres.full 2>&1 || break; +done + +rm $testfile + +echo "Verify directory's extent count" +nextents=$($XFS_IO_PROG -c 'stat' $testdir | grep nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm -rf $testdir + +# success, all done +status=0 +exit diff --git a/tests/xfs/526.out b/tests/xfs/526.out new file mode 100644 index 00000000..d055f56d --- /dev/null +++ b/tests/xfs/526.out @@ -0,0 +1,17 @@ +QA output created by 526 +Format and mount fs +Consume free space +Create fragmented filesystem +Inject reduce_max_iextents error tag +Inject bmap_alloc_minlen_extent error tag +* Create directory entries +Verify directory's extent count +* Rename: Populate destination directory +Populate $dstdir by moving new directory entries +Verify $dstdir's extent count +* Create multiple hard links to a single file +Create multiple hardlinks +Verify directory's extent count +* Create multiple symbolic links to a single file +Create multiple symbolic links +Verify directory's extent count diff --git a/tests/xfs/group b/tests/xfs/group index bd38aff0..d089797b 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -523,3 +523,4 @@ 523 auto quick realtime growfs 524 auto quick punch zero insert collapse 525 auto quick attr +526 auto quick dir hardlink symlink From patchwork Mon Jan 18 06:20:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12026635 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 87320C433E0 for ; Mon, 18 Jan 2021 06:23:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6205B22597 for ; Mon, 18 Jan 2021 06:23:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732400AbhARGWx (ORCPT ); Mon, 18 Jan 2021 01:22:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732091AbhARGWP (ORCPT ); Mon, 18 Jan 2021 01:22:15 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E5C9C0613D6; Sun, 17 Jan 2021 22:21:00 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id q4so8067100plr.7; Sun, 17 Jan 2021 22:21:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gj45JGvYkk5W0jnWrfD2y/z7Uml5Qb0gG1OtUd9hCwI=; b=nHDIMit//PWT82oWBKX//4Pd9lfIYSYvGeqrCpF9S8WEGvLW75uo3P16j4FW+t7SRe Lp6UCQ8fBUT6vdFrTEEzudPLjJ6QnRS3RHywmbd/fPRZaCA+0uZlRcg47/f1jRWYLUrh hMGQ5W849ugH56aEt9EndilDX3sgQ0Oe1G0LEyRLdevp14uwXAVWRgl2LkNF/5ypFCAb kBtpcgEbQ2Pvhn8mnih/yv7VxGeqB/Zv+fmr5RO/LSzoQvG1BULDV/oSxhfatVxjZv6M 5BqE3aAsI4RRKjK91/eVPOsfiQeQ13ZSd29W/lFo451unP7nKBPHIK0Ijips/Le0f2f7 8CQA== 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=gj45JGvYkk5W0jnWrfD2y/z7Uml5Qb0gG1OtUd9hCwI=; b=lmvkgwrsrNTxxJCBzbAQ+EugL/P+DrbdnxzvHJ2hr33yUHd9fbptu/ArOxImnNFNG5 EkD6S4/dlZmVwz2ltYQNjA8tSEW9QolYEeU00Iob9Wkvt42NpSI/s+6M0B/zMCWr6Qo9 4E5QxHP3roDh/Cpv033Ziyy4smYsEqE4fZWsI2JbQKcTmY9OTZolP5MAcMCk3/Kdx9YS JfsNVSI1ktOT/+RuaGzZmRv0x5GG1g14sG339Yv6lLfEN/D4bBsvrNS8lOzzly/z9w8t vIWgRVouMSR+ngL4TShuJydPlfaW2hfKrSiko8bmAaUZAvWmn6HHxcWX/YrgB1FBSuZ9 n0+Q== X-Gm-Message-State: AOAM530mSJNn4V0wbi+o07sTE7fOBNeShFyqZ4/YEHa/GbpgaeX5ziUn iardLO7/wgMP/OGSqOZ7iEogAITHQuI= X-Google-Smtp-Source: ABdhPJwPWxJ+xZ25KsHt/HqIyDOtiAQSSW8WQXMyBrTDglsOyHXpZUj1vx6CSQyG2P1wPzxeRZA+vw== X-Received: by 2002:a17:90a:517:: with SMTP id h23mr3693425pjh.108.1610950859645; Sun, 17 Jan 2021 22:20:59 -0800 (PST) Received: from localhost.localdomain ([122.179.96.31]) by smtp.gmail.com with ESMTPSA id t1sm14608423pfq.154.2021.01.17.22.20.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 22:20:59 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com, djwong@kernel.org Subject: [PATCH V4 07/11] xfs: Check for extent overflow when writing to unwritten extent Date: Mon, 18 Jan 2021 11:50:18 +0530 Message-Id: <20210118062022.15069-8-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118062022.15069-1-chandanrlinux@gmail.com> References: <20210118062022.15069-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This test verifies that XFS does not cause inode fork's extent count to overflow when writing to an unwritten extent. Signed-off-by: Chandan Babu R --- tests/xfs/527 | 89 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/527.out | 11 ++++++ tests/xfs/group | 1 + 3 files changed, 101 insertions(+) create mode 100755 tests/xfs/527 create mode 100644 tests/xfs/527.out diff --git a/tests/xfs/527 b/tests/xfs/527 new file mode 100755 index 00000000..cd67bce4 --- /dev/null +++ b/tests/xfs/527 @@ -0,0 +1,89 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 527 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# writing to an unwritten extent. +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.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/inject + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_debug +_require_xfs_io_command "falloc" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "Format and mount fs" +_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_file_block_size $SCRATCH_MNT) + +testfile=${SCRATCH_MNT}/testfile + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +nr_blks=15 + +for io in Buffered Direct; do + echo "* $io write to unwritten extent" + + echo "Fallocate $nr_blks blocks" + $XFS_IO_PROG -f -c "falloc 0 $((nr_blks * bsize))" $testfile >> $seqres.full + + if [[ $io == "Buffered" ]]; then + xfs_io_flag="" + else + xfs_io_flag="-d" + fi + + echo "$io write to every other block of fallocated space" + for i in $(seq 1 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -s $xfs_io_flag -c "pwrite $((i * bsize)) $bsize" \ + $testfile >> $seqres.full 2>&1 + [[ $? != 0 ]] && break + done + + echo "Verify \$testfile's extent count" + nextents=$($XFS_IO_PROG -c 'stat' $testfile | grep nextents) + nextents=${nextents##fsxattr.nextents = } + if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 + fi + + rm $testfile +done + +# super_block->s_wb_err will have a newer seq value when compared to "/"'s +# file->f_sb_err. Consume it here so that xfs_scrub can does not error out. +$XFS_IO_PROG -c syncfs $SCRATCH_MNT >> $seqres.full 2>&1 + +# success, all done +status=0 +exit diff --git a/tests/xfs/527.out b/tests/xfs/527.out new file mode 100644 index 00000000..3597ad92 --- /dev/null +++ b/tests/xfs/527.out @@ -0,0 +1,11 @@ +QA output created by 527 +Format and mount fs +Inject reduce_max_iextents error tag +* Buffered write to unwritten extent +Fallocate 15 blocks +Buffered write to every other block of fallocated space +Verify $testfile's extent count +* Direct write to unwritten extent +Fallocate 15 blocks +Direct write to every other block of fallocated space +Verify $testfile's extent count diff --git a/tests/xfs/group b/tests/xfs/group index d089797b..627813fe 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -524,3 +524,4 @@ 524 auto quick punch zero insert collapse 525 auto quick attr 526 auto quick dir hardlink symlink +527 auto quick From patchwork Mon Jan 18 06:20:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12026633 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 ED4C5C433E6 for ; Mon, 18 Jan 2021 06:23:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C871F22597 for ; Mon, 18 Jan 2021 06:23:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730151AbhARGWw (ORCPT ); Mon, 18 Jan 2021 01:22:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732105AbhARGWP (ORCPT ); Mon, 18 Jan 2021 01:22:15 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BD4CC0613ED; Sun, 17 Jan 2021 22:21:02 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id l23so9088003pjg.1; Sun, 17 Jan 2021 22:21:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2CYE49v+RIGfn0VhLazHIy4EkPBRnVc7nREuOfR/ZBk=; b=R11hkxihYLhnxxBmvJbvCCbY4yFhGKcyMzVPRbqCI6KI+7eoA3bgi7JLwl7494wm3E WzM5Q2ACMIHhUShLGJNkBWFyzPGd/7J0J9B+fu50Xf1Gjl3ko9t3gUQzXxYkkcFt+lGF xnM4C0BqB11XqC6Ezx4gvPbBy1aL79p0/IrdtSIVmCLTNQBbgmoa9LC7gcxAk48+IS6v i2+p8f2ljHLnO+HGQS4OlbFjZXmFyP3sZTXgYm8c40c49laC70dd5V6Q+ZHX/vaIfNjo aBwmck4XcG5uviJ66YcB6UiETnGfgZyLhtXiPjbtvutDGH6hbWLuDNhCrO5lqcl0Y5jh cZTA== 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=2CYE49v+RIGfn0VhLazHIy4EkPBRnVc7nREuOfR/ZBk=; b=TZ2PpoeTSDeSIv4GqDvxExhPyvzg8mAMm5oGxXIgMjG5riIHGrKYW11Cn9gWKVaqzu dzQQxNh6JDW05KheYUAAOKUz6g+wA2z7YhT9l0rtl4SlMoGqTW8PgDOkuLljL2TD1EnP 6yQgd3Lc2iZmCvdyJqMyhciLWkSw/kD7W6x+l6SankKBhgvLuMHPceCoB/Gle4TDGNkv RBiQfzJ1OFOJ1OJxUAmgZGgTdIfJT7NWLQVLQv/rmTNeTiPYLfPVGv+287iOJhN8+GCx 7mSdy2fCuGczB3pgWE9l69xzA5uV2iVoIDVKPfjF7ryKC8d2G646C8QV128fSYp4eqKI R25Q== X-Gm-Message-State: AOAM531liH0E6M2R2vFhAedGVpeHQ68RcX0QWZb/Rx5j06YU780soJ9K Yf23D5KTPw39NCbrglkWZE8tOm4QsKk= X-Google-Smtp-Source: ABdhPJw/Y4BFYXB7tZDC0pez4/KCnjjRSq64lypTi4t9nxVBKskfs+vpWozrlAo//h7j9Ig7gtlQbA== X-Received: by 2002:a17:90b:287:: with SMTP id az7mr23731898pjb.70.1610950861902; Sun, 17 Jan 2021 22:21:01 -0800 (PST) Received: from localhost.localdomain ([122.179.96.31]) by smtp.gmail.com with ESMTPSA id t1sm14608423pfq.154.2021.01.17.22.20.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 22:21:01 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com, djwong@kernel.org Subject: [PATCH V4 08/11] xfs: Check for extent overflow when moving extent from cow to data fork Date: Mon, 18 Jan 2021 11:50:19 +0530 Message-Id: <20210118062022.15069-9-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118062022.15069-1-chandanrlinux@gmail.com> References: <20210118062022.15069-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This test verifies that XFS does not cause inode fork's extent count to overflow when writing to/funshare-ing a shared extent. Signed-off-by: Chandan Babu R --- tests/xfs/528 | 110 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/528.out | 12 +++++ tests/xfs/group | 1 + 3 files changed, 123 insertions(+) create mode 100755 tests/xfs/528 create mode 100644 tests/xfs/528.out diff --git a/tests/xfs/528 b/tests/xfs/528 new file mode 100755 index 00000000..269d368d --- /dev/null +++ b/tests/xfs/528 @@ -0,0 +1,110 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 528 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# writing to a shared extent. +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.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/reflink +. ./common/inject + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_scratch_reflink +_require_xfs_debug +_require_xfs_io_command "reflink" +_require_xfs_io_command "funshare" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "Format and mount fs" +_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_block_size $SCRATCH_MNT) + +nr_blks=15 + +srcfile=${SCRATCH_MNT}/srcfile +dstfile=${SCRATCH_MNT}/dstfile + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Create a \$srcfile having an extent of length $nr_blks blocks" +$XFS_IO_PROG -f -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + -c fsync $srcfile >> $seqres.full + +echo "* Write to shared extent" + +echo "Share the extent with \$dstfile" +$XFS_IO_PROG -f -c "reflink $srcfile" $dstfile >> $seqres.full + +echo "Buffered write to every other block of \$dstfile's shared extent" +for i in $(seq 1 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -s -c "pwrite $((i * bsize)) $bsize" $dstfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +echo "Verify \$dstfile's extent count" +nextents=$($XFS_IO_PROG -c 'stat' $dstfile | grep nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm $dstfile + +echo "* Funshare shared extent" + +echo "Share the extent with \$dstfile" +$XFS_IO_PROG -f -c "reflink $srcfile" $dstfile >> $seqres.full + +echo "Funshare every other block of \$dstfile's shared extent" +for i in $(seq 1 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -s -c "funshare $((i * bsize)) $bsize" $dstfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +echo "Verify \$dstfile's extent count" +nextents=$($XFS_IO_PROG -c 'stat' $dstfile | grep nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +# super_block->s_wb_err will have a newer seq value when compared to "/"'s +# file->f_sb_err. Consume it here so that xfs_scrub can does not error out. +$XFS_IO_PROG -c syncfs $SCRATCH_MNT >> $seqres.full 2>&1 + +# success, all done +status=0 +exit + diff --git a/tests/xfs/528.out b/tests/xfs/528.out new file mode 100644 index 00000000..d0f2c878 --- /dev/null +++ b/tests/xfs/528.out @@ -0,0 +1,12 @@ +QA output created by 528 +Format and mount fs +Inject reduce_max_iextents error tag +Create a $srcfile having an extent of length 15 blocks +* Write to shared extent +Share the extent with $dstfile +Buffered write to every other block of $dstfile's shared extent +Verify $dstfile's extent count +* Funshare shared extent +Share the extent with $dstfile +Funshare every other block of $dstfile's shared extent +Verify $dstfile's extent count diff --git a/tests/xfs/group b/tests/xfs/group index 627813fe..c85aac6b 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -525,3 +525,4 @@ 525 auto quick attr 526 auto quick dir hardlink symlink 527 auto quick +528 auto quick reflink From patchwork Mon Jan 18 06:20:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12026627 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 B74E7C4332D for ; Mon, 18 Jan 2021 06:22:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 94D9222581 for ; Mon, 18 Jan 2021 06:22:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732285AbhARGW1 (ORCPT ); Mon, 18 Jan 2021 01:22:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730634AbhARGWU (ORCPT ); Mon, 18 Jan 2021 01:22:20 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6FAAC061786; Sun, 17 Jan 2021 22:21:04 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id m5so9080700pjv.5; Sun, 17 Jan 2021 22:21:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=glIlnlSgDUKeauealF0Vvm3N8x6rNgHNGcwKkgZ+AhI=; b=edv74rNOM18C9CJnyneMm3dE3FizEJfempn7ETNQPvLkTXnQwFQ2mvEHxiOZVrz6UL HlVg9UWwU4vIkzMP3DFdO1uMQikKegpAWP29TTj98azcLBNbhG/L8oC15DsLLb0uY+4Y k/hioodFgdSigE4F9PRlB5oUe7XlcASz2ytmr5Z4v0A6ApOv6J6Gk42J0TF4TfHbgy3j DR6WW9jH2U2zMGQDsb7Ggz+JqttBfiYw8nuGcEb2TDDY0ZLYPvkN/AGOy6GjP9hgKY4o mjD0JNpfPv4b2KLNKVLNatokp4hWjpwi9tF+H4zZkP7PgmxI/EpI1/1lq5ke6KrB9iIE 3sPA== 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=glIlnlSgDUKeauealF0Vvm3N8x6rNgHNGcwKkgZ+AhI=; b=gG+ideEtRDNPVXbGfq57JEpDwvtniWfihxs4RtVq/kZlAUzc6bieksS38EBsoS/r1L KMhQ5Yf3jTOHMk7lMnesbIvm3Wu7+dTP5sKsabUyIHBno8Vb2fmxq+R9SDzXxx9qlzUH xhRJATuHWQ0OFUq+6OQJJjrzX242GQFsKkgQJIPBbd/94yeWH/y+L9aDRh+8s4sZ2Tsf ocpmCDEi7j5uNMMLYAAGM5LoGailbeiG4PHQwi78q98JTdxWwmwWr2+yQsJIDHGOASfP xofepDLD09RVatiD3kxGBg+30pKzHu4TlMxxs//PhoPy41c63GzqYi7FfAxvLscnbS5h M+ng== X-Gm-Message-State: AOAM5322S5+mDUEm7xQDuzNGwhN2iZbzLdfnw1Kmr1otejEZXX0mnq7O Y+h7bq9Fm10Y+7fmpx2ARHLKzS1Sr6k= X-Google-Smtp-Source: ABdhPJxq3YYCjVRfLbfd5FGa1Di/jVcPCEhTqWSsaXkw0Q/Pfp3XUqhmW23qHbrgeB9zu+AVuafT0g== X-Received: by 2002:a17:90b:346:: with SMTP id fh6mr24555534pjb.225.1610950864165; Sun, 17 Jan 2021 22:21:04 -0800 (PST) Received: from localhost.localdomain ([122.179.96.31]) by smtp.gmail.com with ESMTPSA id t1sm14608423pfq.154.2021.01.17.22.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 22:21:03 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com, djwong@kernel.org Subject: [PATCH V4 09/11] xfs: Check for extent overflow when remapping an extent Date: Mon, 18 Jan 2021 11:50:20 +0530 Message-Id: <20210118062022.15069-10-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118062022.15069-1-chandanrlinux@gmail.com> References: <20210118062022.15069-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This test verifies that XFS does not cause inode fork's extent count to overflow when remapping extents from one file's inode fork to another. Signed-off-by: Chandan Babu R --- tests/xfs/529 | 82 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/529.out | 8 +++++ tests/xfs/group | 1 + 3 files changed, 91 insertions(+) create mode 100755 tests/xfs/529 create mode 100644 tests/xfs/529.out diff --git a/tests/xfs/529 b/tests/xfs/529 new file mode 100755 index 00000000..f6a5922f --- /dev/null +++ b/tests/xfs/529 @@ -0,0 +1,82 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 529 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# remapping extents from one file's inode fork to another. +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.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/reflink +. ./common/inject + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_scratch_reflink +_require_xfs_debug +_require_xfs_io_command "reflink" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "* Reflink remap extents" + +echo "Format and mount fs" +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_block_size $SCRATCH_MNT) + +srcfile=${SCRATCH_MNT}/srcfile +dstfile=${SCRATCH_MNT}/dstfile + +nr_blks=15 + +echo "Create \$srcfile having an extent of length $nr_blks blocks" +$XFS_IO_PROG -f -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + -c fsync $srcfile >> $seqres.full + +echo "Create \$dstfile having an extent of length $nr_blks blocks" +$XFS_IO_PROG -f -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + -c fsync $dstfile >> $seqres.full + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Reflink every other block from \$srcfile into \$dstfile" +for i in $(seq 1 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -c "reflink $srcfile $((i * bsize)) $((i * bsize)) $bsize" \ + $dstfile >> $seqres.full 2>&1 +done + +echo "Verify \$dstfile's extent count" +nextents=$($XFS_IO_PROG -c 'stat' $dstfile | grep nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +# success, all done +status=0 +exit diff --git a/tests/xfs/529.out b/tests/xfs/529.out new file mode 100644 index 00000000..687a8bd2 --- /dev/null +++ b/tests/xfs/529.out @@ -0,0 +1,8 @@ +QA output created by 529 +* Reflink remap extents +Format and mount fs +Create $srcfile having an extent of length 15 blocks +Create $dstfile having an extent of length 15 blocks +Inject reduce_max_iextents error tag +Reflink every other block from $srcfile into $dstfile +Verify $dstfile's extent count diff --git a/tests/xfs/group b/tests/xfs/group index c85aac6b..bc3958b3 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -526,3 +526,4 @@ 526 auto quick dir hardlink symlink 527 auto quick 528 auto quick reflink +529 auto quick reflink From patchwork Mon Jan 18 06:20:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12026631 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 08C74C433E0 for ; Mon, 18 Jan 2021 06:23:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C53A3227BF for ; Mon, 18 Jan 2021 06:23:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732390AbhARGWu (ORCPT ); Mon, 18 Jan 2021 01:22:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732203AbhARGWU (ORCPT ); Mon, 18 Jan 2021 01:22:20 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 008DAC061793; Sun, 17 Jan 2021 22:21:06 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id i7so10304031pgc.8; Sun, 17 Jan 2021 22:21:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MIvnJ0VsDhNnrp8Hs5gLG61IFY55F0VThKgOo2dcDHI=; b=a3OxbXxQSDDnBU5kEuXvEzm6TGCO7E2XuFasNdiIibXP+iIekCCHwv7Jh1uQULOWXU 87e15c4pDuZKdi13TWWcNWE4VOvvE3kVZwvVuYvT8CfbPPEqiv0e8q6Hr/Y6hWA8Z/74 IXlDEfJgya2g5R24tEZdMgMICgu98emxQSWGSrCwGCa4taMYGcKAQ/46Y0tzubA4Lc2h SFnA7hGuJxtKAknCz/MeWUQtDPwTInKc5IowXxkz+0dJJVc+00rkGXUC3qKjG+4YXG5v yemrmyl3rGPqB4wIPiCnwcN31R/6/J2cDUT4pp+7Z3kovS7VYZA6t50i0oW3agq4C09k WwJA== 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=MIvnJ0VsDhNnrp8Hs5gLG61IFY55F0VThKgOo2dcDHI=; b=HtzrlZ/kNrtoAoNYwQDQFEajn/cdYXPvAt8cudvEktLLBmPQj8MNcEoJuu4GbkO+tg nXkfbmxq6dYu8Br3g00r4L2oa18g6jyqvxoy9JqrnAb8r3TVi9f0uTRb3G82CfE0gaBr mkKOxqIgtOK4GfBrLciBavmB75rnqy7Vsl3rzTX7G3pfhIpZ/sP1xK9LAxqIwqHCZ/+9 3VaCwTdwFPNreGq7u2WGmKoTOUZXmlz8bfp/aJcAutbfLeGFoi9pQSYNr/gNV5PQ1VHx kFv7PAhk8/goNOxRX6ulj0jxWhIFy0+WLhoqErl6J/idcVSUjffSw6MBRgZl8nC0HZ3J zz5g== X-Gm-Message-State: AOAM532PLk0GGL4G8YWo3ABhhChVnyIst9dq8ww6WfxlFluV5ifD+lP7 w7BdMGmcYB2Vq/D4SrJ1nnONVit/jQ4= X-Google-Smtp-Source: ABdhPJzuQjUwpL//jMBAmj96Z7oGNxLReANFeOXllzPK//EiPgKBchwQ/GGMVDl9mi9b7pmSUjStRQ== X-Received: by 2002:a63:585a:: with SMTP id i26mr24425570pgm.330.1610950866463; Sun, 17 Jan 2021 22:21:06 -0800 (PST) Received: from localhost.localdomain ([122.179.96.31]) by smtp.gmail.com with ESMTPSA id t1sm14608423pfq.154.2021.01.17.22.21.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 22:21:06 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com, djwong@kernel.org Subject: [PATCH V4 10/11] xfs: Check for extent overflow when swapping extents Date: Mon, 18 Jan 2021 11:50:21 +0530 Message-Id: <20210118062022.15069-11-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118062022.15069-1-chandanrlinux@gmail.com> References: <20210118062022.15069-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This test verifies that XFS does not cause inode fork's extent count to overflow when swapping forks across two files. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- tests/xfs/530 | 109 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/530.out | 13 ++++++ tests/xfs/group | 1 + 3 files changed, 123 insertions(+) create mode 100755 tests/xfs/530 create mode 100644 tests/xfs/530.out diff --git a/tests/xfs/530 b/tests/xfs/530 new file mode 100755 index 00000000..0986d8bf --- /dev/null +++ b/tests/xfs/530 @@ -0,0 +1,109 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 530 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# swapping forks between files +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.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/inject + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_debug +_require_xfs_scratch_rmapbt +_require_xfs_io_command "fcollapse" +_require_xfs_io_command "swapext" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "* Swap extent forks" + +echo "Format and mount fs" +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_block_size $SCRATCH_MNT) + +srcfile=${SCRATCH_MNT}/srcfile +donorfile=${SCRATCH_MNT}/donorfile + +echo "Create \$donorfile having an extent of length 67 blocks" +$XFS_IO_PROG -f -s -c "pwrite -b $((17 * bsize)) 0 $((17 * bsize))" $donorfile \ + >> $seqres.full + +# After the for loop the donor file will have the following extent layout +# | 0-4 | 5 | 6 | 7 | 8 | 9 | 10 | +echo "Fragment \$donorfile" +for i in $(seq 5 10); do + start_offset=$((i * bsize)) + $XFS_IO_PROG -f -c "fcollapse $start_offset $bsize" $donorfile >> $seqres.full +done + +echo "Create \$srcfile having an extent of length 18 blocks" +$XFS_IO_PROG -f -s -c "pwrite -b $((18 * bsize)) 0 $((18 * bsize))" $srcfile \ + >> $seqres.full + +echo "Fragment \$srcfile" +# After the for loop the src file will have the following extent layout +# | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7-10 | +for i in $(seq 1 7); do + start_offset=$((i * bsize)) + $XFS_IO_PROG -f -c "fcollapse $start_offset $bsize" $srcfile >> $seqres.full +done + +echo "Collect \$donorfile's extent count" +donor_nr_exts=$($XFS_IO_PROG -c 'stat' $donorfile | grep nextents) +donor_nr_exts=${donor_nr_exts##fsxattr.nextents = } + +echo "Collect \$srcfile's extent count" +src_nr_exts=$($XFS_IO_PROG -c 'stat' $srcfile | grep nextents) +src_nr_exts=${src_nr_exts##fsxattr.nextents = } + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Swap \$srcfile's and \$donorfile's extent forks" +$XFS_IO_PROG -f -c "swapext $donorfile" $srcfile >> $seqres.full 2>&1 + +echo "Check for \$donorfile's extent count overflow" +nextents=$($XFS_IO_PROG -c 'stat' $donorfile | grep nextents) +nextents=${nextents##fsxattr.nextents = } + +if (( $nextents == $src_nr_exts )); then + echo "\$donorfile: Extent count overflow check failed" +fi + +echo "Check for \$srcfile's extent count overflow" +nextents=$($XFS_IO_PROG -c 'stat' $srcfile | grep nextents) +nextents=${nextents##fsxattr.nextents = } + +if (( $nextents == $donor_nr_exts )); then + echo "\$srcfile: Extent count overflow check failed" +fi + +# success, all done +status=0 +exit diff --git a/tests/xfs/530.out b/tests/xfs/530.out new file mode 100644 index 00000000..9f55608b --- /dev/null +++ b/tests/xfs/530.out @@ -0,0 +1,13 @@ +QA output created by 530 +* Swap extent forks +Format and mount fs +Create $donorfile having an extent of length 67 blocks +Fragment $donorfile +Create $srcfile having an extent of length 18 blocks +Fragment $srcfile +Collect $donorfile's extent count +Collect $srcfile's extent count +Inject reduce_max_iextents error tag +Swap $srcfile's and $donorfile's extent forks +Check for $donorfile's extent count overflow +Check for $srcfile's extent count overflow diff --git a/tests/xfs/group b/tests/xfs/group index bc3958b3..81a15582 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -527,3 +527,4 @@ 527 auto quick 528 auto quick reflink 529 auto quick reflink +530 auto quick From patchwork Mon Jan 18 06:20:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12026629 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 03C37C43331 for ; Mon, 18 Jan 2021 06:22:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D586F22581 for ; Mon, 18 Jan 2021 06:22:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732328AbhARGWc (ORCPT ); Mon, 18 Jan 2021 01:22:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732262AbhARGWX (ORCPT ); Mon, 18 Jan 2021 01:22:23 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30A56C061794; Sun, 17 Jan 2021 22:21:09 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id t6so8084163plq.1; Sun, 17 Jan 2021 22:21:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AGBhOkzc7abONTpUtgMEjxirIhOapL82Xzhyg1JPP1A=; b=GLokwA88TdhpVog/ezxJvyH90S9sQPOJ5I0BdKpXgBwwgq/b8W0REafwp+PS6RE3L1 8VnOD1wDT1fn7IDMSjf7b35J5Y6wfjmkBrZweFMY1oMrVIGEKzE+JNlySiKf5TiXX5MP qEXznRFke1lSYzRWZ3wUewDJTCW3YAGuG7WPdQ5TcbhR5f3vj+0ClyCt9K1vJx5ZlHgs xKyk2fwMS0gFqIpJW6gAkXYi+YbcNww4AaA9zWFE/lyrlFJO3S7/DcpfJ+QQTO36Bh4j YUScdA13eG+6jQsFs6CIh3SrJFiDkfCeOV+SrFT5mkOVMeVFfCak8nh2/AukumC/Tv5B /ZJg== 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=AGBhOkzc7abONTpUtgMEjxirIhOapL82Xzhyg1JPP1A=; b=iFn9VOZuTG8aLpp7hBpTNfahvjAOliKZP+2apQ9q27XyaQ3tIT8lIGuvbdOjMiQvAS QFUbRNbiNuG4vU39S/ChHBdxrQEJGuFzSCAORKo0Xoipk8ndVKICgLfD+1tKCJl3sdOF qDi3R6hdOit8JAp1tNLtEplq5zg/e562H2ktczvHXk8f1XcPucod0B2fU2jtd/0vf8sQ jLMmT4XKWJ9QgXO50egBRX28Oc8l/vpZED65MKkYzE33NmQexcwjBM9t8/Byv/+XADcC j/aDwEukiiWMxGSFaK+3hgsD5XcGwf9+3Fn+D7r1HSlvKMJ809+k8NBjYBbvOeEiaXVw eEvw== X-Gm-Message-State: AOAM531c3HV72SpcJfCfXocAIFD6YxeRU3JZ67gov3xqm70goVXY6dUE slTAyVf7AbqjogVzQRwjxuZ+41FShg0= X-Google-Smtp-Source: ABdhPJzoi8sBcRNyLJ5p/V4vdIHKmpIvfEFvejHWc3xfxzNIQ0XbPOvNcDX+nRtHhGpLDPnYV/fsQg== X-Received: by 2002:a17:90a:a60d:: with SMTP id c13mr25067886pjq.11.1610950868686; Sun, 17 Jan 2021 22:21:08 -0800 (PST) Received: from localhost.localdomain ([122.179.96.31]) by smtp.gmail.com with ESMTPSA id t1sm14608423pfq.154.2021.01.17.22.21.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jan 2021 22:21:08 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com, djwong@kernel.org Subject: [PATCH V4 11/11] xfs: Stress test with bmap_alloc_minlen_extent error tag enabled Date: Mon, 18 Jan 2021 11:50:22 +0530 Message-Id: <20210118062022.15069-12-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210118062022.15069-1-chandanrlinux@gmail.com> References: <20210118062022.15069-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit adds a stress test that executes fsstress with bmap_alloc_minlen_extent error tag enabled. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- tests/xfs/531 | 84 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/531.out | 7 ++++ tests/xfs/group | 1 + 3 files changed, 92 insertions(+) create mode 100755 tests/xfs/531 create mode 100644 tests/xfs/531.out diff --git a/tests/xfs/531 b/tests/xfs/531 new file mode 100755 index 00000000..fd92c3ea --- /dev/null +++ b/tests/xfs/531 @@ -0,0 +1,84 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 531 +# +# Execute fsstress with bmap_alloc_minlen_extent error tag enabled. +# +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.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/inject +. ./common/populate + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_debug +_require_test_program "punch-alternating" +_require_xfs_io_error_injection "bmap_alloc_minlen_extent" + +echo "Format and mount fs" +_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_file_block_size $SCRATCH_MNT) + +echo "Consume free space" +fillerdir=$SCRATCH_MNT/fillerdir +nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT) +nr_free_blks=$((nr_free_blks * 90 / 100)) + +_fill_fs $((bsize * nr_free_blks)) $fillerdir $bsize 0 >> $seqres.full 2>&1 + +echo "Create fragmented filesystem" +for dentry in $(ls -1 $fillerdir/); do + $here/src/punch-alternating $fillerdir/$dentry >> $seqres.full +done + +echo "Inject bmap_alloc_minlen_extent error tag" +_scratch_inject_error bmap_alloc_minlen_extent 1 + +echo "Scale fsstress args" +args=$(_scale_fsstress_args -p $((LOAD_FACTOR * 75)) -n $((TIME_FACTOR * 1000))) + +echo "Execute fsstress in background" +$FSSTRESS_PROG -d $SCRATCH_MNT $args \ + -f bulkstat=0 \ + -f bulkstat1=0 \ + -f fiemap=0 \ + -f getattr=0 \ + -f getdents=0 \ + -f getfattr=0 \ + -f listfattr=0 \ + -f mread=0 \ + -f read=0 \ + -f readlink=0 \ + -f readv=0 \ + -f stat=0 \ + -f aread=0 \ + -f dread=0 > /dev/null 2>&1 + +# success, all done +status=0 +exit diff --git a/tests/xfs/531.out b/tests/xfs/531.out new file mode 100644 index 00000000..67f40654 --- /dev/null +++ b/tests/xfs/531.out @@ -0,0 +1,7 @@ +QA output created by 531 +Format and mount fs +Consume free space +Create fragmented filesystem +Inject bmap_alloc_minlen_extent error tag +Scale fsstress args +Execute fsstress in background diff --git a/tests/xfs/group b/tests/xfs/group index 81a15582..f4cb5af6 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -528,3 +528,4 @@ 528 auto quick reflink 529 auto quick reflink 530 auto quick +531 auto stress