From patchwork Wed Apr 19 21:13:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13217372 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A67FCC77B7A for ; Wed, 19 Apr 2023 21:14:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231263AbjDSVOF (ORCPT ); Wed, 19 Apr 2023 17:14:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231164AbjDSVOC (ORCPT ); Wed, 19 Apr 2023 17:14:02 -0400 Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1754A4C1A for ; Wed, 19 Apr 2023 14:14:01 -0700 (PDT) Received: by mail-qv1-xf2e.google.com with SMTP id 6a1803df08f44-5ed99ebe076so7846d6.2 for ; Wed, 19 Apr 2023 14:14:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20221208.gappssmtp.com; s=20221208; t=1681938840; x=1684530840; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=LWOiix+CZpnRrg0RGVEFc9lRocCcVk4TK0A2OuoCLpQ=; b=MO7Kb8Vs5ORbE3wSBmxNeJWNi9Sravzn/OaWnZXaTxxtusxyFdtppTC+THXVTfDgLY SPMwypC8H0+xIGopBkdd6L00tUmj20Fglp43eBAwV8YVy2dlqhF+OIpOzRCtYIsMIzeQ +kedH52LS44N94kL/YUrm0907kvewOEdYRbjd8c5U6gcYKSWPbhuaJjBdqy46Dnaljjq EWi1nnwZQeQusOrxb6yeo64XbddMb+2id6FWw6q4Pw4VgFn4oXHp/pHo00/PUbLjRPL7 J19OrumIQ4b7yopTuUul0vPqx70mVpPwCxKFIW6O6yIT74CxrFrpsSCA/xV3v0uj+fir /OwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681938840; x=1684530840; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LWOiix+CZpnRrg0RGVEFc9lRocCcVk4TK0A2OuoCLpQ=; b=c6DjuVt423Swv8SlZGl+bj3I7bBOB081tvfoXq59v25Dbh18J7h6bV6y9MZawPdOs/ Hjz+kbNBbFKyx1ylKG03FGe6Svt72JIZ5My8T+LWVUNuEDypEGmUQGvKB5j88+ptj0Jz lmOT618LRxwvr+U/awiMaT9tlo1d9GswX3lIHhOwFDbjQT3oKy88IfXxf+Kr2N84rOI0 zGg1+oLFwHE/znU5mNXqYs8n1W3Dm74ryRLH4UmkWkXViC+iXnon8zUyyqiSlNNdvF+s baW5kTumAL5V2cYgN1ho2u6NAdMh0BgSNxZyW1KqW6UOfC904mEhgd/wm3UTTC61Og/u fBWw== X-Gm-Message-State: AAQBX9dLY4BUmd5mSRIHrFwJjpfdyu+C6LIB+mFhn3MAZY/uQinAnlbZ lMtubwFJXp9/tAw/TKlzPHj6ZrUZBmV8tmDS51ZLQA== X-Google-Smtp-Source: AKy350bNlbMn2eJG67kjeEIey3N2TZegE1G4Zchw1rNS2Kcer+7sOMNlmGbfQ57dNFutxVuBt5aRVA== X-Received: by 2002:ad4:5fcc:0:b0:5e3:c84a:9422 with SMTP id jq12-20020ad45fcc000000b005e3c84a9422mr7926qvb.2.1681938839893; Wed, 19 Apr 2023 14:13:59 -0700 (PDT) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id r184-20020a37a8c1000000b007441b675e81sm3106277qke.22.2023.04.19.14.13.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 14:13:59 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 01/11] btrfs-progs: fix kerncompat.h include ordering for libbtrfs Date: Wed, 19 Apr 2023 17:13:43 -0400 Message-Id: X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org We're keeping a libbtrfs compatible kerncompat.h around to make it easier to modify the rest of btrfs-progs. Unfortunately we also use some of kernel-lib in libbtrfs, and those also include kerncompat.h. Those getting included first means we'll pull include/kerncompat.h instead of libbtrfs/kerncompat.h, which will mess things up. Fix this by making sure we include our local copy of kerncompat.h first before we include any other header in btrfs-progs. Signed-off-by: Josef Bacik --- libbtrfs/ctree.h | 4 ++-- libbtrfs/send-utils.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libbtrfs/ctree.h b/libbtrfs/ctree.h index e7a51c4b..ea2a680e 100644 --- a/libbtrfs/ctree.h +++ b/libbtrfs/ctree.h @@ -22,14 +22,14 @@ #include #if BTRFS_FLAT_INCLUDES +#include "libbtrfs/kerncompat.h" #include "kernel-lib/list.h" #include "kernel-lib/rbtree.h" -#include "libbtrfs/kerncompat.h" #include "libbtrfs/ioctl.h" #else +#include #include #include -#include #include #endif /* BTRFS_FLAT_INCLUDES */ diff --git a/libbtrfs/send-utils.c b/libbtrfs/send-utils.c index 831ec0dc..eb0ed5af 100644 --- a/libbtrfs/send-utils.c +++ b/libbtrfs/send-utils.c @@ -24,10 +24,10 @@ #include #include #include -#include "kernel-lib/rbtree.h" #include "libbtrfs/ctree.h" #include "libbtrfs/send-utils.h" #include "libbtrfs/ioctl.h" +#include "kernel-lib/rbtree.h" static int btrfs_subvolid_resolve_sub(int fd, char *path, size_t *path_len, u64 subvol_id); From patchwork Wed Apr 19 21:13:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13217373 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9285C77B73 for ; Wed, 19 Apr 2023 21:14:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231290AbjDSVOG (ORCPT ); Wed, 19 Apr 2023 17:14:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229659AbjDSVOE (ORCPT ); Wed, 19 Apr 2023 17:14:04 -0400 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A82D3AA4 for ; Wed, 19 Apr 2023 14:14:03 -0700 (PDT) Received: by mail-qv1-xf31.google.com with SMTP id dd8so952233qvb.13 for ; Wed, 19 Apr 2023 14:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20221208.gappssmtp.com; s=20221208; t=1681938842; x=1684530842; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=sykxFQmUFupV7i2Su20Pk9+z0F4Z9qrvZt39lUd5Yps=; b=Y9Yq7uzryyPXRdtLOV4786X0oNSS/2Ha9IktvP/liuZzxzaUPrtNDdPeXvqLPE29eJ PADTaPMw5z7DXmK1Rk92jUJvYB5mUFarewyUopiku2iVoY36pb5I9cEMCQ6zVma/nYt1 tWZkXC1I8oPwydZqz09ijbYaIQRvBNiuJBQir0ZllMIje/KM7Ry1G9u+pKbP2xQIbYLC BaBBaOlozLqpGONH+zpwEmRvohIrz3rdqISuFB4VoV7TCpxTpSvtgn74DgfZiIEHc5UY 2K1wTwQpHrdFfIxkKvXw7DfGE5igzTML/YOHhLFH1O66fvplEJVMRMvFiALm+BD6aB/u Xj/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681938842; x=1684530842; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sykxFQmUFupV7i2Su20Pk9+z0F4Z9qrvZt39lUd5Yps=; b=K5wp4ic5ql2HBPYkYWTvfAvHExFyIrzbTFN6Aoqt6attM2phg/NlVESZHjBJoAJ4IX TKKyfd339vI4ZOkX7MrDA/S2JIZtK7bYkTzYOqv5iZ+PSH/EUtkDnyhC+4s9oymMr+hu xAne6bTRH1s6J3mIKbZg2NCLRxNq/KM0nywusu8Ahxg1C4CFCwJQM4pZVvq4KoCjsvz+ JudoQXp4svgF6O0FHlT5wUkjll8VmgKO0XlKGzDaTOEr0bHPT1jdiv7J324j4gusEbjh 0zZfBm2TxLxzx142t7UHMVAqWIiErPfP3jwMA0tiYmq924BM3W4bYshcPze4MmmDCtQG TMOw== X-Gm-Message-State: AAQBX9fFEND1TtWKbTteZg7kWeHs9Tuy/r/CDIQOIMzHKk9u0CsdqMo2 lfZd0CEbWW4qLXdvNtaPEROI/snGGqIqvEVLojCdnQ== X-Google-Smtp-Source: AKy350avdbVWsGVTJEoqwRyqNag99g5vZKmmPmU7bIaCh3BaCZvPWonwWwZTz8AQrvNBuH9U/nEhFQ== X-Received: by 2002:a05:6214:252a:b0:5ef:8004:e0b4 with SMTP id gg10-20020a056214252a00b005ef8004e0b4mr19179092qvb.48.1681938842323; Wed, 19 Apr 2023 14:14:02 -0700 (PDT) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id i3-20020ad45383000000b005e3c45c5cbdsm3553974qvv.96.2023.04.19.14.14.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 14:14:01 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 02/11] btrfs-progs: use $SUDO_HELPER in convert tests for temp files Date: Wed, 19 Apr 2023 17:13:44 -0400 Message-Id: X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org While running make test-convert as a normal user I ran into this problem where we do sudo find into a mktemp file that's created as the normal user. This results in find getting a EPERM while trying to mess with that temp file. Fix this by using $SUDO_HELPER for all the tempfile manipulations so that root is the owner of everything, which allows the convert tests to run as a normal user. Signed-off-by: Josef Bacik --- tests/common.convert | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/common.convert b/tests/common.convert index 264972fa..160909eb 100644 --- a/tests/common.convert +++ b/tests/common.convert @@ -113,32 +113,32 @@ convert_test_perm() { _assert_path "$1" PERMTMP="$1" - FILES_LIST=$(mktemp --tmpdir btrfs-progs-convert-filelist.XXXXXX) + FILES_LIST=$($SUDO_HELPER mktemp --tmpdir btrfs-progs-convert-filelist.XXXXXX) run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/test" "bs=$nodesize" \ count=1 status=noxfer >/dev/null 2>&1 run_check_stdout $SUDO_HELPER find "$TEST_MNT" -type f ! -name 'image' -fprint "$FILES_LIST" # Fix directory entries order - sort "$FILES_LIST" -o "$FILES_LIST" - for file in `cat "$FILES_LIST"` ;do + $SUDO_HELPER sort "$FILES_LIST" -o "$FILES_LIST" + for file in `$SUDO_HELPER cat "$FILES_LIST"` ;do run_check_stdout $SUDO_HELPER getfacl --absolute-names "$file" >> "$PERMTMP" done - rm -- "$FILES_LIST" + $SUDO_HELPER rm -- "$FILES_LIST" } # list acls of files on $TEST_MNT # $1: path where the acls will be stored convert_test_acl() { local ACLSTMP ACLTMP="$1" - FILES_LIST=$(mktemp --tmpdir btrfs-progs-convert-filelist.XXXXXX) + FILES_LIST=$($SUDO_HELPER mktemp --tmpdir btrfs-progs-convert-filelist.XXXXXX) run_check_stdout $SUDO_HELPER find "$TEST_MNT/acls" -type f -fprint "$FILES_LIST" # Fix directory entries order - sort "$FILES_LIST" -o "$FILES_LIST" - for file in `cat "$FILES_LIST"`;do + $SUDO_HELPER sort "$FILES_LIST" -o "$FILES_LIST" + for file in `$SUDO_HELPER cat "$FILES_LIST"`;do run_check_stdout $SUDO_HELPER getfattr --absolute-names -d "$file" >> "$ACLTMP" done - rm -- "$FILES_LIST" + $SUDO_HELPER rm -- "$FILES_LIST" } # do conversion with given features and nodesize, fsck afterwards From patchwork Wed Apr 19 21:13:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13217374 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8F10C77B78 for ; Wed, 19 Apr 2023 21:14:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230102AbjDSVOI (ORCPT ); Wed, 19 Apr 2023 17:14:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231254AbjDSVOF (ORCPT ); Wed, 19 Apr 2023 17:14:05 -0400 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B33064C1A for ; Wed, 19 Apr 2023 14:14:04 -0700 (PDT) Received: by mail-qv1-xf2c.google.com with SMTP id oo30so967263qvb.12 for ; Wed, 19 Apr 2023 14:14:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20221208.gappssmtp.com; s=20221208; t=1681938843; x=1684530843; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=SD7EFyz1yLBLPVn7LfRqego19EUivGa1u7H8Jm5a5zk=; b=1vzg6y6KPAe92vfL76UUADSFcIjsGewQdNK9jAQfprZ0GfcxZSszFzRoX3/ejCszn/ WGKnhRg7X9lELjCQYnL8pGNJecenITEzLmNHcDOQ5HST476DlP/ixD+SoGZwDH2gXg7J 0DcfoffnYDgWVctkvLTbgmk5co1yPIcyxue6nJvDSR2haxkW5yY8LZaFOsyPzGn5V6jo ChMIa+hW5kSNhlgyyhkQY1pvC70ebRyqJeGWoxvbkiYW6gbySQRn9R1vePZiQhhjL1oo t1fP2yklTVAL6w21VWOP0Kw4mnBBQf1AfleQw+8trpd80xyzwKETaPsbfGbquN5vHpSN dDHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681938843; x=1684530843; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SD7EFyz1yLBLPVn7LfRqego19EUivGa1u7H8Jm5a5zk=; b=cfMKz5gTaelwZ6geG7czr5aUYCRGVd1Icyr5pRRzJlluPoKbBT49zPHg8AtUSfIwlO ScFQqZ0QMuKLWuw6a+/lGjLJabXlBC6cNx3FcZHyA9dN4zLMXS21kGkDSxHY71f5y7on hwrIY5yUnJBjaKv6MtUVJJ6x65GaTT01dN5ah5x4MEf66n1NtyS0AvE8Zm4V0NXfShiJ FsgWVzRWGZGqDdXb1M9A20vTZq+F+tTCMWgNsMMj8IH5Y5l41gdI4un3A+xi62yRsVCw B5idR5bbULHXC6n00eN7wMlL52c9U2qMEbE5qUkEZl+Nxo6kSNvYUKLpiyo8aJxeFDGT tzuQ== X-Gm-Message-State: AAQBX9eYNqT3vNvKgyfV4Lb9f4dtp+M8Nsy7uvEzYIpagIsQeYKvoRcF FWCIy44ocKj1rm9KHpAC7cimK9Y4gPEJU8ob94HNDg== X-Google-Smtp-Source: AKy350ba4xzRhXf9cDUB9YofuwS6vDrhhfqoUpY/YF/4hDX/DembK3qDTcWYXYD8NZzpmXLJnskEjg== X-Received: by 2002:a05:6214:2305:b0:5f1:6a35:60be with SMTP id gc5-20020a056214230500b005f16a3560bemr7053456qvb.23.1681938843630; Wed, 19 Apr 2023 14:14:03 -0700 (PDT) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id h1-20020a05620a21c100b0074bcf3ac7casm2046904qka.44.2023.04.19.14.14.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 14:14:03 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 03/11] btrfs-progs: re-add __init to include/kerncompat.h Date: Wed, 19 Apr 2023 17:13:45 -0400 Message-Id: <5a4ffce3fba84f2989eed75fe6ef7a96d0bbf0eb.1681938648.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Now that we're properly separated with libbtrfs/kerncompat.h and include/kerncompat.h, go ahead and add the __init definition back so we can have it available for the kernel synced files. Signed-off-by: Josef Bacik --- include/kerncompat.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/kerncompat.h b/include/kerncompat.h index 4dce65c0..62b6a357 100644 --- a/include/kerncompat.h +++ b/include/kerncompat.h @@ -578,11 +578,7 @@ struct work_struct { typedef struct wait_queue_head_s { } wait_queue_head_t; -/* - * __init cannot be defined in kerncompat.h as it's still part of libbtrfs and - * the macro name is too generic and can break build. #define __init -*/ #define __cold #endif From patchwork Wed Apr 19 21:13:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13217376 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97688C6FD18 for ; Wed, 19 Apr 2023 21:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231520AbjDSVOQ (ORCPT ); Wed, 19 Apr 2023 17:14:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229621AbjDSVOJ (ORCPT ); Wed, 19 Apr 2023 17:14:09 -0400 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 139E05BB2 for ; Wed, 19 Apr 2023 14:14:06 -0700 (PDT) Received: by mail-qv1-xf2c.google.com with SMTP id oo30so967320qvb.12 for ; Wed, 19 Apr 2023 14:14:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20221208.gappssmtp.com; s=20221208; t=1681938845; x=1684530845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=SJFHYpzg/BWb0+L36ouRDJHQln9hI+T690Hv7pHjBKg=; b=AR8KJdM4EcHjURB0OJce+qHywHgwXwVY5Pue6fiQpXsYFoHc35MUPMc7VavxJjw/h8 HXG2pgVtdEFxXmTJi2Ie1NbqBkspZMFkcTFk5j0Brlebv2nLm8kb28D/SN6ZsGuqE3x4 xJ1EIgfCLRW1C8e3EZ5MuQQCuwIrNqrSjjvLa9fx8a62QCoE5c0YFrJyMZOvchb858uZ uyn2qqmfnwI+C7QCasPffxZm3AKUXieDoHx3ntzcPsOrKwJAUifG+Ce6gG7NPuGWWd+h zmuKgD2vvPfnkVg4RIohP9A3Ict6wT0grNXagpiAPoHet3srCCYbRrQTvgDdisurhy6+ j+8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681938845; x=1684530845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SJFHYpzg/BWb0+L36ouRDJHQln9hI+T690Hv7pHjBKg=; b=R99t3lmyYJA0bH0M4FdX6a/ISZjTN9aATCu51G1NJrC5I22EYkxV/vKXDwkD/xxwrJ XLwSAPPj8yTKh0dZeuZxFCC7yx5tOke7D9dxaP49oY9cZXnraZavm82Xe1PqdNj34TVt dKn7l+uITFaOTjp1u6GAGyxVNsv+SeIGZh65o19NKB0YxT6X+GPQ2tKZhqRzQPZQt7fv koMua900q7Lyz9XA4L+Y48hh+dHf0KNsJ/UYwOtMGGtsfsWOTVAXMDckhaVLVso9YJqw ceH6xJIqt8A/im0WjjPnm50SRNGZCFerYAmYW1aNZmsrRdxe19WucuyVI5UU2ziiVlTM oAjw== X-Gm-Message-State: AAQBX9c0aZ/FsgdnFvTSxefu1+RBNU9CcaFsjwRjPcOTBM7lA8iSlDTp bLsMQie5Ha7nyS0I0xWokDnLbJ88WBfrGvcEi4l14Q== X-Google-Smtp-Source: AKy350bux3JJbVAYGZZBEuCftweMRGgwjnhmJ4d4ZwCnNh1LLq9qHRbZ+Cvzo4Ee8MB0ZsJqIiNnTQ== X-Received: by 2002:a05:6214:21e5:b0:5e9:752:766b with SMTP id p5-20020a05621421e500b005e90752766bmr33898628qvj.47.1681938845181; Wed, 19 Apr 2023 14:14:05 -0700 (PDT) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id x20-20020a0ce254000000b005f372f4a561sm1608qvl.35.2023.04.19.14.14.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 14:14:04 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 04/11] btrfs-progs: introduce UASSERT() for purely userspace code Date: Wed, 19 Apr 2023 17:13:46 -0400 Message-Id: <7d000d6803f9f2d4c02a858f5d0126dcb684a5c1.1681938648.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org While syncing messages.[ch] I had to back out the ASSERT() code in kerncompat.h, which means we now rely on the kernel code for ASSERT(). In order to maintain some semblance of separation introduce UASSERT() and use that in all the purely userspace code. Signed-off-by: Josef Bacik --- check/clear-cache.c | 4 ++-- check/main.c | 10 +++++----- check/mode-common.c | 12 ++++++------ check/mode-lowmem.c | 20 ++++++++++---------- cmds/filesystem-du.c | 2 +- cmds/filesystem-usage.c | 6 +++--- cmds/qgroup.c | 22 +++++++++++----------- cmds/replace.c | 4 ++-- cmds/rescue-chunk-recover.c | 6 +++--- cmds/rescue.c | 4 ++-- cmds/subvolume-list.c | 20 ++++++++++---------- common/device-utils.c | 4 ++-- common/messages.h | 6 ++++++ common/units.c | 4 ++-- convert/common.c | 4 ++-- convert/main.c | 2 +- image/main.c | 2 +- libbtrfs/send-stream.c | 3 ++- mkfs/main.c | 4 ++-- 19 files changed, 73 insertions(+), 66 deletions(-) diff --git a/check/clear-cache.c b/check/clear-cache.c index 0a3001a4..ecc95167 100644 --- a/check/clear-cache.c +++ b/check/clear-cache.c @@ -505,12 +505,12 @@ int truncate_free_ino_items(struct btrfs_root *root) fi = btrfs_item_ptr(leaf, path.slots[0], struct btrfs_file_extent_item); extent_type = btrfs_file_extent_type(leaf, fi); - ASSERT(extent_type == BTRFS_FILE_EXTENT_REG); + UASSERT(extent_type == BTRFS_FILE_EXTENT_REG); extent_disk_bytenr = btrfs_file_extent_disk_bytenr(leaf, fi); extent_num_bytes = btrfs_file_extent_disk_num_bytes (leaf, fi); extent_offset = found_key.offset - btrfs_file_extent_offset(leaf, fi); - ASSERT(extent_offset == 0); + UASSERT(extent_offset == 0); ret = btrfs_free_extent(trans, root, extent_disk_bytenr, extent_num_bytes, 0, root->objectid, BTRFS_FREE_INO_OBJECTID, 0); diff --git a/check/main.c b/check/main.c index 9a7f40e7..1a9ad50c 100644 --- a/check/main.c +++ b/check/main.c @@ -9680,14 +9680,14 @@ static int build_roots_info_cache(void) rii->level = (u8)-1; entry = &rii->cache_extent; ret = insert_cache_extent(roots_info_cache, entry); - ASSERT(ret == 0); + UASSERT(ret == 0); } else { rii = container_of(entry, struct root_item_info, cache_extent); } - ASSERT(rii->cache_extent.start == root_id); - ASSERT(rii->cache_extent.size == 1); + UASSERT(rii->cache_extent.start == root_id); + UASSERT(rii->cache_extent.size == 1); if (level > rii->level || rii->level == (u8)-1) { rii->level = level; @@ -9726,8 +9726,8 @@ static int maybe_repair_root_item(struct btrfs_path *path, } rii = container_of(entry, struct root_item_info, cache_extent); - ASSERT(rii->cache_extent.start == root_id); - ASSERT(rii->cache_extent.size == 1); + UASSERT(rii->cache_extent.start == root_id); + UASSERT(rii->cache_extent.size == 1); if (rii->node_count != 1) { fprintf(stderr, diff --git a/check/mode-common.c b/check/mode-common.c index c8ac235d..ef272368 100644 --- a/check/mode-common.c +++ b/check/mode-common.c @@ -224,8 +224,8 @@ int check_prealloc_extent_written(u64 disk_bytenr, u64 num_bytes) iref = (struct btrfs_extent_inline_ref *)ptr; type = btrfs_extent_inline_ref_type(path.nodes[0], iref); - ASSERT(type == BTRFS_EXTENT_DATA_REF_KEY || - type == BTRFS_SHARED_DATA_REF_KEY); + UASSERT(type == BTRFS_EXTENT_DATA_REF_KEY || + type == BTRFS_SHARED_DATA_REF_KEY); if (type == BTRFS_EXTENT_DATA_REF_KEY) { struct btrfs_extent_data_ref *dref; @@ -398,7 +398,7 @@ int insert_inode_item(struct btrfs_trans_handle *trans, btrfs_set_stack_timespec_sec(&ii.mtime, now); ret = btrfs_insert_inode(trans, root, ino, &ii); - ASSERT(!ret); + UASSERT(!ret); warning("root %llu inode %llu recreating inode item, this may " "be incomplete, please check permissions and content after " @@ -985,7 +985,7 @@ int repair_imode_common(struct btrfs_root *root, struct btrfs_path *path) int ret; btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); - ASSERT(key.type == BTRFS_INODE_ITEM_KEY); + UASSERT(key.type == BTRFS_INODE_ITEM_KEY); if (root->objectid == BTRFS_ROOT_TREE_OBJECTID) { /* In root tree we only have two possible imode */ if (key.objectid == BTRFS_ROOT_TREE_OBJECTID) @@ -1033,7 +1033,7 @@ int check_repair_free_space_inode(struct btrfs_path *path) int ret = 0; btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); - ASSERT(key.type == BTRFS_INODE_ITEM_KEY && is_fstree(key.objectid)); + UASSERT(key.type == BTRFS_INODE_ITEM_KEY && is_fstree(key.objectid)); iitem = btrfs_item_ptr(path->nodes[0], path->slots[0], struct btrfs_inode_item); mode = btrfs_inode_mode(path->nodes[0], iitem); @@ -1607,7 +1607,7 @@ static int get_num_devs_in_chunk_tree(struct btrfs_fs_info *fs_info) return ret; /* We should be the first slot, and chunk tree should not be empty*/ - ASSERT(path.slots[0] == 0 && btrfs_header_nritems(path.nodes[0])); + UASSERT(path.slots[0] == 0 && btrfs_header_nritems(path.nodes[0])); btrfs_item_key_to_cpu(path.nodes[0], &key, path.slots[0]); diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c index 10258d34..f0e5f8d6 100644 --- a/check/mode-lowmem.c +++ b/check/mode-lowmem.c @@ -833,7 +833,7 @@ static int find_dir_index(struct btrfs_root *root, u64 dirid, u64 location_id, int slot; int ret; - ASSERT(index_ret); + UASSERT(index_ret); /* search from the last index */ key.objectid = dirid; @@ -1029,7 +1029,7 @@ static int repair_ternary_lowmem(struct btrfs_root *root, u64 dir_ino, u64 ino, stage++; /* stage must be smllarer than 3 */ - ASSERT(stage < 3); + UASSERT(stage < 3); trans = btrfs_start_transaction(root, 1); if (stage == 2) { @@ -1351,7 +1351,7 @@ static int find_inode_ref(struct btrfs_root *root, struct btrfs_key *key, int slot; int ret; - ASSERT(index_ret); + UASSERT(index_ret); btrfs_init_path(&path); ret = btrfs_search_slot(NULL, root, key, &path, 0, 0); @@ -1945,7 +1945,7 @@ recover: recover_ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); /* This really shouldn't happen, or we have a big problem */ - ASSERT(recover_ret == 0); + UASSERT(recover_ret == 0); return ret; } @@ -2193,7 +2193,7 @@ static int __count_dir_isize(struct btrfs_root *root, u64 ino, int type, int cur = 0; int total = 0; - ASSERT(size_ret); + UASSERT(size_ret); *size_ret = 0; key.objectid = ino; @@ -2247,7 +2247,7 @@ static int count_dir_isize(struct btrfs_root *root, u64 ino, u64 *size) u64 index_size; int ret; - ASSERT(size); + UASSERT(size); ret = __count_dir_isize(root, ino, BTRFS_DIR_ITEM_KEY, &item_size); if (ret) goto out; @@ -2451,7 +2451,7 @@ static int repair_inode_nlinks_lowmem(struct btrfs_root *root, btrfs_item_key_to_cpu(path->nodes[0], &old_key, path->slots[0]); if (name && namelen) { - ASSERT(namelen <= BTRFS_NAME_LEN); + UASSERT(namelen <= BTRFS_NAME_LEN); memcpy(namebuf, name, namelen); name_len = namelen; } else { @@ -2550,7 +2550,7 @@ static int repair_inode_gen_lowmem(struct btrfs_root *root, } transid = trans->transid; btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); - ASSERT(key.type == BTRFS_INODE_ITEM_KEY); + UASSERT(key.type == BTRFS_INODE_ITEM_KEY); btrfs_release_path(path); @@ -4188,8 +4188,8 @@ static int repair_extent_item_generation(struct btrfs_path *path) int ret; btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); - ASSERT(key.type == BTRFS_METADATA_ITEM_KEY || - key.type == BTRFS_EXTENT_ITEM_KEY); + UASSERT(key.type == BTRFS_METADATA_ITEM_KEY || + key.type == BTRFS_EXTENT_ITEM_KEY); get_extent_item_generation(key.objectid, &new_gen); ret = avoid_extents_overwrite(); diff --git a/cmds/filesystem-du.c b/cmds/filesystem-du.c index 0e1210e0..33b6d901 100644 --- a/cmds/filesystem-du.c +++ b/cmds/filesystem-du.c @@ -87,7 +87,7 @@ static int add_shared_extent(u64 start, u64 len, struct rb_root *root) { struct shared_extent *sh; - ASSERT(len != 0); + UASSERT(len != 0); sh = calloc(1, sizeof(*sh)); if (!sh) diff --git a/cmds/filesystem-usage.c b/cmds/filesystem-usage.c index e483c104..d1e7eed1 100644 --- a/cmds/filesystem-usage.c +++ b/cmds/filesystem-usage.c @@ -383,15 +383,15 @@ static void get_raid56_space_info(struct btrfs_ioctl_space_args *sargs, size = info_ptr->size / (info_ptr->num_stripes - parities_count); if (info_ptr->type & BTRFS_BLOCK_GROUP_DATA) { - ASSERT(l_data_ratio >= 0); + UASSERT(l_data_ratio >= 0); *r_data_chunks += size; *r_data_used += size * l_data_ratio; } else if (info_ptr->type & BTRFS_BLOCK_GROUP_METADATA) { - ASSERT(l_metadata_ratio >= 0); + UASSERT(l_metadata_ratio >= 0); *r_metadata_chunks += size; *r_metadata_used += size * l_metadata_ratio; } else if (info_ptr->type & BTRFS_BLOCK_GROUP_SYSTEM) { - ASSERT(l_system_ratio >= 0); + UASSERT(l_system_ratio >= 0); *r_system_chunks += size; *r_system_used += size * l_system_ratio; } diff --git a/cmds/qgroup.c b/cmds/qgroup.c index 49014d57..125362b8 100644 --- a/cmds/qgroup.c +++ b/cmds/qgroup.c @@ -222,7 +222,7 @@ static void qgroup_setup_print_column(enum btrfs_qgroup_column_enum column) { int i; - ASSERT(0 <= column && column <= BTRFS_QGROUP_ALL); + UASSERT(0 <= column && column <= BTRFS_QGROUP_ALL); if (column < BTRFS_QGROUP_ALL) { btrfs_qgroup_columns[column].need_print = 1; @@ -332,7 +332,7 @@ static void print_qgroup_column(struct btrfs_qgroup *qgroup, int unit_mode = btrfs_qgroup_columns[column].unit_mode; int max_len = btrfs_qgroup_columns[column].max_len; - ASSERT(0 <= column && column < BTRFS_QGROUP_ALL); + UASSERT(0 <= column && column < BTRFS_QGROUP_ALL); switch (column) { @@ -617,9 +617,9 @@ static int qgroup_setup_comparer(struct btrfs_qgroup_comparer_set **comp_set, struct btrfs_qgroup_comparer_set *set = *comp_set; int size; - ASSERT(set != NULL); - ASSERT(comparer < BTRFS_QGROUP_COMP_MAX); - ASSERT(set->ncomps <= set->total); + UASSERT(set != NULL); + UASSERT(comparer < BTRFS_QGROUP_COMP_MAX); + UASSERT(set->ncomps <= set->total); if (set->ncomps == set->total) { void *tmp; @@ -641,7 +641,7 @@ static int qgroup_setup_comparer(struct btrfs_qgroup_comparer_set **comp_set, *comp_set = set; } - ASSERT(set->comps[set->ncomps].comp_func == NULL); + UASSERT(set->comps[set->ncomps].comp_func == NULL); set->comps[set->ncomps].comp_func = all_comp_funcs[comparer]; set->comps[set->ncomps].is_descending = is_descending; @@ -1014,9 +1014,9 @@ static int qgroup_setup_filter(struct btrfs_qgroup_filter_set **filter_set, struct btrfs_qgroup_filter_set *set = *filter_set; int size; - ASSERT(set != NULL); - ASSERT(filter < BTRFS_QGROUP_FILTER_MAX); - ASSERT(set->nfilters <= set->total); + UASSERT(set != NULL); + UASSERT(filter < BTRFS_QGROUP_FILTER_MAX); + UASSERT(set->nfilters <= set->total); if (set->nfilters == set->total) { void *tmp; @@ -1038,7 +1038,7 @@ static int qgroup_setup_filter(struct btrfs_qgroup_filter_set **filter_set, *filter_set = set; } - ASSERT(set->filters[set->nfilters].filter_func == NULL); + UASSERT(set->filters[set->nfilters].filter_func == NULL); set->filters[set->nfilters].filter_func = all_filter_funcs[filter]; set->filters[set->nfilters].data = data; set->nfilters++; @@ -1114,7 +1114,7 @@ static void __update_columns_max_len(struct btrfs_qgroup *bq, int len; unsigned unit_mode = btrfs_qgroup_columns[column].unit_mode; - ASSERT(0 <= column && column < BTRFS_QGROUP_ALL); + UASSERT(0 <= column && column < BTRFS_QGROUP_ALL); switch (column) { diff --git a/cmds/replace.c b/cmds/replace.c index ad914306..2748b7fb 100644 --- a/cmds/replace.c +++ b/cmds/replace.c @@ -519,7 +519,7 @@ time2string(char *buf, size_t s, __u64 t) time_t t_time_t; t_time_t = (time_t)t; - ASSERT((__u64)t_time_t == t); + UASSERT((__u64)t_time_t == t); localtime_r(&t_time_t, &t_tm); strftime(buf, s, "%e.%b %T", &t_tm); return buf; @@ -529,7 +529,7 @@ static char * progress2string(char *buf, size_t s, int progress_1000) { snprintf(buf, s, "%d.%01d%%", progress_1000 / 10, progress_1000 % 10); - ASSERT(s > 0); + UASSERT(s > 0); buf[s - 1] = '\0'; return buf; } diff --git a/cmds/rescue-chunk-recover.c b/cmds/rescue-chunk-recover.c index 500509fd..6a1b6734 100644 --- a/cmds/rescue-chunk-recover.c +++ b/cmds/rescue-chunk-recover.c @@ -1455,7 +1455,7 @@ open_ctree_with_broken_chunk(struct recover_control *rc) goto out_devices; } - ASSERT(!memcmp(disk_super->fsid, rc->fs_devices->fsid, BTRFS_FSID_SIZE)); + UASSERT(!memcmp(disk_super->fsid, rc->fs_devices->fsid, BTRFS_FSID_SIZE)); fs_info->sectorsize = btrfs_super_sectorsize(disk_super); fs_info->nodesize = btrfs_super_nodesize(disk_super); fs_info->stripesize = btrfs_super_stripesize(disk_super); @@ -1467,7 +1467,7 @@ open_ctree_with_broken_chunk(struct recover_control *rc) features = btrfs_super_incompat_flags(disk_super); if (features & BTRFS_FEATURE_INCOMPAT_METADATA_UUID) - ASSERT(!memcmp(disk_super->metadata_uuid, + UASSERT(!memcmp(disk_super->metadata_uuid, fs_info->fs_devices->metadata_uuid, BTRFS_FSID_SIZE)); @@ -1869,7 +1869,7 @@ static int check_one_csum(int fd, u64 start, u32 len, u32 tree_csum, int csum_size = 0; u8 expected_csum[BTRFS_CSUM_SIZE]; - ASSERT(0); + UASSERT(0); data = malloc(len); if (!data) diff --git a/cmds/rescue.c b/cmds/rescue.c index 28a54a65..cbeaa6f2 100644 --- a/cmds/rescue.c +++ b/cmds/rescue.c @@ -322,8 +322,8 @@ static int clear_uuid_tree(struct btrfs_fs_info *fs_info) ret = btrfs_search_slot(trans, uuid_root, &key, &path, -1, 1); if (ret < 0) goto out; - ASSERT(ret > 0); - ASSERT(path.slots[0] == 0); + UASSERT(ret > 0); + UASSERT(path.slots[0] == 0); nr = btrfs_header_nritems(path.nodes[0]); if (nr == 0) { diff --git a/cmds/subvolume-list.c b/cmds/subvolume-list.c index 750fc4e6..e0a7b339 100644 --- a/cmds/subvolume-list.c +++ b/cmds/subvolume-list.c @@ -284,7 +284,7 @@ void btrfs_list_setup_print_column(enum btrfs_list_column_enum column) { int i; - ASSERT(0 <= column && column <= BTRFS_LIST_ALL); + UASSERT(0 <= column && column <= BTRFS_LIST_ALL); if (column < BTRFS_LIST_ALL) { btrfs_list_columns[column].need_print = 1; @@ -367,9 +367,9 @@ static int btrfs_list_setup_comparer(struct btrfs_list_comparer_set **comp_set, struct btrfs_list_comparer_set *set = *comp_set; int size; - ASSERT(set != NULL); - ASSERT(comparer < BTRFS_LIST_COMP_MAX); - ASSERT(set->ncomps <= set->total); + UASSERT(set != NULL); + UASSERT(comparer < BTRFS_LIST_COMP_MAX); + UASSERT(set->ncomps <= set->total); if (set->ncomps == set->total) { void *tmp; @@ -391,7 +391,7 @@ static int btrfs_list_setup_comparer(struct btrfs_list_comparer_set **comp_set, *comp_set = set; } - ASSERT(set->comps[set->ncomps].comp_func == NULL); + UASSERT(set->comps[set->ncomps].comp_func == NULL); set->comps[set->ncomps].comp_func = all_comp_funcs[comparer]; set->comps[set->ncomps].is_descending = is_descending; @@ -1027,9 +1027,9 @@ static void btrfs_list_setup_filter(struct btrfs_list_filter_set **filter_set, struct btrfs_list_filter_set *set = *filter_set; int size; - ASSERT(set != NULL); - ASSERT(filter < BTRFS_LIST_FILTER_MAX); - ASSERT(set->nfilters <= set->total); + UASSERT(set != NULL); + UASSERT(filter < BTRFS_LIST_FILTER_MAX); + UASSERT(set->nfilters <= set->total); if (set->nfilters == set->total) { void *tmp; @@ -1051,7 +1051,7 @@ static void btrfs_list_setup_filter(struct btrfs_list_filter_set **filter_set, *filter_set = set; } - ASSERT(set->filters[set->nfilters].filter_func == NULL); + UASSERT(set->filters[set->nfilters].filter_func == NULL); if (filter == BTRFS_LIST_FILTER_DELETED) set->only_deleted = 1; @@ -1129,7 +1129,7 @@ static void print_subvolume_column(struct root_info *subv, char tstr[256]; char uuidparse[BTRFS_UUID_UNPARSED_SIZE]; - ASSERT(0 <= column && column < BTRFS_LIST_ALL); + UASSERT(0 <= column && column < BTRFS_LIST_ALL); switch (column) { case BTRFS_LIST_OBJECTID: diff --git a/common/device-utils.c b/common/device-utils.c index cb1a7a9d..2e8aeb8b 100644 --- a/common/device-utils.c +++ b/common/device-utils.c @@ -539,7 +539,7 @@ ssize_t btrfs_direct_pio(int rw, int fd, void *buf, size_t count, off_t offset) int ret; ssize_t ret_rw; - ASSERT(rw == READ || rw == WRITE); + UASSERT(rw == READ || rw == WRITE); if (fstat(fd, &stat_buf) == -1) { error("fstat failed: %m"); @@ -579,7 +579,7 @@ ssize_t btrfs_direct_pio(int rw, int fd, void *buf, size_t count, off_t offset) } if (rw == WRITE) { - ASSERT(iosize == count); + UASSERT(iosize == count); memcpy(bounce_buf, buf, count); ret_rw = pwrite(fd, bounce_buf, iosize, offset); } else { diff --git a/common/messages.h b/common/messages.h index da97c045..b512544f 100644 --- a/common/messages.h +++ b/common/messages.h @@ -145,4 +145,10 @@ enum common_error { __attribute__ ((format (printf, 2, 3))) void error_msg(enum common_error error, const char *msg, ...); +#ifndef BTRFS_DISABLE_BACKTRACE +#define UASSERT(c) assert_trace(#c, __FILE__, __func__, __LINE__, (long)(c)) +#else +#define UASSERT(c) assert(c) +#endif + #endif diff --git a/common/units.c b/common/units.c index 8d708cdd..27eac098 100644 --- a/common/units.c +++ b/common/units.c @@ -79,7 +79,7 @@ int pretty_size_snprintf(u64 size, char *str, size_t str_size, unsigned unit_mod /* Unknown mode */ if (!base) { internal_error("unknown unit base, mode %u", unit_mode); - ASSERT(0); + UASSERT(0); return -1; } @@ -135,7 +135,7 @@ int pretty_size_snprintf(u64 size, char *str, size_t str_size, unsigned unit_mod if (num_divs >= ARRAY_SIZE(unit_suffix_binary)) { str[0] = '\0'; internal_error("unsupported unit suffix, index %d", num_divs); - ASSERT(0); + UASSERT(0); return -1; } diff --git a/convert/common.c b/convert/common.c index 1a85085f..f104d93f 100644 --- a/convert/common.c +++ b/convert/common.c @@ -44,7 +44,7 @@ static int reserve_free_space(struct cache_tree *free_tree, u64 len, struct cache_extent *cache; int found = 0; - ASSERT(ret_start != NULL); + UASSERT(ret_start != NULL); cache = first_cache_extent(free_tree); while (cache) { if (cache->size > len) { @@ -807,7 +807,7 @@ int make_convert_btrfs(int fd, struct btrfs_mkfs_config *cfg, int ret; /* Source filesystem must be opened, checked and analyzed in advance */ - ASSERT(!cache_tree_empty(used_space)); + UASSERT(!cache_tree_empty(used_space)); /* * reserve space for temporary superblock first diff --git a/convert/main.c b/convert/main.c index 3f54ea30..16520914 100644 --- a/convert/main.c +++ b/convert/main.c @@ -1167,7 +1167,7 @@ static int do_convert(const char *devname, u32 convert_flags, u32 nodesize, if (ret) goto fail; - ASSERT(cctx.total_bytes != 0); + UASSERT(cctx.total_bytes != 0); blocksize = cctx.blocksize; if (blocksize < 4096) { error("block size is too small: %u < 4096", blocksize); diff --git a/image/main.c b/image/main.c index 43ee660d..7fa215c1 100644 --- a/image/main.c +++ b/image/main.c @@ -1399,7 +1399,7 @@ static int restore_one_work(struct mdrestore_struct *mdres, int compress_method = mdres->compress_method; int ret; - ASSERT(is_power_of_2(bufsize)); + UASSERT(is_power_of_2(bufsize)); if (compress_method == COMPRESS_ZLIB) { strm.zalloc = Z_NULL; diff --git a/libbtrfs/send-stream.c b/libbtrfs/send-stream.c index 2e89814a..16aef3ab 100644 --- a/libbtrfs/send-stream.c +++ b/libbtrfs/send-stream.c @@ -26,6 +26,7 @@ #include "libbtrfs/send-stream.h" #include "libbtrfs/ctree.h" #include "libbtrfs/crc32c.h" +#include "common/messages.h" struct btrfs_send_stream { char read_buf[BTRFS_SEND_BUF_SIZE]; @@ -108,7 +109,7 @@ static int read_cmd(struct btrfs_send_stream *sctx) memset(sctx->cmd_attrs, 0, sizeof(sctx->cmd_attrs)); - ASSERT(sizeof(*sctx->cmd_hdr) <= sizeof(sctx->read_buf)); + UASSERT(sizeof(*sctx->cmd_hdr) <= sizeof(sctx->read_buf)); ret = read_buf(sctx, sctx->read_buf, sizeof(*sctx->cmd_hdr)); if (ret < 0) goto out; diff --git a/mkfs/main.c b/mkfs/main.c index 686c6b2f..4856cf96 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -272,7 +272,7 @@ static int __recow_root(struct btrfs_trans_handle *trans, struct btrfs_root *roo goto out; ret = 0; btrfs_item_key_to_cpu(path.nodes[0], &found_key, 0); - ASSERT(btrfs_comp_cpu_keys(&key, &found_key) == 0); + UASSERT(btrfs_comp_cpu_keys(&key, &found_key) == 0); next: ret = btrfs_next_leaf(root, &path); @@ -782,7 +782,7 @@ static int create_uuid_tree(struct btrfs_trans_handle *trans) }; int ret = 0; - ASSERT(fs_info->uuid_root == NULL); + UASSERT(fs_info->uuid_root == NULL); root = btrfs_create_tree(trans, fs_info, &key); if (IS_ERR(root)) { ret = PTR_ERR(root); From patchwork Wed Apr 19 21:13:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13217375 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF78CC77B78 for ; Wed, 19 Apr 2023 21:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230195AbjDSVOS (ORCPT ); Wed, 19 Apr 2023 17:14:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229739AbjDSVON (ORCPT ); Wed, 19 Apr 2023 17:14:13 -0400 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4F536A66 for ; Wed, 19 Apr 2023 14:14:07 -0700 (PDT) Received: by mail-qv1-xf35.google.com with SMTP id m16so993820qvx.9 for ; Wed, 19 Apr 2023 14:14:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20221208.gappssmtp.com; s=20221208; t=1681938846; x=1684530846; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=VZPuTKMf29prda0AlpX7LFRIYMCQ9eqOXnvIkO1GWUI=; b=g6PhRLv43QNTVE/1mn+ib47qTnp/ZWpn7Xihy9sJDl2ua1uboNKT16HN3Yu4evvxfH hUa0ggep/JExU8FmiLnliaWy6poNkDKbh4h8JxLo+4hU7DiEbjfw/OtuhOjrA7Tx+fiu XVwG0ANJvT4T+x19aoPS24Oq4kyvduAvz8AmegPXvZZMjYVXsGBU81z+lRWMiFRiRx2u lfnAHSIICEasW/LFQGv0+oVEoW6aXzJH6JDV4uSUUqrM+yyarbzpQ5KyOTin/hDDGGau XdYb4qL81G1raRAAqwREoJGmK5v5QK2f+L+M9GYma4MqVzM8XFE98qukh8lLa4PVYly2 ZymQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681938846; x=1684530846; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VZPuTKMf29prda0AlpX7LFRIYMCQ9eqOXnvIkO1GWUI=; b=ErVxcLB0g8taz4dcNfIDc0Dn0N1Fvsm+WbL370sJfwsjpl+wGQSdk113WENjf+/o6P RiN14V6hHhdApAFemBvI02i/vbF4tUP1Gp8hze08SftdjcL9tCGIjEPHbIaShpwAY+sQ el0l1Dhn+Q4hkD9To9liSYVyCsQbapmrHx69FlzV7wTu8LvxdkOs2d+EXh3RbMoCtAxI l6TVHP5MvHd7suMFElzKhBFus4sjjryFFsyrMAt/wmnrqnRVEh3SRXeGc2unqB2OEzmB ZsUbHruoGb7+ZPBej4GezBrXfngfxHdtbG9fZwcjo2O+L4oB6613KtO7vnDekCmcD/an dNEA== X-Gm-Message-State: AAQBX9fld1M/TZt0aBdheGp2jYgzpHZQBefjHa6fSgvT1yPzRs228ZP0 7qB9Om4O0kGDmuloV0+WUfveU7LGTPE0wgrr2i6fQg== X-Google-Smtp-Source: AKy350b44mqYcrjeW468KISOC+ECalofzIEfpFCVSIisOavfG/v95u+LvL6USRak7QSoEIh+zKPzUA== X-Received: by 2002:a05:6214:c66:b0:5b8:6efe:77f4 with SMTP id t6-20020a0562140c6600b005b86efe77f4mr31973047qvj.46.1681938846456; Wed, 19 Apr 2023 14:14:06 -0700 (PDT) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id l19-20020a0ce093000000b005eee5f1f30bsm327qvk.46.2023.04.19.14.14.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 14:14:06 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 05/11] btrfs-progs: move BTRFS_DISABLE_BACKTRACE check in print_trace Date: Wed, 19 Apr 2023 17:13:47 -0400 Message-Id: X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Everybody who calls print_trace wraps it around this check, move the check instead to print_trace and remove the check from all the callers. Signed-off-by: Josef Bacik --- common/messages.c | 3 --- include/kerncompat.h | 10 +++------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/common/messages.c b/common/messages.c index 2d9d55c0..4ef7a34a 100644 --- a/common/messages.c +++ b/common/messages.c @@ -96,10 +96,7 @@ void internal_error(const char *fmt, ...) vfprintf(stderr, fmt, vargs); va_end(vargs); fputc('\n', stderr); - -#ifndef BTRFS_DISABLE_BACKTRACE print_trace(); -#endif } static bool should_print(int level) diff --git a/include/kerncompat.h b/include/kerncompat.h index 62b6a357..cb2a9400 100644 --- a/include/kerncompat.h +++ b/include/kerncompat.h @@ -94,17 +94,17 @@ #define BUILD_ASSERT(x) #endif -#ifndef BTRFS_DISABLE_BACKTRACE -#define MAX_BACKTRACE 16 static inline void print_trace(void) { +#ifndef BTRFS_DISABLE_BACKTRACE +#define MAX_BACKTRACE 16 void *array[MAX_BACKTRACE]; int size; size = backtrace(array, MAX_BACKTRACE); backtrace_symbols_fd(array, size, 2); -} #endif +} static inline void warning_trace(const char *assertion, const char *filename, const char *func, unsigned line, long val) @@ -114,9 +114,7 @@ static inline void warning_trace(const char *assertion, const char *filename, fprintf(stderr, "%s:%u: %s: Warning: assertion `%s` failed, value %ld\n", filename, line, func, assertion, val); -#ifndef BTRFS_DISABLE_BACKTRACE print_trace(); -#endif } static inline void bugon_trace(const char *assertion, const char *filename, @@ -127,9 +125,7 @@ static inline void bugon_trace(const char *assertion, const char *filename, fprintf(stderr, "%s:%u: %s: BUG_ON `%s` triggered, value %ld\n", filename, line, func, assertion, val); -#ifndef BTRFS_DISABLE_BACKTRACE print_trace(); -#endif abort(); exit(1); } From patchwork Wed Apr 19 21:13:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13217378 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A571BC77B73 for ; Wed, 19 Apr 2023 21:14:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231347AbjDSVOj (ORCPT ); Wed, 19 Apr 2023 17:14:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231411AbjDSVOO (ORCPT ); Wed, 19 Apr 2023 17:14:14 -0400 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE33A8A42 for ; Wed, 19 Apr 2023 14:14:08 -0700 (PDT) Received: by mail-qv1-xf30.google.com with SMTP id oo30so967404qvb.12 for ; Wed, 19 Apr 2023 14:14:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20221208.gappssmtp.com; s=20221208; t=1681938848; x=1684530848; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Wp7JRuy1EErxfwqeKDMuoBMSJHlCf3KZHOe0EPEXt7Y=; b=T2Uf62MHAwawIn+KQOX9hKH+ebyjz0j6tF8Klv7FxlcPKISlH0fu20ryFr/7L63blV 8X7FXobtZiicty1rhyCoQalchOwmG3j+XH0L0UFyz/LZK7ghDSEWmjaYlQiJfx7F7EKX RcaKkrXDw1AjyQSQImsnKcytOH1kdgNHyb23D5WDA53QlXTN/NouWy1I/5906xptYfA6 dmnNpbHnv713XneQvhbFbDRbgAynv4B549TK9zgs78Zv8+foR2yDrxfyWTjlmAogJczR Nt9Py0yUJDjdwE7sqJzaeApguJScJ/c6gMGqJbZvmHKYCrdW/KmYMkLjXpxGshOSpv6k FrXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681938848; x=1684530848; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wp7JRuy1EErxfwqeKDMuoBMSJHlCf3KZHOe0EPEXt7Y=; b=Ps4pSJXFXvT0rOXuWPFtI8j3hHr9ZIz3rbzXru8h3LYnTA12nqBT44LgvvkvWrcXvw VOx/9ic8d8VuY7PAxcTquod9dArAYoLqX3EcExLVCMAVJ50oolRd3Pu1ziWzmF0MGWRF bRunDbFDsQK7khitEMsiKM8yDYm9E+ZsSz+WRktJuSovH1hYpXnu3jfvLXKto1YRoegK ywuDokmOmStIoSK5WY9MS/vBYGbweZlID4uciYSH+sMc9PA/kX+SY2Xt0JoDpBLUm5Uk NE4awmoYnaWpmCEdV5Uh4v5DfkbsI8QXJsGRMO6XitbzCSUJNvLCofJZ+FnrrtPablf6 X9Ig== X-Gm-Message-State: AAQBX9dKMCMsi7pyGakCd5FS1qb+c2sHyg8Fw+8OObfdx76Ce3moS5Xk jqGlivAJJ7JhTR4FKP6oMNoyZ8hyap4RgVqtnUr2dw== X-Google-Smtp-Source: AKy350aHxHo1r15noBlojZZC5/VmmDnZR+2bathopwu0HRoRg+h5IrDSe6jPhSTbWnTWqhvH0OHXvg== X-Received: by 2002:a05:6214:2a89:b0:5d1:acb8:f126 with SMTP id jr9-20020a0562142a8900b005d1acb8f126mr26006986qvb.38.1681938847811; Wed, 19 Apr 2023 14:14:07 -0700 (PDT) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id bj30-20020a05620a191e00b007486aae42fasm4942966qkb.33.2023.04.19.14.14.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 14:14:07 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 06/11] btrfs-progs: remove the _on() related message helpers Date: Wed, 19 Apr 2023 17:13:48 -0400 Message-Id: X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org We have different helpers for warning_on and error_on(), which take the condition and then do the printf. However we can just check the condition in the macro and call the normal warning or error helper, so clean this usage up and delete the unneeded message helpers. Signed-off-by: Josef Bacik --- common/messages.c | 34 ---------------------------------- common/messages.h | 20 ++++++-------------- 2 files changed, 6 insertions(+), 48 deletions(-) diff --git a/common/messages.c b/common/messages.c index 4ef7a34a..5e7f2dfa 100644 --- a/common/messages.c +++ b/common/messages.c @@ -52,40 +52,6 @@ void __btrfs_error(const char *fmt, ...) fputc('\n', stderr); } -__attribute__ ((format (printf, 2, 3))) -int __btrfs_warning_on(int condition, const char *fmt, ...) -{ - va_list args; - - if (!condition) - return 0; - - fputs(PREFIX_WARNING, stderr); - va_start(args, fmt); - vfprintf(stderr, fmt, args); - va_end(args); - fputc('\n', stderr); - - return 1; -} - -__attribute__ ((format (printf, 2, 3))) -int __btrfs_error_on(int condition, const char *fmt, ...) -{ - va_list args; - - if (!condition) - return 0; - - fputs(PREFIX_ERROR, stderr); - va_start(args, fmt); - vfprintf(stderr, fmt, args); - va_end(args); - fputc('\n', stderr); - - return 1; -} - __attribute__ ((format (printf, 1, 2))) void internal_error(const char *fmt, ...) { diff --git a/common/messages.h b/common/messages.h index b512544f..6a105484 100644 --- a/common/messages.h +++ b/common/messages.h @@ -50,13 +50,11 @@ #define error_on(cond, fmt, ...) \ do { \ - if ((cond)) \ + if ((cond)) { \ PRINT_TRACE_ON_ERROR; \ - if ((cond)) \ PRINT_VERBOSE_ERROR; \ - __btrfs_error_on((cond), (fmt), ##__VA_ARGS__); \ - if ((cond)) \ - DO_ABORT_ON_ERROR; \ + __btrfs_error((fmt), ##__VA_ARGS__); \ + } \ } while (0) #define error_btrfs_util(err) \ @@ -81,11 +79,11 @@ #define warning_on(cond, fmt, ...) \ do { \ - if ((cond)) \ + if ((cond)) { \ PRINT_TRACE_ON_ERROR; \ - if ((cond)) \ PRINT_VERBOSE_ERROR; \ - __btrfs_warning_on((cond), (fmt), ##__VA_ARGS__); \ + __btrfs_warning((fmt), ##__VA_ARGS__); \ + } \ } while (0) __attribute__ ((format (printf, 1, 2))) @@ -94,12 +92,6 @@ void __btrfs_warning(const char *fmt, ...); __attribute__ ((format (printf, 1, 2))) void __btrfs_error(const char *fmt, ...); -__attribute__ ((format (printf, 2, 3))) -int __btrfs_warning_on(int condition, const char *fmt, ...); - -__attribute__ ((format (printf, 2, 3))) -int __btrfs_error_on(int condition, const char *fmt, ...); - __attribute__ ((format (printf, 1, 2))) void internal_error(const char *fmt, ...); From patchwork Wed Apr 19 21:13:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13217377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FCA7C77B78 for ; Wed, 19 Apr 2023 21:14:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229978AbjDSVOh (ORCPT ); Wed, 19 Apr 2023 17:14:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231446AbjDSVOO (ORCPT ); Wed, 19 Apr 2023 17:14:14 -0400 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D57B7680 for ; Wed, 19 Apr 2023 14:14:10 -0700 (PDT) Received: by mail-qt1-x82c.google.com with SMTP id ay32so50849qtb.0 for ; Wed, 19 Apr 2023 14:14:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20221208.gappssmtp.com; s=20221208; t=1681938849; x=1684530849; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=wn5ETOHgeL99ji5uW62ENcETMqZPjSkdK0pWCTqtEio=; b=LukgFlt1IpVsnnsAxKG/S8cVu1KiPP6nIE8EjRd0IqInC9QqiLFoCzcXUxyPnpEDoL WJQ23ov5diSrdqkqFd+VYMYrAYQ6ilI+BqXw4Yr5zLf1T+PS8Quszz1V7+4GF6moJSdZ Sc9L2NzXrcXT0RHY54BkZ/HRmGpNn5R2mT+zgZeLdNQORRjY8UzZIdd+38/+ge1anFNQ cFKCTVdMhjrQDa1M+7yjgTVHZ2/u+vl5S9Mi1xjkNDEv4NPmXoeq7aXV3bswjmdzGK93 AFrpczfTZ+4TldzxWW8tt/arg+1q4mXcnxDP/oyaC8lTEZMML4M0mLkAxuEoNiDe2meJ 3GuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681938849; x=1684530849; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wn5ETOHgeL99ji5uW62ENcETMqZPjSkdK0pWCTqtEio=; b=iViFRztkuil7qwAWJE9OuTZsWWhKT2EgjFBSJxErq/WnVYPRKJdpA/Y/IER3lWgEIJ yCFBLWRpP6iqwodfwVisRJswxMV3jGirtnbr34pX39d6TMUXmHZnzDVgJdUBOJtEsqhx sRqrQA8t3wroYFbXCaprwkwPHHLWq5CUYEnyWYQ+16W+PwYXj3azmG5mN75Y5VNRRV4O fQd9luDcB/jqCoYOqoYuizbvUNfE9CmBgDPL/8Z9CgtAKYhHmxnYLD9K8EngV92i55U5 2UL/JnVECywYRCyXxuGKWFCihvfA7k9yd2hiH3LEugPx6t5gD3R5Cs7cGkV7jbxrm0Bt D+1g== X-Gm-Message-State: AAQBX9cUIZUPO7hv1y7gwu7jwse/tbT/UptJ4cvxMJMN5nFHJwlhxG+r NzZxJJpOmAeH4D7/wh/GiPpUZnINh9m0RxQkh1om7A== X-Google-Smtp-Source: AKy350arUOoLH+N/qfWjo0uymRqXxfzYOs4TZzN3gu2z56ch+QxcnkpuGMXVrGM5NdRkIxxP8I1Qtg== X-Received: by 2002:ac8:5f0b:0:b0:3e6:4069:9136 with SMTP id x11-20020ac85f0b000000b003e640699136mr7054851qta.45.1681938849159; Wed, 19 Apr 2023 14:14:09 -0700 (PDT) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id y9-20020a05620a25c900b00745f3200f54sm4897993qko.112.2023.04.19.14.14.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 14:14:08 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 07/11] btrfs-progs: consolidate the btrfs message helpers Date: Wed, 19 Apr 2023 17:13:49 -0400 Message-Id: X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org These helpers all do variations on the same thing, so add a helper to just do the printf part, and a macro to handle the special prefix and postfix, and then make the helpers just use the macro and new helper. Signed-off-by: Josef Bacik --- common/messages.c | 32 +------------------------------- common/messages.h | 30 +++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 38 deletions(-) diff --git a/common/messages.c b/common/messages.c index 5e7f2dfa..d6dc219b 100644 --- a/common/messages.c +++ b/common/messages.c @@ -19,9 +19,6 @@ #include "common/messages.h" #include "common/utils.h" -#define PREFIX_ERROR "ERROR: " -#define PREFIX_WARNING "WARNING: " - static const char *common_error_string[] = { [ERROR_MSG_MEMORY] = "not enough memory", [ERROR_MSG_START_TRANS] = "failed to start transaction", @@ -29,40 +26,13 @@ static const char *common_error_string[] = { }; __attribute__ ((format (printf, 1, 2))) -void __btrfs_warning(const char *fmt, ...) -{ - va_list args; - - fputs(PREFIX_WARNING, stderr); - va_start(args, fmt); - vfprintf(stderr, fmt, args); - va_end(args); - fputc('\n', stderr); -} - -__attribute__ ((format (printf, 1, 2))) -void __btrfs_error(const char *fmt, ...) +void __btrfs_printf(const char *fmt, ...) { va_list args; - fputs(PREFIX_ERROR, stderr); va_start(args, fmt); vfprintf(stderr, fmt, args); va_end(args); - fputc('\n', stderr); -} - -__attribute__ ((format (printf, 1, 2))) -void internal_error(const char *fmt, ...) -{ - va_list vargs; - - va_start(vargs, fmt); - fputs("INTERNAL " PREFIX_ERROR, stderr); - vfprintf(stderr, fmt, vargs); - va_end(vargs); - fputc('\n', stderr); - print_trace(); } static bool should_print(int level) diff --git a/common/messages.h b/common/messages.h index 6a105484..4bb9866e 100644 --- a/common/messages.h +++ b/common/messages.h @@ -40,6 +40,28 @@ #define DO_ABORT_ON_ERROR do { } while (0) #endif +#define PREFIX_ERROR "ERROR: " +#define PREFIX_WARNING "WARNING: " + +#define __btrfs_msg(prefix, fmt, ...) \ + do { \ + fputs((prefix), stderr); \ + __btrfs_printf((fmt), ##__VA_ARGS__); \ + fputc('\n', stderr); \ + } while (0) + +#define __btrfs_warning(fmt, ...) \ + __btrfs_msg(PREFIX_WARNING, fmt, ##__VA_ARGS__) + +#define __btrfs_error(fmt, ...) \ + __btrfs_msg(PREFIX_ERROR, fmt, ##__VA_ARGS__) + +#define internal_error(fmt, ...) \ + do { \ + __btrfs_msg("INTERNAL " PREFIX_ERROR, fmt, ##__VA_ARGS__); \ + print_trace(); \ + } while (0) + #define error(fmt, ...) \ do { \ PRINT_TRACE_ON_ERROR; \ @@ -87,13 +109,7 @@ } while (0) __attribute__ ((format (printf, 1, 2))) -void __btrfs_warning(const char *fmt, ...); - -__attribute__ ((format (printf, 1, 2))) -void __btrfs_error(const char *fmt, ...); - -__attribute__ ((format (printf, 1, 2))) -void internal_error(const char *fmt, ...); +void __btrfs_printf(const char *fmt, ...); /* * Level of messages that must be printed by default (in case the verbosity From patchwork Wed Apr 19 21:13:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13217381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C396C6FD18 for ; Wed, 19 Apr 2023 21:14:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231446AbjDSVOn (ORCPT ); Wed, 19 Apr 2023 17:14:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231497AbjDSVOO (ORCPT ); Wed, 19 Apr 2023 17:14:14 -0400 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC3E98A46 for ; Wed, 19 Apr 2023 14:14:11 -0700 (PDT) Received: by mail-qv1-xf2c.google.com with SMTP id js7so1038400qvb.5 for ; Wed, 19 Apr 2023 14:14:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20221208.gappssmtp.com; s=20221208; t=1681938851; x=1684530851; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=d+WPaH+BJdDVExYFVFvljS9QVfX7dpOxEOOc15sE7t4=; b=bXuoHvj2OI4ej26oQlqlT7KfPiuHYrCeccGbnRo2L6ew3vha7RUpITirGlxtcM9fnS xIwXxDf8mYBJyvzs1627pYvmTAw5ANFC/qvKarFpaK2R/BFbefJ/c4dkRcloWLfFNuNm efvEnSQMYAsrXjRfpAuedfuU/SfcG6BAekb3f6cLucyOur36OIBXv7WGYtFRjctZFMc3 OIVvVCL99bTsYBD0VeL/jILkdG5AWnf375w7CQmjsZjBX4Ha+aLasDaD2BlH+HH4QV/2 q1PIUToy7gKRszgClEMRz4p9sFFxqGrp4XUSU+ygIJhXi+t3Us6lXjRapDETKWoh/kWa sS1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681938851; x=1684530851; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d+WPaH+BJdDVExYFVFvljS9QVfX7dpOxEOOc15sE7t4=; b=GpSI33cL8+26ImL8uGJNWyZ62kRSYTVdF1toKutS5xKAxtTvXXs5gwgEduR790j7iU GXM66YK2SaFHiXJwAqqNnq0R2KseuyozGko45gG0z6WLRncbqOlIrPcjVaRFK5puB7BM MYv125DSV3L57QrxXQhJeXn2pwioM7EVHvQDe3EziFbyQg1MErvXy1bsNX/y3HioKaRQ XgfsOXai0DfxGK0pJll754rC60lhlTq3+Xr01OcIZRtoNQ6gN+z3ROvPBCyfIOrzMyoR RpV9e33o6dxoMrYsr3qNnQtE5AbNhGEryBH7OgTKVe/WpMJQIC5/ZE0JQc1Mil1MVCWE BNYA== X-Gm-Message-State: AAQBX9f6fShxvYZOjepzUTraMz1h3TYgFG+Qkh4W9htyzvybT30o/+Wl TYDQiCZzhm3Vcs47dtAQLh4cFCVoY9hdo/LNvgQYZw== X-Google-Smtp-Source: AKy350a1nI8TQlqODqy3sD82H1BQ5GQEElwKA6N9VZQRMmG34cZ1KJqTHYJWsK3FAWULZTa4PQoWsA== X-Received: by 2002:a05:6214:76a:b0:5ab:e259:b2a9 with SMTP id f10-20020a056214076a00b005abe259b2a9mr3799238qvz.14.1681938850565; Wed, 19 Apr 2023 14:14:10 -0700 (PDT) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id w10-20020a0cff0a000000b005e45f6cb74bsm4581921qvt.79.2023.04.19.14.14.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 14:14:10 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 08/11] btrfs-progs: rename the qgroup structs to match the kernel Date: Wed, 19 Apr 2023 17:13:50 -0400 Message-Id: <51b703790d273fe3104a5ae1920836b942310b1a.1681938648.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Now that the libbtrfs stuff has it's own local copy of ctree.h and ioctl.h, let's rename these qgroup struct members to match the kernel names, this way it'll make it easier to sync the kernel code into btrfs-progs. Signed-off-by: Josef Bacik --- check/qgroup-verify.c | 16 ++++---- cmds/qgroup.c | 20 ++++------ kernel-shared/ctree.h | 80 +++++++++++++++++++------------------- kernel-shared/print-tree.c | 18 ++++----- 4 files changed, 64 insertions(+), 70 deletions(-) diff --git a/check/qgroup-verify.c b/check/qgroup-verify.c index 3d7b9ddf..db49e3c9 100644 --- a/check/qgroup-verify.c +++ b/check/qgroup-verify.c @@ -870,12 +870,12 @@ static struct qgroup_count *alloc_count(struct btrfs_disk_key *key, c->key = *key; item = &c->diskinfo; - item->referenced = btrfs_qgroup_info_referenced(leaf, disk); + item->referenced = btrfs_qgroup_info_rfer(leaf, disk); item->referenced_compressed = - btrfs_qgroup_info_referenced_compressed(leaf, disk); - item->exclusive = btrfs_qgroup_info_exclusive(leaf, disk); + btrfs_qgroup_info_rfer_cmpr(leaf, disk); + item->exclusive = btrfs_qgroup_info_excl(leaf, disk); item->exclusive_compressed = - btrfs_qgroup_info_exclusive_compressed(leaf, disk); + btrfs_qgroup_info_excl_cmpr(leaf, disk); INIT_LIST_HEAD(&c->groups); INIT_LIST_HEAD(&c->members); INIT_LIST_HEAD(&c->bad_list); @@ -1594,14 +1594,14 @@ static int repair_qgroup_info(struct btrfs_fs_info *info, btrfs_set_qgroup_info_generation(path.nodes[0], info_item, trans->transid); - btrfs_set_qgroup_info_referenced(path.nodes[0], info_item, + btrfs_set_qgroup_info_rfer(path.nodes[0], info_item, count->info.referenced); - btrfs_set_qgroup_info_referenced_compressed(path.nodes[0], info_item, + btrfs_set_qgroup_info_rfer_cmpr(path.nodes[0], info_item, count->info.referenced_compressed); - btrfs_set_qgroup_info_exclusive(path.nodes[0], info_item, + btrfs_set_qgroup_info_excl(path.nodes[0], info_item, count->info.exclusive); - btrfs_set_qgroup_info_exclusive_compressed(path.nodes[0], info_item, + btrfs_set_qgroup_info_excl_cmpr(path.nodes[0], info_item, count->info.exclusive_compressed); btrfs_mark_buffer_dirty(path.nodes[0]); diff --git a/cmds/qgroup.c b/cmds/qgroup.c index 125362b8..ab4e9ecf 100644 --- a/cmds/qgroup.c +++ b/cmds/qgroup.c @@ -807,12 +807,11 @@ static int update_qgroup_info(int fd, struct qgroup_lookup *qgroup_lookup, u64 q return PTR_ERR(bq); bq->info.generation = btrfs_stack_qgroup_info_generation(info); - bq->info.referenced = btrfs_stack_qgroup_info_referenced(info); + bq->info.referenced = btrfs_stack_qgroup_info_rfer(info); bq->info.referenced_compressed = - btrfs_stack_qgroup_info_referenced_compressed(info); - bq->info.exclusive = btrfs_stack_qgroup_info_exclusive(info); - bq->info.exclusive_compressed = - btrfs_stack_qgroup_info_exclusive_compressed(info); + btrfs_stack_qgroup_info_rfer_cmpr(info); + bq->info.exclusive = btrfs_stack_qgroup_info_excl(info); + bq->info.exclusive_compressed = btrfs_stack_qgroup_info_excl_cmpr(info); return 0; } @@ -828,13 +827,10 @@ static int update_qgroup_limit(int fd, struct qgroup_lookup *qgroup_lookup, return PTR_ERR(bq); bq->limit.flags = btrfs_stack_qgroup_limit_flags(limit); - bq->limit.max_referenced = - btrfs_stack_qgroup_limit_max_referenced(limit); - bq->limit.max_exclusive = - btrfs_stack_qgroup_limit_max_exclusive(limit); - bq->limit.rsv_referenced = - btrfs_stack_qgroup_limit_rsv_referenced(limit); - bq->limit.rsv_exclusive = btrfs_stack_qgroup_limit_rsv_exclusive(limit); + bq->limit.max_referenced = btrfs_stack_qgroup_limit_max_rfer(limit); + bq->limit.max_exclusive = btrfs_stack_qgroup_limit_max_excl(limit); + bq->limit.rsv_referenced = btrfs_stack_qgroup_limit_rsv_rfer(limit); + bq->limit.rsv_exclusive = btrfs_stack_qgroup_limit_rsv_excl(limit); return 0; } diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h index 93e1850c..df7526d4 100644 --- a/kernel-shared/ctree.h +++ b/kernel-shared/ctree.h @@ -1103,10 +1103,10 @@ struct btrfs_free_space_info { struct btrfs_qgroup_info_item { __le64 generation; - __le64 referenced; - __le64 referenced_compressed; - __le64 exclusive; - __le64 exclusive_compressed; + __le64 rfer; + __le64 rfer_cmpr; + __le64 excl; + __le64 excl_cmpr; } __attribute__ ((__packed__)); /* flags definition for qgroup limits */ @@ -1119,10 +1119,10 @@ struct btrfs_qgroup_info_item { struct btrfs_qgroup_limit_item { __le64 flags; - __le64 max_referenced; - __le64 max_exclusive; - __le64 rsv_referenced; - __le64 rsv_exclusive; + __le64 max_rfer; + __le64 max_excl; + __le64 rsv_rfer; + __le64 rsv_excl; } __attribute__ ((__packed__)); struct btrfs_space_info { @@ -2466,48 +2466,48 @@ BTRFS_SETGET_STACK_FUNCS(stack_qgroup_status_rescan, /* btrfs_qgroup_info_item */ BTRFS_SETGET_FUNCS(qgroup_info_generation, struct btrfs_qgroup_info_item, generation, 64); -BTRFS_SETGET_FUNCS(qgroup_info_referenced, struct btrfs_qgroup_info_item, - referenced, 64); -BTRFS_SETGET_FUNCS(qgroup_info_referenced_compressed, - struct btrfs_qgroup_info_item, referenced_compressed, 64); -BTRFS_SETGET_FUNCS(qgroup_info_exclusive, struct btrfs_qgroup_info_item, - exclusive, 64); -BTRFS_SETGET_FUNCS(qgroup_info_exclusive_compressed, - struct btrfs_qgroup_info_item, exclusive_compressed, 64); +BTRFS_SETGET_FUNCS(qgroup_info_rfer, struct btrfs_qgroup_info_item, + rfer, 64); +BTRFS_SETGET_FUNCS(qgroup_info_rfer_cmpr, + struct btrfs_qgroup_info_item, rfer_cmpr, 64); +BTRFS_SETGET_FUNCS(qgroup_info_excl, struct btrfs_qgroup_info_item, + excl, 64); +BTRFS_SETGET_FUNCS(qgroup_info_excl_cmpr, + struct btrfs_qgroup_info_item, excl_cmpr, 64); BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_generation, struct btrfs_qgroup_info_item, generation, 64); -BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_referenced, - struct btrfs_qgroup_info_item, referenced, 64); -BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_referenced_compressed, - struct btrfs_qgroup_info_item, referenced_compressed, 64); -BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_exclusive, - struct btrfs_qgroup_info_item, exclusive, 64); -BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_exclusive_compressed, - struct btrfs_qgroup_info_item, exclusive_compressed, 64); +BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_rfer, + struct btrfs_qgroup_info_item, rfer, 64); +BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_rfer_cmpr, + struct btrfs_qgroup_info_item, rfer_cmpr, 64); +BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_excl, + struct btrfs_qgroup_info_item, excl, 64); +BTRFS_SETGET_STACK_FUNCS(stack_qgroup_info_excl_cmpr, + struct btrfs_qgroup_info_item, excl_cmpr, 64); /* btrfs_qgroup_limit_item */ BTRFS_SETGET_FUNCS(qgroup_limit_flags, struct btrfs_qgroup_limit_item, flags, 64); -BTRFS_SETGET_FUNCS(qgroup_limit_max_referenced, struct btrfs_qgroup_limit_item, - max_referenced, 64); -BTRFS_SETGET_FUNCS(qgroup_limit_max_exclusive, struct btrfs_qgroup_limit_item, - max_exclusive, 64); -BTRFS_SETGET_FUNCS(qgroup_limit_rsv_referenced, struct btrfs_qgroup_limit_item, - rsv_referenced, 64); -BTRFS_SETGET_FUNCS(qgroup_limit_rsv_exclusive, struct btrfs_qgroup_limit_item, - rsv_exclusive, 64); +BTRFS_SETGET_FUNCS(qgroup_limit_max_rfer, struct btrfs_qgroup_limit_item, + max_rfer, 64); +BTRFS_SETGET_FUNCS(qgroup_limit_max_excl, struct btrfs_qgroup_limit_item, + max_excl, 64); +BTRFS_SETGET_FUNCS(qgroup_limit_rsv_rfer, struct btrfs_qgroup_limit_item, + rsv_rfer, 64); +BTRFS_SETGET_FUNCS(qgroup_limit_rsv_excl, struct btrfs_qgroup_limit_item, + rsv_excl, 64); BTRFS_SETGET_STACK_FUNCS(stack_qgroup_limit_flags, struct btrfs_qgroup_limit_item, flags, 64); -BTRFS_SETGET_STACK_FUNCS(stack_qgroup_limit_max_referenced, - struct btrfs_qgroup_limit_item, max_referenced, 64); -BTRFS_SETGET_STACK_FUNCS(stack_qgroup_limit_max_exclusive, - struct btrfs_qgroup_limit_item, max_exclusive, 64); -BTRFS_SETGET_STACK_FUNCS(stack_qgroup_limit_rsv_referenced, - struct btrfs_qgroup_limit_item, rsv_referenced, 64); -BTRFS_SETGET_STACK_FUNCS(stack_qgroup_limit_rsv_exclusive, - struct btrfs_qgroup_limit_item, rsv_exclusive, 64); +BTRFS_SETGET_STACK_FUNCS(stack_qgroup_limit_max_rfer, + struct btrfs_qgroup_limit_item, max_rfer, 64); +BTRFS_SETGET_STACK_FUNCS(stack_qgroup_limit_max_excl, + struct btrfs_qgroup_limit_item, max_excl, 64); +BTRFS_SETGET_STACK_FUNCS(stack_qgroup_limit_rsv_rfer, + struct btrfs_qgroup_limit_item, rsv_rfer, 64); +BTRFS_SETGET_STACK_FUNCS(stack_qgroup_limit_rsv_excl, + struct btrfs_qgroup_limit_item, rsv_excl, 64); /* btrfs_balance_item */ BTRFS_SETGET_FUNCS(balance_item_flags, struct btrfs_balance_item, flags, 64); diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c index 3fb6a37c..37a1f74c 100644 --- a/kernel-shared/print-tree.c +++ b/kernel-shared/print-tree.c @@ -1089,12 +1089,10 @@ static void print_qgroup_info(struct extent_buffer *eb, int slot) "\t\treferenced %llu referenced_compressed %llu\n" "\t\texclusive %llu exclusive_compressed %llu\n", (unsigned long long)btrfs_qgroup_info_generation(eb, qg_info), - (unsigned long long)btrfs_qgroup_info_referenced(eb, qg_info), - (unsigned long long)btrfs_qgroup_info_referenced_compressed(eb, - qg_info), - (unsigned long long)btrfs_qgroup_info_exclusive(eb, qg_info), - (unsigned long long)btrfs_qgroup_info_exclusive_compressed(eb, - qg_info)); + (unsigned long long)btrfs_qgroup_info_rfer(eb, qg_info), + (unsigned long long)btrfs_qgroup_info_rfer_cmpr(eb, qg_info), + (unsigned long long)btrfs_qgroup_info_excl(eb, qg_info), + (unsigned long long)btrfs_qgroup_info_excl_cmpr(eb, qg_info)); } static void print_qgroup_limit(struct extent_buffer *eb, int slot) @@ -1106,10 +1104,10 @@ static void print_qgroup_limit(struct extent_buffer *eb, int slot) "\t\tmax_referenced %lld max_exclusive %lld\n" "\t\trsv_referenced %lld rsv_exclusive %lld\n", (unsigned long long)btrfs_qgroup_limit_flags(eb, qg_limit), - (long long)btrfs_qgroup_limit_max_referenced(eb, qg_limit), - (long long)btrfs_qgroup_limit_max_exclusive(eb, qg_limit), - (long long)btrfs_qgroup_limit_rsv_referenced(eb, qg_limit), - (long long)btrfs_qgroup_limit_rsv_exclusive(eb, qg_limit)); + (long long)btrfs_qgroup_limit_max_rfer(eb, qg_limit), + (long long)btrfs_qgroup_limit_max_excl(eb, qg_limit), + (long long)btrfs_qgroup_limit_rsv_rfer(eb, qg_limit), + (long long)btrfs_qgroup_limit_rsv_excl(eb, qg_limit)); } static void print_persistent_item(struct extent_buffer *eb, void *ptr, From patchwork Wed Apr 19 21:13:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13217379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EE85C6FD18 for ; Wed, 19 Apr 2023 21:14:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231411AbjDSVOl (ORCPT ); Wed, 19 Apr 2023 17:14:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbjDSVOP (ORCPT ); Wed, 19 Apr 2023 17:14:15 -0400 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C16E9011 for ; Wed, 19 Apr 2023 14:14:13 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id fg9so671406qtb.1 for ; Wed, 19 Apr 2023 14:14:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20221208.gappssmtp.com; s=20221208; t=1681938852; x=1684530852; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=YbfPxKg4s1QAD9wvrakSLQozJGyxPWm1Hoqc+IIgfvA=; b=fY6FY4kFAUnA4EpIBHOAD5LmyDS1KdjhuR3zhY4A2aXy0l0y7DIvAgm8WkXr/hT8KY MexUHhb65OIhJw4RXIg91wo7pMxvzT71diHSy88kVTuvTMF40UNtSRn3O55veOD0brB0 PIghBrDh7cjKKHXr/mjO8NSqNii7yCg7Z4qT3fstjmYz/mA35NtXbNau1BuQKqQl9g2J kVoCKLgQlFSGa+6ViieoCTmLFO0b2jOmGp5kqXQ6KAuBkEvrMojaFk4wkiK/jphe2OGg 2gqMcpbdW6uRJprx09HDmTZL0Zf0gP3D1jREGbt8QysSouQQilYxI4QiniOT0yVUv5Qs P91g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681938852; x=1684530852; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YbfPxKg4s1QAD9wvrakSLQozJGyxPWm1Hoqc+IIgfvA=; b=LfjGm18kXP1EE57AcOSEYoBn3OTRlKgENEU1n6fRn+CQbxX4AO/9+FeD7raRxlUHj2 3chfJVXOBuh3Ez0zpRblmn6yKiAFnlg52juk8s/ghvtD5DW4y2GBur9XZ9f8/OlLhNkR e82o421MQWIeJjc7GnokSfPcw1D0soGC7vEbLsq2bEjZxcAF3FyGCf++3XIT4Ph0mPAb R9S4TYaXWI/XzbeqYwgj5piZ1g6QpiXImvlD/RXVAJ58xjmmR6PuP6Fg8VaCE9hu6rq/ NbMAA/a7P1xDc8dw+WHvE47s9aiWsJg3Ks4ENGP+tglIg3ivqufQ+JktqelHqT7OG4Iy miaQ== X-Gm-Message-State: AAQBX9clfgQe5syitWgXUnSeRislso2VGuqTjAo6lB9sg69X2XuLGiXf stR2qB/n46EN3tQXi3mhLUqO6eXcUTUg+cZ/9Uo9fg== X-Google-Smtp-Source: AKy350YiqrRh8DqPPWVPw6VQQ+PxtwID4r4vhzpnkaMtpCmeRkY7Gq6uYcfCuHtbiKOTA6296itCpg== X-Received: by 2002:a05:622a:1ba4:b0:3ef:2d98:ecdf with SMTP id bp36-20020a05622a1ba400b003ef2d98ecdfmr8264250qtb.55.1681938851986; Wed, 19 Apr 2023 14:14:11 -0700 (PDT) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id ea19-20020a05620a489300b0074ad0812747sm1387620qkb.77.2023.04.19.14.14.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 14:14:11 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 09/11] btrfs-progs: remove fs_info argument from btrfs_check_* helpers Date: Wed, 19 Apr 2023 17:13:51 -0400 Message-Id: <76907ec19d13a8bd8bb3ab860b5e7f1450716170.1681938648.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This can be pulled out of the extent buffer that is passed in, drop the fs_info argument from the function. Signed-off-by: Josef Bacik --- check/main.c | 12 ++++++------ check/mode-lowmem.c | 10 +++++----- kernel-shared/ctree.c | 12 ++++++------ kernel-shared/ctree.h | 6 ++---- kernel-shared/disk-io.c | 4 ++-- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/check/main.c b/check/main.c index 1a9ad50c..8c3a10a1 100644 --- a/check/main.c +++ b/check/main.c @@ -1921,9 +1921,9 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path, } if (btrfs_is_leaf(next)) - status = btrfs_check_leaf(gfs_info, NULL, next); + status = btrfs_check_leaf(NULL, next); else - status = btrfs_check_node(gfs_info, NULL, next); + status = btrfs_check_node(NULL, next); if (status != BTRFS_TREE_BLOCK_CLEAN) { free_extent_buffer(next); err = -EIO; @@ -3702,9 +3702,9 @@ static int check_fs_root(struct btrfs_root *root, /* We may not have checked the root block, lets do that now */ if (btrfs_is_leaf(root->node)) - status = btrfs_check_leaf(gfs_info, NULL, root->node); + status = btrfs_check_leaf(NULL, root->node); else - status = btrfs_check_node(gfs_info, NULL, root->node); + status = btrfs_check_node(NULL, root->node); if (status != BTRFS_TREE_BLOCK_CLEAN) return -EIO; @@ -4608,9 +4608,9 @@ static int check_block(struct btrfs_root *root, rec->info_level = level; if (btrfs_is_leaf(buf)) - status = btrfs_check_leaf(gfs_info, &rec->parent_key, buf); + status = btrfs_check_leaf(&rec->parent_key, buf); else - status = btrfs_check_node(gfs_info, &rec->parent_key, buf); + status = btrfs_check_node(&rec->parent_key, buf); if (status != BTRFS_TREE_BLOCK_CLEAN) { if (opt_check_repair) diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c index f0e5f8d6..1672da26 100644 --- a/check/mode-lowmem.c +++ b/check/mode-lowmem.c @@ -2695,7 +2695,7 @@ static int check_inode_item(struct btrfs_root *root, struct btrfs_path *path) * we need to bail otherwise we could end up stuck. */ if (path->slots[0] == 0 && - btrfs_check_leaf(gfs_info, NULL, path->nodes[0])) + btrfs_check_leaf(NULL, path->nodes[0])) ret = -EIO; if (ret < 0) { @@ -5001,7 +5001,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path, if (*level == 0) { /* skip duplicate check */ if (check || !check_all) { - ret = btrfs_check_leaf(gfs_info, NULL, cur); + ret = btrfs_check_leaf(NULL, cur); if (ret != BTRFS_TREE_BLOCK_CLEAN) { err |= -EIO; break; @@ -5018,7 +5018,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path, break; } if (check || !check_all) { - ret = btrfs_check_node(gfs_info, NULL, cur); + ret = btrfs_check_node(NULL, cur); if (ret != BTRFS_TREE_BLOCK_CLEAN) { err |= -EIO; break; @@ -5066,9 +5066,9 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path, break; if (btrfs_is_leaf(next)) - status = btrfs_check_leaf(gfs_info, NULL, next); + status = btrfs_check_leaf(NULL, next); else - status = btrfs_check_node(gfs_info, NULL, next); + status = btrfs_check_node(NULL, next); if (status != BTRFS_TREE_BLOCK_CLEAN) { free_extent_buffer(next); err |= -EIO; diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c index 7d1b1316..fb56a863 100644 --- a/kernel-shared/ctree.c +++ b/kernel-shared/ctree.c @@ -612,9 +612,9 @@ static void generic_err(const struct extent_buffer *buf, int slot, } enum btrfs_tree_block_status -btrfs_check_node(struct btrfs_fs_info *fs_info, - struct btrfs_key *parent_key, struct extent_buffer *node) +btrfs_check_node(struct btrfs_key *parent_key, struct extent_buffer *node) { + struct btrfs_fs_info *fs_info = node->fs_info; unsigned long nr = btrfs_header_nritems(node); struct btrfs_key key, next_key; int slot; @@ -683,9 +683,9 @@ fail: } enum btrfs_tree_block_status -btrfs_check_leaf(struct btrfs_fs_info *fs_info, - struct btrfs_key *parent_key, struct extent_buffer *leaf) +btrfs_check_leaf(struct btrfs_key *parent_key, struct extent_buffer *leaf) { + struct btrfs_fs_info *fs_info = leaf->fs_info; /* No valid key type is 0, so all key should be larger than this key */ struct btrfs_key prev_key = {0, 0, 0}; struct btrfs_key key; @@ -811,9 +811,9 @@ static int noinline check_block(struct btrfs_fs_info *fs_info, parent_key_ptr = &key; } if (level == 0) - ret = btrfs_check_leaf(fs_info, parent_key_ptr, path->nodes[0]); + ret = btrfs_check_leaf(parent_key_ptr, path->nodes[0]); else - ret = btrfs_check_node(fs_info, parent_key_ptr, path->nodes[level]); + ret = btrfs_check_node(parent_key_ptr, path->nodes[level]); if (ret == BTRFS_TREE_BLOCK_CLEAN) return 0; return -EIO; diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h index df7526d4..13264387 100644 --- a/kernel-shared/ctree.h +++ b/kernel-shared/ctree.h @@ -2705,11 +2705,9 @@ int btrfs_comp_cpu_keys(const struct btrfs_key *k1, const struct btrfs_key *k2); int btrfs_del_ptr(struct btrfs_root *root, struct btrfs_path *path, int level, int slot); enum btrfs_tree_block_status -btrfs_check_node(struct btrfs_fs_info *fs_info, - struct btrfs_key *parent_key, struct extent_buffer *buf); +btrfs_check_node(struct btrfs_key *parent_key, struct extent_buffer *buf); enum btrfs_tree_block_status -btrfs_check_leaf(struct btrfs_fs_info *fs_info, - struct btrfs_key *parent_key, struct extent_buffer *buf); +btrfs_check_leaf(struct btrfs_key *parent_key, struct extent_buffer *buf); void reada_for_search(struct btrfs_fs_info *fs_info, struct btrfs_path *path, int level, int slot, u64 objectid); struct extent_buffer *read_node_slot(struct btrfs_fs_info *fs_info, diff --git a/kernel-shared/disk-io.c b/kernel-shared/disk-io.c index 3d2574d9..b5ad89c2 100644 --- a/kernel-shared/disk-io.c +++ b/kernel-shared/disk-io.c @@ -389,9 +389,9 @@ struct extent_buffer* read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr, * btrfs ins dump-tree. */ if (btrfs_header_level(eb)) - ret = btrfs_check_node(fs_info, NULL, eb); + ret = btrfs_check_node(NULL, eb); else - ret = btrfs_check_leaf(fs_info, NULL, eb); + ret = btrfs_check_leaf(NULL, eb); if (!ret || candidate_mirror == mirror_num) { btrfs_set_buffer_uptodate(eb); return eb; From patchwork Wed Apr 19 21:13:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13217380 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85779C77B73 for ; Wed, 19 Apr 2023 21:14:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231508AbjDSVOo (ORCPT ); Wed, 19 Apr 2023 17:14:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231627AbjDSVOW (ORCPT ); Wed, 19 Apr 2023 17:14:22 -0400 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 411247A81 for ; Wed, 19 Apr 2023 14:14:15 -0700 (PDT) Received: by mail-qt1-x82c.google.com with SMTP id ay32so51054qtb.0 for ; Wed, 19 Apr 2023 14:14:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20221208.gappssmtp.com; s=20221208; t=1681938854; x=1684530854; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=j/qID2aK7guLS3RQBbBN2oiEtayDypekSvW8QS8Mam0=; b=sGgvGHu95egDROVS9xHTSZaL/H54pNg20489r3S2JyYkUzrE1cIX1EOCmzTctLalL1 82Jya8lC0BEf/iunr2dhCct4v5bq+QwW4y+z/05+DTN+toSffWm1KO1fmCuKN7TGbQO0 5qKq7D00Vin8HLhCRSQE9Jbzom3Nsx9Op4Puyr6l34EqG1veMjvJUxa8GqY67YQ/Qbt9 ZKjiXtNJd11RQ2WWQO51NEYlpHwV/aLsNJX/T4m6IGgZVXcoLUa4Nn2xchcGpt9hF7oG so7u8wcabRV30MdKZOvset5q/e/KKLWIw8Wt7r+Sjr6cK5GJIW9ExGNSP0KtYd0ph6u/ Jj5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681938854; x=1684530854; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j/qID2aK7guLS3RQBbBN2oiEtayDypekSvW8QS8Mam0=; b=fPqGmMS7PMd8aB/OYZr/5Fkz7VspkeNAS8rzqg2LT5Vt6elW3w4yHG0opsnGT886m4 DnHMMedinF1ZepN9WhM2Rtl6xCpxRAA7KJ9xrucH1czN2YHyElYLw1sSadKNn/if1EvR ALWi3ZMBz6qjlm118Hntn5wv+SX8zXnhr4UQlc6pni3TCv2Df2aFvBnPpi+Bo17WJFdV ZF/RZYGTvHDqtYwgXuioJ5qTt4LQqwVzQI/RuqJXO+zFbxPlIiiGN/Wo6UU1ow7bhFOc 55PMDelvT1FH6hmm4ybQb9emyurU09Pg9f3Vmxy0QDu54QSiVS9gKj2onf5xLPg6PtAC RJYA== X-Gm-Message-State: AAQBX9fufmidzRuPYCRUQ9CWMLWta1LSo1ntzWwMwV/oHbJfQtDp5M2N InQb1Tp+brVyNFR0Ax5T1MpIZb2hznPPMmsi0RgQKA== X-Google-Smtp-Source: AKy350ZGCIPdUUbnsz9gPR/4Ay+9aTlgTXablpATguNCHt7ZP1tsUHuEXpZNXDVm9maT98xPK3cyWw== X-Received: by 2002:ac8:58d5:0:b0:3ed:4a17:8b04 with SMTP id u21-20020ac858d5000000b003ed4a178b04mr7616595qta.68.1681938854367; Wed, 19 Apr 2023 14:14:14 -0700 (PDT) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id u18-20020a05622a14d200b003eda962ed24sm39190qtx.22.2023.04.19.14.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 14:14:14 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 10/11] btrfs-progs: add a btrfs check helper for checking blocks Date: Wed, 19 Apr 2023 17:13:52 -0400 Message-Id: <4f7342dabcc239185623abebdac57a30d0db259e.1681938648.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org btrfs check wants to be able to record corrupted extents if it finds any bad blocks. This has been done directly inside of the btrfs_check_leaf/btrfs_check_node helpers, but these are going to be sync'ed from the kernel in the future. Add another helper and move the corrupt block handling into this helper and keep it inside of the check code. Signed-off-by: Josef Bacik --- check/main.c | 16 +++------------- check/mode-lowmem.c | 11 ++++------- check/repair.c | 29 +++++++++++++++++++++++++++++ check/repair.h | 3 ++- kernel-shared/ctree.c | 22 ++-------------------- 5 files changed, 40 insertions(+), 41 deletions(-) diff --git a/check/main.c b/check/main.c index 8c3a10a1..467c8a57 100644 --- a/check/main.c +++ b/check/main.c @@ -1920,10 +1920,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path, goto out; } - if (btrfs_is_leaf(next)) - status = btrfs_check_leaf(NULL, next); - else - status = btrfs_check_node(NULL, next); + status = btrfs_check_block_for_repair(next, NULL); if (status != BTRFS_TREE_BLOCK_CLEAN) { free_extent_buffer(next); err = -EIO; @@ -3701,10 +3698,7 @@ static int check_fs_root(struct btrfs_root *root, wc->root_level = level; /* We may not have checked the root block, lets do that now */ - if (btrfs_is_leaf(root->node)) - status = btrfs_check_leaf(NULL, root->node); - else - status = btrfs_check_node(NULL, root->node); + status = btrfs_check_block_for_repair(root->node, NULL); if (status != BTRFS_TREE_BLOCK_CLEAN) return -EIO; @@ -4607,11 +4601,7 @@ static int check_block(struct btrfs_root *root, } rec->info_level = level; - if (btrfs_is_leaf(buf)) - status = btrfs_check_leaf(&rec->parent_key, buf); - else - status = btrfs_check_node(&rec->parent_key, buf); - + status = btrfs_check_block_for_repair(buf, &rec->parent_key); if (status != BTRFS_TREE_BLOCK_CLEAN) { if (opt_check_repair) status = try_to_fix_bad_block(root, buf, status); diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c index 1672da26..3cf8d97f 100644 --- a/check/mode-lowmem.c +++ b/check/mode-lowmem.c @@ -2695,7 +2695,7 @@ static int check_inode_item(struct btrfs_root *root, struct btrfs_path *path) * we need to bail otherwise we could end up stuck. */ if (path->slots[0] == 0 && - btrfs_check_leaf(NULL, path->nodes[0])) + btrfs_check_block_for_repair(path->nodes[0], NULL)) ret = -EIO; if (ret < 0) { @@ -5001,7 +5001,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path, if (*level == 0) { /* skip duplicate check */ if (check || !check_all) { - ret = btrfs_check_leaf(NULL, cur); + ret = btrfs_check_block_for_repair(cur, NULL); if (ret != BTRFS_TREE_BLOCK_CLEAN) { err |= -EIO; break; @@ -5018,7 +5018,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path, break; } if (check || !check_all) { - ret = btrfs_check_node(NULL, cur); + ret = btrfs_check_block_for_repair(cur, NULL); if (ret != BTRFS_TREE_BLOCK_CLEAN) { err |= -EIO; break; @@ -5065,10 +5065,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path, if (ret < 0) break; - if (btrfs_is_leaf(next)) - status = btrfs_check_leaf(NULL, next); - else - status = btrfs_check_node(NULL, next); + status = btrfs_check_block_for_repair(next, NULL); if (status != BTRFS_TREE_BLOCK_CLEAN) { free_extent_buffer(next); err |= -EIO; diff --git a/check/repair.c b/check/repair.c index f84df9cf..71b2a277 100644 --- a/check/repair.c +++ b/check/repair.c @@ -299,3 +299,32 @@ out: extent_io_tree_cleanup(&used); return ret; } + +enum btrfs_tree_block_status btrfs_check_block_for_repair(struct extent_buffer *eb, + struct btrfs_key *first_key) +{ + struct btrfs_fs_info *fs_info = eb->fs_info; + enum btrfs_tree_block_status status; + + if (btrfs_is_leaf(eb)) + status = btrfs_check_leaf(first_key, eb); + else + status = btrfs_check_node(first_key, eb); + + if (status == BTRFS_TREE_BLOCK_CLEAN) + return status; + + if (btrfs_header_owner(eb) == BTRFS_EXTENT_TREE_OBJECTID) { + struct btrfs_key key; + + if (first_key) + memcpy(&key, first_key, sizeof(struct btrfs_key)); + else + btrfs_node_key_to_cpu(eb, &key, 0); + btrfs_add_corrupt_extent_record(fs_info, &key, + eb->start, eb->len, + btrfs_header_level(eb)); + } + return status; + +} diff --git a/check/repair.h b/check/repair.h index 3e6ffcf6..d4222600 100644 --- a/check/repair.h +++ b/check/repair.h @@ -43,5 +43,6 @@ int btrfs_mark_used_tree_blocks(struct btrfs_fs_info *fs_info, struct extent_io_tree *tree); int btrfs_mark_used_blocks(struct btrfs_fs_info *fs_info, struct extent_io_tree *tree); - +enum btrfs_tree_block_status btrfs_check_block_for_repair(struct extent_buffer *eb, + struct btrfs_key *first_key); #endif diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c index fb56a863..c1c2059b 100644 --- a/kernel-shared/ctree.c +++ b/kernel-shared/ctree.c @@ -668,17 +668,8 @@ btrfs_check_node(struct btrfs_key *parent_key, struct extent_buffer *node) goto fail; } } - return BTRFS_TREE_BLOCK_CLEAN; + ret = BTRFS_TREE_BLOCK_CLEAN; fail: - if (btrfs_header_owner(node) == BTRFS_EXTENT_TREE_OBJECTID) { - if (parent_key) - memcpy(&key, parent_key, sizeof(struct btrfs_key)); - else - btrfs_node_key_to_cpu(node, &key, 0); - btrfs_add_corrupt_extent_record(fs_info, &key, - node->start, node->len, - btrfs_header_level(node)); - } return ret; } @@ -782,17 +773,8 @@ btrfs_check_leaf(struct btrfs_key *parent_key, struct extent_buffer *leaf) prev_key.offset = key.offset; } - return BTRFS_TREE_BLOCK_CLEAN; + ret = BTRFS_TREE_BLOCK_CLEAN; fail: - if (btrfs_header_owner(leaf) == BTRFS_EXTENT_TREE_OBJECTID) { - if (parent_key) - memcpy(&key, parent_key, sizeof(struct btrfs_key)); - else - btrfs_item_key_to_cpu(leaf, &key, 0); - - btrfs_add_corrupt_extent_record(fs_info, &key, - leaf->start, leaf->len, 0); - } return ret; } From patchwork Wed Apr 19 21:13:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 13217382 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D995C77B7A for ; Wed, 19 Apr 2023 21:14:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231612AbjDSVOp (ORCPT ); Wed, 19 Apr 2023 17:14:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231822AbjDSVO1 (ORCPT ); Wed, 19 Apr 2023 17:14:27 -0400 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D7595BA1 for ; Wed, 19 Apr 2023 14:14:17 -0700 (PDT) Received: by mail-qt1-x836.google.com with SMTP id ay32so51114qtb.0 for ; Wed, 19 Apr 2023 14:14:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20221208.gappssmtp.com; s=20221208; t=1681938856; x=1684530856; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=1D0JTWr+48h833wqFxSK8OWDmOY8G0DtKAhOU43AEoc=; b=SySFXEHNWbRnt4wBjdlWD/dQyWUS6n0Y/G5SEDpGLq+LKp2sWBNhhlKaSqNr8FrF3g PidIif44mqqki5d6rBL3T4FCym372KywF1y4A7phPkXw0YPym4vZmjd8E851hPoOJIzf ueTvuU6CHdaI9xhwflKYvp7KkxZXyIXW4H2Pza/nG/M8yKtsyVJwCBbuwvJymKA/zBND l4zC3T8to3cE137raRrX5UajCaQnMqCY+FWjg9pQdoulKY1pPkuIyodY7h5XFW08t2Qv OC8TfS1lGHwe/wHuZXrl0Vrf6cfh5yTOFPUVa7kBS2LRo7t1WqTQDYqSU2GmbxClA0Tp Ku/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681938856; x=1684530856; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1D0JTWr+48h833wqFxSK8OWDmOY8G0DtKAhOU43AEoc=; b=ZObtqnrpBnefQZcBamxm42UcgGBTYsOjdd50cO/LuxPxdbWTdzB5Ka6djFQh97n2KN x5M4XbEsH/mjah7cg4bA60mDtzWQNx5I4zsLUaEa8N/Kelei48s857OkOuHrl0AX5+Qu waBTo+Vs8/Ibn77qiwA1mrNXSZB4wuHciovl+GbfbfUT2oBrJGihSPipV5aST8sT1xdi WI60pIWZDTeY4Pq6o9rbUWFS17JhZWsqIibPZGh34v+3llLeD1+qn0ge5IbhKSjZRqiA VpDDrt41pNxV0/v+nNfZC04LWZDKSXHzibA67+AUfU/XnDVhxmpECcunN3hxbXCRetGx 6ESQ== X-Gm-Message-State: AAQBX9cDOijtUYDjEayycxmYrVCVIXR8j4OdTTIHQecieM4QNMaHPq35 QOaSA1evi/3mP+Bdy5CyfnGfR4+ZA5j75pAcgmaDJw== X-Google-Smtp-Source: AKy350bIVIULhYsUklqlxWuleL2+OZ7hHkp/ypgJqLg0KLsTKxCBn7Efhciwx1hgBi0cs7Cvg+MKew== X-Received: by 2002:a05:622a:18a4:b0:3ef:3824:b8b0 with SMTP id v36-20020a05622a18a400b003ef3824b8b0mr6872248qtc.5.1681938855835; Wed, 19 Apr 2023 14:14:15 -0700 (PDT) Received: from localhost (cpe-174-109-170-245.nc.res.rr.com. [174.109.170.245]) by smtp.gmail.com with ESMTPSA id p129-20020a374287000000b007339c5114a9sm4944649qka.103.2023.04.19.14.14.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 14:14:15 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 11/11] btrfs-progs: remove parent_key arg from btrfs_check_* helpers Date: Wed, 19 Apr 2023 17:13:53 -0400 Message-Id: X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Now that this is unused by these helpers and only used by the repair related code we can remove this argument from the main helpers. Signed-off-by: Josef Bacik --- check/repair.c | 4 ++-- kernel-shared/ctree.c | 17 ++++------------- kernel-shared/ctree.h | 6 ++---- kernel-shared/disk-io.c | 4 ++-- 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/check/repair.c b/check/repair.c index 71b2a277..8c1e2027 100644 --- a/check/repair.c +++ b/check/repair.c @@ -307,9 +307,9 @@ enum btrfs_tree_block_status btrfs_check_block_for_repair(struct extent_buffer * enum btrfs_tree_block_status status; if (btrfs_is_leaf(eb)) - status = btrfs_check_leaf(first_key, eb); + status = btrfs_check_leaf(eb); else - status = btrfs_check_node(first_key, eb); + status = btrfs_check_node(eb); if (status == BTRFS_TREE_BLOCK_CLEAN) return status; diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c index c1c2059b..911ec51c 100644 --- a/kernel-shared/ctree.c +++ b/kernel-shared/ctree.c @@ -611,8 +611,7 @@ static void generic_err(const struct extent_buffer *buf, int slot, fprintf(stderr, "\n"); } -enum btrfs_tree_block_status -btrfs_check_node(struct btrfs_key *parent_key, struct extent_buffer *node) +enum btrfs_tree_block_status btrfs_check_node(struct extent_buffer *node) { struct btrfs_fs_info *fs_info = node->fs_info; unsigned long nr = btrfs_header_nritems(node); @@ -673,8 +672,7 @@ fail: return ret; } -enum btrfs_tree_block_status -btrfs_check_leaf(struct btrfs_key *parent_key, struct extent_buffer *leaf) +enum btrfs_tree_block_status btrfs_check_leaf(struct extent_buffer *leaf) { struct btrfs_fs_info *fs_info = leaf->fs_info; /* No valid key type is 0, so all key should be larger than this key */ @@ -781,21 +779,14 @@ fail: static int noinline check_block(struct btrfs_fs_info *fs_info, struct btrfs_path *path, int level) { - struct btrfs_key key; - struct btrfs_key *parent_key_ptr = NULL; enum btrfs_tree_block_status ret; if (path->skip_check_block) return 0; - if (path->nodes[level + 1]) { - btrfs_node_key_to_cpu(path->nodes[level + 1], &key, - path->slots[level + 1]); - parent_key_ptr = &key; - } if (level == 0) - ret = btrfs_check_leaf(parent_key_ptr, path->nodes[0]); + ret = btrfs_check_leaf(path->nodes[0]); else - ret = btrfs_check_node(parent_key_ptr, path->nodes[level]); + ret = btrfs_check_node(path->nodes[level]); if (ret == BTRFS_TREE_BLOCK_CLEAN) return 0; return -EIO; diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h index 13264387..d81d7c02 100644 --- a/kernel-shared/ctree.h +++ b/kernel-shared/ctree.h @@ -2704,10 +2704,8 @@ int btrfs_convert_one_bg(struct btrfs_trans_handle *trans, u64 bytenr); int btrfs_comp_cpu_keys(const struct btrfs_key *k1, const struct btrfs_key *k2); int btrfs_del_ptr(struct btrfs_root *root, struct btrfs_path *path, int level, int slot); -enum btrfs_tree_block_status -btrfs_check_node(struct btrfs_key *parent_key, struct extent_buffer *buf); -enum btrfs_tree_block_status -btrfs_check_leaf(struct btrfs_key *parent_key, struct extent_buffer *buf); +enum btrfs_tree_block_status btrfs_check_node(struct extent_buffer *buf); +enum btrfs_tree_block_status btrfs_check_leaf(struct extent_buffer *buf); void reada_for_search(struct btrfs_fs_info *fs_info, struct btrfs_path *path, int level, int slot, u64 objectid); struct extent_buffer *read_node_slot(struct btrfs_fs_info *fs_info, diff --git a/kernel-shared/disk-io.c b/kernel-shared/disk-io.c index b5ad89c2..7d165720 100644 --- a/kernel-shared/disk-io.c +++ b/kernel-shared/disk-io.c @@ -389,9 +389,9 @@ struct extent_buffer* read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr, * btrfs ins dump-tree. */ if (btrfs_header_level(eb)) - ret = btrfs_check_node(NULL, eb); + ret = btrfs_check_node(eb); else - ret = btrfs_check_leaf(NULL, eb); + ret = btrfs_check_leaf(eb); if (!ret || candidate_mirror == mirror_num) { btrfs_set_buffer_uptodate(eb); return eb;