From patchwork Fri Nov 13 11:26:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 11903099 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 672B5697 for ; Fri, 13 Nov 2020 11:28:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 418C42224F for ; Fri, 13 Nov 2020 11:28:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="P/neKgFV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726531AbgKML1s (ORCPT ); Fri, 13 Nov 2020 06:27:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726405AbgKML1n (ORCPT ); Fri, 13 Nov 2020 06:27:43 -0500 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87544C0617A7; Fri, 13 Nov 2020 03:27:33 -0800 (PST) Received: by mail-pl1-x642.google.com with SMTP id cp9so4424038plb.1; Fri, 13 Nov 2020 03:27:33 -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=JNlJl80nokkfIDrzLdrxnx4cQjGrCYfO2o/A7orSY7s=; b=P/neKgFVO0bqx3pG4bsi/b4E5WwkulVBricSjG+xFBYrMR3qRkQHmv9CZjOKeYGkp3 b+CKFmm+Fs5Ms30M3mejzeXIBNwItzC+Nm0R6GfF3ycYhp9SlT44vOD7kdOz393EmLLX hkD7Znuzl/KCp7eVZRHgT0Ogg/8cYxkeGIOWS4qWC5S7Lv4zwrTvEKgcw8qo2OgVQ4lH RY0c/B1Rnb64nIgNjTfDayRmPEhpH9vFgmxPvk3k6rPkTTnTNE6vsAXXgOU5e40p1P/t NVU6iWejIgWXHCPDTMSJPaJw9p0og1ntxwF/kbXA1AuTv39QVXA2+wHN/hT5SIc4Lrc1 YcKA== 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=JNlJl80nokkfIDrzLdrxnx4cQjGrCYfO2o/A7orSY7s=; b=IHpqkuJFpeaEMWxslDKXSMTjTJUCxwbJypKkJgmAXq7z4RHzKauk9TZ1KIdtodbGwA i0DWpzeg3EPduG4i3pQDbIssufhwbKqRcISsWj++bhLQl+d22wyOlXLdhBVmxl9JAczb bJRSjEP/Z1302vZC5pvZiHalX8LsYGuKUCoiJsQeTkGzNvRq08HjGOhE86npuCrxEi5r VahEMHkm5wsW52mwW2O/WX5/Fyxqm4ABoM+1dPWEXBzW4U0skGFBU1gquRCt7bANF3j7 b1TglJCVqxViyJ8vPMiHTwV9dqGkXs00ZQ1fJvvWxjULI7d5wM40vDRCwLYY9DEBzdvi 7Jpg== X-Gm-Message-State: AOAM531Dqi6CkLd3TEYOXQcbghE8UisIz5xuznxMkAdAHMKbC/p8l+iU p7yVoS2w+HRvjBoOaZjjWhgJBnIulBs= X-Google-Smtp-Source: ABdhPJz/HYt/kNAWMVgCXuwdixfvIS7A/UFkAlt7cxbVB50gScymv7xDPsY0Hnor5s8VQW2zC/J51A== X-Received: by 2002:a17:902:760c:b029:d6:efa5:4cdd with SMTP id k12-20020a170902760cb02900d6efa54cddmr1819661pll.56.1605266852878; Fri, 13 Nov 2020 03:27:32 -0800 (PST) Received: from localhost.localdomain ([122.172.185.167]) by smtp.gmail.com with ESMTPSA id w131sm9410857pfd.14.2020.11.13.03.27.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 03:27:32 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com Subject: [PATCH 01/11] common/xfs: Add a helper to get an inode fork's extent count Date: Fri, 13 Nov 2020 16:56:53 +0530 Message-Id: <20201113112704.28798-2-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113112704.28798-1-chandanrlinux@gmail.com> References: <20201113112704.28798-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@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 79dab058..45cd329c 100644 --- a/common/xfs +++ b/common/xfs @@ -883,6 +883,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 Fri Nov 13 11:26:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 11903103 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 538ED139F for ; Fri, 13 Nov 2020 11:28:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A8AA2224C for ; Fri, 13 Nov 2020 11:28:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J2ziz39v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726563AbgKML2W (ORCPT ); Fri, 13 Nov 2020 06:28:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726493AbgKML1n (ORCPT ); Fri, 13 Nov 2020 06:27:43 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C14FC061A04; Fri, 13 Nov 2020 03:27:36 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id c20so7375910pfr.8; Fri, 13 Nov 2020 03:27:36 -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=8ehVuNvOmS0r5As9G9ddM7RoBFx7tHtjMsmcu9AMKtU=; b=J2ziz39vLs1r8M7RzYmVmo0TXDbzvA8X4fGoAd5KcdVdtjIc9IkmS2qUSnW8ZMkbtF JzqpYy7IzNUJUOEZ8UnPEKDiO72AKWg9WosP37rFFtEAtBnX5t4RMvCezFV0PaFnJbMT xOpgpXE41zCtdyz5XiV6LT02j1IbAkL/0KJi8Uu3qGgBfUtX9HwiA2kgbU4ZIy5sAqw5 dosEvnUJ2d7b6o2pSNh+usw+Dh95sojmuwtygop/cfQwJfdhXeAjW/ict1A47Kzbq8ib rbsDIMe2RVzdfIQDGRkB1GoJIRs1pqo5HvpGEp35hsEryVpW2DZNKVA1fLVIZAdzCFWx wwuw== 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=8ehVuNvOmS0r5As9G9ddM7RoBFx7tHtjMsmcu9AMKtU=; b=TILs8ojsWGBNcCZ4TK+Fo9kVEGuTa12w1e8IcLcSI2tNPKNPdXlhAMuIfWfVCajaAu R8XiErGrYmE8X5rjUjvVIYTy2Cr4wU50/sAE6ju1Qu6bONbkHDYGDji9JE1+cBDguBhq 3jlJOC8H/9XNAEeIiSKndkje/Cjnib3Pvq7qso6vx7ivwOyVtHtWLceDd6FBm+/jgL8J bxdamQtw9fnG15YUHh/dNonJSqWabZHvrIKHwBFuxUzwNG8J/KJyrK2LDubIEl5XPhnT zF6etTka3ClxhFRxrnbuqQOWVm0Uu6TsjF2JbGi61vKpej7lXaa38Rz/0nmDq6yNhHfS 4WnA== X-Gm-Message-State: AOAM530+S/tJurdRFNHq5DxbAnJ5MJFxrRGYREci2ssS5c8tyml7spky qzQ+YBK/2ajRKAbbUOKvsCzU75i3FVA= X-Google-Smtp-Source: ABdhPJxqBA+wpiehq0G7y2MyxDaKAjHJm1Da7eb79DzmJ2FyeOnJ+Hs+UB4xkr03oPYPcySWUwulEg== X-Received: by 2002:a65:62ca:: with SMTP id m10mr1687709pgv.407.1605266855423; Fri, 13 Nov 2020 03:27:35 -0800 (PST) Received: from localhost.localdomain ([122.172.185.167]) by smtp.gmail.com with ESMTPSA id w131sm9410857pfd.14.2020.11.13.03.27.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 03:27:34 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com Subject: [PATCH 02/11] xfs: Check for extent overflow when trivally adding a new extent Date: Fri, 13 Nov 2020 16:56:54 +0530 Message-Id: <20201113112704.28798-3-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113112704.28798-1-chandanrlinux@gmail.com> References: <20201113112704.28798-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@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 (limited to non-realtime files). Signed-off-by: Chandan Babu R --- tests/xfs/522 | 214 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/522.out | 24 ++++++ tests/xfs/group | 1 + 3 files changed, 239 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..a54fe136 --- /dev/null +++ b/tests/xfs/522 @@ -0,0 +1,214 @@ +#! /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 (limited to non-realtime 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/quota +. ./common/inject + +# 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_xfs_io_command "falloc" +_require_xfs_io_error_injection "reduce_max_iextents" +_require_xfs_io_error_injection "bmap_alloc_minlen_extent" + +delalloc_to_written_extent() +{ + echo "* Delalloc to written extent conversion" + + echo "Format and mount fs" + _scratch_mkfs >> $seqres.full + _scratch_mount >> $seqres.full + + testfile=$SCRATCH_MNT/testfile + bsize=$(_get_block_size $SCRATCH_MNT) + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + nr_blks=$((15 * 2)) + + echo "Create fragmented file" + for i in $(seq 0 2 $((nr_blks - 1))); do + xfs_io -f -c "pwrite $((i * bsize)) $bsize" -c fsync $testfile >> $seqres.full 2>&1 + [[ $? != 0 ]] && break + done + + testino=$(stat -c "%i" $testfile) + + _scratch_unmount >> $seqres.full + + echo "Verify \$testfile's extent count" + + nextents=$(_scratch_get_iext_count $testino 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 +} + +falloc_unwritten_extent() +{ + echo "* Fallocate of unwritten extents" + + echo "Format and mount fs" + _scratch_mkfs >> $seqres.full + _scratch_mount >> $seqres.full + + testfile=$SCRATCH_MNT/testfile + bsize=$(_get_block_size $SCRATCH_MNT) + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + nr_blks=$((15 * 2)) + + echo "Fallocate fragmented file" + for i in $(seq 0 2 $((nr_blks - 1))); do + xfs_io -f -c "falloc $((i * bsize)) $bsize" $testfile >> $seqres.full 2>&1 + [[ $? != 0 ]] && break + done + + testino=$(stat -c "%i" $testfile) + + _scratch_unmount >> $seqres.full + + echo "Verify \$testfile's extent count" + + nextents=$(_scratch_get_iext_count $testino 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 +} + +quota_inode_extend() +{ + echo "* Extend quota inodes" + + echo "Format and mount fs" + _scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full + _scratch_mount -o uquota >> $seqres.full + + testfile=$SCRATCH_MNT/testfile + bsize=$(_get_block_size $SCRATCH_MNT) + + echo "Consume free space" + dd if=/dev/zero of=${testfile} bs=${bsize} >> $seqres.full 2>&1 + sync + + echo "Create fragmented filesystem" + $here/src/punch-alternating $testfile >> $seqres.full + sync + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + echo "Inject bmap_alloc_minlen_extent error tag" + xfs_io -x -c 'inject bmap_alloc_minlen_extent' $SCRATCH_MNT + + nr_blks=20 + + # This is a rough calculation; It doesn't take block headers into + # consideration. + # gdb -batch vmlinux -ex 'print sizeof(struct xfs_disk_dquot)' + # $1 = 104 + nr_quotas_per_block=$((bsize / 104)) + nr_quotas=$((nr_quotas_per_block * nr_blks)) + + echo "Extend uquota file" + for i in $(seq 0 $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 +} + +directio_write() +{ + echo "* Directio write" + + echo "Format and mount fs" + _scratch_mkfs >> $seqres.full + _scratch_mount >> $seqres.full + + testfile=$SCRATCH_MNT/testfile + bsize=$(_get_block_size $SCRATCH_MNT) + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + nr_blks=$((15 * 2)) + + echo "Create fragmented file via directio writes" + for i in $(seq 0 2 $((nr_blks - 1))); do + xfs_io -d -f -c "pwrite $((i * bsize)) $bsize" -c fsync $testfile >> $seqres.full 2>&1 + [[ $? != 0 ]] && break + done + + testino=$(stat -c "%i" $testfile) + + _scratch_unmount >> $seqres.full + + echo "Verify \$testfile's extent count" + + nextents=$(_scratch_get_iext_count $testino 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 +} + +delalloc_to_written_extent +falloc_unwritten_extent +quota_inode_extend +directio_write + +# success, all done +status=0 +exit diff --git a/tests/xfs/522.out b/tests/xfs/522.out new file mode 100644 index 00000000..98791aae --- /dev/null +++ b/tests/xfs/522.out @@ -0,0 +1,24 @@ +QA output created by 522 +* Delalloc to written extent conversion +Format and mount fs +Inject reduce_max_iextents error tag +Create fragmented file +Verify $testfile's extent count +* Fallocate of unwritten extents +Format and mount fs +Inject reduce_max_iextents error tag +Fallocate fragmented file +Verify $testfile's extent count +* Extend quota inodes +Format and mount fs +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 +* Directio write +Format and mount fs +Inject reduce_max_iextents error tag +Create fragmented file via directio writes +Verify $testfile'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 Fri Nov 13 11:26:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 11903165 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50FB515E6 for ; Fri, 13 Nov 2020 12:05:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2FCF92224F for ; Fri, 13 Nov 2020 12:05:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NAiR9KTG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727115AbgKMMFO (ORCPT ); Fri, 13 Nov 2020 07:05:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726495AbgKML1n (ORCPT ); Fri, 13 Nov 2020 06:27:43 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC55BC061A47; Fri, 13 Nov 2020 03:27:38 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id v12so7350759pfm.13; Fri, 13 Nov 2020 03:27:38 -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=tDNJv2hKsH0A5GF/u9+v/0f2U4xIn/WtS6Vk2OEsrlw=; b=NAiR9KTGTOTNFhUGoNYjOTjcd+fnGj4UGePcd/1luvGey+tw3s2HsyFDcl6dLJwGpn ymRHwvQmC95OB+gK81PAfZSlCTEswiFgSh+AUhgdbzWR97lRXB5lvzP9sWAuu84kk8Q5 eehXeO/IZBb5bSzGEgysH94qwTKM6d8k4SVjT4LyhLmmgtss+Q2YqXK955lrI3l7yXlQ TGoiMlBPtVDqBvFt/jqtLn4syu+8q77uNc1FBS9Zl7+gaGeAdQibcBf4Z9saNhdwKdjO X+QNXrvTZB4C9fr2exkVfy1QQMAFz0AHkkFjqf9ushwuVDnmzbOfSmmRID2m2YuqTBGb DZUw== 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=tDNJv2hKsH0A5GF/u9+v/0f2U4xIn/WtS6Vk2OEsrlw=; b=gRO+zK7w21cTSPbr/TDuH5JoxgQQZUpY3pSQdSfk/e2bTj3QWj/iND+kfzSOM6AxV6 gaKXIxeudwj2ESywmANUyfuXjimf0pNIwKGrMCbu+DUyYvOmj6zoPbTa+dHciWtwxeDQ 9RJsc2roFi/BPo/z8PvNm69rsm+RrmNUXoz+qcOcMO+nTHdvG1tDyY62X9CGbpr6qi+G tTAhtgP5G1QvJF8LMvWcFFe/PBdtoESbd2/X5vlrW+/4U0jLSlJz5cnotIe0o8lECJhN yMKHdzaIco6oq9XdtpdUlpZDq/b2Uct76xL3Nog37povOEB8KJ9X7s8mjJKUdKPkwiiS jcyw== X-Gm-Message-State: AOAM531QUYXQHEq8RT6ciDo9WlviBl1YUxUJ5HETTqerjC/AWqOG2AEi FGFg8ZaJy5AOgrA3ZAVk/fMwsTavaeI= X-Google-Smtp-Source: ABdhPJxX0SVG2TKANFVjVB5vPi8NfGu7EJGrd7CoKnlvdNqmGBDh83HUcia3+4P4mq+GfasE9Wh99A== X-Received: by 2002:a05:6a00:4a:b029:18b:3748:8931 with SMTP id i10-20020a056a00004ab029018b37488931mr1587838pfk.61.1605266857945; Fri, 13 Nov 2020 03:27:37 -0800 (PST) Received: from localhost.localdomain ([122.172.185.167]) by smtp.gmail.com with ESMTPSA id w131sm9410857pfd.14.2020.11.13.03.27.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 03:27:37 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com Subject: [PATCH 03/11] xfs: Check for extent overflow when trivally adding a new extent Date: Fri, 13 Nov 2020 16:56:55 +0530 Message-Id: <20201113112704.28798-4-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113112704.28798-1-chandanrlinux@gmail.com> References: <20201113112704.28798-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org 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 (limited to realtime files only). Signed-off-by: Chandan Babu R --- tests/xfs/523 | 176 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/523.out | 18 +++++ tests/xfs/group | 1 + 3 files changed, 195 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..4f5b3584 --- /dev/null +++ b/tests/xfs/523 @@ -0,0 +1,176 @@ +#! /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 inode fork's extent count to overflow when +# adding a single extent while there's no possibility of splitting an existing +# mapping (limited to realtime files only). +# +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 + +# 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 + +grow_rtinodes() +{ + 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 + + testfile=$SCRATCH_MNT/testfile + + echo "Consume free space" + dd if=/dev/zero of=${testfile} bs=${dbsize} >> $seqres.full 2>&1 + sync + + echo "Create fragmented filesystem" + $here/src/punch-alternating $testfile >> $seqres.full + sync + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + echo "Inject bmap_alloc_minlen_extent error tag" + xfs_io -x -c 'inject bmap_alloc_minlen_extent' $SCRATCH_MNT + + echo "Grow realtime volume" + xfs_growfs -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="" +} + +rtfile_extend() +{ + echo "* Test extending an rt file" + + _scratch_mkfs | _filter_mkfs >> $seqres.full 2> $tmp.mkfs + . $tmp.mkfs + + echo "Create fake rt volume" + nr_blks=$((15 * 2)) + rtextsz=$dbsize + rtdevsz=$((2 * nr_blks * 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=$rtdevsz >> $seqres.full + _scratch_mount >> $seqres.full + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + echo "Create fragmented file on rt volume" + testfile=$SCRATCH_MNT/testfile + for i in $(seq 0 2 $((nr_blks - 1))); do + xfs_io -Rf -c "pwrite $((i * dbsize)) $dbsize" -c fsync \ + $testfile >> $seqres.full 2>&1 + [[ $? != 0 ]] && break + done + + testino=$(stat -c "%i" $testfile) + + _scratch_unmount >> $seqres.full + + echo "Verify \$testfile's extent count" + nextents=$(_scratch_get_iext_count $testino 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 + + 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="" +} + +grow_rtinodes +rtfile_extend + +# success, all done +status=0 +exit diff --git a/tests/xfs/523.out b/tests/xfs/523.out new file mode 100644 index 00000000..16b4e0ad --- /dev/null +++ b/tests/xfs/523.out @@ -0,0 +1,18 @@ +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 +* Test extending an rt file +Create fake rt volume +Format and mount rt volume +Inject reduce_max_iextents error tag +Create fragmented file on rt volume +Verify $testfile'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 Fri Nov 13 11:26:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 11903171 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 231F8921 for ; Fri, 13 Nov 2020 12:05:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF11822240 for ; Fri, 13 Nov 2020 12:05:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kxgFGxq/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727122AbgKMMFP (ORCPT ); Fri, 13 Nov 2020 07:05:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726396AbgKML1n (ORCPT ); Fri, 13 Nov 2020 06:27:43 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CC52C0613D1; Fri, 13 Nov 2020 03:27:41 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id b63so3770211pfg.12; Fri, 13 Nov 2020 03:27:41 -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=pot8Kf6jgb7e4v+fUhEDLSV5g2CFkO2k7KfvRf+68oY=; b=kxgFGxq/1u37Jm/TVHSs0lWzdVdbnY+FMjyo/eXi02lymZktLpLXXbTD+PEsk12i4z vHDoynGr3iuZjCOcDCZ+eSdCdeNm5tsWvTw3pjPrcWiTIPtG1743c9jx20x8Uqc2Nqrv 9AxKYnxkMx/GaXPh7W8wOLXXieMJZLt9HrmyueHCsApryO7ghRcLqeSFS8JRgiEIC39p lOjc1t9+tedVJzIiC9NZ8uOmS3WJomeHva9coDWShsuFlR76qyL1eEI0Xi9IVLBTJ3S7 ghlPNmzvHqbr5Vrqby0sPOUFoms2tRSvuNP4Ozxu31ALSkZjGBc5XYs214wHgcOcAD0Q NI3Q== 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=pot8Kf6jgb7e4v+fUhEDLSV5g2CFkO2k7KfvRf+68oY=; b=Rw77QNWbiqt3ZIuORA//+Mb9RfrYivxlSFcubejKG57m0HZfk673YSl7apOixcFzPY j+A7B7CNNWM9dmZqEd2d4AkL/wNCAznN0kEk5ZOS8iuy1Dfuk5VIbej/0cXV+UoQUaUL qrAFg4zQLjia+7GCz8ZBSPp1tHwNAcCVuQc2zb6WyIEL2y6LhN7ZqADBbubad9uf0Wev Xt5klMmNF3+GruS8GB6D93+ALwv94yzYwzDgDaOxxAfBODRLvIMDjG8Pudgi86Y6n1Z1 U6FEzbWPC7wWDI+ZXqLcB4/+Ij/hc7dZVyLAV0vOopwTzXaw7ddF/FjXWZmJ6oDwsnFG cinw== X-Gm-Message-State: AOAM532yMMIbEyUcjo8aKaAmS///6mM/xNFLkUBdCWbtze94grLJCUdU QPEasa6JuqpG7SeRtIRg1/CtEKX1Jf4= X-Google-Smtp-Source: ABdhPJxLyJmeXCIHXWdOv+m8H6wH29UFH+rZHE8snEnDn2a5RvpYTuH1+X6y7F/bRuh+Wc+TCL6rOA== X-Received: by 2002:a17:90a:d997:: with SMTP id d23mr814367pjv.218.1605266860492; Fri, 13 Nov 2020 03:27:40 -0800 (PST) Received: from localhost.localdomain ([122.172.185.167]) by smtp.gmail.com with ESMTPSA id w131sm9410857pfd.14.2020.11.13.03.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 03:27:39 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com Subject: [PATCH 04/11] xfs: Check for extent overflow when punching a hole Date: Fri, 13 Nov 2020 16:56:56 +0530 Message-Id: <20201113112704.28798-5-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113112704.28798-1-chandanrlinux@gmail.com> References: <20201113112704.28798-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@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 --- tests/xfs/524 | 210 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/524.out | 25 ++++++ tests/xfs/group | 1 + 3 files changed, 236 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..9e140c99 --- /dev/null +++ b/tests/xfs/524 @@ -0,0 +1,210 @@ +#! /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 "finsert" +_require_xfs_io_command "fcollapse" +_require_xfs_io_command "fzero" +_require_test_program "punch-alternating" +_require_xfs_io_error_injection "reduce_max_iextents" + +punch_range() +{ + echo "* Fpunch regular file" + + echo "Format and mount fs" + _scratch_mkfs >> $seqres.full + _scratch_mount >> $seqres.full + + testfile=$SCRATCH_MNT/testfile + bsize=$(_get_block_size $SCRATCH_MNT) + + nr_blks=30 + + echo "Create \$testfile" + xfs_io -f -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + -c sync $testfile >> $seqres.full + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + echo "fpunch alternating blocks" + $here/src/punch-alternating $testfile >> $seqres.full 2>&1 + + testino=$(stat -c "%i" $testfile) + + _scratch_unmount >> $seqres.full + + echo "Verify \$testfile's extent count" + + nextents=$(_scratch_get_iext_count $testino 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 +} + +finsert_range() +{ + echo "* Finsert regular file" + + echo "Format and mount fs" + _scratch_mkfs >> $seqres.full + _scratch_mount >> $seqres.full + + testfile=$SCRATCH_MNT/testfile + bsize=$(_get_block_size $SCRATCH_MNT) + + nr_blks=30 + + echo "Create \$testfile" + xfs_io -f -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + -c sync $testfile >> $seqres.full + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + echo "Finsert at every other block offset" + for i in $(seq 1 2 $((nr_blks - 1))); do + xfs_io -f -c "finsert $((i * bsize)) $bsize" $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break + done + + testino=$(stat -c "%i" $testfile) + + _scratch_unmount >> $seqres.full + + echo "Verify \$testfile's extent count" + + nextents=$(_scratch_get_iext_count $testino 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 +} + +fcollapse_range() +{ + echo "* Fcollapse regular file" + + echo "Format and mount fs" + _scratch_mkfs >> $seqres.full + _scratch_mount >> $seqres.full + + testfile=$SCRATCH_MNT/testfile + bsize=$(_get_block_size $SCRATCH_MNT) + + nr_blks=30 + + echo "Create \$testfile" + xfs_io -f -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + -c sync $testfile >> $seqres.full + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + echo "Fcollapse at every other block offset" + for i in $(seq 1 $((nr_blks / 2 - 1))); do + xfs_io -f -c "fcollapse $((i * bsize)) $bsize" $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break + done + + testino=$(stat -c "%i" $testfile) + + _scratch_unmount >> $seqres.full + + echo "Verify \$testfile's extent count" + + nextents=$(_scratch_get_iext_count $testino 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 +} + +fzero_range() +{ + echo "* Fzero regular file" + + echo "Format and mount fs" + _scratch_mkfs >> $seqres.full + _scratch_mount >> $seqres.full + + testfile=$SCRATCH_MNT/testfile + bsize=$(_get_block_size $SCRATCH_MNT) + + nr_blks=30 + + echo "Create \$testfile" + xfs_io -f -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + -c sync $testfile >> $seqres.full + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + echo "Fzero at every other block offset" + for i in $(seq 1 2 $((nr_blks - 1))); do + xfs_io -f -c "fzero $((i * bsize)) $bsize" $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break + done + + testino=$(stat -c "%i" $testfile) + + _scratch_unmount >> $seqres.full + + echo "Verify \$testfile's extent count" + + nextents=$(_scratch_get_iext_count $testino 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 +} + +punch_range +finsert_range +fcollapse_range +fzero_range + +# success, all done +status=0 +exit diff --git a/tests/xfs/524.out b/tests/xfs/524.out new file mode 100644 index 00000000..58f7d7ae --- /dev/null +++ b/tests/xfs/524.out @@ -0,0 +1,25 @@ +QA output created by 524 +* Fpunch regular file +Format and mount fs +Create $testfile +Inject reduce_max_iextents error tag +fpunch alternating blocks +Verify $testfile's extent count +* Finsert regular file +Format and mount fs +Create $testfile +Inject reduce_max_iextents error tag +Finsert at every other block offset +Verify $testfile's extent count +* Fcollapse regular file +Format and mount fs +Create $testfile +Inject reduce_max_iextents error tag +Fcollapse at every other block offset +Verify $testfile's extent count +* Fzero regular file +Format and mount fs +Create $testfile +Inject reduce_max_iextents error tag +Fzero at every other block offset +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 Fri Nov 13 11:26:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 11903163 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B837A14C0 for ; Fri, 13 Nov 2020 12:05:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 949972224C for ; Fri, 13 Nov 2020 12:05:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NzpboTfJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727107AbgKMMFN (ORCPT ); Fri, 13 Nov 2020 07:05:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726184AbgKML1o (ORCPT ); Fri, 13 Nov 2020 06:27:44 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8841C061A49; Fri, 13 Nov 2020 03:27:43 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id a18so7390466pfl.3; Fri, 13 Nov 2020 03:27:43 -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=z7HROPP4p0WyFli+42wxjrz7OGx+y1FoxAU7QHFJXTg=; b=NzpboTfJEMzgZyXR3Cja3DvZ0/2FZmyxj+A7CLGoKlE9ICYKAU7jiBZiX9NNT5LzZL UQaXbXiOxZth4VpNwYWP4jqjKOCJNXc8CtpmYYI8wVmFaFXVcOA66AY41hMu/Jcx4j/j J2GrahHtkEGCrpFxsj6kqZureJKh5OlmOqF04nu7XpvSqOblxNlBqmlw5xt0b8rsGWaU JnqH0/J/LSJ0PxpFMh7meWxBAgD27kqsbOKrhBIpfk/uymC+fBv1pNRkpw+z3+1TGB5Z nwv6wvHcJUjMN4eUhhKG0kgE+vmi+uGCso7TYKNbRopkpClC1Q0vcwPCFqZv58epk2By +ryw== 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=z7HROPP4p0WyFli+42wxjrz7OGx+y1FoxAU7QHFJXTg=; b=bS23mKUjdxPa5ZGHmVa0ehwWrMj8luCCSe58wpBhnyt4k40Kj3BGfrq8sE/yXbwTv9 zjEjvHkNe53Fa2HSey8lfbpJDAllJ0stfotP78wkWlt59/m67fgMejV01LwD47D8C6Al wNKLgCnwdq81vT4LG0hyY2FcW+UPrt/lEAnv21GNHAyf0y1i7Zt+JNqaK5IzvQy3CIug OdeNtc/VTZD5G6YBtXWAZxZtzMdHYEQRGtU2CovHggzSrZ1prnPX98uAUKu1ul0M7uK6 Hx0rnTAnPxGJXIkftOv6F0OYRU1pDJHx1kHv/HjO5gSBRv5Sy+af51cQ5AIIyrVR9b6f OAUg== X-Gm-Message-State: AOAM5320rJ3sYMsKupywrG3wdqV3YeVGkvjmC2lNrnECkc8sNVA4HbCj 0bauUxuUnxQXf/ItEi+TpJJybZlWleU= X-Google-Smtp-Source: ABdhPJzOxTKSVyJY2TXe21Qo9TbXfT6uQbmmEyrcISXRJdsMR+sBuHmpe9tFGejs45dChb1mzsRXiA== X-Received: by 2002:a17:90b:180f:: with SMTP id lw15mr2452378pjb.119.1605266862983; Fri, 13 Nov 2020 03:27:42 -0800 (PST) Received: from localhost.localdomain ([122.172.185.167]) by smtp.gmail.com with ESMTPSA id w131sm9410857pfd.14.2020.11.13.03.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 03:27:42 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com Subject: [PATCH 05/11] xfs: Check for extent overflow when adding/removing xattrs Date: Fri, 13 Nov 2020 16:56:57 +0530 Message-Id: <20201113112704.28798-6-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113112704.28798-1-chandanrlinux@gmail.com> References: <20201113112704.28798-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@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 --- tests/xfs/525 | 154 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/525.out | 16 +++++ tests/xfs/group | 1 + 3 files changed, 171 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..1d5d6e7c --- /dev/null +++ b/tests/xfs/525 @@ -0,0 +1,154 @@ +#! /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 + +# 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" + +attr_set() +{ + echo "* Set xattrs" + + echo "Format and mount fs" + _scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full + _scratch_mount >> $seqres.full + + bsize=$(_get_block_size $SCRATCH_MNT) + + testfile=$SCRATCH_MNT/testfile + + echo "Consume free space" + dd if=/dev/zero of=${testfile} bs=${bsize} >> $seqres.full 2>&1 + sync + + echo "Create fragmented filesystem" + $here/src/punch-alternating $testfile >> $seqres.full + sync + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + echo "Inject bmap_alloc_minlen_extent error tag" + xfs_io -x -c 'inject bmap_alloc_minlen_extent' $SCRATCH_MNT + + echo "Create xattrs" + + attr_len=$(uuidgen | wc -c) + nr_attrs=$((bsize * 20 / attr_len)) + for i in $(seq 1 $nr_attrs); do + $SETFATTR_PROG -n "trusted.""$(uuidgen)" $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break + done + + testino=$(stat -c "%i" $testfile) + + _scratch_unmount >> $seqres.full + + echo "Verify uquota inode's extent count" + + nextents=$(_scratch_get_iext_count $testino attr || \ + _fail "Unable to obtain inode fork's extent count") + if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 + fi +} + +attr_remove() +{ + echo "* Remove xattrs" + + echo "Format and mount fs" + _scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full + _scratch_mount >> $seqres.full + + bsize=$(_get_block_size $SCRATCH_MNT) + + testfile=$SCRATCH_MNT/testfile + + echo "Consume free space" + dd if=/dev/zero of=${testfile} bs=${bsize} >> $seqres.full 2>&1 + sync + + echo "Create fragmented filesystem" + $here/src/punch-alternating $testfile >> $seqres.full + sync + + testino=$(stat -c "%i" $testfile) + + naextents=0 + last="" + + attr_len=$(uuidgen | wc -c) + nr_attrs=$((bsize / attr_len)) + + echo "Create initial xattr extents" + while (( $naextents < 4 )); do + xfs_io -x -c 'inject bmap_alloc_minlen_extent' $SCRATCH_MNT + + for i in $(seq 1 $nr_attrs); do + last="trusted.""$(uuidgen)" + $SETFATTR_PROG -n $last $testfile + done + + _scratch_unmount >> $seqres.full + + naextents=$(_scratch_get_iext_count $testino attr || \ + _fail "Unable to obtain inode fork's extent count") + + _scratch_mount >> $seqres.full + done + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + echo "Remove xattr to trigger -EFBIG" + $SETFATTR_PROG -x "$last" $testfile >> $seqres.full 2>&1 + if [[ $? == 0 ]]; then + echo "Xattr removal succeeded; Should have failed " + exit 1 + fi +} + +attr_set +attr_remove + +# success, all done +status=0 +exit diff --git a/tests/xfs/525.out b/tests/xfs/525.out new file mode 100644 index 00000000..cc40e6e2 --- /dev/null +++ b/tests/xfs/525.out @@ -0,0 +1,16 @@ +QA output created by 525 +* Set xattrs +Format and mount fs +Consume free space +Create fragmented filesystem +Inject reduce_max_iextents error tag +Inject bmap_alloc_minlen_extent error tag +Create xattrs +Verify uquota inode's extent count +* Remove xattrs +Format and mount fs +Consume free space +Create fragmented filesystem +Create initial xattr extents +Inject reduce_max_iextents error tag +Remove xattr to trigger -EFBIG 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 Fri Nov 13 11:26:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 11903159 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3E495921 for ; Fri, 13 Nov 2020 12:05:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 16D032224C for ; Fri, 13 Nov 2020 12:05:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pOlShzuX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbgKMMFI (ORCPT ); Fri, 13 Nov 2020 07:05:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726437AbgKML1r (ORCPT ); Fri, 13 Nov 2020 06:27:47 -0500 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B096C0617A6; Fri, 13 Nov 2020 03:27:46 -0800 (PST) Received: by mail-pg1-x52c.google.com with SMTP id w4so6826148pgg.13; Fri, 13 Nov 2020 03:27: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=sSHIjMLszJX+fVahS+/Q1sywlr/Eq7uHni2gPmOwKNk=; b=pOlShzuXLn698yv4OYxW4BZjsrcJZEw5++VUjQzzpswf/oWoqWKbLRSSQhDEpakyIk w3/EfOA4i39FauTmv61xR7RKNi8e+l3XZzszG3DbipTy/3JlYWM584haASZKCYIu8iHB YDjaqnUV3ssFVTArDhd0kvPLqkiG0gzVDUtOYy+ohettnpVtogtMekaS7iL27C538BVT XgKBSZ1ydr2+yNNjND/qTCqpFQ3K3nxi2ovxbex+Quc52XCtWPvaHs02c3pqVfbxGhDn SIHb8T+y20lEdBpAQHFMIdCWThuQiOnZO4frNVQZVL/ZpHdhkZibz/3gEWqEf3/2DM2b 2v7w== 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=sSHIjMLszJX+fVahS+/Q1sywlr/Eq7uHni2gPmOwKNk=; b=s9eXhDjPLHYV/9b4bdyMUty8quiUnVaBjEpTIAF4dvwwgeE+UlILULPy48WOM59QdC NVmw4EaOLIICv208HEWwWrrgBeOhVxCKUWIJwqRBkp0pU13gic1fWZmpZLTK5TMQF6Ks kOvTKG1jgNBxdNgOYro8uOzZw/qgXrPD8ofLoLc44IYXofJqmY3k+EKzn9opUPGp9Yde OrY+mW0XwMoEE3gl/6sWrsT08iNZpFIQC0ClXJdZeY55M6WLd//1ytaJClFWpw4GMO7s ijNK1SKNFeTCeTbh81RifXH1stAqg0madLWVxmZ3G4PmbdxIWWFu1AwPr5qDC6WYZO/J lNYg== X-Gm-Message-State: AOAM530RDX12dD4ph1GOMrERaxpOKR2lYC45sR8hs/qOx5Vq6Qe4ZUFO boIYNz2/umLYVa9MLDmEIenULurAhaI= X-Google-Smtp-Source: ABdhPJyACVH1kNluM4vUTAlSniSmKM0R+2+DPxUsDI6Jz0yS+ZW4du35cejZBFwEI0ygdym6IIxlVw== X-Received: by 2002:a17:90a:cf84:: with SMTP id i4mr1478255pju.88.1605266865583; Fri, 13 Nov 2020 03:27:45 -0800 (PST) Received: from localhost.localdomain ([122.172.185.167]) by smtp.gmail.com with ESMTPSA id w131sm9410857pfd.14.2020.11.13.03.27.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 03:27: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 Subject: [PATCH 06/11] xfs: Check for extent overflow when adding/removing dir entries Date: Fri, 13 Nov 2020 16:56:58 +0530 Message-Id: <20201113112704.28798-7-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113112704.28798-1-chandanrlinux@gmail.com> References: <20201113112704.28798-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@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 | 360 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/526.out | 47 ++++++ tests/xfs/group | 1 + 3 files changed, 408 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..39cfbcf8 --- /dev/null +++ b/tests/xfs/526 @@ -0,0 +1,360 @@ +#! /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 + +# 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 + +dir_entry_create() +{ + echo "* Create directory entries" + + echo "Format and mount fs" + _scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full + _scratch_mount >> $seqres.full + + testfile=$SCRATCH_MNT/testfile + + echo "Consume free space" + dd if=/dev/zero of=${testfile} bs=${dbsize} >> $seqres.full 2>&1 + sync + + echo "Create fragmented filesystem" + $here/src/punch-alternating $testfile >> $seqres.full + sync + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + echo "Inject bmap_alloc_minlen_extent error tag" + xfs_io -x -c 'inject bmap_alloc_minlen_extent' $SCRATCH_MNT + + echo "Create directory entries" + dent_len=$(uuidgen | wc -c) + nr_dents=$((dbsize * 20 / dent_len)) + for i in $(seq 1 $nr_dents); do + touch $SCRATCH_MNT/$(uuidgen) >> $seqres.full 2>&1 || break + done + + dirino=$(stat -c "%i" $SCRATCH_MNT) + + _scratch_unmount >> $seqres.full + + echo "Verify directory's extent count" + + nextents=$(_scratch_get_iext_count $dirino data || \ + _fail "Unable to obtain inode fork's extent count") + if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + fi +} + +dir_entry_rename_dst() +{ + echo "* Rename: Populate destination directory" + + echo "Format and mount fs" + _scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full + _scratch_mount >> $seqres.full + + testfile=$SCRATCH_MNT/testfile + + echo "Consume free space" + dd if=/dev/zero of=${testfile} bs=${dbsize} >> $seqres.full 2>&1 + sync + + echo "Create fragmented filesystem" + $here/src/punch-alternating $testfile >> $seqres.full + sync + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + echo "Inject bmap_alloc_minlen_extent error tag" + xfs_io -x -c 'inject bmap_alloc_minlen_extent' $SCRATCH_MNT + + dstdir=$SCRATCH_MNT/dstdir + mkdir $dstdir + + dent_len=$(uuidgen | wc -c) + nr_dents=$((dirbsize * 20 / dent_len)) + + echo "Populate \$dstdir by mv-ing new directory entries" + for i in $(seq 1 $nr_dents); do + file=${SCRATCH_MNT}/$(uuidgen) + touch $file || break + mv $file $dstdir >> $seqres.full 2>&1 || break + done + + dirino=$(stat -c "%i" $dstdir) + + _scratch_unmount >> $seqres.full + + echo "Verify \$dstdir's extent count" + + nextents=$(_scratch_get_iext_count $dirino data || \ + _fail "Unable to obtain inode fork's extent count") + if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + fi +} + +dir_entry_rename_src() +{ + echo "* Rename: Populate source directory and mv one entry to destination directory" + + echo "Format and mount fs" + _scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full + _scratch_mount >> $seqres.full + + testfile=$SCRATCH_MNT/testfile + + echo "Consume free space" + dd if=/dev/zero of=${testfile} bs=${dbsize} >> $seqres.full 2>&1 + sync + + echo "Create fragmented filesystem" + $here/src/punch-alternating $testfile >> $seqres.full + sync + + srcdir=${SCRATCH_MNT}/srcdir + dstdir=${SCRATCH_MNT}/dstdir + + mkdir $srcdir $dstdir + + dirino=$(stat -c "%i" $srcdir) + + dent_len=$(uuidgen | wc -c) + nr_dents=$((dirbsize / dent_len)) + nextents=0 + last="" + + echo "Populate \$srcdir with atleast 4 extents" + while (( $nextents < 4 )); do + xfs_io -x -c 'inject bmap_alloc_minlen_extent' $SCRATCH_MNT + + for i in $(seq 1 $nr_dents); do + last=${srcdir}/$(uuidgen) + touch $last || break + done + + _scratch_unmount >> $seqres.full + + nextents=$(_scratch_get_iext_count $dirino data || \ + _fail "Unable to obtain inode fork's extent count") + + _scratch_mount >> $seqres.full + done + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + echo "Move an entry from \$srcdir to trigger -EFBIG" + mv $last $dstdir >> $seqres.full 2>&1 + if [[ $? == 0 ]]; then + echo "Moving from \$srcdir to \$dstdir succeeded; Should have failed" + fi + + _scratch_unmount >> $seqres.full +} + +dir_entry_create_hard_links() +{ + echo "* Create multiple hard links to a single file" + + echo "Format and mount fs" + _scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full + _scratch_mount >> $seqres.full + + testfile=$SCRATCH_MNT/testfile + + echo "Consume free space" + dd if=/dev/zero of=${testfile} bs=${dbsize} >> $seqres.full 2>&1 + sync + + echo "Create fragmented filesystem" + $here/src/punch-alternating $testfile >> $seqres.full + sync + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + echo "Inject bmap_alloc_minlen_extent error tag" + xfs_io -x -c 'inject bmap_alloc_minlen_extent' $SCRATCH_MNT + + dent_len=$(uuidgen | wc -c) + nr_dents=$((dirbsize * 20 / dent_len)) + + echo "Create multiple hardlinks" + for i in $(seq 1 $nr_dents); do + ln $testfile ${SCRATCH_MNT}/$(uuidgen) >> $seqres.full 2>&1 || break + done + + dirino=$(stat -c "%i" $SCRATCH_MNT) + + _scratch_unmount >> $seqres.full + + echo "Verify directory's extent count" + + nextents=$(_scratch_get_iext_count $dirino data || \ + _fail "Unable to obtain inode fork's extent count") + if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + fi +} + +dir_entry_create_symlinks() +{ + echo "* Create multiple symbolic links to a single file" + + echo "Format and mount fs" + _scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full + _scratch_mount >> $seqres.full + + testfile=$SCRATCH_MNT/testfile + + echo "Consume free space" + dd if=/dev/zero of=${testfile} bs=${dbsize} >> $seqres.full 2>&1 + sync + + echo "Create fragmented filesystem" + $here/src/punch-alternating $testfile >> $seqres.full + sync + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + echo "Inject bmap_alloc_minlen_extent error tag" + xfs_io -x -c 'inject bmap_alloc_minlen_extent' $SCRATCH_MNT + + dent_len=$(uuidgen | wc -c) + nr_dents=$((dirbsize * 20 / dent_len)) + + echo "Create multiple symbolic links" + for i in $(seq 1 $nr_dents); do + ln -s $testfile ${SCRATCH_MNT}/$(uuidgen) >> $seqres.full 2>&1 || break; + done + + dirino=$(stat -c "%i" $SCRATCH_MNT) + + _scratch_unmount >> $seqres.full + + echo "Verify directory's extent count" + + nextents=$(_scratch_get_iext_count $dirino data || \ + _fail "Unable to obtain inode fork's extent count") + if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + fi +} + +dir_entry_remove() +{ + echo "* Populate a directory and remove one entry" + + echo "Format and mount fs" + _scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full + _scratch_mount >> $seqres.full + + testfile=$SCRATCH_MNT/testfile + + echo "Consume free space" + dd if=/dev/zero of=${testfile} bs=${dbsize} >> $seqres.full 2>&1 + sync + + echo "Create fragmented filesystem" + $here/src/punch-alternating $testfile >> $seqres.full + sync + + dirino=$(stat -c "%i" $SCRATCH_MNT) + + dent_len=$(uuidgen | wc -c) + nr_dents=$((dirbsize / dent_len)) + nextents=0 + last="" + + echo "Populate directory with atleast 4 extents" + while (( $nextents < 4 )); do + xfs_io -x -c 'inject bmap_alloc_minlen_extent' $SCRATCH_MNT + + for i in $(seq 1 $nr_dents); do + last=${SCRATCH_MNT}/$(uuidgen) + touch $last || break + done + + _scratch_unmount >> $seqres.full + + nextents=$(_scratch_get_iext_count $dirino data || \ + _fail "Unable to obtain inode fork's extent count") + + _scratch_mount >> $seqres.full + done + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + + echo "Remove an entry from directory to trigger -EFBIG" + rm $last >> $seqres.full 2>&1 + if [[ $? == 0 ]]; then + echo "Removing file succeeded; Should have failed" + fi + + _scratch_unmount >> $seqres.full +} + +# 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 + +dir_entry_create +dir_entry_rename_dst +dir_entry_rename_src +dir_entry_create_hard_links +dir_entry_create_symlinks +dir_entry_remove + +# success, all done +status=0 +exit diff --git a/tests/xfs/526.out b/tests/xfs/526.out new file mode 100644 index 00000000..21f77cd8 --- /dev/null +++ b/tests/xfs/526.out @@ -0,0 +1,47 @@ +QA output created by 526 +* Create directory entries +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 +Format and mount fs +Consume free space +Create fragmented filesystem +Inject reduce_max_iextents error tag +Inject bmap_alloc_minlen_extent error tag +Populate $dstdir by mv-ing new directory entries +Verify $dstdir's extent count +* Rename: Populate source directory and mv one entry to destination directory +Format and mount fs +Consume free space +Create fragmented filesystem +Populate $srcdir with atleast 4 extents +Inject reduce_max_iextents error tag +Move an entry from $srcdir to trigger -EFBIG +* Create multiple hard links to a single file +Format and mount fs +Consume free space +Create fragmented filesystem +Inject reduce_max_iextents error tag +Inject bmap_alloc_minlen_extent error tag +Create multiple hardlinks +Verify directory's extent count +* Create multiple symbolic links to a single file +Format and mount fs +Consume free space +Create fragmented filesystem +Inject reduce_max_iextents error tag +Inject bmap_alloc_minlen_extent error tag +Create multiple symbolic links +Verify directory's extent count +* Populate a directory and remove one entry +Format and mount fs +Consume free space +Create fragmented filesystem +Populate directory with atleast 4 extents +Inject reduce_max_iextents error tag +Remove an entry from directory to trigger -EFBIG 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 Fri Nov 13 11:26:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 11903115 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2379E17D5 for ; Fri, 13 Nov 2020 11:30:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 009B722250 for ; Fri, 13 Nov 2020 11:30:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="opaNPkM8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726629AbgKML27 (ORCPT ); Fri, 13 Nov 2020 06:28:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726537AbgKML1u (ORCPT ); Fri, 13 Nov 2020 06:27:50 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5458C0617A7; Fri, 13 Nov 2020 03:27:48 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id e21so6840377pgr.11; Fri, 13 Nov 2020 03:27: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=ag0ThtAmmIS0jZbX6kt+1QfXYKyDbhQi52bVA0ddi/U=; b=opaNPkM8jCXyu4MR+WZbDanu1VtFi3lBK3Sdgf9jfSxW8msKChmKpXPtuPIgr39FYN 0B193QfkjIf/aM5I4CccV1Z9zxLUfBfh+CYr/cMiw6gI6kQMjobfyZvtZ1h1KCyuPPW7 GzkOzW5EMOrBWAV7FSSx6tG8JjqTnV2+qZ+E6bteRnH5HAiSsZyza0JIOJkT9DJLc4tn ey/x6Y4XajKvfOCa/05hNy8NTT/pUvb8/TRlZn40G/aH2SdfqNwvTvIKA6isYUATQymx uH2kBn+PRbU5oykjnh4jzCGulEL9KCP2lgS0YFvRcDeZypsqlZCdxOAekhgr/+OOH4TE qXOQ== 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=ag0ThtAmmIS0jZbX6kt+1QfXYKyDbhQi52bVA0ddi/U=; b=bw4AsEReB8tV1dsYkyifTVQl7NSh3ZJ/xlhC9G+a7d39QmB0G4WWQizo+Xe0XY82MF mCcjaPaSOZA9rDsHuJXghZTSXEXpjoeNqImcjwJsH/t4/XXLfsqRZLwxc5LlPa3BEo4/ C/HFimyvmgGr3Ya3HjE2mR3EAyo9RtacHT8LABczoavdgFLzVU25g0+JQpjByBj3UIMi UdhpFX7PLhlfNz6T2xktOyMsnKSlgri4ClHhKBem0e/fVaq/2B/2YHhsm5BoghrPg2rC q85nmkELF9d4v4XEDTRpAjqA+xmmN8cztXF+zMsO03JIXZIjrz1qbnujvoH91ZQWMXc/ ZTUA== X-Gm-Message-State: AOAM532xuXr1l/gd7opo1aXqC2+0CCfm8TSFWqNRexCXngphQmBn00ZW Gjg94h93QXLYYfNTqOsKFreF1hhwv0I= X-Google-Smtp-Source: ABdhPJwM82fkOnLldKAM5R0HP/zE+hB7E75joHAyIw7yXF3jazROKhheNZ3EPL8jNJA7uHmNR06QEg== X-Received: by 2002:a17:90b:4683:: with SMTP id ir3mr2512765pjb.212.1605266868012; Fri, 13 Nov 2020 03:27:48 -0800 (PST) Received: from localhost.localdomain ([122.172.185.167]) by smtp.gmail.com with ESMTPSA id w131sm9410857pfd.14.2020.11.13.03.27.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 03:27: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 Subject: [PATCH 07/11] xfs: Check for extent overflow when writing to unwritten extent Date: Fri, 13 Nov 2020 16:56:59 +0530 Message-Id: <20201113112704.28798-8-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113112704.28798-1-chandanrlinux@gmail.com> References: <20201113112704.28798-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@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 | 125 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/527.out | 13 +++++ tests/xfs/group | 1 + 3 files changed, 139 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..f040aee4 --- /dev/null +++ b/tests/xfs/527 @@ -0,0 +1,125 @@ +#! /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" + +buffered_write_to_unwritten_extent() +{ + echo "* Buffered write to unwritten extent" + + echo "Format and mount fs" + _scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full + _scratch_mount >> $seqres.full + + bsize=$(_get_block_size $SCRATCH_MNT) + + testfile=${SCRATCH_MNT}/testfile + + nr_blks=15 + + echo "Fallocate $nr_blks blocks" + xfs_io -f -c "falloc 0 $((nr_blks * bsize))" $testfile >> $seqres.full + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c "inject reduce_max_iextents" $SCRATCH_MNT + + echo "Buffered write to every other block of fallocated space" + for i in $(seq 1 2 $((nr_blks - 1))); do + xfs_io -f -c "pwrite $((i * bsize)) $bsize" -c fsync $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break + done + + testino=$(stat -c "%i" $testfile) + + _scratch_unmount >> $seqres.full + + echo "Verify \$testfile's extent count" + + nextents=$(_scratch_get_iext_count $testino data || \ + _fail "Unable to obtain inode fork's extent count") + if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + fi +} + +direct_write_to_unwritten_extent() +{ + echo "* Direct I/O write to unwritten extent" + + echo "Format and mount fs" + _scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full + _scratch_mount >> $seqres.full + + bsize=$(_get_block_size $SCRATCH_MNT) + + testfile=${SCRATCH_MNT}/testfile + + nr_blks=15 + + echo "Fallocate $nr_blks blocks" + xfs_io -f -c "falloc 0 $((nr_blks * bsize))" $testfile >> $seqres.full + + echo "Inject reduce_max_iextents error tag" + xfs_io -x -c "inject reduce_max_iextents" $SCRATCH_MNT + + echo "Direct I/O write to every other block of fallocated space" + for i in $(seq 1 2 $((nr_blks - 1))); do + xfs_io -f -d -c "pwrite $((i * bsize)) $bsize" $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break + done + + testino=$(stat -c "%i" $testfile) + + _scratch_unmount >> $seqres.full + + echo "Verify \$testfile's extent count" + + nextents=$(_scratch_get_iext_count $testino data || \ + _fail "Unable to obtain inode fork's extent count") + if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + fi +} + +buffered_write_to_unwritten_extent +direct_write_to_unwritten_extent + +# success, all done +status=0 +exit diff --git a/tests/xfs/527.out b/tests/xfs/527.out new file mode 100644 index 00000000..6aa5e9ed --- /dev/null +++ b/tests/xfs/527.out @@ -0,0 +1,13 @@ +QA output created by 527 +* Buffered write to unwritten extent +Format and mount fs +Fallocate 15 blocks +Inject reduce_max_iextents error tag +Buffered write to every other block of fallocated space +Verify $testfile's extent count +* Direct I/O write to unwritten extent +Format and mount fs +Fallocate 15 blocks +Inject reduce_max_iextents error tag +Direct I/O 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 Fri Nov 13 11:27:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 11903117 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 173D915E6 for ; Fri, 13 Nov 2020 11:30:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E36D322240 for ; Fri, 13 Nov 2020 11:30:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MbXPjWTW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726433AbgKMLa3 (ORCPT ); Fri, 13 Nov 2020 06:30:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726557AbgKML2V (ORCPT ); Fri, 13 Nov 2020 06:28:21 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AB30C061A48; Fri, 13 Nov 2020 03:27:51 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id g7so7403789pfc.2; Fri, 13 Nov 2020 03:27: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=It9eDeqASlzE9iUH+GF+Ahf6+010vIJ6aAmZ1pUVA6o=; b=MbXPjWTWDFzL2HlAU2cikiB0Cnby+n1+6Tn6prekIwGO/DpNBciUTA3t58TuhzJsqJ d025eb5zzW4WExbMxq3LqgdFpWRVVAWidq5jcKc36I17BnZha3Ex64x8jPtOAljy+jHh 67+kw6ouqioVQQ8qKW/qduYnAU+iR33LrP5ULly6ZARK7VIkerU5OPor3xyE8FFHmZxw UTMa7ot7lizR12rNGrcB/2LMx//gOo7ttfjBYopRGChS/y2QvSZ2kwRBTkXC56W39Yem w6cc0MaMDVt4G5p/lEv4Fij2gQYiJ7bhqq8wE7YMLpwx3/Aoyu+hRp/V5HcvQPTVbRFv ej6g== 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=It9eDeqASlzE9iUH+GF+Ahf6+010vIJ6aAmZ1pUVA6o=; b=ma0I4tOpac/XnmHRcAwtAyEA/xyVlmSZMcSNNeojQaQgvtmLAyufM8NtqR+chYsrjl kekiNVbVnfZSy3nBtygfm1qZ+C7uPefH5hC/kLF9hA3vSDE2IyBf24VP3o5BAs0gNbyn YHnw2qVre3EkC1EkWlPx09yOpWmbg5pJa7C3HpxAUSU7vRrUol/8v868lrinL4m7rPeo 6IqhoTN9HA0IiAbSn21bj3yXpjmyJa8i7NkF3dY9wSEsievdPRJo9jJNF06zndNrIknq 5jDwYsH2GHIVkuohPTm6Nb6i9hjOGHxqXxxATYkf+gHpXrOdoAFF3d6JfSI+stD+AnfU jUqQ== X-Gm-Message-State: AOAM5304bYkxfsrX2fskElvHsKoAj6vc4RKS+pUMhbX1TjTBZd9cfMxB tBKjCotSRULzwSphacTLFz6isDnbAd0= X-Google-Smtp-Source: ABdhPJykxrzjQJsuoZntCYc5exbIBytAP1Irz6H0p8b909saHqqs4Zk153UnqJ8Ol+tiY4SgU9D8Jw== X-Received: by 2002:a17:90a:4215:: with SMTP id o21mr2426060pjg.166.1605266870492; Fri, 13 Nov 2020 03:27:50 -0800 (PST) Received: from localhost.localdomain ([122.172.185.167]) by smtp.gmail.com with ESMTPSA id w131sm9410857pfd.14.2020.11.13.03.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 03:27:49 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com Subject: [PATCH 08/11] xfs: Check for extent overflow when moving extent from cow to data fork Date: Fri, 13 Nov 2020 16:57:00 +0530 Message-Id: <20201113112704.28798-9-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113112704.28798-1-chandanrlinux@gmail.com> References: <20201113112704.28798-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org This test verifies that XFS does not cause inode fork's extent count to overflow when writing to a shared extent. Signed-off-by: Chandan Babu R --- tests/xfs/528 | 87 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/528.out | 8 +++++ tests/xfs/group | 1 + 3 files changed, 96 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..0d39f05e --- /dev/null +++ b/tests/xfs/528 @@ -0,0 +1,87 @@ +#! /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_error_injection "reduce_max_iextents" + +echo "* Write to shared extent" + +echo "Format and mount fs" +_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $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 a \$srcfile having an extent of length $nr_blks blocks" +xfs_io -f -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + -c fsync $srcfile >> $seqres.full + +echo "Share the extent with \$dstfile" +xfs_io -f -c "reflink $srcfile" $dstfile >> $seqres.full + +echo "Inject reduce_max_iextents error tag" +xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + +echo "Buffered write to every other block of \$dstfile's shared extent" +for i in $(seq 1 2 $((nr_blks - 1))); do + xfs_io -f -c "pwrite $((i * bsize)) $bsize" -c fsync $dstfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +ino=$(stat -c "%i" $dstfile) + +_scratch_unmount >> $seqres.full + +echo "Verify \$dstfile's extent count" + +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" +fi + +# success, all done +status=0 +exit + diff --git a/tests/xfs/528.out b/tests/xfs/528.out new file mode 100644 index 00000000..8666488b --- /dev/null +++ b/tests/xfs/528.out @@ -0,0 +1,8 @@ +QA output created by 528 +* Write to shared extent +Format and mount fs +Create a $srcfile having an extent of length 15 blocks +Share the extent with $dstfile +Inject reduce_max_iextents error tag +Buffered write to 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 Fri Nov 13 11:27:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 11903109 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 952EC697 for ; Fri, 13 Nov 2020 11:30:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 794C72137B for ; Fri, 13 Nov 2020 11:30:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tDTsWMN0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726530AbgKML24 (ORCPT ); Fri, 13 Nov 2020 06:28:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726546AbgKML2H (ORCPT ); Fri, 13 Nov 2020 06:28:07 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90B52C061A4A; Fri, 13 Nov 2020 03:27:53 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id s2so4407746plr.9; Fri, 13 Nov 2020 03:27: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=m+PciDivRWXUvLdWNX7xttPep6/rYh/hZOshTARBJVQ=; b=tDTsWMN0pwf2JFb4E5vnygFc1BAB/c4pvdgaz/lF+mjroWt/Rp8FMqAMcJDE6ubO6F p4dC1AF4o7knA0pElXC0CNhw7yf7mIP10pG2kPxxl5H7Q4XYqlK4XEqQyggAOh+HzNc2 tJ1JV7Q//f6dtKEiSRIatdichyHFdXBpN9kj1M8R1g5BlkqNgJ57UzBx0t7K7Tz2kiXh dBgfRQ9lbwBuqqhhsKKyvRgaw6qv6V8CSTdNW6uLWn8OBIa7k7TObJgts6gM/ZOvSxhU FsAFA34Ox3wxnysjEzuJw3FGdIl3IHKXED7sOdFsTQ8seQRR9gx8zDE+7TdaV/hoQ7Uq c7ag== 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=m+PciDivRWXUvLdWNX7xttPep6/rYh/hZOshTARBJVQ=; b=eSg51VMHqcg0zOoutv1GOU81zV7DmxrGxlZBzlKUOT5WMa+GS6uXeokxoLFfhYhzcf VK4N4doQKkIgVXpU6ubtuY4FsK5WgX+ZWP7qjYj88rsgRi19piFbXtuVYED5ssZvYfdn XEf1ZcX70QZ0zlTo0s7IEnW6D3XTIPZIhvpk+3MAO7Spd56tMmqrFpFFwCgW1UZsR1Yc d/nB3yArv8imbU7ziZ31LnpZ0PjWverBLhxj5pymCF3s0PpJLTnVKOj4QTKSCJ4qZpsv 8aMAwc3JNQqrdfiIx9GJdbvm9AhTDhqIXkY+H2g8dWtSwHXAx0gcz2LZG3H4/N9QFtUw TYww== X-Gm-Message-State: AOAM533svphGX4xNpZuUoFVlJXpJIzIMQqVxwwSDQTf1vL8tap60OMEU 4C2kDoHqcDn+wAU+BaYN3CofTK8vz+8= X-Google-Smtp-Source: ABdhPJzCh6KcHeuJUJgubAdEXMNdz5pcjtSot7PJwxy2EqoSEaQrvCkRyI33u/+D2VArJbciIVzaxw== X-Received: by 2002:a17:902:8685:b029:d7:bb:aa2 with SMTP id g5-20020a1709028685b02900d700bb0aa2mr1813554plo.13.1605266872870; Fri, 13 Nov 2020 03:27:52 -0800 (PST) Received: from localhost.localdomain ([122.172.185.167]) by smtp.gmail.com with ESMTPSA id w131sm9410857pfd.14.2020.11.13.03.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 03:27: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 Subject: [PATCH 09/11] xfs: Check for extent overflow when remapping an extent Date: Fri, 13 Nov 2020 16:57:01 +0530 Message-Id: <20201113112704.28798-10-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113112704.28798-1-chandanrlinux@gmail.com> References: <20201113112704.28798-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@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 | 86 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/529.out | 8 +++++ tests/xfs/group | 1 + 3 files changed, 95 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..a44ce199 --- /dev/null +++ b/tests/xfs/529 @@ -0,0 +1,86 @@ +#! /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 -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 -f -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + -c fsync $dstfile >> $seqres.full + +echo "Inject reduce_max_iextents error tag" +xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + +echo "Reflink every other block from \$srcfile into \$dstfile" +for i in $(seq 1 2 $((nr_blks - 1))); do + xfs_io -f -c "reflink $srcfile $((i * bsize)) $((i * bsize)) $bsize" \ + $dstfile >> $seqres.full 2>&1 +done + +ino=$(stat -c "%i" $dstfile) + +_scratch_unmount >> $seqres.full + +echo "Verify \$dstfile's extent count" + +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" +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 Fri Nov 13 11:27:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 11903107 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2CF6915E6 for ; Fri, 13 Nov 2020 11:30:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0197022240 for ; Fri, 13 Nov 2020 11:30:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U9NrPQ4c" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726489AbgKML24 (ORCPT ); Fri, 13 Nov 2020 06:28:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726405AbgKML2H (ORCPT ); Fri, 13 Nov 2020 06:28:07 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 105F6C061A4B; Fri, 13 Nov 2020 03:27:56 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id r186so6886693pgr.0; Fri, 13 Nov 2020 03:27:56 -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=Rfh6r8h4r1l5e9rz2uPEKmppi0Azq2EOi1A6KcIRpTM=; b=U9NrPQ4cTUgytfjmgn56s0mIbMqZuup0oblQM2gSH03T+K4Sz8Exjgy7S/JC6lxiwy aF3jDSGdm7lAAhLOz0tXwEPqSSi3iiHop+Bj2KuCp5wYlnoJWcFSuCsAY3ChguOi7VnX GmXv5ZMBVjPzL4cGkkVZPsRpCMMGw4Klu2/0w643WDlqRnshUFslDURvTFVSwv0V+vp8 eXEjsL4ZvFxZooynNHRBLU+/uA72ke4RPD1BCiFa8h604MWCjUohLWUyZMjjHTnC3Ys4 +nfKEwQIvFAmGbUjegUszTnhQ20d4Z7vfYPwv6FExsaCGL1p1OyxBOB2YmUyaGGX4Gjt kZsA== 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=Rfh6r8h4r1l5e9rz2uPEKmppi0Azq2EOi1A6KcIRpTM=; b=oRb41vnSt1wg1Um9zcEZdRTb1i5WHnMWtwkhzg4NZLgqs1j0qDZawQn3Wg0P1i4LNG NmKgrAclWbBd3Cnlh8Q2aJUHFvGgbXs/JIKqMcMG486FrEUb/fvjLiLPm9H2Wwy4fbMn CulXVdEP8DDXSDCAGjaooMQpGGBBCsnnJbzdAigIBGdkH+4oIhniWpxgHIJ/Ce2GlaHI sbCENAWHZwRHt7dhu6OYhomKfst0e7z+NuNBsfCFZczr1GRX6URV3QN9xZlK8rVlHbud H3b/0ePlJNsyIJWQ1edfEujnv12hnfYMp3LWx4qnU71hcKxHEexETB/NFTgxTFX9SqJR ZPlg== X-Gm-Message-State: AOAM5300dWHBg3sTXROqKFJuK/cQAdIELv2fANFbdNRapmxa0CCN3DY+ I3ZFYduBnKI3fm8FP8X5RgLJLnkW4KE= X-Google-Smtp-Source: ABdhPJxFvUTwceo2pjzxFAVWUSXhbPZqQ3i6fGfKZMNQ/vL/9kTzPCdE3jAXwly2chlwrw9ckMZYaQ== X-Received: by 2002:a63:5754:: with SMTP id h20mr1683521pgm.378.1605266875344; Fri, 13 Nov 2020 03:27:55 -0800 (PST) Received: from localhost.localdomain ([122.172.185.167]) by smtp.gmail.com with ESMTPSA id w131sm9410857pfd.14.2020.11.13.03.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 03:27: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 Subject: [PATCH 10/11] xfs: Check for extent overflow when swapping extents Date: Fri, 13 Nov 2020 16:57:02 +0530 Message-Id: <20201113112704.28798-11-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113112704.28798-1-chandanrlinux@gmail.com> References: <20201113112704.28798-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@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 --- tests/xfs/530 | 115 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/530.out | 13 ++++++ tests/xfs/group | 1 + 3 files changed, 129 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..fccc6de7 --- /dev/null +++ b/tests/xfs/530 @@ -0,0 +1,115 @@ +#! /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 17 blocks" +xfs_io -f -c "pwrite -b $((17 * bsize)) 0 $((17 * bsize))" -c fsync $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 -f -c "fcollapse $start_offset $bsize" $donorfile >> $seqres.full +done +donorino=$(stat -c "%i" $donorfile) + +echo "Create \$srcfile having an extent of length 18 blocks" +xfs_io -f -c "pwrite -b $((18 * bsize)) 0 $((18 * bsize))" -c fsync $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 -f -c "fcollapse $start_offset $bsize" $srcfile >> $seqres.full +done +srcino=$(stat -c "%i" $srcfile) + +_scratch_unmount >> $seqres.full + +echo "Collect \$donorfile's extent count" +donor_nr_exts=$(_scratch_get_iext_count $donorino data || \ + _fail "Unable to obtain inode fork's extent count") + +echo "Collect \$srcfile's extent count" +src_nr_exts=$(_scratch_get_iext_count $srcino data || \ + _fail "Unable to obtain inode fork's extent count") + +_scratch_mount >> $seqres.full + +echo "Inject reduce_max_iextents error tag" +xfs_io -x -c 'inject reduce_max_iextents' $SCRATCH_MNT + +echo "Swap \$srcfile's and \$donorfile's extent forks" +xfs_io -f -c "swapext $donorfile" $srcfile >> $seqres.full 2>&1 + +_scratch_unmount >> $seqres.full + +echo "Check for \$donorfile's extent count overflow" +nextents=$(_scratch_get_iext_count $donorino data || \ + _fail "Unable to obtain inode fork's extent count") +if (( $nextents == $src_nr_exts )); then + echo "\$donorfile: Extent count overflow check failed" +fi + +echo "Check for \$srcfile's extent count overflow" +nextents=$(_scratch_get_iext_count $srcino data || \ + _fail "Unable to obtain inode fork's extent count") +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..996af959 --- /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 17 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 Fri Nov 13 11:27:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 11903161 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 81D1315E6 for ; Fri, 13 Nov 2020 12:05:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B98522252 for ; Fri, 13 Nov 2020 12:05:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jNmEKJAg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726678AbgKMMFH (ORCPT ); Fri, 13 Nov 2020 07:05:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726353AbgKML2H (ORCPT ); Fri, 13 Nov 2020 06:28:07 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EE8EC0613D1; Fri, 13 Nov 2020 03:27:58 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id i13so6850799pgm.9; Fri, 13 Nov 2020 03:27: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=BGm+n+4cGbjW8YX1IQesAH1JhTJWOfK5uX+zfpwxaZg=; b=jNmEKJAg7YiVjLF/3mGOrJY2/nXGx0AnuHcMaijntkLr0t9mG7F3+vZn8KbxD2Wnm1 jqvjq3IyL/ixP9rRro64Ps81uIm61vCvk2nktono6oqw8gByVy0Yih+qtsrDGv2nT6MG Pd7xr/IpkjbO2o1mz1BCn8OMA/lltkRask2sAMWlALcY634HNV/xYO8pQy8FjiAh+D6k hkPq7jADVUQXhjq9Wl/k+Mg1ysu9c8dizWAocdceZLXVkaGzgjtvrPt42tye25ascNUZ uKia5VjeSnFNj77SsnowiPPSBhOTjK1MtGZgite4+snw/rzB/vtMlWB2TEFvK9Vz9ezw EUcg== 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=BGm+n+4cGbjW8YX1IQesAH1JhTJWOfK5uX+zfpwxaZg=; b=CKJuJ/Vhu1N5/HjC0xSMmh/oWcEmZxrHEku8Jgcn3fu0pUegGyG6JeHKjdsaI2EXDp 07HzCTVNj0LDh16aKmEXA96dY6lz6GQndIBySf/RJ8STN7Nfa097msCPOcrqvs4guA7o w0ILOy2XdqsOg1tY7zEXkahUkYVYBVEGKx43xt3lwyBrZMYGm8CZPbGg3+3B9gDSRqXg sf9EjWJt1PA8JaOT64DyH8zfrfEeosYPsQvr5NiHbzRPGLiNUlkoeyUXbthJfJ07me/u 9sZqjs1NAjC5HRFBlObBOZwbZOqV2xVE4qQTdI9CZjoKiPf5zTYVtbcBaBufcdiSH3B/ +vIQ== X-Gm-Message-State: AOAM5309X//PlT0ZCb/jEy7O2y8bsNzFUmOiW1x2YOWzLw5rYDPicwGo 0UaLoRFNBxSxV9Vfm3Nbt9MrQ8lONSI= X-Google-Smtp-Source: ABdhPJxXVGx0v3g6jyM9hNEv0qnhIXHLFqtXATFd5UyFA/b8M7MXvyFfUNOn6OO58Dxu5qmYDMCBjQ== X-Received: by 2002:a17:90a:77ca:: with SMTP id e10mr2365216pjs.113.1605266877710; Fri, 13 Nov 2020 03:27:57 -0800 (PST) Received: from localhost.localdomain ([122.172.185.167]) by smtp.gmail.com with ESMTPSA id w131sm9410857pfd.14.2020.11.13.03.27.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 03:27: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 Subject: [PATCH 11/11] xfs: Stress test with with bmap_alloc_minlen_extent error tag enabled Date: Fri, 13 Nov 2020 16:57:03 +0530 Message-Id: <20201113112704.28798-12-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113112704.28798-1-chandanrlinux@gmail.com> References: <20201113112704.28798-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@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 --- tests/xfs/531 | 85 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/531.out | 6 ++++ 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..e846cc0e --- /dev/null +++ b/tests/xfs/531 @@ -0,0 +1,85 @@ +#! /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 + +# 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_block_size $SCRATCH_MNT) + +testfile=$SCRATCH_MNT/testfile + +echo "Consume free space" +dd if=/dev/zero of=${testfile} bs=${bsize} >> $seqres.full 2>&1 +sync + +echo "Create fragmented filesystem" +$here/src/punch-alternating $testfile >> $seqres.full +sync + +echo "Inject bmap_alloc_minlen_extent error tag" +xfs_io -x -c 'inject bmap_alloc_minlen_extent' $SCRATCH_MNT + +echo "Execute fsstress in background" +$FSSTRESS_PROG -d $SCRATCH_MNT -p128 -n999999999 \ + -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 & + +fsstress_pid=$! +sleep 2m + +echo "Killing fsstress process $fsstress_pid ..." >> $seqres.full +kill $fsstress_pid >> $seqres.full +wait $fsstress_pid + +# success, all done +status=0 +exit diff --git a/tests/xfs/531.out b/tests/xfs/531.out new file mode 100644 index 00000000..e0a419c2 --- /dev/null +++ b/tests/xfs/531.out @@ -0,0 +1,6 @@ +QA output created by 531 +Format and mount fs +Consume free space +Create fragmented filesystem +Inject bmap_alloc_minlen_extent error tag +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