From patchwork Sat Nov 21 08:23:22 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: 11923257 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 BB78F138B for ; Sat, 21 Nov 2020 08:24:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C69322254 for ; Sat, 21 Nov 2020 08:24:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LZHn3CP8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727027AbgKUIXr (ORCPT ); Sat, 21 Nov 2020 03:23:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726629AbgKUIXr (ORCPT ); Sat, 21 Nov 2020 03:23:47 -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 34DF5C0613CF; Sat, 21 Nov 2020 00:23:47 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id f17so940600pge.6; Sat, 21 Nov 2020 00:23:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tuRANglPuvCThAaGoAF4a7CUchGXxnbMIAXQeoen4YY=; b=LZHn3CP84hnZZ/AGPFzjgUj3uiC8QafHA04VQdrJZ5ztVY9kWfORdt3dg6B0MjlS1g 2eqlhtpD9XMdDxdglDp1DG73Jt7HpF8QbXDPP7ljfroRjYMTl6sd/74rK1YPhg4w9P9u rVFhcPoxgUCaqLW+ELp07OLbCqDnZMFvHLJ0TRcf5oNKhX2MbBW+rUoMEK7zzZBQA+oB x+FxFO5pazexxWlos4bvrBnVyL36FXJ/xpjJdYj/ikd/FVKzyTBqUFVJLLVmXtZdYLgf VoocWddkh7mNq/yn5AVdcRE8aLocRRleswMRxhADYY+ghwgd6qtJXGFGTkIKktYs8kjQ YGFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tuRANglPuvCThAaGoAF4a7CUchGXxnbMIAXQeoen4YY=; b=n/J11whLnWSYPN2acRjo+ru0evVWBr+LRPVZQcMy7/wqCuCK5WNjyZ5qFmw69A/oCu aqH8gZt10lyDuEhu0WTvbIn/72GHrLiHBzC4rpUbwvhNy9TOkDc797UZzrJAn0WQ12IE a1ZeNfshRd57dJFg+d9Z5N9h2iI4s8NpKyg7GzdlKR1psvmJt/taRmrXRdyo54OJuS1M HT34HxX51ABKEnWmPH0/kmrVJDc36ew3J6UdHN1Ge8lgYZiQMGbOzwLlh5CATkJJj9tw h7OyeXFAr0S5CDDLOfcJvoMK8rnQa55xgExTJK837qKxyqV64bdKFxAkvM2Cx1G02QLj iCIA== X-Gm-Message-State: AOAM530cl5HdyjhoU7j+n15C0PDm1lBXHveBN3viwd8M8/B6Porg2EZ3 Go3Ilv2H4BwOLp3SjPH1xd1Ze9CN5fY= X-Google-Smtp-Source: ABdhPJxJniW8psw65O2/w5HeUlqLv8jDh+5o6wVUqYFBT4yApSIrijy4XLafhKw+hBOrOB1cmUb7Qg== X-Received: by 2002:a17:90a:7f81:: with SMTP id m1mr9641866pjl.169.1605947026557; Sat, 21 Nov 2020 00:23:46 -0800 (PST) Received: from localhost.localdomain ([122.167.41.102]) by smtp.gmail.com with ESMTPSA id e22sm6167148pfd.153.2020.11.21.00.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Nov 2020 00:23: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 V2 01/11] common/xfs: Add a helper to get an inode fork's extent count Date: Sat, 21 Nov 2020 13:53:22 +0530 Message-Id: <20201121082332.89739-2-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201121082332.89739-1-chandanrlinux@gmail.com> References: <20201121082332.89739-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 3f5c14ba..641d6195 100644 --- a/common/xfs +++ b/common/xfs @@ -903,6 +903,28 @@ _scratch_get_bmx_prefix() { return 1 } +_scratch_get_iext_count() +{ + ino=$1 + whichfork=$2 + + case $whichfork in + "attr") + field=core.naextents + ;; + "data") + field=core.nextents + ;; + *) + return 1 + esac + + nextents=$(_scratch_xfs_db -c "inode $ino" -c "print $field") + nextents=${nextents##${field} = } + + echo $nextents +} + # # Ensures that we don't pass any mount options incompatible with XFS v4 # From patchwork Sat Nov 21 08:23:23 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: 11923259 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 0A9E6175A for ; Sat, 21 Nov 2020 08:24:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA82C22254 for ; Sat, 21 Nov 2020 08:24:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ODQYo6/S" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727096AbgKUIXu (ORCPT ); Sat, 21 Nov 2020 03:23:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726629AbgKUIXu (ORCPT ); Sat, 21 Nov 2020 03:23:50 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6086DC0613CF; Sat, 21 Nov 2020 00:23:50 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id v21so9491109pgi.2; Sat, 21 Nov 2020 00:23:50 -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=7B2hUwJfXTxu96bGaOyZtJ4w7SV/v8RN1Cm21+LWtIU=; b=ODQYo6/Sj89q6d+yrtRoY6afZAGZzZ2efS0Sz3lOHCMH49VvmxMdJt9rxR5rbUeMqp mgCQ11Kkf83ALSEXAmtGmD9c4igF5Rqhf9CZ9o7Gar5ffPwUZXu/xua9NBcV7uUj4TGp CFBIgozZQzFFsPhsKSYCJDDcX/y6l7JZDngczsFYL5krGl06YVyiELj1xgIHqF9PNFgL uBs7rzCixhSYtzZuvTvw6m791uk+QZ7wZCygeUvg38NXgskhNlWbTAQi0ZA+KG+4AOKv /z7QFb1n6FyACHe9wMBWY73HRgP9E6fk5BaF+CMwLAlAPsJhWIGScCTfl2OymekZZ775 sxkQ== 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=7B2hUwJfXTxu96bGaOyZtJ4w7SV/v8RN1Cm21+LWtIU=; b=avkJss14MplTJqeFWCIyclRI9wA3rUcA3ckMPrOpoURtrjbfJ9aXcxQOhbg3kp5YUq X2xThGeAawXy0i933rK5L5q4tatHRYe9aCQFDcWZd+P1XpwSuD5New4V4u69dCtm0Xhl hqN76l30dfRYoVS9j8imtvLrIimaTnXbvw6rqqpnXQghgrNuNldGpGlP+lpUjigxPjaj u71YvGINHvAy83d/X3D8/YPL29LcnaxkYTTuC/8iu04Q68t4rk8zSXEN5Vc3oAqIUaJK iDdmvHIECMISyJuNFLq7C3xbfcBwK9kjSQ+C0WUgLw113o6LG1wewBrVKBChHjWvXOSO cQOA== X-Gm-Message-State: AOAM530dS0L5Af/eRLdUihZCZVYb2En61y4Z3wjWeKMcem4suHo1OPHs DyYFGzWFA96QrEz2gOx4K8eWodnNP84= X-Google-Smtp-Source: ABdhPJw69QkBizs5QZ0ny13e5gEqWJmAJ+Y7F9O/Cz9Y83Egj61jbC++OQAg18By19BztYBeaGouJg== X-Received: by 2002:a62:768b:0:b029:197:dea6:586e with SMTP id r133-20020a62768b0000b0290197dea6586emr4412340pfc.44.1605947029120; Sat, 21 Nov 2020 00:23:49 -0800 (PST) Received: from localhost.localdomain ([122.167.41.102]) by smtp.gmail.com with ESMTPSA id e22sm6167148pfd.153.2020.11.21.00.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Nov 2020 00:23:48 -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 V2 02/11] xfs: Check for extent overflow when trivally adding a new extent Date: Sat, 21 Nov 2020 13:53:23 +0530 Message-Id: <20201121082332.89739-3-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201121082332.89739-1-chandanrlinux@gmail.com> References: <20201121082332.89739-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. Signed-off-by: Chandan Babu R --- tests/xfs/522 | 175 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/522.out | 20 ++++++ tests/xfs/group | 1 + 3 files changed, 196 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..f2ac22cd --- /dev/null +++ b/tests/xfs/522 @@ -0,0 +1,175 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 522 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# adding a single extent while there's no possibility of splitting an existing +# mapping. + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota +. ./common/inject +. ./common/populate + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_quota +_require_xfs_debug +_require_test_program "punch-alternating" +_require_xfs_io_command "falloc" +_require_xfs_io_error_injection "reduce_max_iextents" +_require_xfs_io_error_injection "bmap_alloc_minlen_extent" + +echo "Format and mount fs" +_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full +_scratch_mount -o uquota >> $seqres.full + +bsize=$(_get_file_block_size $SCRATCH_MNT) + +echo "* Delalloc to written extent conversion" + +testfile=$SCRATCH_MNT/testfile + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +nr_blks=$((40 * 2)) + +echo "Create fragmented file" +for i in $(seq 0 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -s -c "pwrite $((i * bsize)) $bsize" $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +echo "Verify \$testfile's extent count" + +nextents=$($XFS_IO_PROG -f -c 'stat' $testfile | grep -i nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 35 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm $testfile + +echo "* Fallocate of unwritten extents" + +echo "Fallocate fragmented file" +for i in $(seq 0 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -c "falloc $((i * bsize)) $bsize" $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +echo "Verify \$testfile's extent count" + +nextents=$($XFS_IO_PROG -f -c 'stat' $testfile | grep -i nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 35 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm $testfile + +echo "* Directio write" + +nr_blks=$((40 * 2)) + +echo "Create fragmented file via directio writes" +for i in $(seq 0 2 $((nr_blks - 1))); do + $XFS_IO_PROG -d -s -f -c "pwrite $((i * bsize)) $bsize" $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +echo "Verify \$testfile's extent count" + +nextents=$($XFS_IO_PROG -f -c 'stat' $testfile | grep -i nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 35 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm $testfile + +echo "* Extend quota inodes" + +echo "Disable reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 0 + +echo "Consume free space" +fillerdir=$SCRATCH_MNT/fillerdir +nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT) +nr_free_blks=$((nr_free_blks * 90 / 100)) + +_fill_fs $((bsize * nr_free_blks)) $fillerdir $bsize 0 >> $seqres.full 2>&1 + +echo "Create fragmented filesystem" +for dentry in $(ls -1 $fillerdir/); do + $here/src/punch-alternating $fillerdir/$dentry >> $seqres.full +done + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Inject bmap_alloc_minlen_extent error tag" +_scratch_inject_error bmap_alloc_minlen_extent 1 + +nr_blks=40 + +# This is a rough calculation; It doesn't take block headers into +# consideration. +# gdb -batch vmlinux -ex 'print sizeof(struct xfs_dqblk)' +# $1 = 136 +nr_quotas_per_block=$((bsize / 136)) +nr_quotas=$((nr_quotas_per_block * nr_blks)) + +echo "Extend uquota file" +for i in $(seq 0 $nr_quotas_per_block $nr_quotas); do + chown $i $testfile >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +_scratch_unmount >> $seqres.full + +echo "Verify uquota inode's extent count" +uquotino=$(_scratch_xfs_db -c sb -c "print uquotino") +uquotino=${uquotino##uquotino = } + +nextents=$(_scratch_get_iext_count $uquotino data || \ + _fail "Unable to obtain inode fork's extent count") +if (( $nextents > 35 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +# success, all done +status=0 +exit diff --git a/tests/xfs/522.out b/tests/xfs/522.out new file mode 100644 index 00000000..99aa430b --- /dev/null +++ b/tests/xfs/522.out @@ -0,0 +1,20 @@ +QA output created by 522 +Format and mount fs +* Delalloc to written extent conversion +Inject reduce_max_iextents error tag +Create fragmented file +Verify $testfile's extent count +* Fallocate of unwritten extents +Fallocate fragmented file +Verify $testfile's extent count +* Directio write +Create fragmented file via directio writes +Verify $testfile's extent count +* Extend quota inodes +Disable reduce_max_iextents error tag +Consume free space +Create fragmented filesystem +Inject reduce_max_iextents error tag +Inject bmap_alloc_minlen_extent error tag +Extend uquota file +Verify uquota inode's extent count diff --git a/tests/xfs/group b/tests/xfs/group index 17f6bc6c..6aff1210 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -519,6 +519,7 @@ 519 auto quick reflink 520 auto quick reflink 521 auto quick realtime growfs +522 auto quick quota 758 auto quick rw attr realtime 759 auto quick rw realtime 760 auto quick rw collapse punch insert zero prealloc From patchwork Sat Nov 21 08:23:24 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: 11923261 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 4170C1746 for ; Sat, 21 Nov 2020 08:24:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D1FD22254 for ; Sat, 21 Nov 2020 08:24:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f2ygw1Xj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727139AbgKUIXx (ORCPT ); Sat, 21 Nov 2020 03:23:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726629AbgKUIXx (ORCPT ); Sat, 21 Nov 2020 03:23:53 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C8EAC0613CF; Sat, 21 Nov 2020 00:23:52 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id v5so6136767pff.10; Sat, 21 Nov 2020 00:23:52 -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=OBNwgYuDDvMsdB1m6qgDy2y5sV0eqFEetefPmt/B85Y=; b=f2ygw1Xjs569KL0o+maHwFI/EHppAjSGV3YPwKME3KFWopNIuHuXljp8wNW09oiQwP ANJgQF4S7V0p7LwMS6mee+OXUe1LIV5pBBPTI0aj1M63JzT6KLHmwkjoz0+B3Do1LDc7 edkljMJPiGE7Pyf4CS9TF98mh8YCMZO7XtuUmzS5mR6kjMGIfZhEjIxv+x/TT0xCznL7 qiNNGItT5hyIshUvQ4BgRLEv9a7YIDACKwfWi/CMIZm8DgewBwU61Q/I0aNvdpD7TN1t VcjNcZz3RtuwOH6I0hYXYHaD5THHf4KTmBVw5vyqNPf1MW6gkniV3oVbia1jdm5qeZlC F+kg== 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=OBNwgYuDDvMsdB1m6qgDy2y5sV0eqFEetefPmt/B85Y=; b=T3tl1BjGXFjkYgBBKJro4IJFCHtTCVtjjnFXuUl72JP32YM/D881klzavzQ9gG4ilk 6tfNZxgPx+y1mYeO5e/m1PA8b19MF2lfeXZQmCVPy4jvMvOb5OcJRrE5tjOQiDTS7cIx w2rIHk15vBsG3tKHGrQWS7xMIDnnK7dTek2JpUNLgsUCtwGJ1l7kuMQdMeendS6bNrLb mx6VFPI/hppLM+UxxctU91AVbYkjEh1vfoi3OUk+Ht44HmXy0HVbb0pliRMQlIm+pLfR RuxZPBPVaS4xkRtg0GunGYqrlt9TAxBY5qHCdHAIczJxObaNAyHL46us0pg6qiHnUPVn hp4g== X-Gm-Message-State: AOAM533K2LAjxGJa615VE5aWorPREoHnx3KP2QOkUmheRvT5UJdPA3EP mzaZKKHtuLhh4AHapo95qRcTsCYpAIc= X-Google-Smtp-Source: ABdhPJxumlU8ypj03XsFhO+r6M2AhM65Rciyh6FzMvl2Mi+nLQJuwXubfkEsaUymAa0XU8Q7dYsBxQ== X-Received: by 2002:a17:90a:16c1:: with SMTP id y1mr14202029pje.168.1605947031624; Sat, 21 Nov 2020 00:23:51 -0800 (PST) Received: from localhost.localdomain ([122.167.41.102]) by smtp.gmail.com with ESMTPSA id e22sm6167148pfd.153.2020.11.21.00.23.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Nov 2020 00:23:51 -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 V2 03/11] xfs: Check for extent overflow when growing realtime bitmap/summary inodes Date: Sat, 21 Nov 2020 13:53:24 +0530 Message-Id: <20201121082332.89739-4-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201121082332.89739-1-chandanrlinux@gmail.com> References: <20201121082332.89739-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 realtime bitmap/summary inode fork's extent count to overflow when growing the realtime volume associated with a filesystem. Signed-off-by: Chandan Babu R --- tests/xfs/523 | 119 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/523.out | 11 +++++ tests/xfs/group | 1 + 3 files changed, 131 insertions(+) create mode 100755 tests/xfs/523 create mode 100644 tests/xfs/523.out diff --git a/tests/xfs/523 b/tests/xfs/523 new file mode 100755 index 00000000..fae7ab1f --- /dev/null +++ b/tests/xfs/523 @@ -0,0 +1,119 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 523 +# +# Verify that XFS does not cause bitmap/summary inode fork's extent count to +# overflow when growing an the realtime volume of the filesystem. +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + _scratch_unmount >> $seqres.full 2>&1 + test -e "$rtdev" && losetup -d $rtdev >> $seqres.full 2>&1 + rm -f $tmp.* $TEST_DIR/$seq.rtvol +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/inject +. ./common/populate + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_test +_require_xfs_debug +_require_test_program "punch-alternating" +_require_xfs_io_error_injection "reduce_max_iextents" +_require_xfs_io_error_injection "bmap_alloc_minlen_extent" +_require_scratch_nocheck + +echo "* Test extending rt inodes" + +_scratch_mkfs | _filter_mkfs >> $seqres.full 2> $tmp.mkfs +. $tmp.mkfs + +echo "Create fake rt volume" +nr_bitmap_blks=40 +nr_bits=$((nr_bitmap_blks * dbsize * 8)) +rtextsz=$dbsize +rtdevsz=$((nr_bits * rtextsz)) +truncate -s $rtdevsz $TEST_DIR/$seq.rtvol +rtdev=$(_create_loop_device $TEST_DIR/$seq.rtvol) + +echo "Format and mount rt volume" + +export USE_EXTERNAL=yes +export SCRATCH_RTDEV=$rtdev +_scratch_mkfs -d size=$((1024 * 1024 * 1024)) \ + -r size=2M,extsize=${rtextsz} >> $seqres.full +_scratch_mount >> $seqres.full + +echo "Consume free space" +fillerdir=$SCRATCH_MNT/fillerdir +nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT) +nr_free_blks=$((nr_free_blks * 90 / 100)) + +_fill_fs $((dbsize * nr_free_blks)) $fillerdir $dbsize 0 >> $seqres.full 2>&1 + +echo "Create fragmented filesystem" +for dentry in $(ls -1 $fillerdir/); do + $here/src/punch-alternating $fillerdir/$dentry >> $seqres.full +done + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Inject bmap_alloc_minlen_extent error tag" +_scratch_inject_error bmap_alloc_minlen_extent 1 + +echo "Grow realtime volume" +$XFS_GROWFS_PROG -r $SCRATCH_MNT >> $seqres.full 2>&1 +if [[ $? == 0 ]]; then + echo "Growfs succeeded; should have failed." + exit 1 +fi + +_scratch_unmount >> $seqres.full + +echo "Verify rbmino's and rsumino's extent count" +for rtino in rbmino rsumino; do + ino=$(_scratch_xfs_db -c sb -c "print $rtino") + ino=${ino##${rtino} = } + echo "$rtino = $ino" >> $seqres.full + + nextents=$(_scratch_get_iext_count $ino data || \ + _fail "Unable to obtain inode fork's extent count") + if (( $nextents > 35 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 + fi +done + +echo "Check filesystem" +_check_xfs_filesystem $SCRATCH_DEV none $rtdev + +losetup -d $rtdev +rm -f $TEST_DIR/$seq.rtvol + +export USE_EXTERNAL="" +export SCRATCH_RTDEV="" + +# success, all done +status=0 +exit diff --git a/tests/xfs/523.out b/tests/xfs/523.out new file mode 100644 index 00000000..7df02970 --- /dev/null +++ b/tests/xfs/523.out @@ -0,0 +1,11 @@ +QA output created by 523 +* Test extending rt inodes +Create fake rt volume +Format and mount rt volume +Consume free space +Create fragmented filesystem +Inject reduce_max_iextents error tag +Inject bmap_alloc_minlen_extent error tag +Grow realtime volume +Verify rbmino's and rsumino's extent count +Check filesystem diff --git a/tests/xfs/group b/tests/xfs/group index 6aff1210..b375a94c 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -520,6 +520,7 @@ 520 auto quick reflink 521 auto quick realtime growfs 522 auto quick quota +523 auto quick realtime growfs 758 auto quick rw attr realtime 759 auto quick rw realtime 760 auto quick rw collapse punch insert zero prealloc From patchwork Sat Nov 21 08:23:25 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: 11923263 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 78F6314C0 for ; Sat, 21 Nov 2020 08:24:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5547722254 for ; Sat, 21 Nov 2020 08:24:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mg2pFbhY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727141AbgKUIXz (ORCPT ); Sat, 21 Nov 2020 03:23:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726629AbgKUIXz (ORCPT ); Sat, 21 Nov 2020 03:23:55 -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 011D3C0613CF; Sat, 21 Nov 2020 00:23:55 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id w14so10175233pfd.7; Sat, 21 Nov 2020 00:23:54 -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=w4cleYl7oMiziSTvwSI4KMR97F6OHUqxMcK8J8SvhMs=; b=mg2pFbhYR2ShW+FKQtVHWFZPo/LzU66d9ZFP0k8bq6oEeIGcoRj4SRL380MqckU3Z0 YJtpBQpSR0QNsJBQjl8J4MjV/PeGSeUrQHaAvCFcrqEyTM8tqSIFZTo1CRnpgKQtNa9K CBQHcWtu7wcDlDHcyv1CZaEKNed1PwYb+7NQb8MDjRrPsjG1URbACLAi0BaWIy0A4SP/ 7IM0l5sd63Yh2/shQqdFLPhv10/To5tKUIKvquhxgmuZ38DVvN3i7h1DMjNSo4FGX1gh OACZg/RqjaxVdjCGlCFcaJS1H5NoqmbTJvYW1gwGfAnlkb1TEe6jsyAn24OeQhx8Ar9P RA3w== 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=w4cleYl7oMiziSTvwSI4KMR97F6OHUqxMcK8J8SvhMs=; b=uT/9Emy2Yp8AKerI/GHJRGXcGYioQK4QHJ1oWAR5gRPOjI21jq/zjKeBC+E8QkKM5m K7LiXnoDsbh6X+55UsJvNvMwmCJi91qaKsoiPqdF7i6r+LeJBaqwQ+lLQvcpXB5ceTfJ INDlXUH24LMgCB/uma/NpMrOjKZUJ2oPL++FrgqWZvpK0ahP2MR7z4+8pxsYCSB6FRfh G0rsh1853sZjts9I2XrPnT2/efHGwbH8ivlpB8MLkVZgK7Mm3XdQkl4RNSs/8BRz8DfB j7pOcj9kYKBF+cbiLjgdXklj+wcAP+ynLhVoSqs8E6n9K1553Ercf5RP1IAcM4weW1tR l5Qw== X-Gm-Message-State: AOAM53119kFUEM3fvnbAD9mLhqszUOGvBmTHxgZoUH3IECmg2I//Nq1j fhO4oO9JoEkV0P0H8XKxR3qG6cmZiVU= X-Google-Smtp-Source: ABdhPJys19/Uh3Y8xvieKM7jx2Zy2YOtkgJlfrUScsPe65g0GJ5vxyHUKpPN5EAJhxZ1/+cORbL0uw== X-Received: by 2002:a63:cb51:: with SMTP id m17mr20006804pgi.337.1605947034120; Sat, 21 Nov 2020 00:23:54 -0800 (PST) Received: from localhost.localdomain ([122.167.41.102]) by smtp.gmail.com with ESMTPSA id e22sm6167148pfd.153.2020.11.21.00.23.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Nov 2020 00:23:53 -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 V2 04/11] xfs: Check for extent overflow when punching a hole Date: Sat, 21 Nov 2020 13:53:25 +0530 Message-Id: <20201121082332.89739-5-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201121082332.89739-1-chandanrlinux@gmail.com> References: <20201121082332.89739-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 | 84 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/524.out | 19 +++++++++++ tests/xfs/group | 1 + 3 files changed, 104 insertions(+) create mode 100755 tests/xfs/524 create mode 100644 tests/xfs/524.out diff --git a/tests/xfs/524 b/tests/xfs/524 new file mode 100755 index 00000000..ba0b1a3b --- /dev/null +++ b/tests/xfs/524 @@ -0,0 +1,84 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 524 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# punching out an extent. +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/inject + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_debug +_require_xfs_io_command "fpunch" +_require_xfs_io_command "finsert" +_require_xfs_io_command "fcollapse" +_require_xfs_io_command "fzero" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "Format and mount fs" +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_file_block_size $SCRATCH_MNT) +nr_blks=80 + +testfile=$SCRATCH_MNT/testfile + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +for op in fpunch finsert fcollapse fzero; do + echo "* $op regular file" + + echo "Create \$testfile" + $XFS_IO_PROG -f -s \ + -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + $testfile >> $seqres.full + + echo "$op alternating blocks" + for i in $(seq 1 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -c "$op $((i * bsize)) $bsize" $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break + done + + echo "Verify \$testfile's extent count" + + nextents=$($XFS_IO_PROG -f -c 'stat' $testfile | grep -i nextents) + nextents=${nextents##fsxattr.nextents = } + if (( $nextents > 35 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 + fi + + rm $testfile +done + +# success, all done +status=0 +exit diff --git a/tests/xfs/524.out b/tests/xfs/524.out new file mode 100644 index 00000000..a957f9c7 --- /dev/null +++ b/tests/xfs/524.out @@ -0,0 +1,19 @@ +QA output created by 524 +Format and mount fs +Inject reduce_max_iextents error tag +* fpunch regular file +Create $testfile +fpunch alternating blocks +Verify $testfile's extent count +* finsert regular file +Create $testfile +finsert alternating blocks +Verify $testfile's extent count +* fcollapse regular file +Create $testfile +fcollapse alternating blocks +Verify $testfile's extent count +* fzero regular file +Create $testfile +fzero alternating blocks +Verify $testfile's extent count diff --git a/tests/xfs/group b/tests/xfs/group index b375a94c..7031cabf 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -521,6 +521,7 @@ 521 auto quick realtime growfs 522 auto quick quota 523 auto quick realtime growfs +524 auto quick punch zero insert collapse 758 auto quick rw attr realtime 759 auto quick rw realtime 760 auto quick rw collapse punch insert zero prealloc From patchwork Sat Nov 21 08:23:26 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: 11923265 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 AF69B138B for ; Sat, 21 Nov 2020 08:24:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D3C622254 for ; Sat, 21 Nov 2020 08:24:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="irSwRXW2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727149AbgKUIX5 (ORCPT ); Sat, 21 Nov 2020 03:23:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726629AbgKUIX5 (ORCPT ); Sat, 21 Nov 2020 03:23:57 -0500 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BEECC0613CF; Sat, 21 Nov 2020 00:23:57 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id q34so9450630pgb.11; Sat, 21 Nov 2020 00:23:57 -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=8p24vg1QYRAdft/ri+YAlOtLiS09tRhRxSLUxtPEzS8=; b=irSwRXW2NN46Msd37wDLyJNWLcVRf81JZ11HON4D8orqVKHbKujnunGXjgthTsGNnp DZpysf1wtQhAufGDRjQ/ATwjUDboupMG6d0+TC42SEOup2aUaESxljYGbXcH0xr32UzX +/HZVstDMbmnt8QT3e5a5FhVFIiHTRWXeyxJGcCuU8H/U1DG+MqJVg67QeCYUDqoaMyW 1b74h/swRRuyqG8Q/xLPXAA7dgY5qP6EVAhs5/gMKouUY4GA3kw9vyA2hXYqhbTHWqor bpwv82KzB6ByM1/rtXIkAXSt/R7QbgGNIMHw99vr+zPZ9hzS1RL8fsbwTUx5yK3nZWn7 aJBA== 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=8p24vg1QYRAdft/ri+YAlOtLiS09tRhRxSLUxtPEzS8=; b=BNsh3UhRhHLhaa3UZCAZ2BWd7avTfKVn9lciZWItKp3ezD5lafu0ecd9kK9TOQ2b/x 3wwRz1iBk2wJH3UumtXaWeeX2MFP/WQPkdZyMj+VvjzLyjRrI4Ad2i0Z4yjO1u7w+xaY Djx+QSXlW8KOhSvppm8A/Hha1qmn4wO/Rhs7TLmi/4f30FhrHoa3efSO43Wx+ZlAox7i xQDEeLvsrfk9aZyPweQWbno2BRuFUBn/i761ebTZuGUiSt9fKxhCj1HXrGbREkIanQZf LJJmBnD5JyCOi3v4D5mZksIRPVfntEmCyjbHV7pQ/H7ljqxJTJ2D/BoSECo/Fzsyy0UX laEg== X-Gm-Message-State: AOAM531EX0iJtjhPArFkEv5omRduDFlh/AEz694CQKCBAjSioA3jR559 D6cwvps3IQPRzLzARlcwwmBFlBV/m/4= X-Google-Smtp-Source: ABdhPJzyaLC9hmHtYXB5wQWHyMXI6y8sSULG2UoDCcLRG8oMqVz2PwX1NiF1dleo5BgIf2JKQMt6wg== X-Received: by 2002:a17:90b:1115:: with SMTP id gi21mr14762423pjb.58.1605947036792; Sat, 21 Nov 2020 00:23:56 -0800 (PST) Received: from localhost.localdomain ([122.167.41.102]) by smtp.gmail.com with ESMTPSA id e22sm6167148pfd.153.2020.11.21.00.23.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Nov 2020 00:23:56 -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 V2 05/11] xfs: Check for extent overflow when adding/removing xattrs Date: Sat, 21 Nov 2020 13:53:26 +0530 Message-Id: <20201121082332.89739-6-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201121082332.89739-1-chandanrlinux@gmail.com> References: <20201121082332.89739-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 | 176 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/525.out | 19 +++++ tests/xfs/group | 1 + 3 files changed, 196 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..07061bbe --- /dev/null +++ b/tests/xfs/525 @@ -0,0 +1,176 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 525 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# Adding/removing xattrs. +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/attr +. ./common/inject +. ./common/populate + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_attrs +_require_xfs_debug +_require_test_program "punch-alternating" +_require_xfs_io_error_injection "reduce_max_iextents" +_require_xfs_io_error_injection "bmap_alloc_minlen_extent" + +echo "Format and mount fs" +_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_block_size $SCRATCH_MNT) + +# To be able to remove xattr entries in a situation where inserting new xattrs +# is prevented due to possible extent count overflow , each xattr insert +# operation should reserve an extent count for deletion of maximum sized xattr +# apart from the extent count required for the xattr insert operation being +# performed. +# +# The following table gives an estimation of the total extent count that needs +# to be reserved for maximum sized "local" xattr insert operation for various +# block sizes, +# +# |-------+----------------------------------------+----------------------------------| +# | Block | Worst case remove extent count | Total extent | +# | size | (XFS_DA_NODE_MAXDEPTH + (64k / bsize)) | count | +# | | | (Xattr insert extent count (6) + | +# | | | Worst case remove extent count) | +# |-------+----------------------------------------+----------------------------------| +# | 1024 | 69 | 75 | +# | 2048 | 37 | 43 | +# | 4096 | 22 | 28 | +# | 32768 | 7 | 13 | +# | 65536 | 6 | 12 | +# |-------+----------------------------------------+----------------------------------| +# Note: Xattr insert extent count = XFS_DA_NODE_MAXDEPTH + 1 = 6. +# +# 35 (which is > 28) has been chosen as the pseudo maximum extent count in the +# XFS kernel module. Hence xattr tests are limited to block sizes >= 4k. + +if (( $bsize < 4096 )); then + _notrun "FSB size ($bsize) is less than 4k" +fi + +attr_len=255 + +testfile=$SCRATCH_MNT/testfile + +echo "Consume free space" +fillerdir=$SCRATCH_MNT/fillerdir +nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT) +nr_free_blks=$((nr_free_blks * 90 / 100)) + +_fill_fs $((bsize * nr_free_blks)) $fillerdir $bsize 0 >> $seqres.full 2>&1 + +echo "Create fragmented filesystem" +for dentry in $(ls -1 $fillerdir/); do + $here/src/punch-alternating $fillerdir/$dentry >> $seqres.full +done + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Inject bmap_alloc_minlen_extent error tag" +_scratch_inject_error bmap_alloc_minlen_extent 1 + +echo "* Set xattrs" + +echo "Create \$testfile" +touch $testfile + +echo "Create xattrs" +nr_attrs=$((bsize * 45 / attr_len)) +for i in $(seq 1 $nr_attrs); do + attr="$(printf "trusted.%0247d" $i)" + $SETFATTR_PROG -n "$attr" $testfile >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +echo "Verify \$testfile's naextent count" + +naextents=$($XFS_IO_PROG -f -c 'stat' $testfile | grep naextents) +naextents=${naextents##fsxattr.naextents = } +if (( $naextents > 35 )); then + echo "Extent count overflow check failed: naextents = $naextents" + exit 1 +fi + +echo "Remove one xattr" +attr="$(printf "trusted.%0247d" 1)" +$SETFATTR_PROG -x "$attr" $testfile + +echo "Remove \$testfile" +rm $testfile + +echo "* Remove xattrs" + +echo "Create \$testfile" +touch $testfile + +echo "Disable reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 0 + +echo "Create initial xattr extents" + +naextents=0 +last="" +start=1 +nr_attrs=$((bsize / attr_len)) + +while (( $naextents < 30 )); do + end=$((start + nr_attrs - 1)) + + for i in $(seq $start $end); do + attr="$(printf "trusted.%0247d" $i)" + $SETFATTR_PROG -n $attr $testfile + done + + start=$((end + 1)) + + naextents=$($XFS_IO_PROG -f -c 'stat' $testfile | grep naextents) + naextents=${naextents##fsxattr.naextents = } +done + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Remove xattr to trigger -EFBIG" +attr="$(printf "trusted.%0247d" 1)" +$SETFATTR_PROG -x "$attr" $testfile >> $seqres.full 2>&1 +if [[ $? == 0 ]]; then + echo "Xattr removal succeeded; Should have failed " + exit 1 +fi + +rm $testfile && echo "Successfully removed \$testfile" + +# success, all done +status=0 +exit diff --git a/tests/xfs/525.out b/tests/xfs/525.out new file mode 100644 index 00000000..c90dc873 --- /dev/null +++ b/tests/xfs/525.out @@ -0,0 +1,19 @@ +QA output created by 525 +Format and mount fs +Consume free space +Create fragmented filesystem +Inject reduce_max_iextents error tag +Inject bmap_alloc_minlen_extent error tag +* Set xattrs +Create $testfile +Create xattrs +Verify $testfile's naextent count +Remove one xattr +Remove $testfile +* Remove xattrs +Create $testfile +Disable reduce_max_iextents error tag +Create initial xattr extents +Inject reduce_max_iextents error tag +Remove xattr to trigger -EFBIG +Successfully removed $testfile diff --git a/tests/xfs/group b/tests/xfs/group index 7031cabf..bfaac6aa 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -522,6 +522,7 @@ 522 auto quick quota 523 auto quick realtime growfs 524 auto quick punch zero insert collapse +525 auto quick attr 758 auto quick rw attr realtime 759 auto quick rw realtime 760 auto quick rw collapse punch insert zero prealloc From patchwork Sat Nov 21 08:23:27 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: 11923267 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 DB87A17D5 for ; Sat, 21 Nov 2020 08:24:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE06922254 for ; Sat, 21 Nov 2020 08:24:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gHTlWXpK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727164AbgKUIYA (ORCPT ); Sat, 21 Nov 2020 03:24:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726629AbgKUIYA (ORCPT ); Sat, 21 Nov 2020 03:24:00 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37237C0613CF; Sat, 21 Nov 2020 00:24:00 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id v21so4911877plo.12; Sat, 21 Nov 2020 00:24:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rAdRS1EDmyYTKWOPc2TF69inX1ML8LobnyJwdxiy0dk=; b=gHTlWXpKYyc/JC4mNwBl1UtXZYVZXG1dOc/q95OP/wPTLEBUng39tYCn6+uKAfOExy pRDX2/5FUB9rP+DuZeuuBgMBw+42u589JHi3XPKpg7tUQnOChrCkkjoOZ5Gi2pWQfs37 aQ/7nc51bIrx2c2Dka1v0ar4d0gzNa9Tn30zsL0w7a6bV0IbrpzLk+GD8ySZtsoqqyNM LjUFRjLPMw/jYKWZ+BhQ1S/jzYfpUQTlCjdUjQqxo39HPjFtH7wBZOz+75+jy2+pvIa4 hbbvpgk+6voT/bjOEzkwUP2Y9/h1+24IGZsJHXZwaZb0P22qOOShZdTf2RNqUsiaw1gk 7Anw== 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=rAdRS1EDmyYTKWOPc2TF69inX1ML8LobnyJwdxiy0dk=; b=ANWUWk4FaDFr33qX1d/5VYhdLmjFZJEwVUDahRc9FwMOxVqR9I5bFyI5xEmjPXYVaK /+PZuuDcxUba9GPuH99tXOxv19MHrKA7pC966TlFX10/iL3CmFw8i+tQAKPMKG1FiQ6O TB7xCJxkvY+fsrf4YBS4iPLR/kwq9z0rXyTaWH1gwnmsMdGDZWoZPZIkjmcvb6SX2cUp gTN2WbaOzBnCf5t/EVQ4Ve/MmjDFfqbxPn6wwoho475wPczf/AX+9ddUSOxV6hqNOVQv Es+LtZBYQOGDVYCw+IY6f8ffG/z+rlAFN+smMZSt6PeYSLw+GVmYjeSFaR87NkISagp+ va2w== X-Gm-Message-State: AOAM5319lTGSApJlcj004IyEMqPY49zOPqMiiMeiQ/Roz/i3CJyiLX6U EQFO7INLMvpHqmIliVfJYqs2l+XKon0= X-Google-Smtp-Source: ABdhPJwdahg+CNjlONwnuksg2TW30bEVYIw61J+fM3EOHpatVJsbaU0llMzjDqTXlwFeMKjsJkLxww== X-Received: by 2002:a17:902:9f86:b029:d6:d25f:7ad8 with SMTP id g6-20020a1709029f86b02900d6d25f7ad8mr16811073plq.4.1605947039338; Sat, 21 Nov 2020 00:23:59 -0800 (PST) Received: from localhost.localdomain ([122.167.41.102]) by smtp.gmail.com with ESMTPSA id e22sm6167148pfd.153.2020.11.21.00.23.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Nov 2020 00:23:58 -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 V2 06/11] xfs: Check for extent overflow when adding/removing dir entries Date: Sat, 21 Nov 2020 13:53:27 +0530 Message-Id: <20201121082332.89739-7-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201121082332.89739-1-chandanrlinux@gmail.com> References: <20201121082332.89739-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 | 283 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/526.out | 32 ++++++ tests/xfs/group | 1 + 3 files changed, 316 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..89e4bf4d --- /dev/null +++ b/tests/xfs/526 @@ -0,0 +1,283 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 526 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# adding/removing directory entries. +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/inject +. ./common/populate + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_debug +_require_test_program "punch-alternating" +_require_xfs_io_error_injection "reduce_max_iextents" +_require_xfs_io_error_injection "bmap_alloc_minlen_extent" + +_scratch_mkfs_sized $((1024 * 1024 * 1024)) | _filter_mkfs >> $seqres.full 2> $tmp.mkfs +. $tmp.mkfs + +# Filesystems with directory block size greater than one FSB will not be tested, +# since "7 (i.e. XFS_DA_NODE_MAXDEPTH + 1 data block + 1 free block) * 2 (fsb +# count) = 14" is greater than the pseudo max extent count limit of 10. +# Extending the pseudo max limit won't help either. Consider the case where 1 +# FSB is 1k in size and 1 dir block is 64k in size (i.e. fsb count = 64). In +# this case, the pseudo max limit has to be greater than 7 * 64 = 448 extents. +if (( $dbsize != $dirbsize )); then + _notrun "FSB size ($dbsize) and directory block size ($dirbsize) do not match" +fi + +echo "Format and mount fs" +_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full +_scratch_mount >> $seqres.full + +echo "Consume free space" +fillerdir=$SCRATCH_MNT/fillerdir +nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT) +nr_free_blks=$((nr_free_blks * 90 / 100)) + +_fill_fs $((dbsize * nr_free_blks)) $fillerdir $dbsize 0 >> $seqres.full 2>&1 + +echo "Create fragmented filesystem" +for dentry in $(ls -1 $fillerdir/); do + $here/src/punch-alternating $fillerdir/$dentry >> $seqres.full +done + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Inject bmap_alloc_minlen_extent error tag" +_scratch_inject_error bmap_alloc_minlen_extent 1 + +dent_len=255 + +echo "* Create directory entries" + +testdir=$SCRATCH_MNT/testdir +mkdir $testdir + +nr_dents=$((dbsize * 40 / dent_len)) +for i in $(seq 1 $nr_dents); do + dentry="$(printf "%0255d" $i)" + touch ${testdir}/$dentry >> $seqres.full 2>&1 || break +done + +echo "Verify directory's extent count" +nextents=$($XFS_IO_PROG -c 'stat' $testdir | grep nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 35 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +dentry="$(printf "%0255d" 1)" +rm $testdir/$dentry && echo "Successfully removed \$dentry" + +rm -rf $testdir + +echo "* Rename: Populate destination directory" + +dstdir=$SCRATCH_MNT/dstdir +mkdir $dstdir + +nr_dents=$((dirbsize * 40 / dent_len)) + +echo "Populate \$dstdir by moving new directory entries" +for i in $(seq 1 $nr_dents); do + dentry="$(printf "%0255d" $i)" + dentry=${SCRATCH_MNT}/${dentry} + touch $dentry || break + mv $dentry $dstdir >> $seqres.full 2>&1 || break +done + +rm $dentry + +echo "Verify \$dstdir's extent count" + +nextents=$($XFS_IO_PROG -c 'stat' $dstdir | grep nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 35 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +dentry="$(printf "%0255d" 1)" +rm $dstdir/$dentry && echo "Successfully removed \$dentry" + +rm -rf $dstdir + +echo "* Create multiple hard links to a single file" + +testdir=$SCRATCH_MNT/testdir +mkdir $testdir + +testfile=$SCRATCH_MNT/testfile +touch $testfile + +nr_dents=$((dirbsize * 40 / dent_len)) + +echo "Create multiple hardlinks" +for i in $(seq 1 $nr_dents); do + dentry="$(printf "%0255d" $i)" + ln $testfile ${testdir}/${dentry} >> $seqres.full 2>&1 || break +done + +rm $testfile + +echo "Verify directory's extent count" +nextents=$($XFS_IO_PROG -c 'stat' $testdir | grep nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 35 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +dentry="$(printf "%0255d" 1)" +rm $testdir/$dentry && echo "Successfully removed \$dentry" + +rm -rf $testdir + +echo "* Create multiple symbolic links to a single file" + +testdir=$SCRATCH_MNT/testdir +mkdir $testdir + +testfile=$SCRATCH_MNT/testfile +touch $testfile + +nr_dents=$((dirbsize * 40 / dent_len)) + +echo "Create multiple symbolic links" +for i in $(seq 1 $nr_dents); do + dentry="$(printf "%0255d" $i)" + ln -s $testfile ${testdir}/${dentry} >> $seqres.full 2>&1 || break; +done + +rm $testfile + +echo "Verify directory's extent count" +nextents=$($XFS_IO_PROG -c 'stat' $testdir | grep nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 35 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +dentry="$(printf "%0255d" 1)" +rm $testdir/$dentry && echo "Successfully removed \$dentry" + +rm -rf $testdir + +echo "* Rename: Populate source directory and mv one entry to destination directory" + +srcdir=${SCRATCH_MNT}/srcdir +dstdir=${SCRATCH_MNT}/dstdir + +mkdir $srcdir +mkdir $dstdir + +echo "Disable reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 0 + +nextents=0 +start=1 +nr_dents=$((dirbsize / dent_len)) + +echo "Populate \$srcdir with atleast 30 extents" +while (( $nextents < 30 )); do + end=$((start + nr_dents - 1)) + + for i in $(seq $start $end); do + dentry="$(printf "%0255d" $i)" + touch ${srcdir}/${dentry} || break + done + + start=$((end + 1)) + + nextents=$($XFS_IO_PROG -c 'stat' $srcdir | grep nextents) + nextents=${nextents##fsxattr.nextents = } +done + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Move an entry from \$srcdir to trigger -EFBIG" +dentry="$(printf "%0255d" 1)" +mv ${srcdir}/${dentry} $dstdir >> $seqres.full 2>&1 +if [[ $? == 0 ]]; then + echo "Moving from \$srcdir to \$dstdir succeeded; Should have failed" +fi + +echo "Disable reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 0 + +rm -rf $srcdir +rm -rf $dstdir + +echo "* Populate a directory and remove one entry" + +testdir=$SCRATCH_MNT/testdir +mkdir $testdir + +nextents=0 +start=1 +nr_dents=$((dirbsize / dent_len)) + +echo "Populate directory with atleast 30 extents" +while (( $nextents < 30 )); do + end=$((start + nr_dents - 1)) + + for i in $(seq $start $end); do + dentry="$(printf "%0255d" $i)" + touch ${testdir}/${dentry} || break + done + + start=$((end + 1)) + + nextents=$($XFS_IO_PROG -c 'stat' $testdir | grep nextents) + nextents=${nextents##fsxattr.nextents = } +done + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Remove an entry from directory to trigger -EFBIG" +dentry="$(printf "%0255d" 1)" +rm ${testdir}/${dentry} >> $seqres.full 2>&1 +if [[ $? == 0 ]]; then + echo "Removing file succeeded; Should have failed" +fi + +echo "Disable reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 0 + +rm -rf $testdir + +# success, all done +status=0 +exit diff --git a/tests/xfs/526.out b/tests/xfs/526.out new file mode 100644 index 00000000..5b1d3fac --- /dev/null +++ b/tests/xfs/526.out @@ -0,0 +1,32 @@ +QA output created by 526 +Format and mount fs +Consume free space +Create fragmented filesystem +Inject reduce_max_iextents error tag +Inject bmap_alloc_minlen_extent error tag +* Create directory entries +Verify directory's extent count +Successfully removed $dentry +* Rename: Populate destination directory +Populate $dstdir by moving new directory entries +Verify $dstdir's extent count +Successfully removed $dentry +* Create multiple hard links to a single file +Create multiple hardlinks +Verify directory's extent count +Successfully removed $dentry +* Create multiple symbolic links to a single file +Create multiple symbolic links +Verify directory's extent count +Successfully removed $dentry +* Rename: Populate source directory and mv one entry to destination directory +Disable reduce_max_iextents error tag +Populate $srcdir with atleast 30 extents +Inject reduce_max_iextents error tag +Move an entry from $srcdir to trigger -EFBIG +Disable reduce_max_iextents error tag +* Populate a directory and remove one entry +Populate directory with atleast 30 extents +Inject reduce_max_iextents error tag +Remove an entry from directory to trigger -EFBIG +Disable reduce_max_iextents error tag diff --git a/tests/xfs/group b/tests/xfs/group index bfaac6aa..0e98d623 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -523,6 +523,7 @@ 523 auto quick realtime growfs 524 auto quick punch zero insert collapse 525 auto quick attr +526 auto quick dir hardlink symlink 758 auto quick rw attr realtime 759 auto quick rw realtime 760 auto quick rw collapse punch insert zero prealloc From patchwork Sat Nov 21 08:23:28 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: 11923269 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 24E5C1746 for ; Sat, 21 Nov 2020 08:24:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0486022264 for ; Sat, 21 Nov 2020 08:24:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XA0cThDH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727188AbgKUIYE (ORCPT ); Sat, 21 Nov 2020 03:24:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726629AbgKUIYD (ORCPT ); Sat, 21 Nov 2020 03:24:03 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E046C0613CF; Sat, 21 Nov 2020 00:24:02 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id g7so10187171pfc.2; Sat, 21 Nov 2020 00:24:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eZ5mUiZxvU45oCmeB9macPQYL8ePYS3CM7WPraEjVoA=; b=XA0cThDHW6jjt5n5OFHGLF3fUWI0XxakyW+m6+KkEg2ejePJ+DgI/+RQcX1J2xGrZU VO9bNpUxHeFpZz34S60vtNq5S00dyNQZyaA7koijScOZmiwnQ+EDf02zSsYaqYcpC/5q ycQ5hSFDBI6vE2lLxF7CJaoI1jqdQP1VRmPWvdy0fHgLYcs1rFQvKBEm7py599dBhaSb g0J9WzPdo+lJID9HyMnIxzGMQ2EOSmHq9ogL7bMn1a8ovMlTPj9TS3RmOmscEL9s7A4o bWw+d1yVTPxsvfWPrqTYZFd0d6OhPeopIKaIk1EvEp8EjMbhh7up1QHCZKjfJWNFms2x DEFg== 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=eZ5mUiZxvU45oCmeB9macPQYL8ePYS3CM7WPraEjVoA=; b=okDS/xV+idVLjf3cFTcqJ0DeHDypShatEqSBotHojtkLvH4YmjFxBxsLwcUevnIYBl vuQ6IQ2IShxe+3W9cKla1sADBFqLTK3O6CkB1U1TFgCiCCH9hGzfHqS55k88VVJnNItN SwfBRyOgEBybP/dPosCKxQ23NcVOJNUdO6GfPjqJFCTYxehFPeLwK6J4zn8nGHmsQ+Nh EdnbS5D4seLESo9cL9wlGLce9wNQAYeMj/Nvi9CzH3AWaUANjr0qln6mWe/wlFHVSA26 4wjq7I6/O67e8NCC3uKGQiBtcInzomNgn9cn8ADWedf9cUGj5utN/fzUhr/gcfCdCxyC gxZA== X-Gm-Message-State: AOAM531/tvWGAwZLpcyyzPkz1uPUfFGWvqOkIC0RM4DGpOFvwxMeRDOI 5x4DuLB/FYimL6YB8s2HgqDre9lebY8= X-Google-Smtp-Source: ABdhPJwsm6UbpWJMophK/bZHqyXafo+uOdJfrzC4+TkqtQyTGeLnl4aljgdeFib7VJOIaDoe43owFA== X-Received: by 2002:a17:90a:a50b:: with SMTP id a11mr14249697pjq.170.1605947041813; Sat, 21 Nov 2020 00:24:01 -0800 (PST) Received: from localhost.localdomain ([122.167.41.102]) by smtp.gmail.com with ESMTPSA id e22sm6167148pfd.153.2020.11.21.00.23.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Nov 2020 00:24:01 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com Subject: [PATCH V2 07/11] xfs: Check for extent overflow when writing to unwritten extent Date: Sat, 21 Nov 2020 13:53:28 +0530 Message-Id: <20201121082332.89739-8-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201121082332.89739-1-chandanrlinux@gmail.com> References: <20201121082332.89739-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 | 89 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/527.out | 11 ++++++ tests/xfs/group | 1 + 3 files changed, 101 insertions(+) create mode 100755 tests/xfs/527 create mode 100644 tests/xfs/527.out diff --git a/tests/xfs/527 b/tests/xfs/527 new file mode 100755 index 00000000..175e7ede --- /dev/null +++ b/tests/xfs/527 @@ -0,0 +1,89 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 527 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# writing to an unwritten extent. +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/inject + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_debug +_require_xfs_io_command "falloc" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "Format and mount fs" +_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_file_block_size $SCRATCH_MNT) + +testfile=${SCRATCH_MNT}/testfile + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +nr_blks=40 + +for io in Buffered Direct; do + echo "* $io write to unwritten extent" + + echo "Fallocate $nr_blks blocks" + $XFS_IO_PROG -f -c "falloc 0 $((nr_blks * bsize))" $testfile >> $seqres.full + + if [[ $io == "Buffered" ]]; then + xfs_io_flag="" + else + xfs_io_flag="-d" + fi + + echo "$io write to every other block of fallocated space" + for i in $(seq 1 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -s $xfs_io_flag -c "pwrite $((i * bsize)) $bsize" \ + $testfile >> $seqres.full 2>&1 + [[ $? != 0 ]] && break + done + + echo "Verify \$testfile's extent count" + nextents=$($XFS_IO_PROG -c 'stat' $testfile | grep nextents) + nextents=${nextents##fsxattr.nextents = } + if (( $nextents > 35 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 + fi + + rm $testfile +done + +# super_block->s_wb_err will have a newer seq value when compared to "/"'s +# file->f_sb_err. Consume it here so that xfs_scrub can does not error out. +$XFS_IO_PROG -c syncfs $SCRATCH_MNT >> $seqres.full 2>&1 + +# success, all done +status=0 +exit diff --git a/tests/xfs/527.out b/tests/xfs/527.out new file mode 100644 index 00000000..d59e7047 --- /dev/null +++ b/tests/xfs/527.out @@ -0,0 +1,11 @@ +QA output created by 527 +Format and mount fs +Inject reduce_max_iextents error tag +* Buffered write to unwritten extent +Fallocate 40 blocks +Buffered write to every other block of fallocated space +Verify $testfile's extent count +* Direct write to unwritten extent +Fallocate 40 blocks +Direct write to every other block of fallocated space +Verify $testfile's extent count diff --git a/tests/xfs/group b/tests/xfs/group index 0e98d623..c17bc140 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -524,6 +524,7 @@ 524 auto quick punch zero insert collapse 525 auto quick attr 526 auto quick dir hardlink symlink +527 auto quick 758 auto quick rw attr realtime 759 auto quick rw realtime 760 auto quick rw collapse punch insert zero prealloc From patchwork Sat Nov 21 08:23:29 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: 11923271 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 5708014C0 for ; Sat, 21 Nov 2020 08:24:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3674422264 for ; Sat, 21 Nov 2020 08:24:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eJz71FEU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727211AbgKUIYF (ORCPT ); Sat, 21 Nov 2020 03:24:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726629AbgKUIYF (ORCPT ); Sat, 21 Nov 2020 03:24:05 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1773BC0613CF; Sat, 21 Nov 2020 00:24:05 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id 131so10172429pfb.9; Sat, 21 Nov 2020 00:24:05 -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=XZZ3HlCYDDFUFUzMpYwLb+U2F98R55JlsxdvagAGOQ8=; b=eJz71FEUJuqiTfexPCqkAtnFFTScoPJNynE1ueEanKotpj8T1lJPTFBrCqtFnZ9TPQ Up6lyh0406AL/B2PuYNGc5uOIT4vW33lWzNThufoiyRlTuW/u82WlDH6jM6DEJljRCnF pN2BEMUKAjph4ZDZbUkO9rQzBcUMUapA15RaU3TL4tGlwYAD3tOLcEETs0bBg19LgWEq RL7hyMTOn4Svwamrt7477MyHXvWCz6g6atjCt+Bx2O5yuYoGd0/wnyLqVbsgTrQssmRg 0BllXdvec9w+VIeVPeKFotyGUszash//wSyO/exUWvt8t0uDzvcpj5wkVSD29olkV5wi 8ngg== 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=XZZ3HlCYDDFUFUzMpYwLb+U2F98R55JlsxdvagAGOQ8=; b=j9meFe9pp2xHAS6rrcLeWjlMXlRRRsH5QL+TmaG1bCNLr5sLpNC0LlmZLIw17dFkhm lxALWPzGs2PxXg0VhsRheNjKxXnW+I3NsuRaLO0O4lMUZX6kEbtTWW9HxZ9dqM6UIgMw MH6x8iLN3QlTQjmEfdiLd6S290FCel4a9wr6K7U4i17xU0fOL2yGP+mDiLKvcraS88yo JdrCmx3srZqH5a9wcS2VGXZ2i6HG/Byyr7izwRal8MEYywMXjrq4r9aLV5/H4owWiHai FtE4XgOAVLHLHjUOFQ//MuA0cTJHtwvebBYLNVGULiNgCjcyvU3RDWJF9oq5jYrR65rG CSGg== X-Gm-Message-State: AOAM530aaokWvxPAC3h976lVWbIX+AO1uYdlm38BqOkBukvTGFC5N0i2 Hv1HLtnoLeTZvYKdOj8KEvjZGRsuYqU= X-Google-Smtp-Source: ABdhPJw2TYLSgiEK9QTkKzSVHenGa0d1m1erkdX8nQDbBgaaE8KNvlFeZKVjBAeFZ8ecv0CFxzHqng== X-Received: by 2002:a63:550e:: with SMTP id j14mr8743141pgb.44.1605947044305; Sat, 21 Nov 2020 00:24:04 -0800 (PST) Received: from localhost.localdomain ([122.167.41.102]) by smtp.gmail.com with ESMTPSA id e22sm6167148pfd.153.2020.11.21.00.24.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Nov 2020 00:24:03 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com Subject: [PATCH V2 08/11] xfs: Check for extent overflow when moving extent from cow to data fork Date: Sat, 21 Nov 2020 13:53:29 +0530 Message-Id: <20201121082332.89739-9-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201121082332.89739-1-chandanrlinux@gmail.com> References: <20201121082332.89739-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/funshare-ing a shared extent. Signed-off-by: Chandan Babu R --- tests/xfs/528 | 110 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/528.out | 12 +++++ tests/xfs/group | 1 + 3 files changed, 123 insertions(+) create mode 100755 tests/xfs/528 create mode 100644 tests/xfs/528.out diff --git a/tests/xfs/528 b/tests/xfs/528 new file mode 100755 index 00000000..d73b2b27 --- /dev/null +++ b/tests/xfs/528 @@ -0,0 +1,110 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 528 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# writing to a shared extent. +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/reflink +. ./common/inject + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_scratch_reflink +_require_xfs_debug +_require_xfs_io_command "reflink" +_require_xfs_io_command "funshare" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "Format and mount fs" +_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_block_size $SCRATCH_MNT) + +nr_blks=40 + +srcfile=${SCRATCH_MNT}/srcfile +dstfile=${SCRATCH_MNT}/dstfile + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Create a \$srcfile having an extent of length $nr_blks blocks" +$XFS_IO_PROG -f -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + -c fsync $srcfile >> $seqres.full + +echo "* Write to shared extent" + +echo "Share the extent with \$dstfile" +$XFS_IO_PROG -f -c "reflink $srcfile" $dstfile >> $seqres.full + +echo "Buffered write to every other block of \$dstfile's shared extent" +for i in $(seq 1 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -s -c "pwrite $((i * bsize)) $bsize" $dstfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +echo "Verify \$dstfile's extent count" +nextents=$($XFS_IO_PROG -c 'stat' $dstfile | grep nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 35 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm $dstfile + +echo "* Funshare shared extent" + +echo "Share the extent with \$dstfile" +$XFS_IO_PROG -f -c "reflink $srcfile" $dstfile >> $seqres.full + +echo "Funshare every other block of \$dstfile's shared extent" +for i in $(seq 1 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -s -c "funshare $((i * bsize)) $bsize" $dstfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +echo "Verify \$dstfile's extent count" +nextents=$($XFS_IO_PROG -c 'stat' $dstfile | grep nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 35 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +# super_block->s_wb_err will have a newer seq value when compared to "/"'s +# file->f_sb_err. Consume it here so that xfs_scrub can does not error out. +$XFS_IO_PROG -c syncfs $SCRATCH_MNT >> $seqres.full 2>&1 + +# success, all done +status=0 +exit + diff --git a/tests/xfs/528.out b/tests/xfs/528.out new file mode 100644 index 00000000..33c8512c --- /dev/null +++ b/tests/xfs/528.out @@ -0,0 +1,12 @@ +QA output created by 528 +Format and mount fs +Inject reduce_max_iextents error tag +Create a $srcfile having an extent of length 40 blocks +* Write to shared extent +Share the extent with $dstfile +Buffered write to every other block of $dstfile's shared extent +Verify $dstfile's extent count +* Funshare shared extent +Share the extent with $dstfile +Funshare every other block of $dstfile's shared extent +Verify $dstfile's extent count diff --git a/tests/xfs/group b/tests/xfs/group index c17bc140..ea892308 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -525,6 +525,7 @@ 525 auto quick attr 526 auto quick dir hardlink symlink 527 auto quick +528 auto quick reflink 758 auto quick rw attr realtime 759 auto quick rw realtime 760 auto quick rw collapse punch insert zero prealloc From patchwork Sat Nov 21 08:23:30 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: 11923273 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 7F8D414C0 for ; Sat, 21 Nov 2020 08:24:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 633D42225B for ; Sat, 21 Nov 2020 08:24:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kRp3Bfck" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727216AbgKUIYH (ORCPT ); Sat, 21 Nov 2020 03:24:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726629AbgKUIYH (ORCPT ); Sat, 21 Nov 2020 03:24:07 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83815C0613CF; Sat, 21 Nov 2020 00:24:07 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id l11so6182955plt.1; Sat, 21 Nov 2020 00:24:07 -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=RCqROnImwvyXzl6bVYsymZFsI81FeC2UbTuw1mbNivE=; b=kRp3Bfck1o1dl0uqPkakO0a4DwIRcJdvXtbwd7Dxc+ZWDpl9fEGnSkBzArvz9TTRng 9rEmjtXalZ+AyV46EKCSe5ssiSEh8xlP559c2uotwWOn47TY1D3ZKTJQmEHkQq3DoJ5r +B0o7vKn4RvSmTXwpOQ84tce2wmC2ZSSfJ1aVYDtuNkllySI0xhxNsq8snkuvjPdWNEr GtkqOHPk75V54qEmqqG9lMyE8ICB8/12KMne8B1XQVC8RN2QqvP0LvIRYF07Ni5Fq7wd uLd12OJT0/Xj/x1GjZ1eW0epr9yeSRaGexJzrFUVQJPuEXGYhqzFu0Nqp3OmULLXiBD5 8bUQ== 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=RCqROnImwvyXzl6bVYsymZFsI81FeC2UbTuw1mbNivE=; b=cKhmd6TLDMHBloTfVFm0QZ6QVV/bpXD85HF55H/wfRiYs7KppYHt14MlZCpDd920zR Or83Q7gN21yGQrYjN2t/y+kkIrqUgjLLwuk8P0PuuEE6Igj7eGqQBaWtKzP0yVyziyo1 qYwinuxKrQS7CFcEyg9n+ICpzhsIpCYB4LZQxXAn4euUrBx9yOYyjuKPuk5OxQiPJowB rfZw5lppvmkkOYeH3AGJ/QoII2MgdGiNgPr6LkVIIL6JSBaa8+YFiLgTywpxfaEOuQNI fhmOfG4+IbXzTn2Vgbhv+tKGgasletpkSe8YPwzzBK0nSCjAfEmffXjwCERPQthOWG2I rtMg== X-Gm-Message-State: AOAM531vbUWU4ggZYCE3pmbsp0FIBOuwMs9NXXiN8l9MMjfKcnA76feL fYvVmjXCyUkSzXg4IN/IVfO3ju53okA= X-Google-Smtp-Source: ABdhPJw2y+G9xupa/E4XPBD83AqFRLAtRAQg2UqU8B6okhLnts4j1OGCGxfMlVBXvvBlTB71wO5FEg== X-Received: by 2002:a17:902:7486:b029:d9:d4aa:e033 with SMTP id h6-20020a1709027486b02900d9d4aae033mr12594535pll.16.1605947046790; Sat, 21 Nov 2020 00:24:06 -0800 (PST) Received: from localhost.localdomain ([122.167.41.102]) by smtp.gmail.com with ESMTPSA id e22sm6167148pfd.153.2020.11.21.00.24.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Nov 2020 00:24:06 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com Subject: [PATCH V2 09/11] xfs: Check for extent overflow when remapping an extent Date: Sat, 21 Nov 2020 13:53:30 +0530 Message-Id: <20201121082332.89739-10-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201121082332.89739-1-chandanrlinux@gmail.com> References: <20201121082332.89739-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 | 82 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/529.out | 8 +++++ tests/xfs/group | 1 + 3 files changed, 91 insertions(+) create mode 100755 tests/xfs/529 create mode 100644 tests/xfs/529.out diff --git a/tests/xfs/529 b/tests/xfs/529 new file mode 100755 index 00000000..47e738af --- /dev/null +++ b/tests/xfs/529 @@ -0,0 +1,82 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 529 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# remapping extents from one file's inode fork to another. +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/reflink +. ./common/inject + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_scratch_reflink +_require_xfs_debug +_require_xfs_io_command "reflink" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "* Reflink remap extents" + +echo "Format and mount fs" +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_block_size $SCRATCH_MNT) + +srcfile=${SCRATCH_MNT}/srcfile +dstfile=${SCRATCH_MNT}/dstfile + +nr_blks=40 + +echo "Create \$srcfile having an extent of length $nr_blks blocks" +$XFS_IO_PROG -f -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + -c fsync $srcfile >> $seqres.full + +echo "Create \$dstfile having an extent of length $nr_blks blocks" +$XFS_IO_PROG -f -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + -c fsync $dstfile >> $seqres.full + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Reflink every other block from \$srcfile into \$dstfile" +for i in $(seq 1 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -c "reflink $srcfile $((i * bsize)) $((i * bsize)) $bsize" \ + $dstfile >> $seqres.full 2>&1 +done + +echo "Verify \$dstfile's extent count" +nextents=$($XFS_IO_PROG -c 'stat' $dstfile | grep nextents) +nextents=${nextents##fsxattr.nextents = } +if (( $nextents > 35 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +# success, all done +status=0 +exit diff --git a/tests/xfs/529.out b/tests/xfs/529.out new file mode 100644 index 00000000..06b8a769 --- /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 40 blocks +Create $dstfile having an extent of length 40 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 ea892308..96e40901 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -526,6 +526,7 @@ 526 auto quick dir hardlink symlink 527 auto quick 528 auto quick reflink +529 auto quick reflink 758 auto quick rw attr realtime 759 auto quick rw realtime 760 auto quick rw collapse punch insert zero prealloc From patchwork Sat Nov 21 08:23:31 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: 11923275 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 C4E1E14C0 for ; Sat, 21 Nov 2020 08:24:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AAA8E22252 for ; Sat, 21 Nov 2020 08:24:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OH6L9yRn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727249AbgKUIYL (ORCPT ); Sat, 21 Nov 2020 03:24:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727248AbgKUIYK (ORCPT ); Sat, 21 Nov 2020 03:24:10 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED7D9C0613CF; Sat, 21 Nov 2020 00:24:09 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id v5so6137153pff.10; Sat, 21 Nov 2020 00:24:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YLh6ge7d2BSDsnjLgHAlHNx2zVNQlO/eEK4I0Z84xXc=; b=OH6L9yRnYQpQ+C5A7REsQjGXD+5MjSpQZojUcXV8Q+N1dO7R5R3qlt25ql7eCbdg7k XxGPU/tRmt1hTDSQrRiUL5z+/L7tOajvI5IExMtXJjQiScMwj7sM/mnayYt8DgiskHmy v4AnDWwC6N1+uLbbKhkZlRKyqzAvtd7cT5dzaZkJWe1MSzEhhu1H3Rt7a4Z15CAbwuAP 93b3kURRVaSCVYbJVUD0+c03IXMDsCtlkLAxVoiiZjvvKk8G9xRgfdIBIw8ufcGcoQ3Z Jntd1wIz56ARwdizLHJOU0OHmtUfdriMSia27psjUL6YY/ZYYM2LWkh/LwtuLXNSRBup OEyQ== 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=YLh6ge7d2BSDsnjLgHAlHNx2zVNQlO/eEK4I0Z84xXc=; b=O3jdHIO4BtM481unpU46z1qJilBdX+lJVlfnt3t42CBaYalC5AmWBDM0obBDUHN4wU qROokm5QLzTFu1e75kO6BzIK6a8brO3nOcCH1DGSySISbg9ZkQKlQ2EBQ+BpO4cAUqTS r2neaLXbb3OiK0CKgOvqiXSX0AaP3xglDhm3JhzZOBPU8oGnYrvLJquzNIPzaJVO3JVc Tt5CCYVhL6gLlFTOQYg6UjNPpLX7B+lXMdXd833FdO3yUpI+ypTkwZosZFLVZZATQdIG vgNjQ8DywK/tGeZsQYZjnD4PBuyn1oAHRQ4Ljuj7VHl13fFWWm+1FKA1LTk7/gvgOvd+ KNkg== X-Gm-Message-State: AOAM531HlmzzYo9nYNtKN4J1qVDXohvhqUAqBVpYOZOx2ukDvJP2tVaP Xn40HRp41HD9OcMGePGHLcPs2Me6RS8= X-Google-Smtp-Source: ABdhPJw3pTB/TiyBiOb9yVV+26hqQDF6Hyj46ry3e6TVJwovczlkHVeyhCDtrqNlTkA5Le6ub3n9zA== X-Received: by 2002:a17:90b:89:: with SMTP id bb9mr14557442pjb.53.1605947049276; Sat, 21 Nov 2020 00:24:09 -0800 (PST) Received: from localhost.localdomain ([122.167.41.102]) by smtp.gmail.com with ESMTPSA id e22sm6167148pfd.153.2020.11.21.00.24.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Nov 2020 00:24:08 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, darrick.wong@oracle.com Subject: [PATCH V2 10/11] xfs: Check for extent overflow when swapping extents Date: Sat, 21 Nov 2020 13:53:31 +0530 Message-Id: <20201121082332.89739-11-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201121082332.89739-1-chandanrlinux@gmail.com> References: <20201121082332.89739-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 | 109 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/530.out | 13 ++++++ tests/xfs/group | 1 + 3 files changed, 123 insertions(+) create mode 100755 tests/xfs/530 create mode 100644 tests/xfs/530.out diff --git a/tests/xfs/530 b/tests/xfs/530 new file mode 100755 index 00000000..d4137324 --- /dev/null +++ b/tests/xfs/530 @@ -0,0 +1,109 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 530 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# swapping forks between files +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/inject + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_debug +_require_xfs_scratch_rmapbt +_require_xfs_io_command "fcollapse" +_require_xfs_io_command "swapext" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "* Swap extent forks" + +echo "Format and mount fs" +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_block_size $SCRATCH_MNT) + +srcfile=${SCRATCH_MNT}/srcfile +donorfile=${SCRATCH_MNT}/donorfile + +echo "Create \$donorfile having an extent of length 67 blocks" +$XFS_IO_PROG -f -s -c "pwrite -b $((67 * bsize)) 0 $((67 * bsize))" $donorfile \ + >> $seqres.full + +# After the for loop the donor file will have the following extent layout +# | 0-4 | 5 | 6 | 7 | ... | 34 | 35 | +echo "Fragment \$donorfile" +for i in $(seq 5 35); do + start_offset=$((i * bsize)) + $XFS_IO_PROG -f -c "fcollapse $start_offset $bsize" $donorfile >> $seqres.full +done + +echo "Create \$srcfile having an extent of length 67 blocks" +$XFS_IO_PROG -f -s -c "pwrite -b $((67 * bsize)) 0 $((67 * bsize))" $srcfile \ + >> $seqres.full + +echo "Fragment \$srcfile" +# After the for loop the src file will have the following extent layout +# | 0 | 1 | 2 | ... | 29 | 30 | 31-35 | +for i in $(seq 1 31); do + start_offset=$((i * bsize)) + $XFS_IO_PROG -f -c "fcollapse $start_offset $bsize" $srcfile >> $seqres.full +done + +echo "Collect \$donorfile's extent count" +donor_nr_exts=$($XFS_IO_PROG -c 'stat' $donorfile | grep nextents) +donor_nr_exts=${donor_nr_exts##fsxattr.nextents = } + +echo "Collect \$srcfile's extent count" +src_nr_exts=$($XFS_IO_PROG -c 'stat' $srcfile | grep nextents) +src_nr_exts=${src_nr_exts##fsxattr.nextents = } + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Swap \$srcfile's and \$donorfile's extent forks" +$XFS_IO_PROG -f -c "swapext $donorfile" $srcfile >> $seqres.full 2>&1 + +echo "Check for \$donorfile's extent count overflow" +nextents=$($XFS_IO_PROG -c 'stat' $donorfile | grep nextents) +nextents=${nextents##fsxattr.nextents = } + +if (( $nextents == $src_nr_exts )); then + echo "\$donorfile: Extent count overflow check failed" +fi + +echo "Check for \$srcfile's extent count overflow" +nextents=$($XFS_IO_PROG -c 'stat' $srcfile | grep nextents) +nextents=${nextents##fsxattr.nextents = } + +if (( $nextents == $donor_nr_exts )); then + echo "\$srcfile: Extent count overflow check failed" +fi + +# success, all done +status=0 +exit diff --git a/tests/xfs/530.out b/tests/xfs/530.out new file mode 100644 index 00000000..2fc6bf00 --- /dev/null +++ b/tests/xfs/530.out @@ -0,0 +1,13 @@ +QA output created by 530 +* Swap extent forks +Format and mount fs +Create $donorfile having an extent of length 67 blocks +Fragment $donorfile +Create $srcfile having an extent of length 67 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 96e40901..289a082d 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -527,6 +527,7 @@ 527 auto quick 528 auto quick reflink 529 auto quick reflink +530 auto quick 758 auto quick rw attr realtime 759 auto quick rw realtime 760 auto quick rw collapse punch insert zero prealloc From patchwork Sat Nov 21 08:23:32 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: 11923277 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 035991746 for ; Sat, 21 Nov 2020 08:24:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D167722240 for ; Sat, 21 Nov 2020 08:24:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BtaJfDqO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727267AbgKUIYO (ORCPT ); Sat, 21 Nov 2020 03:24:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727200AbgKUIYN (ORCPT ); Sat, 21 Nov 2020 03:24:13 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CC49C0613CF; Sat, 21 Nov 2020 00:24:12 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id 18so6151148pli.13; Sat, 21 Nov 2020 00:24:12 -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=FZgARtFP3MafucsdIxRriBvkxf7XoFVmTv9PLFeynHY=; b=BtaJfDqOtZiJYyaUxTulMy1/OYKrqs7vthgS3xU9AWEfuPyWzsXO8LUfNNJFR7Xywj E2fDQEKHlWWyQVyIWJzLfQU7jDY/ytNhhV286VXXoaY7UQAFfZKWzL2lFABMQgutFQoX 5cNFSYpqHvfld2f4wxSw4KPwU/7QULl1nf9U0me+5za7B4W1CQIf73VamPd4SVBRgU2Q d2fq9lda16XMeHUH+QwpaemmzdrJuKeKSuXBgfEqmCDq6qw2WvILzX3D/no/e+x6R65F sn47NuWnGPRwKj1sZtmCfzVClJZG48Mz40lsZjBjwjKokmXw1QSlO3UFnob9sUfPYt2k 0rJQ== 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=FZgARtFP3MafucsdIxRriBvkxf7XoFVmTv9PLFeynHY=; b=qALF7eUVLWv0VX7od64FSML3C1Rbpm4Wpx/FsZcACSNQg1s0PrFBSg/ROK0n9yLGVn Xpq1zvODupRWP+KFbxuuAJxJEjxwL8W7iSIgGG9mkJxbEfX1uNjf9XSpkchtFmRSxJ5R pdFpQbGf10t0uTRQPQHe9JE9MU1dzdjnBNGUmyvji/eNKJCrosjubb2zQXJRvgUuphHu MBBqjvWLtUFUhOkYICJgVtQOclrsT30+nP092vdpxXUEkb/N8byQZnaDXfGRJngXsv0f AfCm7DDL+vHLqMvrw18PmyafEYh9DqjQyQPNyjk29jBjufysTJ5Tnsd2RyUMJyAjlApY oNrw== X-Gm-Message-State: AOAM533QdIFVBBN/A6fugMfnwuznr9Kts0vBQkLOLvubVdY44+IAzzwI y5wSqumR8gbVYl+oKJDkwnfQfkAi8h4= X-Google-Smtp-Source: ABdhPJyck96xRpxghgCuwFMrJzEey0Raijd0xeJHBxMF+/0PFKWEYebz27qZWutZNrMzaVL0EZRV8w== X-Received: by 2002:a17:902:864c:b029:d8:b3b1:b91c with SMTP id y12-20020a170902864cb02900d8b3b1b91cmr17657160plt.79.1605947051699; Sat, 21 Nov 2020 00:24:11 -0800 (PST) Received: from localhost.localdomain ([122.167.41.102]) by smtp.gmail.com with ESMTPSA id e22sm6167148pfd.153.2020.11.21.00.24.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Nov 2020 00:24:11 -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 V2 11/11] xfs: Stress test with with bmap_alloc_minlen_extent error tag enabled Date: Sat, 21 Nov 2020 13:53:32 +0530 Message-Id: <20201121082332.89739-12-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201121082332.89739-1-chandanrlinux@gmail.com> References: <20201121082332.89739-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 | 84 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/531.out | 7 ++++ tests/xfs/group | 1 + 3 files changed, 92 insertions(+) create mode 100755 tests/xfs/531 create mode 100644 tests/xfs/531.out diff --git a/tests/xfs/531 b/tests/xfs/531 new file mode 100755 index 00000000..983524b4 --- /dev/null +++ b/tests/xfs/531 @@ -0,0 +1,84 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 531 +# +# Execute fsstress with bmap_alloc_minlen_extent error tag enabled. +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/inject +. ./common/populate + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_debug +_require_test_program "punch-alternating" +_require_xfs_io_error_injection "bmap_alloc_minlen_extent" + +echo "Format and mount fs" +_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_file_block_size $SCRATCH_MNT) + +echo "Consume free space" +fillerdir=$SCRATCH_MNT/fillerdir +nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT) +nr_free_blks=$((nr_free_blks * 90 / 100)) + +_fill_fs $((bsize * nr_free_blks)) $fillerdir $bsize 0 >> $seqres.full 2>&1 + +echo "Create fragmented filesystem" +for dentry in $(ls -1 $fillerdir/); do + $here/src/punch-alternating $fillerdir/$dentry >> $seqres.full +done + +echo "Inject bmap_alloc_minlen_extent error tag" +_scratch_inject_error bmap_alloc_minlen_extent 1 + +echo "Scale fsstress args" +args=$(_scale_fsstress_args -p 75 -n 10000) + +echo "Execute fsstress in background" +$FSSTRESS_PROG -d $SCRATCH_MNT $args \ + -f bulkstat=0 \ + -f bulkstat1=0 \ + -f fiemap=0 \ + -f getattr=0 \ + -f getdents=0 \ + -f getfattr=0 \ + -f listfattr=0 \ + -f mread=0 \ + -f read=0 \ + -f readlink=0 \ + -f readv=0 \ + -f stat=0 \ + -f aread=0 \ + -f dread=0 > /dev/null 2>&1 + +# success, all done +status=0 +exit diff --git a/tests/xfs/531.out b/tests/xfs/531.out new file mode 100644 index 00000000..67f40654 --- /dev/null +++ b/tests/xfs/531.out @@ -0,0 +1,7 @@ +QA output created by 531 +Format and mount fs +Consume free space +Create fragmented filesystem +Inject bmap_alloc_minlen_extent error tag +Scale fsstress args +Execute fsstress in background diff --git a/tests/xfs/group b/tests/xfs/group index 289a082d..f09c742b 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -528,6 +528,7 @@ 528 auto quick reflink 529 auto quick reflink 530 auto quick +531 auto stress 758 auto quick rw attr realtime 759 auto quick rw realtime 760 auto quick rw collapse punch insert zero prealloc