From patchwork Mon Mar 8 15:50:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12122829 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E061C433E6 for ; Mon, 8 Mar 2021 15:52:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A3B165220 for ; Mon, 8 Mar 2021 15:52:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230194AbhCHPv5 (ORCPT ); Mon, 8 Mar 2021 10:51:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230046AbhCHPvZ (ORCPT ); Mon, 8 Mar 2021 10:51:25 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D7B5C06174A; Mon, 8 Mar 2021 07:51:25 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id e6so6659654pgk.5; Mon, 08 Mar 2021 07:51:25 -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=a60rAA10+0aRj/BaRwZZKR5m5VDRjd9v9w0MF3LiagM=; b=k606r/2QLpUbO4nlydC3IQyLzq5LFE6jASFnA/aGQo64GqfXBZLwtERibos6NeTl7a zpuZy9B1duGOBMHjEuYmyMmiF4wrMd82cU7PHz2aZlEeDr+9a7Id5JHVUdvfJ3z44ZLn E3ueqWLzk+G8xoPhC/Pifbd2VV6jXA9r63X3WL+/YpzmHW7/AY+laC/3QgWiQFFa/0D6 GTFGk29GbdTY+WYIF6B8gIqs8UQ0tut0Ms8aciTMz97gi4IGcokG7JOeIY7zzmpoJy1b gb71XUy6I3Cv3RxN7d09F4UVh4OCrCdi8VBwtO2wVTU41hLXQsaAfTAJLk2z4dWWOVMi p77g== 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=a60rAA10+0aRj/BaRwZZKR5m5VDRjd9v9w0MF3LiagM=; b=HzCmg9KmO/txI9cEH49dQkRhnDPLIAX6YGSlAkt6gFzqkygKyIUx6xtYqndUXHcrUS LayxtSfuxvZ0XCdEgjT5ovqeoBOsyPGRu/2RjpQmCwzf89oZsZIsf+U9tF/vNlcVkcSP D+/BHIxEFvmS2x3/cR8B7+UzUEb1ChORjRGRBi1l4n0Q8k70Y6OPonWhwqK0THcjmABJ SUSscOSYw+cNxD11JBPKvsv4Wd9Lu8kz+zmvk7fGE/wtXrrma0F9U6HtKtioovQgfNS/ /+xQMxEtmF1SOsIHoCyT7g3QffICEoOFgdcRLJPHuRDqo/NP8FbXFpm4y8qypIURVb5z h01A== X-Gm-Message-State: AOAM530afpC+N2LLADYFkRb5UJULd4ieaeAKQov58MzmZXu9p/oPs16W WyaXwDHOG9zJaUCdsX+wki21sG0N2pw= X-Google-Smtp-Source: ABdhPJwOZi/49KfYEBCq6rlDsIXyDGzoJ0DFPkR1xiWYp8Dkc1x3kOM4T7onZFQZ7gYFsKy9XC37sw== X-Received: by 2002:a62:8103:0:b029:1ef:26e4:494f with SMTP id t3-20020a6281030000b02901ef26e4494fmr19171525pfd.41.1615218684816; Mon, 08 Mar 2021 07:51:24 -0800 (PST) Received: from localhost.localdomain ([122.182.238.13]) by smtp.gmail.com with ESMTPSA id s4sm11086378pji.2.2021.03.08.07.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 07:51:24 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org Subject: [PATCH V5 01/13] _check_xfs_filesystem: sync fs before running scrub Date: Mon, 8 Mar 2021 21:20:59 +0530 Message-Id: <20210308155111.53874-2-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210308155111.53874-1-chandanrlinux@gmail.com> References: <20210308155111.53874-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Tests can create a scenario in which a call to syncfs() issued at the end of the execution of the test script would return an error code. xfs_scrub internally calls syncfs() before starting the actual online consistency check operation. Since this call to syncfs() fails, xfs_scrub ends up returning without performing consistency checks on the test filesystem. This can mask a possible on-disk data structure corruption. To fix the above stated problem, this commit invokes syncfs() prior to executing xfs_scrub. Suggested-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- common/xfs | 1 + 1 file changed, 1 insertion(+) diff --git a/common/xfs b/common/xfs index 2156749d..7ec89492 100644 --- a/common/xfs +++ b/common/xfs @@ -467,6 +467,7 @@ _check_xfs_filesystem() # Run online scrub if we can. mntpt="$(_is_dev_mounted $device)" if [ -n "$mntpt" ] && _supports_xfs_scrub "$mntpt" "$device"; then + $XFS_IO_PROG -c syncfs $mntpt >> $seqres.full 2>&1 "$XFS_SCRUB_PROG" $scrubflag -v -d -n $mntpt > $tmp.scrub 2>&1 if [ $? -ne 0 ]; then _log_err "_check_xfs_filesystem: filesystem on $device failed scrub" From patchwork Mon Mar 8 15:51:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12122833 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D95FBC43331 for ; Mon, 8 Mar 2021 15:52:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BAA9D65224 for ; Mon, 8 Mar 2021 15:52:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229573AbhCHPv6 (ORCPT ); Mon, 8 Mar 2021 10:51:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbhCHPv1 (ORCPT ); Mon, 8 Mar 2021 10:51:27 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56CB8C06174A; Mon, 8 Mar 2021 07:51:27 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id kk2-20020a17090b4a02b02900c777aa746fso3357514pjb.3; Mon, 08 Mar 2021 07:51:27 -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=EuvjnEG/FpNrBBt/9X3rBuaBuMlpS/vb3MZt/Qx6vlY=; b=sXeV2VSCwrS2s1AUeFsCKsPggE7DGN2K67mgW5tAjZEtIi/tett8hi7xiDJrXjKep8 yvy+3mwnawoPXNRWXKs3veoBo9JhOKo4aFPXPyVESekHSdQJJFZmZGAO/uOQFxtQNgEE XAFpeoPO0TDytM0P5mU119+CufVbl5ulbQ2ExGvkx8+QZ6HaAYIBGBkAqBr8Fnth5bXG zWbdqEYyZjNS5yv7rWrWB8NbShwjyQKZYULUN/uFZYbI2ESFGOtZoptLNRSKfwYWz9eQ BhgkrCE48HGKKfrmJ9g4QoF4bCx2GMV/qDEv3S6PpQzlOPWnzvC3XNOAXJEqtUFCH76c hXfg== 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=EuvjnEG/FpNrBBt/9X3rBuaBuMlpS/vb3MZt/Qx6vlY=; b=oLG1cbRFk0F69boIhD2kh0GMEuhMX0fArZzSfU92o7gkuEUFQRe1fqFh+cMaNMW/1I EHg052ktdTMpR8EeuM+5c/gW96I/lg/ipVkufMTh5ectDzCTaQYH45fbR0/4PTO1KJyS Yv0Tc4e9h7yId6WsbWpRyDMD19WzLGn5uyaZSYGZ7ZirQvs7nA7w6zPXoZqzVxGGL+Ph kXOw1WNakkNCJpWf+eoLCed/cFSO5WvM0DGYQ16J9N7aH2KIH0+KXpl6k2pXXnjL3Ky1 qncklIA7yvDZ849E/XgnPcnLnQD/SAuRZ3giJhgnZwSNBuqrdPbHvZ+76P49PeuDbVKq XDsQ== X-Gm-Message-State: AOAM531A4pKhs7WbAftUkZaS+341L7ZBsb07nuAMzyVKEFNc3sHsjC5v AtI0xg3BvzTUpSD0w4zrN1obHRJTHGQ= X-Google-Smtp-Source: ABdhPJwiTKxIbGkgM8vgKGPG90sGyS/KWfOJd6kDVGXylqHFXIEj9d8imvQSgfJyOcI60pkgAVCOlw== X-Received: by 2002:a17:902:7002:b029:e5:e1fc:7e88 with SMTP id y2-20020a1709027002b02900e5e1fc7e88mr18672006plk.30.1615218686837; Mon, 08 Mar 2021 07:51:26 -0800 (PST) Received: from localhost.localdomain ([122.182.238.13]) by smtp.gmail.com with ESMTPSA id s4sm11086378pji.2.2021.03.08.07.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 07:51:26 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org Subject: [PATCH V5 02/13] common/xfs: Add a helper to get an inode fork's extent count Date: Mon, 8 Mar 2021 21:21:00 +0530 Message-Id: <20210308155111.53874-3-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210308155111.53874-1-chandanrlinux@gmail.com> References: <20210308155111.53874-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit adds the helper _scratch_get_iext_count() which returns an inode fork's extent count. Signed-off-by: Chandan Babu R --- common/xfs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/common/xfs b/common/xfs index 7ec89492..f0ae321e 100644 --- a/common/xfs +++ b/common/xfs @@ -914,6 +914,29 @@ _scratch_get_bmx_prefix() { return 1 } +_scratch_get_iext_count() +{ + local ino=$1 + local whichfork=$2 + local nextents=0 + local field="" + + case $whichfork in + "attr") + field=core.naextents + ;; + "data") + field=core.nextents + ;; + *) + return 1 + esac + + nextents=$(_scratch_xfs_get_metadata_field $field "inode $ino") + + echo $nextents +} + # # Ensures that we don't pass any mount options incompatible with XFS v4 # From patchwork Mon Mar 8 15:51:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12122835 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC853C4332E for ; Mon, 8 Mar 2021 15:52:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E63565225 for ; Mon, 8 Mar 2021 15:52:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229505AbhCHPv7 (ORCPT ); Mon, 8 Mar 2021 10:51:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229928AbhCHPv3 (ORCPT ); Mon, 8 Mar 2021 10:51:29 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5745FC06174A; Mon, 8 Mar 2021 07:51:29 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id d8so5045909plg.10; Mon, 08 Mar 2021 07:51:29 -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=41YtaORrrIuxqpPCdPrGdEctYzNj9wJAAYHDpYyjBDU=; b=tT9o47F7C9JqktZwquT+MIHutEHXYpukiQEp41IMsXEcF4EFQAJDf2XFmzUoWDtgve yi9jWZU/k9wq63ypBUdKYY0huUeB+NNl/X2cppC2XrqtC4arps3STmcPFwoLBQ3ffPhf mUvL54Wp8B7PNLkiRYEWH5TTp8KKkPbx/js/afiWrZCRXt87cj0cToRzVN6R0bR+PqRU uuVhpbQQJWo53vfJba/yKTyuWi1pwiHIDaI+7ykJ+JPlQpusOFpTEmKDM8uADWC6hefY 7SrHS2EnKGMyaNcU8G6mCUpgGKyS7d5kWOPcoX4nnTNRexyOvN0iF5jmvXCnbLWlUS7K d5aQ== 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=41YtaORrrIuxqpPCdPrGdEctYzNj9wJAAYHDpYyjBDU=; b=Ca+S+alTtBto7mf11NvYP8IxFdYi4r3P36gJ5OdRZmC4NL4ZtWNGvPrJzgrEPFzH4y sH/gdxE6VZ5RWupw428U6KST+7S5clBq3BI/tm3qgp61yr1W1aWHBxGBFLXs5pJ39Gbf apubjRkUN2GYzXd56f+EdUry9gC5rA6OTkMgOqhiKpcw+YfQ4NdyvajTJUezPLr17W2N T+OvTDwbtG+UrAMMXheqNOjTZk8homDS22VbQWNAMfGdIcRAeTN8rKMhXV38xWZssCwC 3lj+oJDDnz00wrltXUxZYqPhsFvajhtaX8C3sXJmxp+A7N0QqP3PYovWdJHnMWOJXdEK OGLw== X-Gm-Message-State: AOAM531EG0KL3YHwf5fgcsTw7j7mudbDWEnw1OBh/QOPeieWmMTa1x4R VC47HZGWlElVVlEjgLFfFT0V0GkoWqs= X-Google-Smtp-Source: ABdhPJw7rUzENdNu99E6xsbg25zo/Gj/M8B5Mj4AmtZWgVZ+sU1J+rOkVJZ77XhYaJZIXAT8gGy5Pg== X-Received: by 2002:a17:902:b78a:b029:e4:8ce6:fb64 with SMTP id e10-20020a170902b78ab02900e48ce6fb64mr22022930pls.77.1615218688838; Mon, 08 Mar 2021 07:51:28 -0800 (PST) Received: from localhost.localdomain ([122.182.238.13]) by smtp.gmail.com with ESMTPSA id s4sm11086378pji.2.2021.03.08.07.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 07:51:28 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org Subject: [PATCH V5 03/13] common/xfs: Add helper to obtain fsxattr field value Date: Mon, 8 Mar 2021 21:21:01 +0530 Message-Id: <20210308155111.53874-4-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210308155111.53874-1-chandanrlinux@gmail.com> References: <20210308155111.53874-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit adds a helper function to obtain the value of a particular field of an inode's fsxattr fields. Signed-off-by: Chandan Babu R --- common/xfs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/common/xfs b/common/xfs index f0ae321e..9a0ab484 100644 --- a/common/xfs +++ b/common/xfs @@ -194,6 +194,18 @@ _xfs_get_file_block_size() $XFS_INFO_PROG "$path" | grep realtime | sed -e 's/^.*extsz=\([0-9]*\).*$/\1/g' } +xfs_get_fsxattr() +{ + local field="$1" + local path="$2" + local value="" + + value=$($XFS_IO_PROG -c "stat" "$path" | grep "$field") + value=${value##fsxattr.${field} = } + + echo "$value" +} + # xfs_check script is planned to be deprecated. But, we want to # be able to invoke "xfs_check" behavior in xfstests in order to # maintain the current verification levels. From patchwork Mon Mar 8 15:51:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12122831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72CD9C433E9 for ; Mon, 8 Mar 2021 15:52:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A08765225 for ; Mon, 8 Mar 2021 15:52:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229928AbhCHPv7 (ORCPT ); Mon, 8 Mar 2021 10:51:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbhCHPvb (ORCPT ); Mon, 8 Mar 2021 10:51:31 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CB61C06174A; Mon, 8 Mar 2021 07:51:31 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id 30so497195ple.4; Mon, 08 Mar 2021 07:51:31 -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=4pNf/1KuFd//2XezWJ+O5ap4zDVy3ElxxRcnw29ck7g=; b=UliJyCaGc4wklhaIoX+n2+DFfolGShy35imimba5No7IZ0uQ7z2Zmf03pogQLMAQqH QL/4bRLU51kOD2EwZwYz0Ymi9HOWUmVg4+RYHSBM8u1h2eIUgB2QwEGrWZ8AxmkiNItU BD4I9rfTlOhSefjIeAKWfvY8he4bIRE2GdIS3EAydad/QZiDk9Y7j/p66uQOe/9gEO/9 zRZIaxJ1i8JfX6Gw7C9P/E2l4LIZbGN0WpCVwryiW7U/i7IEYEaIYikgb1Z76o9+9ciT 5rFI5nWsKRsVNv6fJ0il0wXoiXKxyPs+J0prZ2EN1MyvuWWSdTDN6BYn1l9AaHqM1FZB Wxpw== 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=4pNf/1KuFd//2XezWJ+O5ap4zDVy3ElxxRcnw29ck7g=; b=dATelBr26XGg0lGugy/lcYNtI2jvRP9YSLUjJBslC0sv/zMn3/sDUlY3BD8ZFVE6T8 CmcCzNNRervVp9o2ljcxZyorMwDY132H3e3iMSzefVCLjUhAcZTWTZIiomOqu77mTnG0 9OjS9DM1bIGFYP17EMa/XzgXVmeZg2uLlO+cDQWSOxXXpryAzXoLqauPysPrmQcc7hDO HfkK6GAQlsh+pRdOSy18mXSf90FwWwXTWQLBWGsyTG4bnlaagMsIwO7OAUuJ0fMiw/w0 xt6Oicgxx17aZfpmaQ70oWp7d+JPuYFyEIFSb5ds+HvXW2PkbPrzuVYGq7EvwZ2I2wtc wpvg== X-Gm-Message-State: AOAM530elskGTcc7FzRmucDv4aQd+7FaeUsLXHv3Fqo2jn16qRWLhufK K2JSqhLTM7EMUTkk3wQMakfBGLymPt4= X-Google-Smtp-Source: ABdhPJx+lFSnZ3WtDEnE3nlRwea7B4zyffFfTZmsFZ+I4cQY3HC21QR1u/SB07BjXOnrXVvztKZfSw== X-Received: by 2002:a17:902:c48d:b029:e6:f7d:a76d with SMTP id n13-20020a170902c48db02900e60f7da76dmr8859784plx.66.1615218690851; Mon, 08 Mar 2021 07:51:30 -0800 (PST) Received: from localhost.localdomain ([122.182.238.13]) by smtp.gmail.com with ESMTPSA id s4sm11086378pji.2.2021.03.08.07.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 07:51:30 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org Subject: [PATCH V5 04/13] xfs: Check for extent overflow when trivally adding a new extent Date: Mon, 8 Mar 2021 21:21:02 +0530 Message-Id: <20210308155111.53874-5-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210308155111.53874-1-chandanrlinux@gmail.com> References: <20210308155111.53874-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This test verifies that XFS does not cause inode fork's extent count to overflow when adding a single extent while there's no possibility of splitting an existing mapping. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- tests/xfs/528 | 171 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/528.out | 20 ++++++ tests/xfs/group | 1 + 3 files changed, 192 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..5eb1021a --- /dev/null +++ b/tests/xfs/528 @@ -0,0 +1,171 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 528 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# adding a single extent while there's no possibility of splitting an existing +# mapping. + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/quota +. ./common/inject +. ./common/populate + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_quota +_require_xfs_debug +_require_test_program "punch-alternating" +_require_xfs_io_command "falloc" +_require_xfs_io_error_injection "reduce_max_iextents" +_require_xfs_io_error_injection "bmap_alloc_minlen_extent" + +echo "Format and mount fs" +_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full +_scratch_mount -o uquota >> $seqres.full + +bsize=$(_get_file_block_size $SCRATCH_MNT) + +echo "* Delalloc to written extent conversion" + +testfile=$SCRATCH_MNT/testfile + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +nr_blks=$((15 * 2)) + +echo "Create fragmented file" +for i in $(seq 0 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -s -c "pwrite $((i * bsize)) $bsize" $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +echo "Verify \$testfile's extent count" + +nextents=$(xfs_get_fsxattr nextents $testfile) +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm $testfile + +echo "* Fallocate unwritten extents" + +echo "Fallocate fragmented file" +for i in $(seq 0 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -c "falloc $((i * bsize)) $bsize" $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +echo "Verify \$testfile's extent count" + +nextents=$(xfs_get_fsxattr nextents $testfile) +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm $testfile + +echo "* Directio write" + +echo "Create fragmented file via directio writes" +for i in $(seq 0 2 $((nr_blks - 1))); do + $XFS_IO_PROG -d -s -f -c "pwrite $((i * bsize)) $bsize" $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +echo "Verify \$testfile's extent count" + +nextents=$(xfs_get_fsxattr nextents $testfile) +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm $testfile + +# Check if XFS gracefully returns with an error code when we try to increase +# extent count of user quota inode beyond the pseudo max extent count limit. +echo "* Extend quota inodes" + +echo "Disable reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 0 + +echo "Consume free space" +fillerdir=$SCRATCH_MNT/fillerdir +nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT) +nr_free_blks=$((nr_free_blks * 90 / 100)) + +_fill_fs $((bsize * nr_free_blks)) $fillerdir $bsize 0 >> $seqres.full 2>&1 + +echo "Create fragmented filesystem" +for dentry in $(ls -1 $fillerdir/); do + $here/src/punch-alternating $fillerdir/$dentry >> $seqres.full +done + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Inject bmap_alloc_minlen_extent error tag" +_scratch_inject_error bmap_alloc_minlen_extent 1 + +nr_blks=20 + +# This is a rough calculation; It doesn't take block headers into +# consideration. +# gdb -batch vmlinux -ex 'print sizeof(struct xfs_dqblk)' +# $1 = 136 +nr_quotas_per_block=$((bsize / 136)) +nr_quotas=$((nr_quotas_per_block * nr_blks)) + +echo "Extend uquota file" +for i in $(seq 0 $nr_quotas_per_block $nr_quotas); do + chown $i $testfile >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +_scratch_unmount >> $seqres.full + +echo "Verify uquota inode's extent count" +uquotino=$(_scratch_xfs_get_metadata_field 'uquotino' 'sb 0') + +nextents=$(_scratch_get_iext_count $uquotino data || \ + _fail "Unable to obtain inode fork's extent count") +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +# success, all done +status=0 +exit diff --git a/tests/xfs/528.out b/tests/xfs/528.out new file mode 100644 index 00000000..3973cc15 --- /dev/null +++ b/tests/xfs/528.out @@ -0,0 +1,20 @@ +QA output created by 528 +Format and mount fs +* Delalloc to written extent conversion +Inject reduce_max_iextents error tag +Create fragmented file +Verify $testfile's extent count +* Fallocate unwritten extents +Fallocate fragmented file +Verify $testfile's extent count +* Directio write +Create fragmented file via directio writes +Verify $testfile's extent count +* Extend quota inodes +Disable reduce_max_iextents error tag +Consume free space +Create fragmented filesystem +Inject reduce_max_iextents error tag +Inject bmap_alloc_minlen_extent error tag +Extend uquota file +Verify uquota inode's extent count diff --git a/tests/xfs/group b/tests/xfs/group index e861cec9..2356c4a9 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -525,3 +525,4 @@ 525 auto quick mkfs 526 auto quick mkfs 527 auto quick quota +528 auto quick quota From patchwork Mon Mar 8 15:51:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12122841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D110C43603 for ; Mon, 8 Mar 2021 15:52:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5467165220 for ; Mon, 8 Mar 2021 15:52:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230056AbhCHPv7 (ORCPT ); Mon, 8 Mar 2021 10:51:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbhCHPvd (ORCPT ); Mon, 8 Mar 2021 10:51:33 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9A48C06174A; Mon, 8 Mar 2021 07:51:33 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id q2-20020a17090a2e02b02900bee668844dso3208474pjd.3; Mon, 08 Mar 2021 07:51: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=6ihEZoDgsRmmlYcoS0S1pXr2KamqMw/qSaPB9FaNuZA=; b=oNYgw5Q3+MjNwtYT1XCbOdv1lnvBShX3z6BSdHfm6/RbZcFQ0LZH58GT6VaIQELvVz EyXHkpgVgYlw4zWcXjgX8nTngQYXp0oL0Jtw5/otTJsTIMRV4w3rl7gSOGcyUSGvlIMM kJSUabt2d2jPGQkyKNpWveJ7zrSy5MyAdwA+w8HXMH6SwkyI9gNcQyF+ktxuPrTTeLBh XCCkXgZSa17238+QShjqt2B9CLl/yZqNSzdNUlETT69lP6dwwG3VQE2UiBCMlJ/XEYNG ddxer3U6OLRipUBHyKDjGJBQcp74ufXe/RpsgZRDVSO3pC8UlSyx5p8l8ZP+PKqOgs5f emFg== 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=6ihEZoDgsRmmlYcoS0S1pXr2KamqMw/qSaPB9FaNuZA=; b=he3vjZIFc2XWvyrTimeQXSG8gXZ1FTwUlXcLNH06l6ryQm0QGCae+ij94yOeefISnd vczJW6USule+Z+m84SLVkhoHDrgw+H3mZFMAKrhzcZL/iYDUn2iah8gIH28HQQy0L3HT tG4xB9g2NQ5C76bkhOndPHlolIzRtErPvoBzAavoIWevyQs3zaSiJfsx5v55yeebPZii hRGFaXYfdCz85fJGne36v+R7sZkCxDsu6t29MDKz6ITsGpjzGCFIJkNCsWoZEOIuO/Rs Wq7FhQNABTiVgyamIBYZy4Bkx4OR4dnu6otwgtvqeqUHq2sSx62fQErCEAHzaJVUVsZp Rx4g== X-Gm-Message-State: AOAM531AKB5YKMmp3SW4IbD/PF+lDkmAKPo8HhSfOJ3rsQ/pSqUShRKn hZdfQ05dCz3YG3qX6rb0hBUBpqj27cU= X-Google-Smtp-Source: ABdhPJximgFXBxRX/iztJ9q+J9IMNiIkHamMsQtBwo4uu8nj7Tz0k04NGSoOHF0fNon1JJxyKoSPkA== X-Received: by 2002:a17:90a:5d09:: with SMTP id s9mr24781600pji.172.1615218693172; Mon, 08 Mar 2021 07:51:33 -0800 (PST) Received: from localhost.localdomain ([122.182.238.13]) by smtp.gmail.com with ESMTPSA id s4sm11086378pji.2.2021.03.08.07.51.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 07:51:32 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org Subject: [PATCH V5 05/13] xfs: Check for extent overflow when growing realtime bitmap/summary inodes Date: Mon, 8 Mar 2021 21:21:03 +0530 Message-Id: <20210308155111.53874-6-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210308155111.53874-1-chandanrlinux@gmail.com> References: <20210308155111.53874-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Verify that XFS does not cause realtime bitmap/summary inode fork's extent count to overflow when growing the realtime volume associated with a filesystem. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- tests/xfs/529 | 124 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/529.out | 11 ++++ tests/xfs/group | 1 + 3 files changed, 136 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..dd7019f5 --- /dev/null +++ b/tests/xfs/529 @@ -0,0 +1,124 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 529 +# +# 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 +# Note that we don't _require_realtime because we synthesize a rt volume +# below. +_require_test +_require_xfs_debug +_require_test_program "punch-alternating" +_require_xfs_io_error_injection "reduce_max_iextents" +_require_xfs_io_error_injection "bmap_alloc_minlen_extent" +_require_scratch_nocheck + +echo "* Test extending rt inodes" + +_scratch_mkfs | _filter_mkfs >> $seqres.full 2> $tmp.mkfs +. $tmp.mkfs + +echo "Create fake rt volume" +nr_bitmap_blks=25 +nr_bits=$((nr_bitmap_blks * dbsize * 8)) + +# Realtime extent size has to be atleast 4k in size. +if (( $dbsize < 4096 )); then + rtextsz=4096 +else + rtextsz=$dbsize +fi + +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)) -b size=${dbsize} \ + -r size=${rtextsz},extsize=${rtextsz} >> $seqres.full +_try_scratch_mount || _notrun "Couldn't mount fs with synthetic rt volume" + +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_get_metadata_field $rtino "sb 0") + 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 + +# success, all done +status=0 +exit diff --git a/tests/xfs/529.out b/tests/xfs/529.out new file mode 100644 index 00000000..4ee113a4 --- /dev/null +++ b/tests/xfs/529.out @@ -0,0 +1,11 @@ +QA output created by 529 +* 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 2356c4a9..5dff7acb 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -526,3 +526,4 @@ 526 auto quick mkfs 527 auto quick quota 528 auto quick quota +529 auto quick realtime growfs From patchwork Mon Mar 8 15:51:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12122837 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 408E8C432C3 for ; Mon, 8 Mar 2021 15:52:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21A7B65224 for ; Mon, 8 Mar 2021 15:52:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230231AbhCHPv7 (ORCPT ); Mon, 8 Mar 2021 10:51:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbhCHPvf (ORCPT ); Mon, 8 Mar 2021 10:51:35 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAA87C06174A; Mon, 8 Mar 2021 07:51:35 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id jx13so3255099pjb.1; Mon, 08 Mar 2021 07:51:35 -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=OXtz0/qF1hsnvk4d2jDdPDfzlFMenp4VZO0kyImZx64=; b=AW0S0VgDD8fG9L++sIF0pdan65oCzDXXOIR7GZcGhlvV3jdcjnaZCNru5q6UcIk4jq wzRLDnwlW6PgaA6OAo8uXRHaGW8T2C4eGKrVWn4bSYzh+n+4fLYdBuJQn9O9tJQDHLMe tyewC60PKmgdBDpeIySd4KuTIq2+P80/cjwwzJbEq2OYx6Cc1jZfA2Q3YPiY7jzr4cW3 3ro90LXpOq/ujHX1t5bo4le06/a9ZyhD2/rLhEw2lzKRRBD6dhpUPjk+2rJwjMgGmJAB 6fHwWKIaVM5Oy5gq96BhEGIoutT3ePMEt74K2Su3c0v+zoTvvyKcfS6EsA2V3jMuYQk9 ydkg== 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=OXtz0/qF1hsnvk4d2jDdPDfzlFMenp4VZO0kyImZx64=; b=gmP6o2bWWf/Jlsj0N1D00Iy0+pmnHa5i2hRbpShYfUYmoSDcDyuXFBee5Qo93sK6y4 a/McQSwAC07p/3TH/LMIesw3JhR1RSLs6T8PqGt9q1o/gdYi+9vcGCYllK+5D8xmAsnh yZNE3oj7fCoS/pWzsixPLpXRpKJGoiUoBF84sUCPZsyzDYZQoOCM6i6dLojBd0Zl24rK nnnRnDiBa32d8ww4FnVkQszH6KkUt/lUwTCUkKnOcbOKiR5XAz9I7JHlC2ucjh+hL69K RSU+PzI9G7UyM112ph9OszoRK/CHs77rfDGBDIA1d797YcdNeg2fxH6HfATMo42D1fY6 tQcQ== X-Gm-Message-State: AOAM532+HP6ctqusQEFV9pCn1lK0JmH60pU3/JKgP27uuk08LbYv3BBC B277/FtRdYPTVw7yeujbEcoRW0C7smg= X-Google-Smtp-Source: ABdhPJxJwmfHmnCMm4y97tgOxfQ6xl/zoQjKzB/DXss5q+9OsPC69B/6OZfwfQ+wH7NuuYcp8w5DMA== X-Received: by 2002:a17:90a:778a:: with SMTP id v10mr25200225pjk.229.1615218695050; Mon, 08 Mar 2021 07:51:35 -0800 (PST) Received: from localhost.localdomain ([122.182.238.13]) by smtp.gmail.com with ESMTPSA id s4sm11086378pji.2.2021.03.08.07.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 07:51:34 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org Subject: [PATCH V5 06/13] xfs: Check for extent overflow when punching a hole Date: Mon, 8 Mar 2021 21:21:04 +0530 Message-Id: <20210308155111.53874-7-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210308155111.53874-1-chandanrlinux@gmail.com> References: <20210308155111.53874-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This test verifies that XFS does not cause inode fork's extent count to overflow when punching out an extent. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- tests/xfs/530 | 83 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/530.out | 19 +++++++++++ tests/xfs/group | 1 + 3 files changed, 103 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..33a074bc --- /dev/null +++ b/tests/xfs/530 @@ -0,0 +1,83 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 530 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# punching out an extent. +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/inject + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_debug +_require_xfs_io_command "fpunch" +_require_xfs_io_command "finsert" +_require_xfs_io_command "fcollapse" +_require_xfs_io_command "fzero" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "Format and mount fs" +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_file_block_size $SCRATCH_MNT) +nr_blks=30 + +testfile=$SCRATCH_MNT/testfile + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +for op in fpunch finsert fcollapse fzero; do + echo "* $op regular file" + + echo "Create \$testfile" + $XFS_IO_PROG -f -s \ + -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + $testfile >> $seqres.full + + echo "$op alternating blocks" + for i in $(seq 1 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -c "$op $((i * bsize)) $bsize" $testfile \ + >> $seqres.full 2>&1 + [[ $? != 0 ]] && break + done + + echo "Verify \$testfile's extent count" + + nextents=$(xfs_get_fsxattr nextents $testfile) + if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 + fi + + rm $testfile +done + +# success, all done +status=0 +exit diff --git a/tests/xfs/530.out b/tests/xfs/530.out new file mode 100644 index 00000000..4df2d9d0 --- /dev/null +++ b/tests/xfs/530.out @@ -0,0 +1,19 @@ +QA output created by 530 +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 5dff7acb..463d810d 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -527,3 +527,4 @@ 527 auto quick quota 528 auto quick quota 529 auto quick realtime growfs +530 auto quick punch zero insert collapse From patchwork Mon Mar 8 15:51:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12122843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F327EC43332 for ; Mon, 8 Mar 2021 15:52:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D5EF965225 for ; Mon, 8 Mar 2021 15:52:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230242AbhCHPwA (ORCPT ); Mon, 8 Mar 2021 10:52:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230116AbhCHPvh (ORCPT ); Mon, 8 Mar 2021 10:51:37 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4EBAC06174A; Mon, 8 Mar 2021 07:51:37 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id y67so7487068pfb.2; Mon, 08 Mar 2021 07:51:37 -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=MoDGt/puC7EasHZqr7Mk0ROfRwgl6CKozyZM4S00kYM=; b=PQZHt66DgfXOWMSaY3wD2ikpWXJm90zjRWAgNlQWTP7LDhp3xPH2f+l1LZ51v/z3Cn h1lHKWdu6tnm2HorMbFNBSgBzfprDIrzf/oujUoPyjcs3/U06LX7pWW3Ua0KGU0Zpb+z f2dfzA9nw9W7HpZdiH2t944ynQOtMzJtRRKvR7hjqWVBk8b2SCc5+nC9iXsOGZ0joAyE 0xz/lsCDGNbOV40VJdSJFN1A39kSvYeeIN5oGSXDoZOD3ACEFQ/8eHCOX52/9NNolLVO HolJ9hcT7JUnAkBVuTvTHvXuRFnUXAv4AZJJfNGTkK8e0WnGe9B4xfHlQzaAZRX90CGk Gnrw== 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=MoDGt/puC7EasHZqr7Mk0ROfRwgl6CKozyZM4S00kYM=; b=Qz83y4y+LkzRiEaS1GAlK/KZwiu5MYpMQ1WmWLWaB4Vkax0Kj19pD54nfntpWT+Fjq gKHPSLBiq+amvhcoQDPdr5Du0LBtT33CWEXzouaaHxvcBGa7DkLDQNbwMgvrV0vw7Aht jIjCxe/tDYKmZY7J8vss3v6ePmqmTb/DHZSSRTT23JKevh4wTJ1RGMJ/E2cSYBj3M/5U MhjYfbXW9+7s8Ya01aaSieCX6LgORQxYuYU0vULm3jEo3XmI6kQ0L05mvNnxImp/cCYm PlUx8b4wBCBOAwnk7BVrWM5Cv5fNk/ujJgtvncSvvQLUw56RUlGHDvo62m9CpMrbTZsk +9Pg== X-Gm-Message-State: AOAM5306cpBIcxS2FXYKqzPBk+jkoSh15AyEnVNNk33qkzLHMuHINtAr GUbUxlgam1F03QiUyAyl26RZeLFVhKU= X-Google-Smtp-Source: ABdhPJxtyxIY7iq2G8rMRdPPC7MBApGNIVpH3E28cFDuwxoY6N/6yF/OJvSeeNpMfkUDyCxZ5LjMdg== X-Received: by 2002:aa7:9824:0:b029:1ef:2104:c72d with SMTP id q4-20020aa798240000b02901ef2104c72dmr20284365pfl.20.1615218697107; Mon, 08 Mar 2021 07:51:37 -0800 (PST) Received: from localhost.localdomain ([122.182.238.13]) by smtp.gmail.com with ESMTPSA id s4sm11086378pji.2.2021.03.08.07.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 07:51:36 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org Subject: [PATCH V5 07/13] xfs: Check for extent overflow when adding/removing xattrs Date: Mon, 8 Mar 2021 21:21:05 +0530 Message-Id: <20210308155111.53874-8-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210308155111.53874-1-chandanrlinux@gmail.com> References: <20210308155111.53874-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This test verifies that XFS does not cause inode fork's extent count to overflow when adding/removing xattrs. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- tests/xfs/531 | 139 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/531.out | 18 ++++++ tests/xfs/group | 1 + 3 files changed, 158 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..a487318f --- /dev/null +++ b/tests/xfs/531 @@ -0,0 +1,139 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 531 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# adding/removing xattrs. +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/attr +. ./common/inject +. ./common/populate + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_attrs +_require_xfs_debug +_require_test_program "punch-alternating" +_require_xfs_io_error_injection "reduce_max_iextents" +_require_xfs_io_error_injection "bmap_alloc_minlen_extent" + +echo "Format and mount fs" +_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_block_size $SCRATCH_MNT) + +attr_len=255 + +testfile=$SCRATCH_MNT/testfile + +echo "Consume free space" +fillerdir=$SCRATCH_MNT/fillerdir +nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT) +nr_free_blks=$((nr_free_blks * 90 / 100)) + +_fill_fs $((bsize * nr_free_blks)) $fillerdir $bsize 0 >> $seqres.full 2>&1 + +echo "Create fragmented filesystem" +for dentry in $(ls -1 $fillerdir/); do + $here/src/punch-alternating $fillerdir/$dentry >> $seqres.full +done + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Inject bmap_alloc_minlen_extent error tag" +_scratch_inject_error bmap_alloc_minlen_extent 1 + +echo "* Set xattrs" + +echo "Create \$testfile" +touch $testfile + +echo "Create xattrs" +nr_attrs=$((bsize * 20 / attr_len)) +for i in $(seq 1 $nr_attrs); do + attr="$(printf "trusted.%0247d" $i)" + $SETFATTR_PROG -n "$attr" $testfile >> $seqres.full 2>&1 + [[ $? != 0 ]] && break +done + +echo "Verify \$testfile's naextent count" + +naextents=$(xfs_get_fsxattr naextents $testfile) +if (( $naextents > 10 )); then + echo "Extent count overflow check failed: naextents = $naextents" + exit 1 +fi + +echo "Remove \$testfile" +rm $testfile + +echo "* Remove xattrs" + +echo "Create \$testfile" +touch $testfile + +echo "Disable reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 0 + +echo "Create initial xattr extents" + +naextents=0 +last="" +start=1 +nr_attrs=$((bsize / attr_len)) + +while (( $naextents < 4 )); do + end=$((start + nr_attrs - 1)) + + for i in $(seq $start $end); do + attr="$(printf "trusted.%0247d" $i)" + $SETFATTR_PROG -n $attr $testfile + done + + start=$((end + 1)) + + naextents=$(xfs_get_fsxattr naextents $testfile) +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/531.out b/tests/xfs/531.out new file mode 100644 index 00000000..7b699b7a --- /dev/null +++ b/tests/xfs/531.out @@ -0,0 +1,18 @@ +QA output created by 531 +Format and mount fs +Consume free space +Create fragmented filesystem +Inject reduce_max_iextents error tag +Inject bmap_alloc_minlen_extent error tag +* Set xattrs +Create $testfile +Create xattrs +Verify $testfile's naextent count +Remove $testfile +* Remove xattrs +Create $testfile +Disable reduce_max_iextents error tag +Create initial xattr extents +Inject reduce_max_iextents error tag +Remove xattr to trigger -EFBIG +Successfully removed $testfile diff --git a/tests/xfs/group b/tests/xfs/group index 463d810d..7e284841 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -528,3 +528,4 @@ 528 auto quick quota 529 auto quick realtime growfs 530 auto quick punch zero insert collapse +531 auto quick attr From patchwork Mon Mar 8 15:51:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12122845 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5CADC4160E for ; Mon, 8 Mar 2021 15:52:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC93265220 for ; Mon, 8 Mar 2021 15:52:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230116AbhCHPwA (ORCPT ); Mon, 8 Mar 2021 10:52:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230125AbhCHPvj (ORCPT ); Mon, 8 Mar 2021 10:51:39 -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 C7804C06174A; Mon, 8 Mar 2021 07:51:39 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id j12so7304750pfj.12; Mon, 08 Mar 2021 07:51:39 -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=SURDfOI58zJg6c8uN1nhSRiIbw4USkqI3jR97Wr0A2c=; b=M15mPhWbDeeXZvwJ0oXGHm5+IwG/Mw9GINBMS60N6M8g9GU1lFAMpHGImSu2TLNy3W Y9neeQO7OKmwNzxR4/w420Qs/GRIKg1RryJOPo/5DSD6a/lHlNZi80r0T1Yrbbc9c8Ma ctOzZB6MIQP/DIazAF1rEPxk5f+2jfyu3P8+6YvN41tecvWlhzngqWijgqlX6Bzlk8gG RminppRmw91hMdaPTX/IXTdd15MEw3EJHwfGp1c8s13abC5ZKQq8rOhsGWGe0kv4aQr1 KumS2nrlS2t9kOadi2Lxc4gVx/bI8mt/9GntDAUK9BFBK3e0bRTeuWjGR78PE0BzBSUe fnIA== 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=SURDfOI58zJg6c8uN1nhSRiIbw4USkqI3jR97Wr0A2c=; b=p8wKSQmf+4q8X0iKu4BCZ9ZFq0aOtXGYwYul+KENuqV707ETtUiqWahxePQ07hHsEE gIehLK9dApPjMF//iSmG5Z2hfs26FCrgeQYiUb9vUVWi3VOxG+WgTBzVtAdbTAyWXPQQ 0s8shlvLnLuhFSZSV3VaJL+HueGfEi7f5HRQyM20EwyX2hIXuXNTazTarriTh0/ys2/e ky4z4PDrq4KybhMekywgL+aNVs/g8mRws7cx0hBvklbN3j/crHfJVMbXhZ+9HLDoWFuD /tlAH2T8H2j5TdgPCZiREetEPbMfHmlUmPh6lH6uT1AAeqPuKwKLE0ZycLtDDr9JS+HY rSbQ== X-Gm-Message-State: AOAM532cT3lnKZDBLfHhYXSuamhmOp87SCCgo78JjgC2/CjueE8bCDBf qI/yG6mIOcr8ayLQvftKrDJJfeIGE18= X-Google-Smtp-Source: ABdhPJw1GoPQei19pugthODEUo9GMis4q+c1BOrI1OQNO1e2y2q3L2S7tBAymhFVAtqV+XdT2ME+5Q== X-Received: by 2002:a62:7bc4:0:b029:1f1:58ea:4010 with SMTP id w187-20020a627bc40000b02901f158ea4010mr15932658pfc.70.1615218699136; Mon, 08 Mar 2021 07:51:39 -0800 (PST) Received: from localhost.localdomain ([122.182.238.13]) by smtp.gmail.com with ESMTPSA id s4sm11086378pji.2.2021.03.08.07.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 07:51:38 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org Subject: [PATCH V5 08/13] xfs: Check for extent overflow when adding/removing dir entries Date: Mon, 8 Mar 2021 21:21:06 +0530 Message-Id: <20210308155111.53874-9-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210308155111.53874-1-chandanrlinux@gmail.com> References: <20210308155111.53874-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This test verifies that XFS does not cause inode fork's extent count to overflow when adding/removing directory entries. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- tests/xfs/532 | 182 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/532.out | 17 +++++ tests/xfs/group | 1 + 3 files changed, 200 insertions(+) create mode 100755 tests/xfs/532 create mode 100644 tests/xfs/532.out diff --git a/tests/xfs/532 b/tests/xfs/532 new file mode 100755 index 00000000..235b60b5 --- /dev/null +++ b/tests/xfs/532 @@ -0,0 +1,182 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 532 +# +# 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 (( $dirbsize > $dbsize )); then + _notrun "Directory block size ($dirbsize) is larger than FSB size ($dbsize)" +fi + +echo "Format and mount fs" +_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full +_scratch_mount >> $seqres.full + +echo "Consume free space" +fillerdir=$SCRATCH_MNT/fillerdir +nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT) +nr_free_blks=$((nr_free_blks * 90 / 100)) + +_fill_fs $((dbsize * nr_free_blks)) $fillerdir $dbsize 0 >> $seqres.full 2>&1 + +echo "Create fragmented filesystem" +for dentry in $(ls -1 $fillerdir/); do + $here/src/punch-alternating $fillerdir/$dentry >> $seqres.full +done + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Inject bmap_alloc_minlen_extent error tag" +_scratch_inject_error bmap_alloc_minlen_extent 1 + +dent_len=255 + +echo "* Create directory entries" + +testdir=$SCRATCH_MNT/testdir +mkdir $testdir + +nr_dents=$((dbsize * 20 / dent_len)) +for i in $(seq 1 $nr_dents); do + dentry="$(printf "%0255d" $i)" + touch ${testdir}/$dentry >> $seqres.full 2>&1 || break +done + +echo "Verify directory's extent count" +nextents=$(xfs_get_fsxattr nextents $testdir) +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm -rf $testdir + +echo "* Rename: Populate destination directory" + +dstdir=$SCRATCH_MNT/dstdir +mkdir $dstdir + +nr_dents=$((dirbsize * 20 / dent_len)) + +echo "Populate \$dstdir by moving new directory entries" +for i in $(seq 1 $nr_dents); do + dentry="$(printf "%0255d" $i)" + dentry=${SCRATCH_MNT}/${dentry} + touch $dentry || break + mv $dentry $dstdir >> $seqres.full 2>&1 || break +done + +rm $dentry + +echo "Verify \$dstdir's extent count" + +nextents=$(xfs_get_fsxattr nextents $dstdir) +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm -rf $dstdir + +echo "* Create multiple hard links to a single file" + +testdir=$SCRATCH_MNT/testdir +mkdir $testdir + +testfile=$SCRATCH_MNT/testfile +touch $testfile + +nr_dents=$((dirbsize * 20 / dent_len)) + +echo "Create multiple hardlinks" +for i in $(seq 1 $nr_dents); do + dentry="$(printf "%0255d" $i)" + ln $testfile ${testdir}/${dentry} >> $seqres.full 2>&1 || break +done + +rm $testfile + +echo "Verify directory's extent count" +nextents=$(xfs_get_fsxattr nextents $testdir) +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm -rf $testdir + +echo "* Create multiple symbolic links to a single file" + +testdir=$SCRATCH_MNT/testdir +mkdir $testdir + +testfile=$SCRATCH_MNT/testfile +touch $testfile + +nr_dents=$((dirbsize * 20 / dent_len)) + +echo "Create multiple symbolic links" +for i in $(seq 1 $nr_dents); do + dentry="$(printf "%0255d" $i)" + ln -s $testfile ${testdir}/${dentry} >> $seqres.full 2>&1 || break; +done + +rm $testfile + +echo "Verify directory's extent count" +nextents=$(xfs_get_fsxattr nextents $testdir) +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm -rf $testdir + +# success, all done +status=0 +exit diff --git a/tests/xfs/532.out b/tests/xfs/532.out new file mode 100644 index 00000000..2766c211 --- /dev/null +++ b/tests/xfs/532.out @@ -0,0 +1,17 @@ +QA output created by 532 +Format and mount fs +Consume free space +Create fragmented filesystem +Inject reduce_max_iextents error tag +Inject bmap_alloc_minlen_extent error tag +* Create directory entries +Verify directory's extent count +* Rename: Populate destination directory +Populate $dstdir by moving new directory entries +Verify $dstdir's extent count +* Create multiple hard links to a single file +Create multiple hardlinks +Verify directory's extent count +* Create multiple symbolic links to a single file +Create multiple symbolic links +Verify directory's extent count diff --git a/tests/xfs/group b/tests/xfs/group index 7e284841..77abeefa 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -529,3 +529,4 @@ 529 auto quick realtime growfs 530 auto quick punch zero insert collapse 531 auto quick attr +532 auto quick dir hardlink symlink From patchwork Mon Mar 8 15:51:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12122839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC5EAC4361B for ; Mon, 8 Mar 2021 15:52:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8914065220 for ; Mon, 8 Mar 2021 15:52:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230125AbhCHPwB (ORCPT ); Mon, 8 Mar 2021 10:52:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230126AbhCHPvl (ORCPT ); Mon, 8 Mar 2021 10:51:41 -0500 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7E45C06174A; Mon, 8 Mar 2021 07:51:41 -0800 (PST) Received: by mail-pg1-x52a.google.com with SMTP id n9so5701874pgi.7; Mon, 08 Mar 2021 07:51: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=zfuKK7VesCcqGVw893PpgWt/azwkJyfREfeco+A63ng=; b=I3a+xj6jxhd/jETS3d7NHRdIpsYoTGrKxZJBu/3me5TFR6ZR+C7+eKVdcljminsLQi SMWBp9OO3JFUgtbU9+ITZ2emtWPAFx6clsfjD266n+UTzu69OZK0azT2XsfhxcPjNd0H 6MTKZPX7oZNeXAGSfUWODzA0bkiYzv2Q5zTGprd1b9wNPJhTvuaVrZ7fV2Ut8e1B/Evd 1SiEJ84syHukDkWZbwM6Emjh5N0p0Z/cTEB0GBfOk9Wu1mjJPEXkvwnON8xCXzUJPZi2 FNuucBvX/0sAIt40xWGQ08VYRYlOXNzDRZJh+1x/MBmoDXmmUKrWcMjkchEwmA3pvJ90 R0Wg== 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=zfuKK7VesCcqGVw893PpgWt/azwkJyfREfeco+A63ng=; b=mfyiLicyr4/zbAubIQ/ho5x4JqtLleiq2NmEWHiKZfrXGxIBLIYvgW0xKikcZbXtBk 5k8H029l2QEhxFSX/ZCxIpsM+dSwhvDilsb/p+eDkoFj8znh58gYw3u2HCiaQ81coTgp bvnH3UYRbrInsWtWjcxZvzwkl0GL+dp7O/kknOSJ6pOhYOgmcGlwdD2MRn8tq7WgWUAj ox0I0aZdRGeTzQvT8ZhLaIFloePcz0uKKsukpxEmR8u7Vf/ktvD04+LaDhvxZbRRWSWu SmMVKpgnYFn506Bj+g5dWS2ohgWhD2FdQhmCV0hEffTZ00zqcmiQeqr8Cnrcmclw4VgR en2Q== X-Gm-Message-State: AOAM532KKPr79wX4fbC1bx4Wu1CgyXlVS2pgeyrpKCPcR/eEdQXOstyI CG6VcE8Ni1NKiXHKXwRkFHx457fxIv8= X-Google-Smtp-Source: ABdhPJwzjrguriiCmzh3HLeaWYXBq2CPR6FXbetjCOLLnVk3zNc0acuasefSMAo8d2N5x2hxYrMSZw== X-Received: by 2002:a62:b606:0:b029:1ec:ecf1:cc5 with SMTP id j6-20020a62b6060000b02901ececf10cc5mr22038807pff.62.1615218701115; Mon, 08 Mar 2021 07:51:41 -0800 (PST) Received: from localhost.localdomain ([122.182.238.13]) by smtp.gmail.com with ESMTPSA id s4sm11086378pji.2.2021.03.08.07.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 07:51:40 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org Subject: [PATCH V5 09/13] xfs: Check for extent overflow when writing to unwritten extent Date: Mon, 8 Mar 2021 21:21:07 +0530 Message-Id: <20210308155111.53874-10-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210308155111.53874-1-chandanrlinux@gmail.com> References: <20210308155111.53874-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This test verifies that XFS does not cause inode fork's extent count to overflow when writing to an unwritten extent. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- tests/xfs/533 | 84 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/533.out | 11 +++++++ tests/xfs/group | 1 + 3 files changed, 96 insertions(+) create mode 100755 tests/xfs/533 create mode 100644 tests/xfs/533.out diff --git a/tests/xfs/533 b/tests/xfs/533 new file mode 100755 index 00000000..af7475f0 --- /dev/null +++ b/tests/xfs/533 @@ -0,0 +1,84 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 533 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# writing to an unwritten extent. +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/inject + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_debug +_require_xfs_io_command "falloc" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "Format and mount fs" +_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_file_block_size $SCRATCH_MNT) + +testfile=${SCRATCH_MNT}/testfile + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +nr_blks=15 + +for io in Buffered Direct; do + echo "* $io write to unwritten extent" + + echo "Fallocate $nr_blks blocks" + $XFS_IO_PROG -f -c "falloc 0 $((nr_blks * bsize))" $testfile >> $seqres.full + + if [[ $io == "Buffered" ]]; then + xfs_io_flag="" + else + xfs_io_flag="-d" + fi + + echo "$io write to every other block of fallocated space" + for i in $(seq 1 2 $((nr_blks - 1))); do + $XFS_IO_PROG -f -s $xfs_io_flag -c "pwrite $((i * bsize)) $bsize" \ + $testfile >> $seqres.full 2>&1 + [[ $? != 0 ]] && break + done + + echo "Verify \$testfile's extent count" + nextents=$(xfs_get_fsxattr nextents $testfile) + if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 + fi + + rm $testfile +done + +# success, all done +status=0 +exit diff --git a/tests/xfs/533.out b/tests/xfs/533.out new file mode 100644 index 00000000..5b93964a --- /dev/null +++ b/tests/xfs/533.out @@ -0,0 +1,11 @@ +QA output created by 533 +Format and mount fs +Inject reduce_max_iextents error tag +* Buffered write to unwritten extent +Fallocate 15 blocks +Buffered write to every other block of fallocated space +Verify $testfile's extent count +* Direct write to unwritten extent +Fallocate 15 blocks +Direct write to every other block of fallocated space +Verify $testfile's extent count diff --git a/tests/xfs/group b/tests/xfs/group index 77abeefa..3ad47d07 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -530,3 +530,4 @@ 530 auto quick punch zero insert collapse 531 auto quick attr 532 auto quick dir hardlink symlink +533 auto quick From patchwork Mon Mar 8 15:51:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12122853 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42D96C41620 for ; Mon, 8 Mar 2021 15:52:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1EF4D65220 for ; Mon, 8 Mar 2021 15:52:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230126AbhCHPwB (ORCPT ); Mon, 8 Mar 2021 10:52:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230135AbhCHPvn (ORCPT ); Mon, 8 Mar 2021 10:51:43 -0500 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF335C06174A; Mon, 8 Mar 2021 07:51:43 -0800 (PST) Received: by mail-pf1-x42e.google.com with SMTP id j12so7304884pfj.12; Mon, 08 Mar 2021 07:51: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=KMFFCYyGzP7zARjeZvJnfjwGPoSsOwwHruKWWLUt1h8=; b=ZFnXW4fKLiN7K1qT9LSmWn9ZQQstu76n271P9MAfOVMIfzfCqi8NqVGZJ4CgcCaB0D u88nZSjeI+zu/MQTQx/qEfLprIuLyRW1C+ZB+jdeyOKgIjmbdulxBjcOzVrGIEPOlNFY G0G3RIgp6Uo87Bf0jmT7xoI+H8v/NVdM3MDXCI8X9dqyuKBB39rsSsbkM8i4zFoPDAaP rs1nPgcIK+n/meiQb1Oqi0b0VC0SErpo87iJpZ/h82z+bhVBxCTw9xCYUBVMAxyZR85c daGMGX1B4j2zF0pVtDi8cgKkBYTddo3OcYCLxCAqa2abThEE8CdHlc1EOthOvWsSDjjd jeaA== 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=KMFFCYyGzP7zARjeZvJnfjwGPoSsOwwHruKWWLUt1h8=; b=VoIcHL1UbASH/uD6y0+GA8deoa58C8Z03sxgl6rVoJkb3aIH6LNdtT/pIYSooAj7aW s2wAvHnLjj+onr14XUzxw6VBcJ8TvTd9CMSJM8RU5euVP4pDPsBl4NBbMyFTbBGQjPRt ZWMsLVlbdpAcr5RUDL7mYL5/DfuJot7WG0SoxYYmfRU5rraOdveM8kVcpRobdkE3uJLc J63VQEfY2V6yTkGWyvufgl8JKEzqFFoCJhYDwgxKhKGOxK01qjnm+86QIPL2tB8JCtGM 3mo9KAQviIyQY+DCwIqv9Pc5deUrJngy9gCqxgewIVpWt/GyGuEU2dX+q/Up/SGIqbKm nBcw== X-Gm-Message-State: AOAM533HVssXPFRwWbk+sVmYYRW3rE2xx66Q4ijcQEat4CJjO4q4OWrq w8g5a52OsT6I6jZAvn1irFd1WJUyfEU= X-Google-Smtp-Source: ABdhPJyEsNaE0pwv8mYd9Wd3BKRiemhmwKWic8ZXClkAdn+63odz8yvF+hgjLc9vuIq/BICFk65cDg== X-Received: by 2002:a63:c601:: with SMTP id w1mr20289129pgg.11.1615218703103; Mon, 08 Mar 2021 07:51:43 -0800 (PST) Received: from localhost.localdomain ([122.182.238.13]) by smtp.gmail.com with ESMTPSA id s4sm11086378pji.2.2021.03.08.07.51.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 07:51:42 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org Subject: [PATCH V5 10/13] xfs: Check for extent overflow when moving extent from cow to data fork Date: Mon, 8 Mar 2021 21:21:08 +0530 Message-Id: <20210308155111.53874-11-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210308155111.53874-1-chandanrlinux@gmail.com> References: <20210308155111.53874-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This test verifies that XFS does not cause inode fork's extent count to overflow when writing to/funshare-ing a shared extent. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- tests/xfs/534 | 104 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/534.out | 12 ++++++ tests/xfs/group | 1 + 3 files changed, 117 insertions(+) create mode 100755 tests/xfs/534 create mode 100644 tests/xfs/534.out diff --git a/tests/xfs/534 b/tests/xfs/534 new file mode 100755 index 00000000..c2fa6cb6 --- /dev/null +++ b/tests/xfs/534 @@ -0,0 +1,104 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 534 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# writing to a shared extent. +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/reflink +. ./common/inject + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_scratch_reflink +_require_xfs_debug +_require_xfs_io_command "reflink" +_require_xfs_io_command "funshare" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "Format and mount fs" +_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_block_size $SCRATCH_MNT) + +nr_blks=15 + +srcfile=${SCRATCH_MNT}/srcfile +dstfile=${SCRATCH_MNT}/dstfile + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Create a \$srcfile having an extent of length $nr_blks blocks" +$XFS_IO_PROG -f -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + -c fsync $srcfile >> $seqres.full + +echo "* Write to shared extent" + +echo "Share the extent with \$dstfile" +_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_get_fsxattr nextents $dstfile) +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +rm $dstfile + +echo "* Funshare shared extent" + +echo "Share the extent with \$dstfile" +_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_get_fsxattr nextents $dstfile) +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +# success, all done +status=0 +exit + diff --git a/tests/xfs/534.out b/tests/xfs/534.out new file mode 100644 index 00000000..53288d12 --- /dev/null +++ b/tests/xfs/534.out @@ -0,0 +1,12 @@ +QA output created by 534 +Format and mount fs +Inject reduce_max_iextents error tag +Create a $srcfile having an extent of length 15 blocks +* Write to shared extent +Share the extent with $dstfile +Buffered write to every other block of $dstfile's shared extent +Verify $dstfile's extent count +* Funshare shared extent +Share the extent with $dstfile +Funshare every other block of $dstfile's shared extent +Verify $dstfile's extent count diff --git a/tests/xfs/group b/tests/xfs/group index 3ad47d07..b4f0c777 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -531,3 +531,4 @@ 531 auto quick attr 532 auto quick dir hardlink symlink 533 auto quick +534 auto quick reflink From patchwork Mon Mar 8 15:51:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12122847 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 141BBC15500 for ; Mon, 8 Mar 2021 15:52:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8FFB65220 for ; Mon, 8 Mar 2021 15:52:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230135AbhCHPwB (ORCPT ); Mon, 8 Mar 2021 10:52:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230149AbhCHPvp (ORCPT ); Mon, 8 Mar 2021 10:51:45 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85CA5C06174A; Mon, 8 Mar 2021 07:51:45 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id t9so3244244pjl.5; Mon, 08 Mar 2021 07:51:45 -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=omVeCqfQM2+8IWZaAvHwZeqv9Px9m8jWqtPJpOspsnE=; b=c2oszHKsD92lSuPczC+r/b1tIr9guTpgH48ft8Hqmd9QHED0Ov6D0mFT7BV1Fcm4py FYpbdAz737Qpfcqz4VjwaygfJ2TomYx7sY4v1NTqSzckJkSCQD6lPFK+QC4eS/gnAgZ1 mBALNW0RgkCOH4RHeZvnB71Poe0eu+pQZpuK3Iv+PRhYjh5NWbr+xJyGbUAcbBHKg4qS 3AvZhAsKL+hhw/BnkMqCr6k3xzDTqFmVHsugE5CF4mulNyEC0V/atetiO78zw3RnWNKG j7JnIQfzheyQTJUxl8sNyCGPyrWqu2Vg6Sh9AgUonlQO2PI2IoW/XXd9SHkgSq5LSc9Q WoIg== 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=omVeCqfQM2+8IWZaAvHwZeqv9Px9m8jWqtPJpOspsnE=; b=Ih7pmeOf0c+LAIMDX/Q8PkgDbqbFNDOYTO9801bIsYiRHyXmqtkJGfMlkAoEI3OxMk OVhapzh3X/CoUj9TK5teI+x+tchIw+JW6goNNlvNfWHjjLEof74hswQkU8CKQ/Iiy/vT DhEn2j8D5Jp9IZUb9AuDaSMFDMPSg3qY13fYhkqf1bWAIfIlOwSiApVqTktgwBREPCpf 7fiWZvx6fYryM6lLrSkqvGvC/K8J/tunbUCilU398Wr69faWJDBepvqZ4M1thrsDWCZk LnD/WVHx7rftSPOxyMeqR+jkzBWO/RRWrel9izqfbPpzv11O8U1Vn1ujaPNTnk5CWoid HDww== X-Gm-Message-State: AOAM531hcLMagO+9orwYiHoPMQ64/YPURrQkdac6W+8Dt88Xw8sAYf+3 Ex4Qxa6W7C7THPJfBTzvs0HW9GyO0pg= X-Google-Smtp-Source: ABdhPJwXyDKe8PF3H0UdbwXrt29EJd3TAbHyZO8NlM+ix8HoXywocs0vxaM7ALKZ5MSND8qNAs9btw== X-Received: by 2002:a17:90b:357:: with SMTP id fh23mr25323804pjb.169.1615218705008; Mon, 08 Mar 2021 07:51:45 -0800 (PST) Received: from localhost.localdomain ([122.182.238.13]) by smtp.gmail.com with ESMTPSA id s4sm11086378pji.2.2021.03.08.07.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 07:51:44 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org Subject: [PATCH V5 11/13] xfs: Check for extent overflow when remapping an extent Date: Mon, 8 Mar 2021 21:21:09 +0530 Message-Id: <20210308155111.53874-12-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210308155111.53874-1-chandanrlinux@gmail.com> References: <20210308155111.53874-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This test verifies that XFS does not cause inode fork's extent count to overflow when remapping extents from one file's inode fork to another. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- tests/xfs/535 | 81 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/535.out | 8 +++++ tests/xfs/group | 1 + 3 files changed, 90 insertions(+) create mode 100755 tests/xfs/535 create mode 100644 tests/xfs/535.out diff --git a/tests/xfs/535 b/tests/xfs/535 new file mode 100755 index 00000000..6bb27c92 --- /dev/null +++ b/tests/xfs/535 @@ -0,0 +1,81 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 535 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# remapping extents from one file's inode fork to another. +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/reflink +. ./common/inject + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_scratch_reflink +_require_xfs_debug +_require_xfs_io_command "reflink" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "* Reflink remap extents" + +echo "Format and mount fs" +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_block_size $SCRATCH_MNT) + +srcfile=${SCRATCH_MNT}/srcfile +dstfile=${SCRATCH_MNT}/dstfile + +nr_blks=15 + +echo "Create \$srcfile having an extent of length $nr_blks blocks" +$XFS_IO_PROG -f -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + -c fsync $srcfile >> $seqres.full + +echo "Create \$dstfile having an extent of length $nr_blks blocks" +$XFS_IO_PROG -f -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \ + -c fsync $dstfile >> $seqres.full + +echo "Inject reduce_max_iextents error tag" +_scratch_inject_error reduce_max_iextents 1 + +echo "Reflink every other block from \$srcfile into \$dstfile" +for i in $(seq 1 2 $((nr_blks - 1))); do + _reflink_range $srcfile $((i * bsize)) $dstfile $((i * bsize)) $bsize \ + >> $seqres.full 2>&1 +done + +echo "Verify \$dstfile's extent count" +nextents=$(xfs_get_fsxattr nextents $dstfile) +if (( $nextents > 10 )); then + echo "Extent count overflow check failed: nextents = $nextents" + exit 1 +fi + +# success, all done +status=0 +exit diff --git a/tests/xfs/535.out b/tests/xfs/535.out new file mode 100644 index 00000000..cfe50f45 --- /dev/null +++ b/tests/xfs/535.out @@ -0,0 +1,8 @@ +QA output created by 535 +* 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 b4f0c777..aed06494 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -532,3 +532,4 @@ 532 auto quick dir hardlink symlink 533 auto quick 534 auto quick reflink +535 auto quick reflink From patchwork Mon Mar 8 15:51:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12122851 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8380BC433E0 for ; Mon, 8 Mar 2021 15:52:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6004B65224 for ; Mon, 8 Mar 2021 15:52:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230149AbhCHPwC (ORCPT ); Mon, 8 Mar 2021 10:52:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230150AbhCHPvr (ORCPT ); Mon, 8 Mar 2021 10:51:47 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87BBDC06174A; Mon, 8 Mar 2021 07:51:47 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id q2-20020a17090a2e02b02900bee668844dso3208826pjd.3; Mon, 08 Mar 2021 07:51: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=gyIQpvibVeWIJVsoXwr/CW1cR4wrDfUs7ZYhFUCt/QI=; b=XiY5UsltYZk49LIf+JloFgs7iiCDx5vORLJpUHtJSy8ad7EyYcUer94rhgfRI5i/DD mJ5bI48vv2OR82XwMsCVnFFf1Qkyhkc5F8q5A5VDeVZLHT8IxFnmio8UuT/aY2ZHs3D2 F5fOjjV9VfszzWk4umxIeK3xe37HT3KmVrodVdS8JCLnJuHNe5AnOKdtODnSlcH6znh4 knTeT6smMJsqsM2ZEcUNgF2udBvgDBfuLOF235wIWk4P6JXsps/TzZIHfT17p3M6PT5i T91c+BkeVGohkfP9wdAPXxYQuKCQ2PSOtvnp+LZTW75p8e5ClB63G5vJOtQMmGcDlWOh ++pg== 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=gyIQpvibVeWIJVsoXwr/CW1cR4wrDfUs7ZYhFUCt/QI=; b=BnmERu1YtW07bfxiEEvZ1NgvYgrD8oDTkyczFclSEgspST/v2sp5tKTVbBkMrP8MZb b2wgCdCXt9sBly9L2lf3NaLUSkr2ZUDSCYZe7U01ZnITR5ixkbuSVbuSLbAfgd/9w5Sd qXs+poGv82ZkT32Vc5cLOw0Vf2LVOnT7fsjy4GQSFcSt7IaOJ+vi+NBTopBuYRuI/Bll /vZQyOABWYCeJL1ihez8olrUckHBputVCieQDSAoLQggvEtb4M+Oj1gO4sXBY7dw9l1L R8YOvMMslaK0aFeBfJ7C2eTUJsJCqavDCnHanOESS7kfcTrw+ex9VOvdtPjCutzeEqsc B4Yw== X-Gm-Message-State: AOAM530aMPmxB8g9GUyNvkhPg8dgIc1pmuwXqoatIMT2MNVZPXpGpQsO jIiy4NY+31edfL7NF/TDKONSyN2E0bM= X-Google-Smtp-Source: ABdhPJxfLMczLk+2v1mo7VK4OT/xya2l9BD4qusGDjDY5nkaEjqmb9AFqIBQhv/IktFCkNAjkXMnCA== X-Received: by 2002:a17:90a:1049:: with SMTP id y9mr25408057pjd.173.1615218706962; Mon, 08 Mar 2021 07:51:46 -0800 (PST) Received: from localhost.localdomain ([122.182.238.13]) by smtp.gmail.com with ESMTPSA id s4sm11086378pji.2.2021.03.08.07.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 07:51:46 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org Subject: [PATCH V5 12/13] xfs: Check for extent overflow when swapping extents Date: Mon, 8 Mar 2021 21:21:10 +0530 Message-Id: <20210308155111.53874-13-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210308155111.53874-1-chandanrlinux@gmail.com> References: <20210308155111.53874-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This test verifies that XFS does not cause inode fork's extent count to overflow when swapping forks across two files. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- tests/xfs/536 | 105 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/536.out | 13 ++++++ tests/xfs/group | 1 + 3 files changed, 119 insertions(+) create mode 100755 tests/xfs/536 create mode 100644 tests/xfs/536.out diff --git a/tests/xfs/536 b/tests/xfs/536 new file mode 100755 index 00000000..245c2feb --- /dev/null +++ b/tests/xfs/536 @@ -0,0 +1,105 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 536 +# +# Verify that XFS does not cause inode fork's extent count to overflow when +# swapping forks between files +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/inject + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_debug +_require_xfs_scratch_rmapbt +_require_xfs_io_command "fcollapse" +_require_xfs_io_command "swapext" +_require_xfs_io_error_injection "reduce_max_iextents" + +echo "* Swap extent forks" + +echo "Format and mount fs" +_scratch_mkfs >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_block_size $SCRATCH_MNT) + +srcfile=${SCRATCH_MNT}/srcfile +donorfile=${SCRATCH_MNT}/donorfile + +echo "Create \$donorfile having an extent of length 67 blocks" +$XFS_IO_PROG -f -s -c "pwrite -b $((17 * bsize)) 0 $((17 * bsize))" $donorfile \ + >> $seqres.full + +# After the for loop the donor file will have the following extent layout +# | 0-4 | 5 | 6 | 7 | 8 | 9 | 10 | +echo "Fragment \$donorfile" +for i in $(seq 5 10); do + start_offset=$((i * bsize)) + $XFS_IO_PROG -f -c "fcollapse $start_offset $bsize" $donorfile >> $seqres.full +done + +echo "Create \$srcfile having an extent of length 18 blocks" +$XFS_IO_PROG -f -s -c "pwrite -b $((18 * bsize)) 0 $((18 * bsize))" $srcfile \ + >> $seqres.full + +echo "Fragment \$srcfile" +# After the for loop the src file will have the following extent layout +# | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7-10 | +for i in $(seq 1 7); do + start_offset=$((i * bsize)) + $XFS_IO_PROG -f -c "fcollapse $start_offset $bsize" $srcfile >> $seqres.full +done + +echo "Collect \$donorfile's extent count" +donor_nr_exts=$(xfs_get_fsxattr nextents $donorfile) + +echo "Collect \$srcfile's extent count" +src_nr_exts=$(xfs_get_fsxattr nextents $srcfile) + +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_get_fsxattr nextents $donorfile) + +if (( $nextents == $src_nr_exts )); then + echo "\$donorfile: Extent count overflow check failed" +fi + +echo "Check for \$srcfile's extent count overflow" +nextents=$(xfs_get_fsxattr nextents $srcfile) + +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/536.out b/tests/xfs/536.out new file mode 100644 index 00000000..f550aa1e --- /dev/null +++ b/tests/xfs/536.out @@ -0,0 +1,13 @@ +QA output created by 536 +* Swap extent forks +Format and mount fs +Create $donorfile having an extent of length 67 blocks +Fragment $donorfile +Create $srcfile having an extent of length 18 blocks +Fragment $srcfile +Collect $donorfile's extent count +Collect $srcfile's extent count +Inject reduce_max_iextents error tag +Swap $srcfile's and $donorfile's extent forks +Check for $donorfile's extent count overflow +Check for $srcfile's extent count overflow diff --git a/tests/xfs/group b/tests/xfs/group index aed06494..ba674a58 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -533,3 +533,4 @@ 533 auto quick 534 auto quick reflink 535 auto quick reflink +536 auto quick From patchwork Mon Mar 8 15:51:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12122849 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D1CAC1550C for ; Mon, 8 Mar 2021 15:52:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 342BD65225 for ; Mon, 8 Mar 2021 15:52:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230409AbhCHPwE (ORCPT ); Mon, 8 Mar 2021 10:52:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230184AbhCHPvt (ORCPT ); Mon, 8 Mar 2021 10:51:49 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72AA6C06174A; Mon, 8 Mar 2021 07:51:49 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id i14so3246765pjz.4; Mon, 08 Mar 2021 07:51:49 -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=y0Z+s7Fjcy2Im2UyVPHCdibGR473jRuqO1r2vb39Jps=; b=kmwh4hScomO48Ui0naYsF5TzL9y4isxsbvPGTXf4/HUQFj2Kj4otuAIBdrGXz55YCc 63TEOqB44ifmVlJA4v1ic/lewkfQqavAg87ZmR8H9Dp6t3Dg2KgHIAm+GyVfbMV+PN1t WoXAxA9oV5P219iBrThB3vloqh9rs3awkiAOmfqGH1GNEiurkNSMfsroV15WKCuELop3 0izC+pKJBBcVHsJIZGxjwFZ2uw9se41tmDhhcPRo7cVbAY0RAhstHSvChfvLt4Eq2mFk onNKLp/RfZ5+NqaAdT4Nj3WGxucGvA1m0JPfSP9aSpZcKaeANnVFR27eYWIyfYn3uzi2 UFkg== 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=y0Z+s7Fjcy2Im2UyVPHCdibGR473jRuqO1r2vb39Jps=; b=FHRgiqFzNXS5L8tGSkM6MGn/lL9O0TKQGQQ2646U0aKNf37VeKmWn1FCxyNEaN/Ca9 D3Xazx9fdrL4+QHhTBFwobuSg3hHD1USNq1AMdWx1w8pQKnX5l4cZdDLOXfsBvAo6SBV lPJgr9bh55/0ehcBLqXwftJzGobhh1Cibfemg2UaIn7Dbv++Lyec7k9HHuz5POmiyrhW Z0nL1ZokdNxkCl2CMNE2OpdlyNXc7IEpsnWwToPJg4ZyDjqR/KlQytntKKWKmWGPyZej f5FjVYlCNoElgbaaDaRYHJLlEN8nkNwZz8RwPuK1HNRuipnSASvbBqgiNfQW715PB53H z9zw== X-Gm-Message-State: AOAM5320aTaUZUlIW1ECdBUSWGRiynssMkqnZDv9409Q3GDdl8l7uj2O ZPjZRXNoxFnofG51aGbXVAQhwubWwC8= X-Google-Smtp-Source: ABdhPJwJnoc0z0XgrK5Bq5d3gRq+HN/V/MNwluJZOoLbHNaHPSxiBT9tsujfmiBnEKYDT/whSPIbRg== X-Received: by 2002:a17:902:6b87:b029:dc:3402:18af with SMTP id p7-20020a1709026b87b02900dc340218afmr21922840plk.29.1615218708849; Mon, 08 Mar 2021 07:51:48 -0800 (PST) Received: from localhost.localdomain ([122.182.238.13]) by smtp.gmail.com with ESMTPSA id s4sm11086378pji.2.2021.03.08.07.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 07:51:48 -0800 (PST) From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org Subject: [PATCH V5 13/13] xfs: Stress test with bmap_alloc_minlen_extent error tag enabled Date: Mon, 8 Mar 2021 21:21:11 +0530 Message-Id: <20210308155111.53874-14-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210308155111.53874-1-chandanrlinux@gmail.com> References: <20210308155111.53874-1-chandanrlinux@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org This commit adds a stress test that executes fsstress with bmap_alloc_minlen_extent error tag enabled. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- tests/xfs/537 | 84 +++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/537.out | 7 ++++ tests/xfs/group | 1 + 3 files changed, 92 insertions(+) create mode 100755 tests/xfs/537 create mode 100644 tests/xfs/537.out diff --git a/tests/xfs/537 b/tests/xfs/537 new file mode 100755 index 00000000..77fa60d9 --- /dev/null +++ b/tests/xfs/537 @@ -0,0 +1,84 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2021 Chandan Babu R. All Rights Reserved. +# +# FS QA Test 537 +# +# Execute fsstress with bmap_alloc_minlen_extent error tag enabled. +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/inject +. ./common/populate + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs xfs +_require_scratch +_require_xfs_debug +_require_test_program "punch-alternating" +_require_xfs_io_error_injection "bmap_alloc_minlen_extent" + +echo "Format and mount fs" +_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full +_scratch_mount >> $seqres.full + +bsize=$(_get_file_block_size $SCRATCH_MNT) + +echo "Consume free space" +fillerdir=$SCRATCH_MNT/fillerdir +nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT) +nr_free_blks=$((nr_free_blks * 90 / 100)) + +_fill_fs $((bsize * nr_free_blks)) $fillerdir $bsize 0 >> $seqres.full 2>&1 + +echo "Create fragmented filesystem" +for dentry in $(ls -1 $fillerdir/); do + $here/src/punch-alternating $fillerdir/$dentry >> $seqres.full +done + +echo "Inject bmap_alloc_minlen_extent error tag" +_scratch_inject_error bmap_alloc_minlen_extent 1 + +echo "Scale fsstress args" +args=$(_scale_fsstress_args -p $((LOAD_FACTOR * 75)) -n $((TIME_FACTOR * 1000))) + +echo "Execute fsstress in background" +$FSSTRESS_PROG -d $SCRATCH_MNT $args \ + -f bulkstat=0 \ + -f bulkstat1=0 \ + -f fiemap=0 \ + -f getattr=0 \ + -f getdents=0 \ + -f getfattr=0 \ + -f listfattr=0 \ + -f mread=0 \ + -f read=0 \ + -f readlink=0 \ + -f readv=0 \ + -f stat=0 \ + -f aread=0 \ + -f dread=0 > /dev/null 2>&1 + +# success, all done +status=0 +exit diff --git a/tests/xfs/537.out b/tests/xfs/537.out new file mode 100644 index 00000000..19633a07 --- /dev/null +++ b/tests/xfs/537.out @@ -0,0 +1,7 @@ +QA output created by 537 +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 ba674a58..5c827727 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -534,3 +534,4 @@ 534 auto quick reflink 535 auto quick reflink 536 auto quick +537 auto stress