From patchwork Tue Mar 9 05:01:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12124081 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 27816C43381 for ; Tue, 9 Mar 2021 05:02:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F01576529C for ; Tue, 9 Mar 2021 05:02:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229553AbhCIFB6 (ORCPT ); Tue, 9 Mar 2021 00:01:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229480AbhCIFBn (ORCPT ); Tue, 9 Mar 2021 00:01:43 -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 33109C06174A; Mon, 8 Mar 2021 21:01:43 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id lr10-20020a17090b4b8ab02900dd61b95c5eso2071025pjb.4; Mon, 08 Mar 2021 21:01: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=W0BjEaPOIKQtoDE+eA2oSNZHxmTPwgVx+fwQsgvNeC8=; b=jHDtDnXX8XKn7G6mwsao0jzknptpkoUpJ9Zx9FUn7LFXGOenTeDICRliKEZkTY0d7M 5RR2Qw7mPmZOuvPiN2Xi9A4ZNKJMWxZ4odH9Ocu+0jBzHValWWu677i2dRrRZSnBJ7E8 PMlgth5ZSKfnMjytKxpn8KYQkrFeYjDar8AwEOE77gQRpoIKnNGw6E87+LESv8UUHIjs X9BIGmR/0/4mhvcF306lT5KYF+rv6N9Z5QPuga3kYs6gMpI94+iigbAXmMcIWublDf7m BRVruQ4mpAE9kuQduHqm5YDGUT32iW5rDe4znHI5PB0CMHZJFiOjcPC0D+MPI7Q+iL/b xGEw== 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=W0BjEaPOIKQtoDE+eA2oSNZHxmTPwgVx+fwQsgvNeC8=; b=fFbQ/KswXkPVMu1/WDRBU6KIbk6KLZD2JaKMlFhD52DBN8HG1QdxeewWtr1tfaQ9aN YoGk04MdW2duHtkbt4tdOrzQtQmqmyQMrwjyG/ED9p6JmLC7R+biQi26rxJj4dDm7EdW GvyE/1Qxd+Y+DPePk3oa62G4VWKCfRWRs5JMfHlIoxnGD11mj7354iaPNEABGuZiUAUh 0nKj0M6l3vvjlpRS6U+0+z3sM1vLljcarzjxaMeMFdGqTKA+VbdzJ8dmh+dm3pFBQKAR yopTxVduYnGU5h39Mx0KQYHZBdJd+wSJfPEsgXyhv19MeB1Zs+gybGueg6peog4ZIfrn 0aRw== X-Gm-Message-State: AOAM531cejmfliJ5DV8ufo3B78FYYp14uMHmNehYO9vSUqMiFzk2+S26 5sSRyG81DIRQatgHu2UXzfZT2AtRZAM= X-Google-Smtp-Source: ABdhPJzN9OindyTc/qAwsNoDZAV3nsH8eyISpExeK3+kRh0O2KSJecUr6mq7SxvhdZZPYvECBttLkw== X-Received: by 2002:a17:902:ed95:b029:e2:d080:7e0e with SMTP id e21-20020a170902ed95b02900e2d0807e0emr24515771plj.85.1615266102518; Mon, 08 Mar 2021 21:01:42 -0800 (PST) Received: from localhost.localdomain ([122.179.125.254]) by smtp.gmail.com with ESMTPSA id a21sm5849577pfh.31.2021.03.08.21.01.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 21:01: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 V6 01/13] _check_xfs_filesystem: sync fs before running scrub Date: Tue, 9 Mar 2021 10:31:12 +0530 Message-Id: <20210309050124.23797-2-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210309050124.23797-1-chandanrlinux@gmail.com> References: <20210309050124.23797-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 Reviewed-by: Darrick J. Wong Reviewed-by: Allison Henderson --- common/xfs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/xfs b/common/xfs index 2156749d..41dd8676 100644 --- a/common/xfs +++ b/common/xfs @@ -467,6 +467,17 @@ _check_xfs_filesystem() # Run online scrub if we can. mntpt="$(_is_dev_mounted $device)" if [ -n "$mntpt" ] && _supports_xfs_scrub "$mntpt" "$device"; then + # 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 + # such a 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. Hence consume such a possible syncfs() failure + # before executing a scrub operation. + $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 Tue Mar 9 05:01:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12124079 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 EDDA0C433E6 for ; Tue, 9 Mar 2021 05:02:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B3AEE652AC for ; Tue, 9 Mar 2021 05:02:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229480AbhCIFB6 (ORCPT ); Tue, 9 Mar 2021 00:01:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229495AbhCIFBp (ORCPT ); Tue, 9 Mar 2021 00:01: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 28E09C06174A; Mon, 8 Mar 2021 21:01:45 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id kk2-20020a17090b4a02b02900c777aa746fso4489900pjb.3; Mon, 08 Mar 2021 21:01: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=wiUX8hmDRkOSLriQemMNaU5Pv5stJo7j+X9UPcM9A8Y=; b=daNfA6hA7U16n/5JORC/z427Q/oezpZ7cYo8P1Dwiq6ZJkt0mTF0xsIMY8MBZDSvRF EK5WjRw+H34V0ZMDZ4t6RnwSI7hQ5Xc3y14KX/X9fH5l9ZzRx8cQbkAvjUZHwDoBA08q SAVvAhvs1fgLqBkO4Xpl30f6jv+F/174OrJJ6ZbSQOYZ6whxZbyiSiLCQkzUWVmX2ari XvtKVGpfopomg/vr7GDdxDgHDgF2/Txy6u7DToPIu1xc9/wyXe12sqpXRIRrQntCphLi HjWkIdJMAGf2PbQPXz62pNoYY1b6KnDoQT2JlJbOC0YVZAnPfw3fzphOWj+zHwbJLecp 3Nbg== 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=wiUX8hmDRkOSLriQemMNaU5Pv5stJo7j+X9UPcM9A8Y=; b=Q4uRzOCm1bErAEd0qblwzO3xoGYHlAjU0jayeL9UvNVijn7jDDLoyzSC7lkMm6F0eE y/FLnu652hZ5MIGdr9U+FqNrEJoQ0W60IkzG5yQXCnGK/SF6eo3mrLGFGZt29APU4Y5v M9DGJWOiHdHFQM902vG/5kr1pmczz4omhLchhbU3izNGr1WklSCBB5QIALP0fkl4I2/1 iJQBBYnliN/Oyw+vGsVQp5kK8+0EfMcuGxFeblFPgLzlckHM8m61yce3yfmdsGiOfu/Z bdTVQQzh0iup4HP6SAIELEOU2ew8xWTg2TJJDvQvv5r6Wp/YUU1fFkvcP20RPnEklgv7 3NcA== X-Gm-Message-State: AOAM531Xswh3kX2Au2CN/LG0hkjvzlOeO5bH7DEMrTutNgu3zXdRTPf7 dzNxmx0T8mQp3l0SMDm6KJAndppahYM= X-Google-Smtp-Source: ABdhPJzKLc04rxCGXcOPS0z00qb7hXidj9VxGgotIP/+kHKwEFKyLBdfR6CVzr4jHX23AkVUD+BrDw== X-Received: by 2002:a17:90a:8c08:: with SMTP id a8mr2751575pjo.136.1615266104601; Mon, 08 Mar 2021 21:01:44 -0800 (PST) Received: from localhost.localdomain ([122.179.125.254]) by smtp.gmail.com with ESMTPSA id a21sm5849577pfh.31.2021.03.08.21.01.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 21:01: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 V6 02/13] common/xfs: Add a helper to get an inode fork's extent count Date: Tue, 9 Mar 2021 10:31:13 +0530 Message-Id: <20210309050124.23797-3-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210309050124.23797-1-chandanrlinux@gmail.com> References: <20210309050124.23797-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 Reviewed-by: Darrick J. Wong Reviewed-by: Allison Henderson --- common/xfs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/common/xfs b/common/xfs index 41dd8676..26ae21b9 100644 --- a/common/xfs +++ b/common/xfs @@ -924,6 +924,26 @@ _scratch_get_bmx_prefix() { return 1 } +_scratch_get_iext_count() +{ + local ino=$1 + local whichfork=$2 + local field="" + + case $whichfork in + "attr") + field=core.naextents + ;; + "data") + field=core.nextents + ;; + *) + return 1 + esac + + _scratch_xfs_get_metadata_field $field "inode $ino" +} + # # Ensures that we don't pass any mount options incompatible with XFS v4 # From patchwork Tue Mar 9 05:01:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12124093 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 CDEA3C4321A for ; Tue, 9 Mar 2021 05:02:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B4B47652AB for ; Tue, 9 Mar 2021 05:02:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229495AbhCIFB6 (ORCPT ); Tue, 9 Mar 2021 00:01:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbhCIFBr (ORCPT ); Tue, 9 Mar 2021 00:01: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 06760C06174A; Mon, 8 Mar 2021 21:01:47 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id kr3-20020a17090b4903b02900c096fc01deso4489636pjb.4; Mon, 08 Mar 2021 21:01: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=Uvm2ympaXZGfUsJPluQGSj18lMDG98QiIjgtePSKgW8=; b=uNzN2wUUgVkZGV4OeyLB7jwIXju9bXbm6mYDZqGwcofDTnYMzssZjXtEzaKExz9oVt SiyMNfmYrMyzC9GsbFISajBRbaaTlD3PfB+hsByReUj0inlmM6abvstGEShDTT7YQpCO NltC6cH8inxUT02wFpRt+MCFSXjfJ0Tix5LyhTSNvHTddg/nJuXXXN029WvuQEq/gZlv cU5nt+Jhi4/YEDNFd5pLYPFJxHmo6Nebhm46cfXwRkMw1tJjScEvtceYyL2pTP8vdRXv fx/BDKPApzSjtEcPMyLk0OUGsTG4crokwvwMcvPc9bYKIeI0OMvW3tcTU43WZyLvONuK 45iQ== 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=Uvm2ympaXZGfUsJPluQGSj18lMDG98QiIjgtePSKgW8=; b=AhzVzC+bpy8+a/nGm/d0UpCy9dJR/O7Uhmp8FH5EFu+02F21+tXbjeCDIM5VnxizDu fY+A0wrTRxh1ro7iZ499YQ9nbKtKAnCrJyh/t6kdj0j/QGE59fd4ewb77hM8wMzGXx+y 7K/nWG9T6M0QCFFH2a1bk3KqSs5GeTmjH11U8fL40qlu2GuNWrRyCyOs9qIv6/IsV0A3 VdTPyABlZ1ArloWeCDa2ua/0pQXKvnARYJe5AztXdV1C2DA6oIWtqNm2qpDoTfeKGbLd x4sAlKMaV/nIUQ9D8QU7VUpO9fZRwqAYErPdEVI7dBNqsHUA/OTu7YYp8TljMG+zVuSU OSZQ== X-Gm-Message-State: AOAM531p00okz1CdhvXc7jzztXY8RYduQ5gevLwGeDxjwtp+mtlxVB+E hZHSk3XWt3LIv7zRu1ARbOjM66UZ+4o= X-Google-Smtp-Source: ABdhPJw1Im2UUJxxSLZkPMhu7RtuUGsCX8Q+YQ9kNENg47hDGF/iCfvpoMNRG/dpFTYNSFddUGYUBA== X-Received: by 2002:a17:902:d202:b029:e4:55cd:dde8 with SMTP id t2-20020a170902d202b02900e455cddde8mr2160481ply.51.1615266106517; Mon, 08 Mar 2021 21:01:46 -0800 (PST) Received: from localhost.localdomain ([122.179.125.254]) by smtp.gmail.com with ESMTPSA id a21sm5849577pfh.31.2021.03.08.21.01.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 21:01: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 V6 03/13] common/xfs: Add helper to obtain fsxattr field value Date: Tue, 9 Mar 2021 10:31:14 +0530 Message-Id: <20210309050124.23797-4-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210309050124.23797-1-chandanrlinux@gmail.com> References: <20210309050124.23797-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 Reviewed-by: Darrick J. Wong --- common/xfs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/xfs b/common/xfs index 26ae21b9..130b3232 100644 --- a/common/xfs +++ b/common/xfs @@ -194,6 +194,15 @@ _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=$($XFS_IO_PROG -c "stat" "$path" | grep "$field") + echo ${value##fsxattr.${field} = } +} + # 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 Tue Mar 9 05:01:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12124089 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 C9558C43603 for ; Tue, 9 Mar 2021 05:02:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3E6F652BE for ; Tue, 9 Mar 2021 05:02:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229515AbhCIFB6 (ORCPT ); Tue, 9 Mar 2021 00:01:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229520AbhCIFBt (ORCPT ); Tue, 9 Mar 2021 00:01:49 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35002C06174A; Mon, 8 Mar 2021 21:01:49 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id d23so2758108plq.2; Mon, 08 Mar 2021 21:01: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=e9VuivX6aKQ1kZhSKHOLtnG6lSuEZSopiR2LX+0lhSY=; b=MkZVGpAWFhowyR3EBcRCgZ4WbJzYaagKgszeWoKp5k2EcwLjckOF7JNgLCd+6TqPZr aCW7vdWXObJcP/GNF/KbnbWWq3snkR+N7Z4cZZjJZE8wD/xkNZF0kfGkF4XF5hSbKslm FmM5tWobznkqLc8rUmaYWF59gYSyYaIqQgyPlo76SA8Qr73mjbf5Vk23eUzZZnhQs92u vX2Ad0ZRQVOsKaowsQQ0yGXc+9uCG2OCXgA/H5XlyH/IpGAQx3iyfwN3JA3DOyScANlA pvuIg+7RZdveQcWB6dcZNC3dWVIK+bABa/xpxkecocrezTMxgCaQ99JHU7/S5zNtsanJ +ygA== 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=e9VuivX6aKQ1kZhSKHOLtnG6lSuEZSopiR2LX+0lhSY=; b=dsJoJm61NuLPl0H7QlTG7nAq61UruKs2C+g8Mn2zfUp2Nlx+T6EFiQ0EjQe9W3hFi+ qIx/EoFFCYwaFAA7c9q4KzMo6cKIlgeBl+oyEZ+9WLmCpvLGoVnQKf/8jOS3JFsTsNO9 R7CraS1o2oO0Q9hU5rymUeLM7UeZ15tBdmZjY6hYHcFaQoLvXNjo9NZGXws860n7Oamr haNRj7w9XeQ6s9dixK4oGUcBd52f3llcJg63A/VsLT4a0AH4bVqyxfLcWGPrK4/1UbEW 6ct1+pam+ys0WSR0WTwkNf4bC4oq/G0kTdlT9Tm3MEoJ5kIwFtOV0oT0/8I5bnq7Yb9Y fSMg== X-Gm-Message-State: AOAM533bAYU/vXRYqGNLjDfPSUVfEGMB+Y3yUd5XPphPXJth39JM6PGx tQfO23UrQIj97vrqZ4Kw1VT7ZrXzKn4= X-Google-Smtp-Source: ABdhPJw+xHoAuvw7FxEXainv9aS/Pns24GMlNEALXwzytLzh145jqXuJGmvlsLMufQRVakb4krSJ3g== X-Received: by 2002:a17:902:e5c7:b029:e5:df58:8155 with SMTP id u7-20020a170902e5c7b02900e5df588155mr21792343plf.55.1615266108492; Mon, 08 Mar 2021 21:01:48 -0800 (PST) Received: from localhost.localdomain ([122.179.125.254]) by smtp.gmail.com with ESMTPSA id a21sm5849577pfh.31.2021.03.08.21.01.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 21:01: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 V6 04/13] xfs: Check for extent overflow when trivally adding a new extent Date: Tue, 9 Mar 2021 10:31:15 +0530 Message-Id: <20210309050124.23797-5-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210309050124.23797-1-chandanrlinux@gmail.com> References: <20210309050124.23797-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. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R Reviewed-by: Allison Henderson --- 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..557e6818 --- /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 Tue Mar 9 05:01:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12124087 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 AA249C43332 for ; Tue, 9 Mar 2021 05:02:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7EF67652AB for ; Tue, 9 Mar 2021 05:02:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229607AbhCIFB7 (ORCPT ); Tue, 9 Mar 2021 00:01:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbhCIFBv (ORCPT ); Tue, 9 Mar 2021 00:01:51 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DA05C06174A; Mon, 8 Mar 2021 21:01:51 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id j12so8545996pfj.12; Mon, 08 Mar 2021 21:01:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/ncwkbzvt+WbLSN/VqIehCEC60/hvj6MmhPTGOtBFyY=; b=K/8l9+fVsxQrUfJd5J+VfsMeUG32+z6IAoKh56mW+AoTQOmrxIgcsSDKpC1m1LARlw v+WKu3nhaxcJzFZmbAjyJACMM+FRLZmJEAgBu/H/g7nENU2xV4WysVCmXxao8WUtsI51 PxEh3+gFWA4R7NGrOxs7n8NQ5BMN0JMT8+2vz9Y0PpjjbNeS/cmRtXNPkPTc4lCR/UrQ +ahTL8Nhel40YXfvLD9kdMjG4wQkPxfiK7Ec4Uu1omIP3fHkxplJo6xjG6TVQruGExH+ W9rhyuO8J7FUWNBKa1McvCd49lXS2wjIAuPDOBrVnkQ21oEQb1+Z5AcIaMunknVcPqXt Z4pQ== 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=/ncwkbzvt+WbLSN/VqIehCEC60/hvj6MmhPTGOtBFyY=; b=soCQkc6CgOdSkweqZ1AtNJTYJPAsLj4coIALXmYSnq+leTMEizXOeVPye++Dyr7hgE wLBqWj34Z1yTEwwdnMD8PullSyUrtM7JTjKmhwZw90qCr/bdiN9D2U1cNoKobcOErbQ7 wtNnDNYtFx2Fh1wHhavMChN7xFNWePo1onLjgrxTMG2BuWZUW8eoieyBCAh/XPUBuOKP idTb9DmK8MYKcqerUR2ZZg1JI2+sQnd3QPb9h17wGEaE3Js7Oc3uDlrDsgRlsEJEoCOZ lLOPYE8qUXGdyUunRsLZHPffJ6LbiwmJr3aLWMdkbb+U/vbB62PQdADpHbGVS8r6KyEq 5VoA== X-Gm-Message-State: AOAM5323OWv20vQeP6YR8f1cTXeG+hxiFkcOxSZ25jgreUY232j7RN6W r106RGs49iliP1aO+4vZUH6fEOfv2CQ= X-Google-Smtp-Source: ABdhPJzumYaHeQQ1BmdIq/Wo59ImxwzH3lsY6JxKz+QzQe7/iTfnvzfLYQ9CKVjqDI7XNCoZVQEVAQ== X-Received: by 2002:a63:4a44:: with SMTP id j4mr23219891pgl.199.1615266110677; Mon, 08 Mar 2021 21:01:50 -0800 (PST) Received: from localhost.localdomain ([122.179.125.254]) by smtp.gmail.com with ESMTPSA id a21sm5849577pfh.31.2021.03.08.21.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 21:01:50 -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 V6 05/13] xfs: Check for extent overflow when growing realtime bitmap/summary inodes Date: Tue, 9 Mar 2021 10:31:16 +0530 Message-Id: <20210309050124.23797-6-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210309050124.23797-1-chandanrlinux@gmail.com> References: <20210309050124.23797-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. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R Reviewed-by: Allison Henderson --- 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 Tue Mar 9 05:01:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12124085 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 6D4ABC43331 for ; Tue, 9 Mar 2021 05:02:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5880E652A4 for ; Tue, 9 Mar 2021 05:02:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229620AbhCIFB7 (ORCPT ); Tue, 9 Mar 2021 00:01:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbhCIFBx (ORCPT ); Tue, 9 Mar 2021 00:01:53 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20C4DC06174A; Mon, 8 Mar 2021 21:01:53 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id e6so7953004pgk.5; Mon, 08 Mar 2021 21:01:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pIBCosXehk5P/5OS1wZp50+lniDs8rcSeJgfrB/gdFc=; b=DYBmEVjW/b21tgQ58mmkcQVW99LqHEwxCfkDEycHJPfuHthfGFMwNMghIw/raTGBEV DtUBrO4ir4B4XG6vlUFNwt+68LWaARlrF63zCsY9T8dTX9KmAWxUjCKqrp0Uq0U7adMi 3P1ZEhj1UMs682k/ftHJjxsrorVa7uq9fvD+BVgPdTnXzbmtoiA1e+G1mFLuCQtV/TDc InUQhH/Wd0vtNZ/lthMqBNERbHfZ1F7GZzJ3D5zYuGnf71szFpEwfBPsBiCchHknD2dW r6AEOfmeI+HTIkQxBVsc4gskP3YbwCRrTjZq9t1NG/RFyqnemtJXAXPa2RRifnz0ku8A dwzg== 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=pIBCosXehk5P/5OS1wZp50+lniDs8rcSeJgfrB/gdFc=; b=sKdVL8LdDeLHYXuaj2BWmDKuAfXSpStDn1ETP3jwJXfWeDSppk1r4InudYeBPtxpxp GveO13nlHoFs3VwqWYRuH9GFlKf/nXCk2Z+fMa+SvvEsFQ9l1egcdr/qDLxrTrw4IFM4 4Ao9v1NKMLnVR7x/se2WUotbgoLfI3Xz2jyAcuUFcPR1jpLe/20juJxqd1Af45BTHHf7 BianZa8pvJWkp1UzHwOQDqM5gOU1vXc11FGFeiCz94yIjDz7otq1Pimc8Vi2+5S/f7yq Lcpic8SWyA1sk8xJhTgbswJjTBVNiWyv/hVXRHvVO9gByeEK43sj3cICkRbj6LeWAPRW O4Sg== X-Gm-Message-State: AOAM531+BuJDDA6BSR0w8RrDZd81H0wn/hrjWA6jKkPsJWorGifajG9z HmrKZEqhcTy68fgr2IuGLuYz6eVSiWY= X-Google-Smtp-Source: ABdhPJzXUqbSyyFjCmxstvHXN/wXRS/uot90CwlUF8DGxJlDIOuzvRz9+tbONYMGSgTCaKvEoiAVjg== X-Received: by 2002:a63:545e:: with SMTP id e30mr23904857pgm.13.1615266112575; Mon, 08 Mar 2021 21:01:52 -0800 (PST) Received: from localhost.localdomain ([122.179.125.254]) by smtp.gmail.com with ESMTPSA id a21sm5849577pfh.31.2021.03.08.21.01.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 21:01:52 -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 V6 06/13] xfs: Check for extent overflow when punching a hole Date: Tue, 9 Mar 2021 10:31:17 +0530 Message-Id: <20210309050124.23797-7-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210309050124.23797-1-chandanrlinux@gmail.com> References: <20210309050124.23797-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 Reviewed-by: Allison Henderson --- 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..f73f199c --- /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 Tue Mar 9 05:01:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12124095 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 2127DC4361A for ; Tue, 9 Mar 2021 05:02:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED6D7652AB for ; Tue, 9 Mar 2021 05:02:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229527AbhCIFB7 (ORCPT ); Tue, 9 Mar 2021 00:01:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229530AbhCIFBz (ORCPT ); Tue, 9 Mar 2021 00:01:55 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28425C06174A; Mon, 8 Mar 2021 21:01:55 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id n17so2414292plc.7; Mon, 08 Mar 2021 21:01:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gOy0uAB+kmgeFjFalqiQ+ZNbpIqcPaD/CaY0LV8aROM=; b=HT3O7Wu+xDYZsUbxVKzWyOASBKLQfd10/omJehs0X8+MS28HLz6nrOBwDdl+M79+mu gossfzsGVuP6Qk37511dmnrCdb8p8jBbbFTQ3QRcohSA5md0x0XyoXFN3HohIyFFB/6a /MtqtYepsHyU7YQpCQmZbceNkm/kx3JW1tGniNhI4c/2pCzvaPKXzxUgW5CT071kUtj1 iqnkMcxDHJN5Bm6bUEzQpEqI5SWMtaT85nqL5N58OGaIRaj7TCdFqEW6ilo5dQRW/uv6 EI00bX/ZpMn1B6Q1UAjSxSnlo+WBtknaEtpd9hTbeHiV2IoTwTFI4UUpo8PsOr4vvY3A NTmQ== 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=gOy0uAB+kmgeFjFalqiQ+ZNbpIqcPaD/CaY0LV8aROM=; b=Ml5Lrj4QyIENP9OnVERaoLE1SiQLLaBP07rhU0z4VGSYjW5jouv5GfS5E2Vz38wCp3 G9TfxsJezYyBMU6z60nIAlIeCOtc8I/dfhx8y65oQHJbuZ5JuCjeuMKNx70/j4pXeIfh UcOVx3vf9eMfdUq0w01UJZrADpGV8R6eO3xU2FwURiEOvAoQMlxpKDoo2R6HnZRNAMvj /orI9lO2KxZpLVF2slzWY36B/m/aKpVajY52zAjVV1EVBdQFeCEBsLsdhy1T0SWpFsLt eLSNR13QdiqTL44ea9w3XgOgbb6ksX8eD5BWuv4/whgIOPiGTh1e72BKcCalgt4A2amX F70g== X-Gm-Message-State: AOAM531C3lgI64Qfc8vH475OSYAibkloGVCwkOYMIS2VBzP6qLwW/kib L26MMTILFibkqBuT+K5djx0Hm9fSors= X-Google-Smtp-Source: ABdhPJwasWI34BiZJETHBi8EU7kJP3UYckPuopyiMD+3wI2t3kJfquznN4HD24Av3HAw3CL0Hs/6kQ== X-Received: by 2002:a17:90a:3902:: with SMTP id y2mr2776175pjb.202.1615266114515; Mon, 08 Mar 2021 21:01:54 -0800 (PST) Received: from localhost.localdomain ([122.179.125.254]) by smtp.gmail.com with ESMTPSA id a21sm5849577pfh.31.2021.03.08.21.01.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 21:01:54 -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 V6 07/13] xfs: Check for extent overflow when adding/removing xattrs Date: Tue, 9 Mar 2021 10:31:18 +0530 Message-Id: <20210309050124.23797-8-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210309050124.23797-1-chandanrlinux@gmail.com> References: <20210309050124.23797-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 Reviewed-by: Allison Henderson --- 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..432c02cb --- /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 Tue Mar 9 05:01:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12124091 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 D94BCC43619 for ; Tue, 9 Mar 2021 05:02:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4F84652A4 for ; Tue, 9 Mar 2021 05:02:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229530AbhCIFB7 (ORCPT ); Tue, 9 Mar 2021 00:01:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbhCIFB5 (ORCPT ); Tue, 9 Mar 2021 00:01:57 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16317C06174A; Mon, 8 Mar 2021 21:01:57 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id fu20so234569pjb.2; Mon, 08 Mar 2021 21:01:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uxvyne9W6+6fgT0VNxza+ydo9Q6Co5gs3i28V+THoQM=; b=BcYZVnPZrM1Jww4so8OjegDZy9xsy6CzNSmziNRTQr1Ko0I06V7CVW6UZKoPjHRd9V cxkxEZb8R50wkXSmz/by2KDzNKHNMu1bpiKsxWKigys0vwDOSvqZ5ZS5Wa1HsPYV7POJ /1fCcG/w++QiO3NOg1yCylT17uXHsvtFawu5xauLRYuQbqDUd5RZa/QmPuDvVdi97do0 i7BWMWbJV6eZc5VFH/KBqmWScBcxf3fNwDM7uJ5l8TkOPCoq4ijHZHapLgHPm50UiGye HWNwi83lKfHFC750Mpuy2HdADc+nl7QCqFzI0MXmjEEhal4rJe6x5sD4OSHicfa3sGSe kWoQ== 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=uxvyne9W6+6fgT0VNxza+ydo9Q6Co5gs3i28V+THoQM=; b=YlffWbrM5oSFARkxb4e/EbL2ZSX6CRHAxpetbYrBBfp0jp1kzciaq0OPyVW4gl+eI1 k6YWxLzyQzrWbQXq/4BmQ+wOiKXY1bqFciCdbNkiyyfNhsOPYw/wcIl99Rw7uvCq2cgf k6N9eNHBVqTdcj0ORImaFbDLx5ukc7kGUpSfe+6vgXVBwgXVYEELAiB1sdQK0Rv9g39G 8JGfSvbjh3ZEy2NIckB432V3sOsgBfsO8zf2+RPU3Q7bQ4tvJ6H/pgfz97Srz6kiQArq cOps22mJ1S8ieQ9m9H+lJ69R4mIMENk2GSJhVMETQqPpXv7fU2t7RjRSJeyey1JQqxPY oGzQ== X-Gm-Message-State: AOAM533M584rPUjM9szIsTHnuwUeHBzoGaJKRMQXeHBgOXoxWtHgp382 u4TsXm9dC3yd9vI2344CgyDDxpccuB8= X-Google-Smtp-Source: ABdhPJyfU//KsdYHO3lZdooi4iO25LfGY5qBN9NwSQFFtpkTYb9t3wt+osez0aVW1ODd3VKu6RHQlg== X-Received: by 2002:a17:90b:33c7:: with SMTP id lk7mr2708202pjb.95.1615266116487; Mon, 08 Mar 2021 21:01:56 -0800 (PST) Received: from localhost.localdomain ([122.179.125.254]) by smtp.gmail.com with ESMTPSA id a21sm5849577pfh.31.2021.03.08.21.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 21:01:56 -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 V6 08/13] xfs: Check for extent overflow when adding/removing dir entries Date: Tue, 9 Mar 2021 10:31:19 +0530 Message-Id: <20210309050124.23797-9-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210309050124.23797-1-chandanrlinux@gmail.com> References: <20210309050124.23797-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. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R Reviewed-by: Allison Henderson --- 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..b241ddeb --- /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 Tue Mar 9 05:01:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12124103 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 0ED9FC4332E for ; Tue, 9 Mar 2021 05:03:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA85B6529E for ; Tue, 9 Mar 2021 05:03:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229599AbhCIFC3 (ORCPT ); Tue, 9 Mar 2021 00:02:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229612AbhCIFB7 (ORCPT ); Tue, 9 Mar 2021 00:01:59 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EC9DC06174A; Mon, 8 Mar 2021 21:01:59 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id o38so7946315pgm.9; Mon, 08 Mar 2021 21:01:59 -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=UoIgnUhVWthCqsPnEF2k+5Wvvq+hQl8O9VoT2BqJBss=; b=RCDwapbH285aJvvPUS6c3Fv2Jehs9yjtOpcQVnk2lEartpQoOml6JwDgIWsWt6nMam Hl0MX4SESsMyL4ukkEhdHCFj1fixoVdB2CdsVwEb44fU2o3EtgVJ2fLdI17Cz9l/6cIE NDgy3ComOBEFdSjLJ52dgmqFfa8J/ppzbgpjlTSxZnURUrp2Sb6twlaupzuMB8m3+INa a7IAI2l9ylyuR3IRr+TNkdqFwYVp7xe3HwnHaraXyS52QXlzE/GL3v0UAhDD7w63dXf9 iarbJ8ueIRafKKM40/Rw542IKniWAwaRbPFkRwl/oj9pnGm9KGdeYrpNAxuOnI7JrPvf v1zw== 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=UoIgnUhVWthCqsPnEF2k+5Wvvq+hQl8O9VoT2BqJBss=; b=np4dzECx/NGpTcaKAEjbstx4yE5JyBFYlczLiGYb+TMCoBTt+fYwfJlnWkLFB+HCD/ dC29hIOpBfRoqrhIqVfrrCMHIB2hxVto529/yoDmxce2e+ZtbbuslBwGOVxa5jvbp3FU c4bducbYJ7Q6G/+vCv3KNhuJ0dThE2zDZLId/A2LoTLa1/LZFsWoBzkptBDNAqK2WsBg e8jG/rfdDp2M1gSvc9zY1upH5utqU0oan24S9VYeubqxuDNhgEX9pgGF/+VMJO0sWMyh SxeR1Cjh5wAggz/MyXbrwcq5jv6Yyj3igx5Sj9bqWzbWXBHWSI12k+JZO0k44OFoyRU5 bmXA== X-Gm-Message-State: AOAM533xeCdY13wq1dmjV5D7s+J42pVThgDhqUtNpDWElEf5NK2y1rQm 00l3zm90jE1KK71yNsbyzOs15qd75OQ= X-Google-Smtp-Source: ABdhPJwwMnWk9sbLUr+y86827Cg/9yTss8pdZj8pUlwcTNRP1gv8Ky+aG3rdhGSrdT/kotu4HvGo4g== X-Received: by 2002:a63:6f8a:: with SMTP id k132mr24406710pgc.59.1615266118622; Mon, 08 Mar 2021 21:01:58 -0800 (PST) Received: from localhost.localdomain ([122.179.125.254]) by smtp.gmail.com with ESMTPSA id a21sm5849577pfh.31.2021.03.08.21.01.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 21:01:58 -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 V6 09/13] xfs: Check for extent overflow when writing to unwritten extent Date: Tue, 9 Mar 2021 10:31:20 +0530 Message-Id: <20210309050124.23797-10-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210309050124.23797-1-chandanrlinux@gmail.com> References: <20210309050124.23797-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. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R Reviewed-by: Allison Henderson --- 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..bb6f075e --- /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 Tue Mar 9 05:01:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12124099 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 E3046C43381 for ; Tue, 9 Mar 2021 05:03:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B463F652B1 for ; Tue, 9 Mar 2021 05:03:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbhCIFC3 (ORCPT ); Tue, 9 Mar 2021 00:02:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbhCIFCB (ORCPT ); Tue, 9 Mar 2021 00:02:01 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19DE1C06174A; Mon, 8 Mar 2021 21:02:01 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id o38so7946371pgm.9; Mon, 08 Mar 2021 21:02:01 -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=B0JiuyjLxAO766Dbi/Flr0AGUrNxdP+HauXEXRBua5E=; b=OU5vu1eK7cp7vcI7PgqHMwWkuozCniccvj5XN9bv59myNjxMGzd0rh2hs4j4XBc6gE 2u2tgAAkTvkqBUeRZ8DZr22LgRz1COS88/A9aVqcziQU5Y738kG68ik8/dfrsfEG9Iw2 XNmXuTCp74Zp8c9bnNdpI0ws/IOgAhBxy+H9OLZXLOG1iJOW0Fxbh8s2g0XBY1Ht8V8Z vznrcsLIZca/SeNES+YrVQkGpmn6GNOCvXpzvr7xFlipYLv8Dsyy9PIBV8Co+yds68In yS6K25NeJIWFy0KUI1t8gjhJ95DRl5vcDtLE8fkxwkTgwW8NRbuvCKOvlskCNo/DzeyH MD/Q== 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=B0JiuyjLxAO766Dbi/Flr0AGUrNxdP+HauXEXRBua5E=; b=JAJzxggIb8o6bxaDE2rgSeym/hO4JPQrMZr06JIhbU3UbBipawAfdbohrCkyvSoXR2 iJ3gFRNqazL77UMw5IT17OI5Lis5+GqodjG7Zpk//t46RedVC36VLu62y5n3dq/Axaka eFm/QtmcSeUX9UoWgwNsgfCzS99qk/tdZf+OXkmnA2r5c7b5tGcUac2NC5lebKnD3cHl pD8e/kkK15NdIDqxct+glYPUjRdRbXLCWdJIod4VsKq9qWH9KRdM27Eikz/zbSF2YITD 52zDHMDX3QLxiiCSkDRwrr91BdkcqqB51otGNT62pNfSg1Yk7FN32Il6St0AHBqnTMgx exDA== X-Gm-Message-State: AOAM53122oLVEGZGALeM/3vDjtdyimYsbgm13psh7flcRI8f1uIfnXzT gwqeWMmGtqo9EO739UHbrOw/9aFkpdk= X-Google-Smtp-Source: ABdhPJwaDBBGci+GxtxtMJni9odsRo2r9Uz9ea8iTUcIeqV997edTGJIPiIeyz9dUoEliACEIrVhiA== X-Received: by 2002:a63:4f57:: with SMTP id p23mr23417416pgl.281.1615266120530; Mon, 08 Mar 2021 21:02:00 -0800 (PST) Received: from localhost.localdomain ([122.179.125.254]) by smtp.gmail.com with ESMTPSA id a21sm5849577pfh.31.2021.03.08.21.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 21:02:00 -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 V6 10/13] xfs: Check for extent overflow when moving extent from cow to data fork Date: Tue, 9 Mar 2021 10:31:21 +0530 Message-Id: <20210309050124.23797-11-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210309050124.23797-1-chandanrlinux@gmail.com> References: <20210309050124.23797-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. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R Reviewed-by: Allison Henderson --- 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..06b21f40 --- /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 Tue Mar 9 05:01:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 12124101 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 CCC15C433E9 for ; Tue, 9 Mar 2021 05:03:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A385D652A8 for ; Tue, 9 Mar 2021 05:03:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229544AbhCIFCa (ORCPT ); Tue, 9 Mar 2021 00:02:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229636AbhCIFCD (ORCPT ); Tue, 9 Mar 2021 00:02:03 -0500 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24D41C06174A; Mon, 8 Mar 2021 21:02:03 -0800 (PST) Received: by mail-pg1-x531.google.com with SMTP id 16so1526157pgo.13; Mon, 08 Mar 2021 21:02:03 -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=+qZtleY3wzxVT6CvlavJW7x8kJqVdaHZImc3EPO0Aek=; b=aQXFiECYtJ/Gv+QJNFFdRaueLjWJ250FB7BkFABvP+Yv3VZVO8N1sGP2fNHKypxM/a ZgU7VPcaiaUWnwMxNRnY81LyAW1yEfQVt1SNkGMZ7joyHI/0cVDBhDtylt3gaZPPXVfm ST466nB/YPi9+1lBpp75JTa+J9cWmNV5bycCgZgqJ0iNxDYjRQNwiQxHbT780naErStk UvF6gDMeuKG8iZMTZ0jKnYbpNCI+xWyOqZ2uaqr5PNXd2W15JX5t6EOgkOCNsYH9+ux3 XJZLwW21MbfZl+8S72VV5jsVbh54sybZI3CPSoZXCCYT91JP+R5eUlfhSdeVYdZEhY8b 5rdg== 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=+qZtleY3wzxVT6CvlavJW7x8kJqVdaHZImc3EPO0Aek=; b=hE5XaX5h0UvzyFmKLwfB5TIGabwYtmUoJ8d5KmYT29LgoZbVFY6gUabJ8kHCRadzPl JIQc4d19SY7oJEm+UJwL29gXEdImcgq7pH1fvGjXWoMD1XsjApPyt6XEdUXjswUSKs0c 6AKTS9qdIgk/sFNNq9ni2Uw6mMgpv3yehA2rDzcXFI7w5TLPYFnj8OhS7jB+4W0V+X84 /lpVIPvbuIepsPu4zVzxLrOeCEegOkO11o24nrnE41+CneqX/TVJooBa4rp7VyHLNesg 2Qt0gPOWwTMBG8bheXvxRwiIGC7Jm6gzc3uAOZhM4rhq3iRNc1PeQnMAocYyujuV/dhp wTHw== X-Gm-Message-State: AOAM530HnI/+C1VqCP57PkHX/u9wQgv+xY4emJGpFtjGCwDY4Ic6GxDe 9PVWeNJz51Sh2fPzEt0PXNRkb39DpmQ= X-Google-Smtp-Source: ABdhPJwk48YdsHFYGYARwzQMGEvxM7N0FPOEIFywtel2tD6J71oHBW+RmWZVWwrizjVskDNUllR69A== X-Received: by 2002:aa7:92c7:0:b029:1ee:75b2:2dab with SMTP id k7-20020aa792c70000b02901ee75b22dabmr24763697pfa.61.1615266122515; Mon, 08 Mar 2021 21:02:02 -0800 (PST) Received: from localhost.localdomain ([122.179.125.254]) by smtp.gmail.com with ESMTPSA id a21sm5849577pfh.31.2021.03.08.21.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 21:02:02 -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 V6 11/13] xfs: Check for extent overflow when remapping an extent Date: Tue, 9 Mar 2021 10:31:22 +0530 Message-Id: <20210309050124.23797-12-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210309050124.23797-1-chandanrlinux@gmail.com> References: <20210309050124.23797-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. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R Reviewed-by: Allison Henderson --- 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..98209e06 --- /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 Tue Mar 9 05:01:23 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: 12124097 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 5E277C433E0 for ; Tue, 9 Mar 2021 05:03:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3438165092 for ; Tue, 9 Mar 2021 05:03:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229689AbhCIFCa (ORCPT ); Tue, 9 Mar 2021 00:02:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbhCIFCF (ORCPT ); Tue, 9 Mar 2021 00:02:05 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A915C06174A; Mon, 8 Mar 2021 21:02:05 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id a4so7952414pgc.11; Mon, 08 Mar 2021 21:02:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jmnH2NVxLNb//OdJ5YGhMoZtosSzwhyj1eElOhU5wIY=; b=onhOpIbx0CfXDoxOUkSPLds2ZIGihgI8X6SJQcR1BSDcnWTfCY9XMqTeCsCu3TMSTo a5dQtBydYnuMxDf9lI3noAD66W7ybNnwSgqPDm/w9gOqT4TQaGixRNgDWkPd4JRFMlS3 RAqIfhd5t8hJL7hxKwJPnV7V7bWOlsh/sB2bkRtrxcWJePFLHIkAWS1BRVqAg8MvHJD4 0ayLUPGLhzYgGLHSLiatv6hRE5bGdVg9OHi8pKVu/ds8FGGLih/VnVWg7pygAaiqjdT3 qqMZrldIPdKo9R+Q6/H6VGA1iQhb0ymqVD4kb1abuo20CLcyPzlq/F3pFMl+Yni+Ym73 9/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=jmnH2NVxLNb//OdJ5YGhMoZtosSzwhyj1eElOhU5wIY=; b=RwlRwIoGCt8fOYX1rybFV8UiiXdt+yFW6KYfsu/L6pEIyoEx7Lkk1LITtF9DkkVLzV azyFKbH8kThR6IgKPGhv4evVtEpCd4NY8n29H6UQzYdAfadUtX3zLdQKPEfIJJEjuxeH TGswVdO8hHu6CWfkmNmuUiiRG7W02hl/5x5gGTueJv/30ucLeqMul+65GQPk5M5D5XpU H6qzD61TWactEpPnwkJSK+jXdGTmBLFun5VPkShwdZR1a5Yq8nW1lhYtPvpZB9feky+U DwOCy45AdhRv1o7QaHU+Xnlq+N5enQYmx/95+lZFTUKASAtlVQlScU47sT0GJ0clJ4FQ YrMw== X-Gm-Message-State: AOAM530vjw8+IKD2Mh3RE1dpFYgJNpkbrveH2SSyrUxGjxxVaXxwhY2E lY8vuYWK5Pmfv9Kv0KLnAaLit+3do7o= X-Google-Smtp-Source: ABdhPJy5k21A4gDJzvnO4f5B8gNB39i9UlHXHlr+UTO8tzQHbKiki7PiMX1BDual+wDefLr6AVu4RQ== X-Received: by 2002:a63:e44a:: with SMTP id i10mr22964629pgk.404.1615266124486; Mon, 08 Mar 2021 21:02:04 -0800 (PST) Received: from localhost.localdomain ([122.179.125.254]) by smtp.gmail.com with ESMTPSA id a21sm5849577pfh.31.2021.03.08.21.02.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 21:02:04 -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 V6 12/13] xfs: Check for extent overflow when swapping extents Date: Tue, 9 Mar 2021 10:31:23 +0530 Message-Id: <20210309050124.23797-13-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210309050124.23797-1-chandanrlinux@gmail.com> References: <20210309050124.23797-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 Reviewed-by: Allison Henderson --- 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..9bb4094a --- /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 Tue Mar 9 05:01:24 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: 12124105 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 40E6AC43331 for ; Tue, 9 Mar 2021 05:03:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B91E65092 for ; Tue, 9 Mar 2021 05:03:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229691AbhCIFCa (ORCPT ); Tue, 9 Mar 2021 00:02:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229652AbhCIFCH (ORCPT ); Tue, 9 Mar 2021 00:02:07 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88714C06174A; Mon, 8 Mar 2021 21:02:07 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id nh23-20020a17090b3657b02900c0d5e235a8so4492258pjb.0; Mon, 08 Mar 2021 21:02:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y0Z+s7Fjcy2Im2UyVPHCdibGR473jRuqO1r2vb39Jps=; b=bWJY/3PYuNpZxTHJwRcjgHbB29cQHzo/ReDTDwlqXafn4N5ktmI6vfF7xG9ZU3TGg1 kpn5g247GyuqZFQBApUQp66mhFOO4btA/UgF7p8K+nZ5lba8hnUJk+LxAEk0LVKnk6yo bI1vNoFqgDVJBJ0Pj9L76f1DaCGZpFDjWA3hdwZh7tTDyddv7xEycAwZ/8vl3U90IL8z xkaQpx1EcPu5kL1tLbHPkdo0mQhDSe2yw62CDVg75VS0Q4jO5W28/ApbA6jq5LTQf7wI mcLBWkg0p6UmYsdD+NuLJrLynBulJ8Nggk62Riyox4sLIoobkAGibzB8LJkfGZIfRG0t w9YA== 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=qyN3lH44NKzSxkuja1Kb5i342bP3MK0a5qIQWmPxlJHaKy6WoK46gACXbyO+W+8WeF BypUX2GrSizdzJwYdnAO/+7lgPWhoaLFhFTAYrLbubHmat0WmVyrTwF66ruBp9En9AE2 FpilpBEvCLgRi/YOFEzP7JvEHFTZ+EMrM2LSQfDVdrQy9zMyxixZneeecnb4aktddUkU 8P2ZHDBcecgs3cp0484hWplVZ1vGdnaF91Yys0t9fZhabjwuuaofN1fDc7pA4TZQJev1 ha1OuqhLX/wi7g2x+p/MEp5oA/+TKqacG7FUVNxKbOtWBkxNa04cTfK7vzpJs0DvApI5 Ay6g== X-Gm-Message-State: AOAM530ucg1beH7o0rQ3o9PQkElhwgc9sV1x01msBHUljsgkKGiUt81f xspWWcMK1R+eHxjh3qBQ1poG4yTTOUA= X-Google-Smtp-Source: ABdhPJy2nJHeU3cC6q+lvLLnXq8DCuZUFVndQQerxS3XkGsWFXipmt+i5Aqmm/QNuKvc10oWIrv/iA== X-Received: by 2002:a17:90a:64c7:: with SMTP id i7mr2682270pjm.95.1615266126400; Mon, 08 Mar 2021 21:02:06 -0800 (PST) Received: from localhost.localdomain ([122.179.125.254]) by smtp.gmail.com with ESMTPSA id a21sm5849577pfh.31.2021.03.08.21.02.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 21:02:06 -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 V6 13/13] xfs: Stress test with bmap_alloc_minlen_extent error tag enabled Date: Tue, 9 Mar 2021 10:31:24 +0530 Message-Id: <20210309050124.23797-14-chandanrlinux@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210309050124.23797-1-chandanrlinux@gmail.com> References: <20210309050124.23797-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 Reviewed-by: Allison Henderson --- 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