From patchwork Wed Sep 14 15:06:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976280 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 BBC5CECAAD3 for ; Wed, 14 Sep 2022 15:07:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229550AbiINPG7 (ORCPT ); Wed, 14 Sep 2022 11:06:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230087AbiINPGr (ORCPT ); Wed, 14 Sep 2022 11:06:47 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06B1776460 for ; Wed, 14 Sep 2022 08:06:45 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id b23so6460794qtr.13 for ; Wed, 14 Sep 2022 08:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=Ph4kscEWnOgHmomTRnjQCm6MKqqe5qRplQf1YaR6vPA=; b=pbOmxjuceCGcRy5w2QDU6VH2T2OYecIrG0ADYbcsKusg0dmvYvWBgvc2CsINcoS6Vr MOZ1lIeNt3TpcUZdTQcK1wbW/ErMeBI0NObvbdnw4o+ifsxkkyZt/XezgdmFu2EizVpC tA0weDt2AATGOrBFNKgRZ6+qdDNo+tQ53eW0LuAh5Y8sPnhlRV3+7APecJcpgnRXOp07 5FUOv+p6Xl1s8ujLLITqYiWqk0GCicW5cDCIa1czBlohqSzU09R62Pmjdb+/1Hx0DW16 HvezKVvLSse3TaPDmqSEigj8Spy4a58FOeaIk0lA658LQKju4MQZWm2bKxTq+ouEtEz5 6upQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=Ph4kscEWnOgHmomTRnjQCm6MKqqe5qRplQf1YaR6vPA=; b=1FrDZ2Ws24lvx9YutTPahRh7MU3UAqGKx1qrW7QKG4DG90QcUiOvImpWexCICxj7YZ 13oliFkEidpGtqTpKOpBbiOTFCo7WlvO23gNF3/HpxBbDdUSu6Hu/yrci4opfAZLVftH AqQqirzvbQ8a0LtCvXVr229LHUVIdD5SaOtxET9RqRMvD6WGKbSZoHCSdg3raQRDkTW6 ThBw/mvGwZ5m7c+ABTNS2R0hHrXrhN7cbLHkImAUm+2oOA7Egi0MihEVYIxCS5NHq7yI KEj6UmvdFFuADfKbO5UHQBOdJkuJSTnKwpI1KB0D3XBWFKY8etszbB6mvy/BYfI4iQV9 s8Rw== X-Gm-Message-State: ACgBeo3UkAf77voXpknWoWWm0TjdPabcSUmIT+aqc+mOo0JRiVxvlphK mtHYPPF7iGG9v3ObIEZSaaHw0NfVgYk56g== X-Google-Smtp-Source: AA6agR7XZylg9NCHXxzgDFrCYdI/7rQX5BIWe8I0QaeeY4sn+jOdqQ2gDBhQbAY5sS++n+xGBuHo4A== X-Received: by 2002:a05:622a:492:b0:35c:be5e:74a1 with SMTP id p18-20020a05622a049200b0035cbe5e74a1mr1459263qtx.677.1663168004521; Wed, 14 Sep 2022 08:06:44 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id w22-20020a05620a0e9600b006ce76811a07sm1890768qkm.75.2022.09.14.08.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:06:44 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 01/17] btrfs: remove set/clear_pending_info helpers Date: Wed, 14 Sep 2022 11:06:25 -0400 Message-Id: <1925067c136aec3e1a01af78dbee66b6b0ebcc26.1663167823.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The last users of these helpers were removed in 5297199a8bca ("btrfs: remove inode number cache feature") so delete these helpers. Signed-off-by: Josef Bacik Reviewed-by: Qu Wenruo Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 8b7b7a212da0..0003ba925d93 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -1644,30 +1644,6 @@ do { \ #define btrfs_clear_pending(info, opt) \ clear_bit(BTRFS_PENDING_##opt, &(info)->pending_changes) -/* - * Helpers for setting pending mount option changes. - * - * Expects corresponding macros - * BTRFS_PENDING_SET_ and CLEAR_ + short mount option name - */ -#define btrfs_set_pending_and_info(info, opt, fmt, args...) \ -do { \ - if (!btrfs_raw_test_opt((info)->mount_opt, opt)) { \ - btrfs_info((info), fmt, ##args); \ - btrfs_set_pending((info), SET_##opt); \ - btrfs_clear_pending((info), CLEAR_##opt); \ - } \ -} while(0) - -#define btrfs_clear_pending_and_info(info, opt, fmt, args...) \ -do { \ - if (btrfs_raw_test_opt((info)->mount_opt, opt)) { \ - btrfs_info((info), fmt, ##args); \ - btrfs_set_pending((info), CLEAR_##opt); \ - btrfs_clear_pending((info), SET_##opt); \ - } \ -} while(0) - /* * Inode flags */ From patchwork Wed Sep 14 15:06:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976281 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 1B7E3C6FA8E for ; Wed, 14 Sep 2022 15:07:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229949AbiINPHA (ORCPT ); Wed, 14 Sep 2022 11:07:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229569AbiINPGs (ORCPT ); Wed, 14 Sep 2022 11:06:48 -0400 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 411AD5C948 for ; Wed, 14 Sep 2022 08:06:47 -0700 (PDT) Received: by mail-qv1-xf33.google.com with SMTP id m9so11956429qvv.7 for ; Wed, 14 Sep 2022 08:06:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=gaUer8CEwSkw6jck6MmuJ2inzW3s41u45ndN6q3Dfjs=; b=ojyLi+vYcgeLc10oJTDHzKy1dzYXZjDc+ZmU72etVPoNo9vClgDGOFYUHqBMid041r SA8J15GTdikCNnRhN9ZgcTwUBgH9AKlZp6GtjU7kZMQRJt9cpL1+bl4VP4pGkOk9co7L nMiLPqjZiBLfOEdK/deC4cNYhTkJBcd1OrgXPuDpdNyCL/lYig6Ci/vZJR7+1kyKZen2 pRJaz+tyYK5L3LjwDY5qciFK8AnS+ocC1SraR30j/Dg5OMSXCyJgxHOP4MAMQ1nNtOm/ Y1XfbgtZJcTqsOKdMLVjAdimtltBedVxv6F1yqxIAhq4S4gd/a8wCVQSU5D5fcK476qf +odg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=gaUer8CEwSkw6jck6MmuJ2inzW3s41u45ndN6q3Dfjs=; b=0Jk6ynhbKsNVI7vBlFf8sD3YAnvnSykBepkOFelZ2y+wtVzMRn2kFzGolpcYD7JxKD T8gQXqkq99GPuJsP3+T/45aP6wxqgLuZIi6NrW4vbG40zSgaX7i83Gf8lxz9s9PuxnGN gWwF49Pg/gMIwdVsH0o+7z+pbp1rfrG815jeJBy+LGl2XYReX2ziDw4SwBEna2+urRqT eX5/pzvlqXa1CgIucCtSV2TvtAE3UI7B6Ps682wZ+53KB9hGUG8FGEylTlLI9x6uAzYS v8+Y05e6ngIXmZwgDLUyHkjzZDpmPD3Ua/J8vAXE5r9Ypy6zZ7CY3dS94gh08X9mgFMu xJnA== X-Gm-Message-State: ACgBeo0A6w8K9vSHMUqSHbSyQInJ5sjdkPZGTb08Ylkde3Ffu6bRJkbV MNi7Pm6AlWpSdKZwofIhjpxVDR+4UEaRHA== X-Google-Smtp-Source: AA6agR7Qk7vAjMIQ18ZTw9pIkU5epnLrzf6skCRp/e1OHaUS38qIaNRh4+uU9pl88g0jL0vVJS5HBA== X-Received: by 2002:a0c:914e:0:b0:479:58a9:d4c1 with SMTP id q72-20020a0c914e000000b0047958a9d4c1mr33188681qvq.86.1663168005922; Wed, 14 Sep 2022 08:06:45 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id ck12-20020a05622a230c00b0031eddc83560sm1671052qtb.90.2022.09.14.08.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:06:45 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 02/17] btrfs: remove BTRFS_TOTAL_BYTES_PINNED_BATCH Date: Wed, 14 Sep 2022 11:06:26 -0400 Message-Id: X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This hasn't been used since 138a12d86574 ("btrfs: rip out btrfs_space_info::total_bytes_pinned") so it is safe to remove. Signed-off-by: Josef Bacik Reviewed-by: Qu Wenruo Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 0003ba925d93..3936bb95331d 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -87,14 +87,6 @@ struct btrfs_ioctl_encoded_io_args; #define BTRFS_DIRTY_METADATA_THRESH SZ_32M -/* - * Use large batch size to reduce overhead of metadata updates. On the reader - * side, we only read it when we are close to ENOSPC and the read overhead is - * mostly related to the number of CPUs, so it is OK to use arbitrary large - * value here. - */ -#define BTRFS_TOTAL_BYTES_PINNED_BATCH SZ_128M - #define BTRFS_MAX_EXTENT_SIZE SZ_128M /* From patchwork Wed Sep 14 15:06:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976282 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 615E9ECAAD3 for ; Wed, 14 Sep 2022 15:07:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230151AbiINPHB (ORCPT ); Wed, 14 Sep 2022 11:07:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229989AbiINPGu (ORCPT ); Wed, 14 Sep 2022 11:06:50 -0400 Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4A1A76970 for ; Wed, 14 Sep 2022 08:06:48 -0700 (PDT) Received: by mail-qv1-xf36.google.com with SMTP id m9so11956490qvv.7 for ; Wed, 14 Sep 2022 08:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=veUf9gN9J/IFyBawP3ng3HjIx1YOMufVA0vFuAgYF2Y=; b=CnmMe4f3y/Ocp+gmuCeMll+rFdK19psJJYBnU18jYAMRMl3BCUHz5sdm7B5wXLVfmy /W2icRUl+c91Pnnq/CPnmImhSBeosKZEr5TZA+JPMuZ2kIFl5JkxchzI4H/pccGN1qyt mnA1TDQUR6mxr8K8X1Fy8CUk43DNPvx1Xc4+K1kEJStN1oO4yhfHqP5UXWcbHQVTlGez ReNpm/Pp9XBjEBtaPmzOoIqcYyCwQ4dM7MzuwqEer9Q04ZPOS8rLHtX7n1iK11kqBCUJ 2Dye0N8B8aHCuKXZuspSp8+6TdqeXFu94Tia6kDafa3whaEAaV0LtpK/3JOqiF51zAB3 Lxhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=veUf9gN9J/IFyBawP3ng3HjIx1YOMufVA0vFuAgYF2Y=; b=7YbBjI8QwAuQntyT4aG09XK5CADSRnJtH+xkOTEtf7Pc5TQ9a3X7Isn0DAcwABXYUL wuy/CgZd6NuaBYJ933qrS8vG/8JI3Rm2UdCAMySS8k0G0R1dI8LqUmYDQEe8lQaHJXVf gfupndwNppGlLaumVLgpcGwZkkxFx/nsjAWfaOCJSL0bxpP2rs6Vk3FXbJAoYvM59e7t r0d5uzZvYfFbXzP4zUdHnNu/k0K0OLYWRwb48pw9qWJY/CPmcXxN7P0Vu0WAq55FnULu euA8xY+DMR8IcdIYsKLlpMGzrh5oRUlXwk5t1JzpSCxGKF2cMQ3Wu2RV9WipvyCtxuSE PU+A== X-Gm-Message-State: ACgBeo2bERTsIlJYwIBWu5oNXJY9xgVXlUs/iiH8GC4zouQEeJz7FqsJ Hogcu37XQj772KVAhIxx23GFCKoVfQXtbQ== X-Google-Smtp-Source: AA6agR4pmh3LOzBDvfH7ybzRSfynhessWdOA9ipME2PbM2HXl0eBrQBAbvGdAEEk+il/NvKNSMZmOQ== X-Received: by 2002:ad4:574f:0:b0:49d:e2f6:215a with SMTP id q15-20020ad4574f000000b0049de2f6215amr32100514qvx.98.1663168007402; Wed, 14 Sep 2022 08:06:47 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id b9-20020ac812c9000000b0035a6f972f84sm1621396qtj.62.2022.09.14.08.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:06:46 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 03/17] btrfs: remove BTRFS_IOPRIO_READA Date: Wed, 14 Sep 2022 11:06:27 -0400 Message-Id: <2ffc1a38bf1e342d2b1a44105b00bf3c8b57686c.1663167823.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The last user of this definition was removed in patch f26c92386028 ("btrfs: remove reada infrastructure") so we can remove this definition. Signed-off-by: Josef Bacik Reviewed-by: Qu Wenruo Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 3936bb95331d..5cf18a120dff 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -82,9 +82,6 @@ struct btrfs_ioctl_encoded_io_args; #define BTRFS_EMPTY_DIR_SIZE 0 -/* ioprio of readahead is set to idle */ -#define BTRFS_IOPRIO_READA (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0)) - #define BTRFS_DIRTY_METADATA_THRESH SZ_32M #define BTRFS_MAX_EXTENT_SIZE SZ_128M From patchwork Wed Sep 14 15:06:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976283 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 CA511ECAAD3 for ; Wed, 14 Sep 2022 15:07:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229650AbiINPHD (ORCPT ); Wed, 14 Sep 2022 11:07:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229837AbiINPGv (ORCPT ); Wed, 14 Sep 2022 11:06:51 -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 4A99877E80 for ; Wed, 14 Sep 2022 08:06:50 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id c11so11363817qtw.8 for ; Wed, 14 Sep 2022 08:06:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=oABoixBFI91oZKgA2zZitFgs73Xzrpga0ZMJ4zfMr6c=; b=FWqjR1XRsMzVwbhYxJpOKZccBoHAga5KffzWRwxN+d0p0KReOxBQD9LfWouUwfWTEe YrQZYgo4jsZPJsYIoxvU59OXRcDgThzTnq39mK7LtAO4ysmk3lgBV3pAxY7WBVzLDIA+ B9Sth2q8HJH2OHNZMEqHZMpWwszr7vP5H1hQaF+g8p2eFRV7Pzn5DHkS1Ufnk2YdiHEf WYCZrcWryxdTx2oMRi2jICNkh5/1rTe6y/WAbrbAakWgD6fwukQWKOTvVqJ9bwVqvUdp Q8QX983KFKeFqUc89vUsf8Rr2w1zce1COQYmJCObLr7+LTi08+NHbIXLIvtFw5/mLIqQ Dq/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=oABoixBFI91oZKgA2zZitFgs73Xzrpga0ZMJ4zfMr6c=; b=Id+V28/ROMZLdl8J/18WEXvzsXjFwMTFj5ouLQcMgEYgUO/Z1VFTcvAmGjFMfpagv6 4wSaKCd5rrl0XMJkxQ7fcdkiEOablUo3gPWAs+otgvIP34dv6MKLYpY6x2TWP55PMGTC nzG6WTs8k0+d7GDRzEceclq/2w2po2sHakfXahXLXohZIWfyjGD41ePQE8qI1hwGISEe Z0hcGdC4aXAnT6mZJBaK+YbU1btMdTwMLn3eRicZG+YNMg2BcY5q3Vqfy9suRyOGoJHO fuUH97tk5bsjBHGyC7ZCPKf8dzvvtF+uKwtK3e4QdTCEd6uUoRjGiWgc37w5JLfT7Owp lXmw== X-Gm-Message-State: ACgBeo2LWDM7EE+e4CfVMHy7InGW2jsKyPGc38aQpa9cAREZrO/1ZQqS ua9qW9Kb69DlLSXEP4aEoW+AoX9fF4CBbQ== X-Google-Smtp-Source: AA6agR7gCMaUQ3A4SIFpMbxGXKASjDZRaIlzaLjDk2fYNZ2Orft/Aa/qiWg204IlprBrkBnyRJY9VA== X-Received: by 2002:a05:622a:f:b0:35b:a648:5871 with SMTP id x15-20020a05622a000f00b0035ba6485871mr20018051qtw.43.1663168008903; Wed, 14 Sep 2022 08:06:48 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id s14-20020ac85ece000000b00339b8a5639csm1609245qtx.95.2022.09.14.08.06.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:06:48 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 04/17] btrfs: move btrfs on disk definitions out of ctree.h Date: Wed, 14 Sep 2022 11:06:28 -0400 Message-Id: <058e41f7732823196f030916c04134418688cbe9.1663167823.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The bulk of our on-disk definitions exist in btrfs_tree.h, which user space can use. Keep things consistent and move the rest of the on disk definitions out of ctree.h into btrfs_tree.h. Note I did have to update all u8's to __u8, but otherwise this is a strict copy and paste. Signed-off-by: Josef Bacik Reviewed-by: Qu Wenruo --- fs/btrfs/ctree.h | 215 +------------------------------- include/uapi/linux/btrfs_tree.h | 213 +++++++++++++++++++++++++++++++ 2 files changed, 214 insertions(+), 214 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 5cf18a120dff..c3a8440d3223 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -50,8 +50,6 @@ struct btrfs_ref; struct btrfs_bio; struct btrfs_ioctl_encoded_io_args; -#define BTRFS_MAGIC 0x4D5F53665248425FULL /* ascii _BHRfS_M, no null */ - /* * Maximum number of mirrors that can be available for all profiles counting * the target device of dev-replace as one. During an active device replace @@ -63,8 +61,6 @@ struct btrfs_ioctl_encoded_io_args; */ #define BTRFS_MAX_MIRRORS (4 + 1) -#define BTRFS_MAX_LEVEL 8 - #define BTRFS_OLDEST_GENERATION 0ULL /* @@ -133,81 +129,9 @@ enum { BTRFS_FS_STATE_COUNT }; -#define BTRFS_BACKREF_REV_MAX 256 -#define BTRFS_BACKREF_REV_SHIFT 56 -#define BTRFS_BACKREF_REV_MASK (((u64)BTRFS_BACKREF_REV_MAX - 1) << \ - BTRFS_BACKREF_REV_SHIFT) - -#define BTRFS_OLD_BACKREF_REV 0 -#define BTRFS_MIXED_BACKREF_REV 1 - -/* - * every tree block (leaf or node) starts with this header. - */ -struct btrfs_header { - /* these first four must match the super block */ - u8 csum[BTRFS_CSUM_SIZE]; - u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */ - __le64 bytenr; /* which block this node is supposed to live in */ - __le64 flags; - - /* allowed to be different from the super from here on down */ - u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; - __le64 generation; - __le64 owner; - __le32 nritems; - u8 level; -} __attribute__ ((__packed__)); - -/* - * this is a very generous portion of the super block, giving us - * room to translate 14 chunks with 3 stripes each. - */ -#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048 - -/* - * just in case we somehow lose the roots and are not able to mount, - * we store an array of the roots from previous transactions - * in the super. - */ -#define BTRFS_NUM_BACKUP_ROOTS 4 -struct btrfs_root_backup { - __le64 tree_root; - __le64 tree_root_gen; - - __le64 chunk_root; - __le64 chunk_root_gen; - - __le64 extent_root; - __le64 extent_root_gen; - - __le64 fs_root; - __le64 fs_root_gen; - - __le64 dev_root; - __le64 dev_root_gen; - - __le64 csum_root; - __le64 csum_root_gen; - - __le64 total_bytes; - __le64 bytes_used; - __le64 num_devices; - /* future */ - __le64 unused_64[4]; - - u8 tree_root_level; - u8 chunk_root_level; - u8 extent_root_level; - u8 fs_root_level; - u8 dev_root_level; - u8 csum_root_level; - /* future and to align */ - u8 unused_8[10]; -} __attribute__ ((__packed__)); - #define BTRFS_SUPER_INFO_OFFSET SZ_64K #define BTRFS_SUPER_INFO_SIZE 4096 +static_assert(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE); /* * The reserved space at the beginning of each device. @@ -216,69 +140,6 @@ struct btrfs_root_backup { */ #define BTRFS_DEVICE_RANGE_RESERVED (SZ_1M) -/* - * the super block basically lists the main trees of the FS - * it currently lacks any block count etc etc - */ -struct btrfs_super_block { - /* the first 4 fields must match struct btrfs_header */ - u8 csum[BTRFS_CSUM_SIZE]; - /* FS specific UUID, visible to user */ - u8 fsid[BTRFS_FSID_SIZE]; - __le64 bytenr; /* this block number */ - __le64 flags; - - /* allowed to be different from the btrfs_header from here own down */ - __le64 magic; - __le64 generation; - __le64 root; - __le64 chunk_root; - __le64 log_root; - - /* - * This member has never been utilized since the very beginning, thus - * it's always 0 regardless of kernel version. We always use - * generation + 1 to read log tree root. So here we mark it deprecated. - */ - __le64 __unused_log_root_transid; - __le64 total_bytes; - __le64 bytes_used; - __le64 root_dir_objectid; - __le64 num_devices; - __le32 sectorsize; - __le32 nodesize; - __le32 __unused_leafsize; - __le32 stripesize; - __le32 sys_chunk_array_size; - __le64 chunk_root_generation; - __le64 compat_flags; - __le64 compat_ro_flags; - __le64 incompat_flags; - __le16 csum_type; - u8 root_level; - u8 chunk_root_level; - u8 log_root_level; - struct btrfs_dev_item dev_item; - - char label[BTRFS_LABEL_SIZE]; - - __le64 cache_generation; - __le64 uuid_tree_generation; - - /* the UUID written into btree blocks */ - u8 metadata_uuid[BTRFS_FSID_SIZE]; - - /* future expansion */ - u8 reserved8[8]; - __le64 reserved[27]; - u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE]; - struct btrfs_root_backup super_roots[BTRFS_NUM_BACKUP_ROOTS]; - - /* Padded to 4096 bytes */ - u8 padding[565]; -} __attribute__ ((__packed__)); -static_assert(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE); - /* * Compat flags that we support. If any incompat flags are set other than the * ones specified below then we will fail to mount @@ -336,43 +197,6 @@ static_assert(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE); (BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF) #define BTRFS_FEATURE_INCOMPAT_SAFE_CLEAR 0ULL -/* - * A leaf is full of items. offset and size tell us where to find - * the item in the leaf (relative to the start of the data area) - */ -struct btrfs_item { - struct btrfs_disk_key key; - __le32 offset; - __le32 size; -} __attribute__ ((__packed__)); - -/* - * leaves have an item area and a data area: - * [item0, item1....itemN] [free space] [dataN...data1, data0] - * - * The data is separate from the items to get the keys closer together - * during searches. - */ -struct btrfs_leaf { - struct btrfs_header header; - struct btrfs_item items[]; -} __attribute__ ((__packed__)); - -/* - * all non-leaf blocks are nodes, they hold only keys and pointers to - * other blocks - */ -struct btrfs_key_ptr { - struct btrfs_disk_key key; - __le64 blockptr; - __le64 generation; -} __attribute__ ((__packed__)); - -struct btrfs_node { - struct btrfs_header header; - struct btrfs_key_ptr ptrs[]; -} __attribute__ ((__packed__)); - /* Read ahead values for struct btrfs_path.reada */ enum { READA_NONE, @@ -1633,43 +1457,6 @@ do { \ #define btrfs_clear_pending(info, opt) \ clear_bit(BTRFS_PENDING_##opt, &(info)->pending_changes) -/* - * Inode flags - */ -#define BTRFS_INODE_NODATASUM (1U << 0) -#define BTRFS_INODE_NODATACOW (1U << 1) -#define BTRFS_INODE_READONLY (1U << 2) -#define BTRFS_INODE_NOCOMPRESS (1U << 3) -#define BTRFS_INODE_PREALLOC (1U << 4) -#define BTRFS_INODE_SYNC (1U << 5) -#define BTRFS_INODE_IMMUTABLE (1U << 6) -#define BTRFS_INODE_APPEND (1U << 7) -#define BTRFS_INODE_NODUMP (1U << 8) -#define BTRFS_INODE_NOATIME (1U << 9) -#define BTRFS_INODE_DIRSYNC (1U << 10) -#define BTRFS_INODE_COMPRESS (1U << 11) - -#define BTRFS_INODE_ROOT_ITEM_INIT (1U << 31) - -#define BTRFS_INODE_FLAG_MASK \ - (BTRFS_INODE_NODATASUM | \ - BTRFS_INODE_NODATACOW | \ - BTRFS_INODE_READONLY | \ - BTRFS_INODE_NOCOMPRESS | \ - BTRFS_INODE_PREALLOC | \ - BTRFS_INODE_SYNC | \ - BTRFS_INODE_IMMUTABLE | \ - BTRFS_INODE_APPEND | \ - BTRFS_INODE_NODUMP | \ - BTRFS_INODE_NOATIME | \ - BTRFS_INODE_DIRSYNC | \ - BTRFS_INODE_COMPRESS | \ - BTRFS_INODE_ROOT_ITEM_INIT) - -#define BTRFS_INODE_RO_VERITY (1U << 0) - -#define BTRFS_INODE_RO_FLAG_MASK (BTRFS_INODE_RO_VERITY) - struct btrfs_map_token { struct extent_buffer *eb; char *kaddr; diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h index 1f7a38ec6ac3..e6bf902b9c92 100644 --- a/include/uapi/linux/btrfs_tree.h +++ b/include/uapi/linux/btrfs_tree.h @@ -10,6 +10,10 @@ #include #endif +#define BTRFS_MAGIC 0x4D5F53665248425FULL /* ascii _BHRfS_M, no null */ + +#define BTRFS_MAX_LEVEL 8 + /* * This header contains the structure definitions and constants used * by file system objects that can be retrieved using @@ -360,6 +364,43 @@ enum btrfs_csum_type { #define BTRFS_FT_XATTR 8 #define BTRFS_FT_MAX 9 +/* + * Inode flags + */ +#define BTRFS_INODE_NODATASUM (1U << 0) +#define BTRFS_INODE_NODATACOW (1U << 1) +#define BTRFS_INODE_READONLY (1U << 2) +#define BTRFS_INODE_NOCOMPRESS (1U << 3) +#define BTRFS_INODE_PREALLOC (1U << 4) +#define BTRFS_INODE_SYNC (1U << 5) +#define BTRFS_INODE_IMMUTABLE (1U << 6) +#define BTRFS_INODE_APPEND (1U << 7) +#define BTRFS_INODE_NODUMP (1U << 8) +#define BTRFS_INODE_NOATIME (1U << 9) +#define BTRFS_INODE_DIRSYNC (1U << 10) +#define BTRFS_INODE_COMPRESS (1U << 11) + +#define BTRFS_INODE_ROOT_ITEM_INIT (1U << 31) + +#define BTRFS_INODE_FLAG_MASK \ + (BTRFS_INODE_NODATASUM | \ + BTRFS_INODE_NODATACOW | \ + BTRFS_INODE_READONLY | \ + BTRFS_INODE_NOCOMPRESS | \ + BTRFS_INODE_PREALLOC | \ + BTRFS_INODE_SYNC | \ + BTRFS_INODE_IMMUTABLE | \ + BTRFS_INODE_APPEND | \ + BTRFS_INODE_NODUMP | \ + BTRFS_INODE_NOATIME | \ + BTRFS_INODE_DIRSYNC | \ + BTRFS_INODE_COMPRESS | \ + BTRFS_INODE_ROOT_ITEM_INIT) + +#define BTRFS_INODE_RO_VERITY (1U << 0) + +#define BTRFS_INODE_RO_FLAG_MASK (BTRFS_INODE_RO_VERITY) + /* * The key defines the order in the tree, and so it also defines (optimal) * block layout. @@ -389,6 +430,108 @@ struct btrfs_key { __u64 offset; } __attribute__ ((__packed__)); +/* + * every tree block (leaf or node) starts with this header. + */ +struct btrfs_header { + /* these first four must match the super block */ + __u8 csum[BTRFS_CSUM_SIZE]; + __u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */ + __le64 bytenr; /* which block this node is supposed to live in */ + __le64 flags; + + /* allowed to be different from the super from here on down */ + __u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; + __le64 generation; + __le64 owner; + __le32 nritems; + __u8 level; +} __attribute__ ((__packed__)); + +/* + * this is a very generous portion of the super block, giving us + * room to translate 14 chunks with 3 stripes each. + */ +#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048 + +/* + * just in case we somehow lose the roots and are not able to mount, + * we store an array of the roots from previous transactions + * in the super. + */ +#define BTRFS_NUM_BACKUP_ROOTS 4 +struct btrfs_root_backup { + __le64 tree_root; + __le64 tree_root_gen; + + __le64 chunk_root; + __le64 chunk_root_gen; + + __le64 extent_root; + __le64 extent_root_gen; + + __le64 fs_root; + __le64 fs_root_gen; + + __le64 dev_root; + __le64 dev_root_gen; + + __le64 csum_root; + __le64 csum_root_gen; + + __le64 total_bytes; + __le64 bytes_used; + __le64 num_devices; + /* future */ + __le64 unused_64[4]; + + __u8 tree_root_level; + __u8 chunk_root_level; + __u8 extent_root_level; + __u8 fs_root_level; + __u8 dev_root_level; + __u8 csum_root_level; + /* future and to align */ + __u8 unused_8[10]; +} __attribute__ ((__packed__)); + +/* + * A leaf is full of items. offset and size tell us where to find + * the item in the leaf (relative to the start of the data area) + */ +struct btrfs_item { + struct btrfs_disk_key key; + __le32 offset; + __le32 size; +} __attribute__ ((__packed__)); + +/* + * leaves have an item area and a data area: + * [item0, item1....itemN] [free space] [dataN...data1, data0] + * + * The data is separate from the items to get the keys closer together + * during searches. + */ +struct btrfs_leaf { + struct btrfs_header header; + struct btrfs_item items[]; +} __attribute__ ((__packed__)); + +/* + * all non-leaf blocks are nodes, they hold only keys and pointers to + * other blocks + */ +struct btrfs_key_ptr { + struct btrfs_disk_key key; + __le64 blockptr; + __le64 generation; +} __attribute__ ((__packed__)); + +struct btrfs_node { + struct btrfs_header header; + struct btrfs_key_ptr ptrs[]; +} __attribute__ ((__packed__)); + struct btrfs_dev_item { /* the internal btrfs device id */ __le64 devid; @@ -472,6 +615,68 @@ struct btrfs_chunk { /* additional stripes go here */ } __attribute__ ((__packed__)); +/* + * the super block basically lists the main trees of the FS + * it currently lacks any block count etc etc + */ +struct btrfs_super_block { + /* the first 4 fields must match struct btrfs_header */ + __u8 csum[BTRFS_CSUM_SIZE]; + /* FS specific UUID, visible to user */ + __u8 fsid[BTRFS_FSID_SIZE]; + __le64 bytenr; /* this block number */ + __le64 flags; + + /* allowed to be different from the btrfs_header from here own down */ + __le64 magic; + __le64 generation; + __le64 root; + __le64 chunk_root; + __le64 log_root; + + /* + * This member has never been utilized since the very beginning, thus + * it's always 0 regardless of kernel version. We always use + * generation + 1 to read log tree root. So here we mark it deprecated. + */ + __le64 __unused_log_root_transid; + __le64 total_bytes; + __le64 bytes_used; + __le64 root_dir_objectid; + __le64 num_devices; + __le32 sectorsize; + __le32 nodesize; + __le32 __unused_leafsize; + __le32 stripesize; + __le32 sys_chunk_array_size; + __le64 chunk_root_generation; + __le64 compat_flags; + __le64 compat_ro_flags; + __le64 incompat_flags; + __le16 csum_type; + __u8 root_level; + __u8 chunk_root_level; + __u8 log_root_level; + struct btrfs_dev_item dev_item; + + char label[BTRFS_LABEL_SIZE]; + + __le64 cache_generation; + __le64 uuid_tree_generation; + + /* the UUID written into btree blocks */ + __u8 metadata_uuid[BTRFS_FSID_SIZE]; + + /* future expansion */ + __u8 reserved8[8]; + __le64 reserved[27]; + __u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE]; + struct btrfs_root_backup super_roots[BTRFS_NUM_BACKUP_ROOTS]; + + /* Padded to 4096 bytes */ + __u8 padding[565]; +} __attribute__ ((__packed__)); + #define BTRFS_FREE_SPACE_EXTENT 1 #define BTRFS_FREE_SPACE_BITMAP 2 @@ -526,6 +731,14 @@ struct btrfs_extent_item_v0 { /* use full backrefs for extent pointers in the block */ #define BTRFS_BLOCK_FLAG_FULL_BACKREF (1ULL << 8) +#define BTRFS_BACKREF_REV_MAX 256 +#define BTRFS_BACKREF_REV_SHIFT 56 +#define BTRFS_BACKREF_REV_MASK (((u64)BTRFS_BACKREF_REV_MAX - 1) << \ + BTRFS_BACKREF_REV_SHIFT) + +#define BTRFS_OLD_BACKREF_REV 0 +#define BTRFS_MIXED_BACKREF_REV 1 + /* * this flag is only used internally by scrub and may be changed at any time * it is only declared here to avoid collisions From patchwork Wed Sep 14 15:06:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976284 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 2710CC6FA8A for ; Wed, 14 Sep 2022 15:07:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229874AbiINPHF (ORCPT ); Wed, 14 Sep 2022 11:07:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230100AbiINPGw (ORCPT ); Wed, 14 Sep 2022 11:06:52 -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 0C1B57694D for ; Wed, 14 Sep 2022 08:06:51 -0700 (PDT) Received: by mail-qv1-xf2e.google.com with SMTP id o13so11944421qvw.12 for ; Wed, 14 Sep 2022 08:06:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=2AjHThnE0yn83nW/cdnIYAI/OvmH2ANgBiP0rzjjGR8=; b=0d5lxOvFrCeeubJjAt/NlkYHa1uXl80nNoEgbWs2YUyix+RE3qhNu8bKMyjGZVbRp0 IUvsIhXd01Uwf32tEd9tas0jhPjxiejlDz9T+7MKpm3pC/kIkAMa+KVWyFfnwmGvuESB 8C7n7VW1NNMp0XDcJ25i5YAet0BTAOlPQWYVzTgqljOhu8lLiXkJxuQH9Rld5lxPVvyr 9TG8UnnevCSqGG0Pd6wVsp0QcC6j2ELCrT6anvyjInX7qcGF+lbsZFwr5F4hw85TqVHt EZ/0OocIEQhJyR8s+Mn1Cn8aVkNpGUPNVEHg4YM4AYgp7kgvrpxe8guVH6CtbJXPQNNm KsRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=2AjHThnE0yn83nW/cdnIYAI/OvmH2ANgBiP0rzjjGR8=; b=NhogA/Y4foXoX/6IR+et4/5LJasK6ANfiKfL9ZHj0UzE3mgV+OrcYPTo4CGQlpyQbk oekMt0b27puOTmEZl5XO1qe6rNO1kZCD8iGh2Q6xcBL3g8dghvpa8PA3Uo8rD0SD9yt+ peBrPzPMA/j2iZD2+TFVZj0Xaw9vKNZlIPtDJX5+25ytdqhnN8yOSKoRWkusj6C5kIxX 2tPAWGz1uUFm0+kxmjue04yO40W6Ax6EDaYbLoc54Mc8ucxy10yT2thxFjvHlMMPEaDD 6JWNvrdyssqBzL+Zkcd1RT2tBQNfX01KJ3TQy+S8ZP8iMvib0wbVpOp0K9H0p5Luughs nqtg== X-Gm-Message-State: ACgBeo2OK/cRoE7wnuiLPWBFV2/n9vwi9GJ2Db8rsX3zdD/D8csapfj9 +mXM8tOGURkZl4EeVrsP6e5rwNqtnGfCHw== X-Google-Smtp-Source: AA6agR79svqG5F0JpaJz0hihMoQLrCsJmdy+yy8VxohsCjqo4oCDoSiZA8/+NWgLvtXPtaet/9z/vw== X-Received: by 2002:a05:6214:528e:b0:4ac:d1bf:59b4 with SMTP id kj14-20020a056214528e00b004acd1bf59b4mr6017832qvb.3.1663168010341; Wed, 14 Sep 2022 08:06:50 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id h16-20020ac85850000000b00342f8d4d0basm1773967qth.43.2022.09.14.08.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:06:49 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 05/17] btrfs: move btrfs_get_block_group helper out of disk-io.h Date: Wed, 14 Sep 2022 11:06:29 -0400 Message-Id: <375729b0fb82db1991d42f26b0853f30a3c9086d.1663167823.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This inline helper calls btrfs_fs_compat_ro(), which is defined in another header. To avoid weird header dependency problems move this helper into disk-io.c with the rest of the global root helpers. Signed-off-by: Josef Bacik Reviewed-by: Johannes Thumshirn --- fs/btrfs/disk-io.c | 7 +++++++ fs/btrfs/disk-io.h | 8 +------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index a887fe67a2a0..d32aa67f962b 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1169,6 +1169,13 @@ struct btrfs_root *btrfs_extent_root(struct btrfs_fs_info *fs_info, u64 bytenr) return btrfs_global_root(fs_info, &key); } +struct btrfs_root *btrfs_block_group_root(struct btrfs_fs_info *fs_info) +{ + if (btrfs_fs_compat_ro(fs_info, BLOCK_GROUP_TREE)) + return fs_info->block_group_root; + return btrfs_extent_root(fs_info, 0); +} + struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans, u64 objectid) { diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h index 7e545ec09a10..084fbe5768e1 100644 --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h @@ -72,6 +72,7 @@ struct btrfs_root *btrfs_global_root(struct btrfs_fs_info *fs_info, struct btrfs_key *key); struct btrfs_root *btrfs_csum_root(struct btrfs_fs_info *fs_info, u64 bytenr); struct btrfs_root *btrfs_extent_root(struct btrfs_fs_info *fs_info, u64 bytenr); +struct btrfs_root *btrfs_block_group_root(struct btrfs_fs_info *fs_info); void btrfs_free_fs_info(struct btrfs_fs_info *fs_info); int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info); @@ -103,13 +104,6 @@ static inline struct btrfs_root *btrfs_grab_root(struct btrfs_root *root) return NULL; } -static inline struct btrfs_root *btrfs_block_group_root(struct btrfs_fs_info *fs_info) -{ - if (btrfs_fs_compat_ro(fs_info, BLOCK_GROUP_TREE)) - return fs_info->block_group_root; - return btrfs_extent_root(fs_info, 0); -} - void btrfs_put_root(struct btrfs_root *root); void btrfs_mark_buffer_dirty(struct extent_buffer *buf); int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid, From patchwork Wed Sep 14 15:06:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976285 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 174D8ECAAD3 for ; Wed, 14 Sep 2022 15:07:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229565AbiINPHH (ORCPT ); Wed, 14 Sep 2022 11:07:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230119AbiINPGz (ORCPT ); Wed, 14 Sep 2022 11:06:55 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B98678218 for ; Wed, 14 Sep 2022 08:06:53 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id i3so6375412qkl.3 for ; Wed, 14 Sep 2022 08:06:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=i6BWu4JC1XN096ArKhIcaU5s6vdKKjahtDAjlDa2K0A=; b=VGJa/3G4/aJTixlxfsPj2TwSt/oLgP0m6GEtawNMGattzb27Y2ht0YTZAKYDM+0Q7B HlX3yZKr0+tgBZoG5/el9KHcgrFPE1+sdTFF+uzRS4l08Zuj3hExmUoWRuxgUuRWA14U keAIQq07OunyVie36QgqOsGZ4uEylm1ZDMnWgCeZK9fZAI0O7RkRIqidqKRnWxdTPYdt iEPhcbZG1zTWCv56bJDHgvwtCHeIN1RTYcntbCER/LOKJa5FjzHHYxF6hFkC/e8h59E6 1W7A/P0HKLos6pPDZtzW0hBB0VS0H6sG0ksSqRrzKCxtOU9IKqrr7oQeeq4DX3LyKn1w x8vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=i6BWu4JC1XN096ArKhIcaU5s6vdKKjahtDAjlDa2K0A=; b=Yc7tEs2RLYo/6F5SW5lM5myRiWxTcMg/rQVWE3C+iWp5xuySbDW0VMgythfX9gCQcP m3jd+R84iqtx+7Jry/UJgwNnZhP/TVH/tvL+bUlQcamUTHSZiShT5tOZdyCDSy+UwxqO IFnseYnYXtgoMbtUhiHlWajsWRgGZgPhCYobZ6IuFeIXCe0MxDCHm3ppTw8Ry0A3kOEX HNv+gAr84OPo/1weVsn0o41wvP1kmMkHI1ldSgcxi5u5YmCKsmjeNR8CFI5RAoP6o7hH qwquhfJfg+ZDbmVvDi+ZGlELwZ1r7K2DrqYKCi1MsA1bjPTkLz/kRYBtjVvmYdyAQKiP j0mA== X-Gm-Message-State: ACgBeo2VT61fDmUhfulAGFdJn+Q2ysmRc4vlTlT+WzsOvZF+6K1btqEk cilD0tuAXwRMcW4CDdIWQTLBz3G+/RSzqw== X-Google-Smtp-Source: AA6agR6HwN9+q27jJ9bZLFEokYaRML3nH86W0o/sB97Vm8s6zLQCe6gA63u+hWKdF3fC3a9nZ2DukA== X-Received: by 2002:a37:b404:0:b0:6c1:a498:2f46 with SMTP id d4-20020a37b404000000b006c1a4982f46mr27520950qkf.509.1663168011756; Wed, 14 Sep 2022 08:06:51 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id t16-20020a05622a01d000b0035bb6c3811asm1739897qtw.53.2022.09.14.08.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:06:51 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 06/17] btrfs: move maximum limits to btrfs_tree.h Date: Wed, 14 Sep 2022 11:06:30 -0400 Message-Id: X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org We have maximum link and name length limits, move these to btrfs_tree.h as they're on disk limitations. Signed-off-by: Josef Bacik Reviewed-by: Qu Wenruo Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 13 ------------- include/uapi/linux/btrfs_tree.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index c3a8440d3223..5e6b025c0870 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -63,19 +63,6 @@ struct btrfs_ioctl_encoded_io_args; #define BTRFS_OLDEST_GENERATION 0ULL -/* - * we can actually store much bigger names, but lets not confuse the rest - * of linux - */ -#define BTRFS_NAME_LEN 255 - -/* - * Theoretical limit is larger, but we keep this down to a sane - * value. That should limit greatly the possibility of collisions on - * inode ref items. - */ -#define BTRFS_LINK_MAX 65535U - #define BTRFS_EMPTY_DIR_SIZE 0 #define BTRFS_DIRTY_METADATA_THRESH SZ_32M diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h index e6bf902b9c92..c85e8c44ab92 100644 --- a/include/uapi/linux/btrfs_tree.h +++ b/include/uapi/linux/btrfs_tree.h @@ -14,6 +14,19 @@ #define BTRFS_MAX_LEVEL 8 +/* + * we can actually store much bigger names, but lets not confuse the rest + * of linux + */ +#define BTRFS_NAME_LEN 255 + +/* + * Theoretical limit is larger, but we keep this down to a sane + * value. That should limit greatly the possibility of collisions on + * inode ref items. + */ +#define BTRFS_LINK_MAX 65535U + /* * This header contains the structure definitions and constants used * by file system objects that can be retrieved using From patchwork Wed Sep 14 15:06:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976286 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 6F21BC6FA8A for ; Wed, 14 Sep 2022 15:07:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230110AbiINPHJ (ORCPT ); Wed, 14 Sep 2022 11:07:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230120AbiINPG4 (ORCPT ); Wed, 14 Sep 2022 11:06:56 -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 E7F1276966 for ; Wed, 14 Sep 2022 08:06:54 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id a20so8726838qtw.10 for ; Wed, 14 Sep 2022 08:06:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=hFAXnhRYrEK3GoxP0LVzN97K3kdl/elyCNFT+DHpGAw=; b=ZsOEjCosT4slGZSYqN8gJbJZE1FXzYHcjWUqH+SzKIxiblUQhGNCPJIN+QGDtAICCe JYUfw24ZBjCMO4uMXvgH75xhO20MHoqqcHuNadDUZgzdj8yyeyaukV9xiBFYkqw9v8cE JJshYjF5+BP2BA+UGE1QfxGc0ZM9zTuBvQFB3IRZEplkjJNR6Kad/CoK1ciHhqJpwDat ItLsTQ7PHLOpel0UfPlW0Yhq7rSzYhDVWc/4ZofaNxUnvmH2syvNKLhb/89yOzeE9jmN dimuqjh1rtCklo5pp3PrrtIwYIqYFwm5MyjJ7a02ShFdfwPa/RlzSDGvAvzmcsLfIQr+ G4kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=hFAXnhRYrEK3GoxP0LVzN97K3kdl/elyCNFT+DHpGAw=; b=n3T+LmQsZCaQNUJ3qR2KGb5svEWZ1AYvkjVIvfIZoUdLMYRcD0tBjcyhF1V2T8mmMh dT/ol7elRmMb6k/7UUd5yZmKy1A+gfEMF8LpLB3Gjhr6ObBg6XQ2MsGmZcdJQbxe6izh F7u6Jsd9ZSBIwcNeSeL2JgjhGIm0a/JUpUD0IXTzlJMvUi4skM0xjZoPmgkHPQroZsV6 XQquUga2x0wb+YNrmQuikelSvQ+Hf0ynR9qxMXUiZZtnmsatzfzNqClVFkYHZUH5mvp/ wbfROrpHCZHNhnOttMjTq3LmAz7HoKWzD8QcCTDO6Bot9A5O3ZpNGgqpRt4TDAV8Mxgb I1ow== X-Gm-Message-State: ACgBeo3NtfyL8fV+k8bimvu272Ndakwn6JIcftL7/pVSYbMDKxebppbd NxiifLkUCl/jt2817oO7ZqF0cStyU3QgkQ== X-Google-Smtp-Source: AA6agR5pdzJq3naYNy/Ij4QqkFdsFrUsqzeUVdG4otXZlQS2Djfn7fasKlDFpSZBn8jEBtB9PAxe2g== X-Received: by 2002:a05:622a:550:b0:344:90ec:50f5 with SMTP id m16-20020a05622a055000b0034490ec50f5mr34105055qtx.466.1663168013393; Wed, 14 Sep 2022 08:06:53 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id i10-20020a05620a404a00b006b98315c6fbsm2122146qko.1.2022.09.14.08.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:06:52 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 07/17] btrfs: move BTRFS_MAX_MIRRORS into scrub.c Date: Wed, 14 Sep 2022 11:06:31 -0400 Message-Id: <37fa62e6907f1eff71e2c77b9dadb324a408d9a2.1663167823.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This is only used locally in scrub.c, move it out of ctree.h into scrub.c. Signed-off-by: Josef Bacik Reviewed-by: Qu Wenruo Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 11 ----------- fs/btrfs/scrub.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 5e6b025c0870..e1ec047deff6 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -50,17 +50,6 @@ struct btrfs_ref; struct btrfs_bio; struct btrfs_ioctl_encoded_io_args; -/* - * Maximum number of mirrors that can be available for all profiles counting - * the target device of dev-replace as one. During an active device replace - * procedure, the target device of the copy operation is a mirror for the - * filesystem data as well that can be used to read data in order to repair - * read errors on other disks. - * - * Current value is derived from RAID1C4 with 4 copies. - */ -#define BTRFS_MAX_MIRRORS (4 + 1) - #define BTRFS_OLDEST_GENERATION 0ULL #define BTRFS_EMPTY_DIR_SIZE 0 diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 9b6a0adccc7b..35fca65f0f2a 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -56,6 +56,17 @@ struct scrub_ctx; #define SCRUB_MAX_PAGES (DIV_ROUND_UP(BTRFS_MAX_METADATA_BLOCKSIZE, PAGE_SIZE)) +/* + * Maximum number of mirrors that can be available for all profiles counting + * the target device of dev-replace as one. During an active device replace + * procedure, the target device of the copy operation is a mirror for the + * filesystem data as well that can be used to read data in order to repair + * read errors on other disks. + * + * Current value is derived from RAID1C4 with 4 copies. + */ +#define BTRFS_MAX_MIRRORS (4 + 1) + struct scrub_recover { refcount_t refs; struct btrfs_io_context *bioc; From patchwork Wed Sep 14 15:06:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976287 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 96642ECAAD3 for ; Wed, 14 Sep 2022 15:07:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230131AbiINPHK (ORCPT ); Wed, 14 Sep 2022 11:07:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230135AbiINPG5 (ORCPT ); Wed, 14 Sep 2022 11:06:57 -0400 Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B8627677C for ; Wed, 14 Sep 2022 08:06:56 -0700 (PDT) Received: by mail-qt1-x832.google.com with SMTP id z18so11374418qts.7 for ; Wed, 14 Sep 2022 08:06:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=5TCbmG9uld2V08UpcqmfC7D6SWwgupMLOva/r65mgSY=; b=FmYSl14yMY/KqA0OOMVBd3V89i5mzH9S+Ti20zoVs3fI/UnqbPN3Ei5sHu4jA121eR zZ1x9HKVph+ghlxED77dVnhT9sTZOWIW17rlTHvS1Ys5od31DUJjNUiIw0MP6vTmLnfg quTEj4SLc8radLpsMIq5+mys80Uzc8Hb+hJCQabKGzbhf59OSnO/eKrQl6/j4ixt/UVD 7lI+kIk7g3Et+QI7Jn3hEyDs3p0/wrGDZByqqiVsl9elN8U+8tJqxkqj6km2YBFaETdp 3aJPq9mlVtEMaG61z/nmZ30Z4r0/s8tJaY9rf1+pGp1XPU3OfMw0dpFhSR0RTL1XqnVP +NTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=5TCbmG9uld2V08UpcqmfC7D6SWwgupMLOva/r65mgSY=; b=Ef7RyWOa4+a5fBIOjdGf+TKF0LpsmNcnj8Q8FydDhd9GDlB5HwY6u/hu0MCpi/a5s5 ngsXfbBvF4+qscZKMY3egfkjAlwFQ/Nrzvn5Znt5F9oxqtcdTMFycRfZK6k0kUOd3IT7 WaVjeVHt5k/FOj/2enQfvA3nG1GKubuw6pLkP3URteSS13lWwe7RMqxqEgdbYq+9IjFx MKyt4rjQw7ZbjpYSIwvBxCve1d07LZcLfYPW3/SMxldEc4POfrBzkRB4kAY4m7vywA9P v+TfYX6oezkE55hHbSWwhRujxhWkGCf7XtKU2PKDrGoAbf1HJZlF3wmAUhgXjoOXkjUc aUOw== X-Gm-Message-State: ACgBeo2sFcPBXlVCAzigk61UsVG5tqD2KrijC+weoHH4FSIN+EjT2L84 Hr/4dA6pJYV3levsJxcOhyH5fLyTtLbDMg== X-Google-Smtp-Source: AA6agR5QfvTwyo9ZSNJI1reE5UF7fjHPoy10asprc2hGvQhd2Ueqj/Xlh5nVpT+BIWhafas68SrckA== X-Received: by 2002:a05:622a:4c6:b0:343:71e9:d661 with SMTP id q6-20020a05622a04c600b0034371e9d661mr33577368qtx.626.1663168014925; Wed, 14 Sep 2022 08:06:54 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id i10-20020a05620a404a00b006b98315c6fbsm2122192qko.1.2022.09.14.08.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:06:54 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 08/17] btrfs: move discard stat defs to free-space-cache.h Date: Wed, 14 Sep 2022 11:06:32 -0400 Message-Id: <5e7f34e068513a3a82b3bc810bc92a0eb0254863.1663167823.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org These definitions are used for discard statistics, move them out of ctree.h and put them in free-space-cache.h. Signed-off-by: Josef Bacik Reviewed-by: Qu Wenruo Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 9 --------- fs/btrfs/free-space-cache.h | 9 +++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index e1ec047deff6..2e6a947a48de 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -58,15 +58,6 @@ struct btrfs_ioctl_encoded_io_args; #define BTRFS_MAX_EXTENT_SIZE SZ_128M -/* - * Deltas are an effective way to populate global statistics. Give macro names - * to make it clear what we're doing. An example is discard_extents in - * btrfs_free_space_ctl. - */ -#define BTRFS_STAT_NR_ENTRIES 2 -#define BTRFS_STAT_CURR 0 -#define BTRFS_STAT_PREV 1 - static inline unsigned long btrfs_chunk_item_size(int num_stripes) { BUG_ON(num_stripes == 0); diff --git a/fs/btrfs/free-space-cache.h b/fs/btrfs/free-space-cache.h index 6d419ba53e95..eaf30f6444dd 100644 --- a/fs/btrfs/free-space-cache.h +++ b/fs/btrfs/free-space-cache.h @@ -43,6 +43,15 @@ static inline bool btrfs_free_space_trimming_bitmap( return (info->trim_state == BTRFS_TRIM_STATE_TRIMMING); } +/* + * Deltas are an effective way to populate global statistics. Give macro names + * to make it clear what we're doing. An example is discard_extents in + * btrfs_free_space_ctl. + */ +#define BTRFS_STAT_NR_ENTRIES 2 +#define BTRFS_STAT_CURR 0 +#define BTRFS_STAT_PREV 1 + struct btrfs_free_space_ctl { spinlock_t tree_lock; struct rb_root free_space_offset; From patchwork Wed Sep 14 15:06:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976288 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 67004C6FA82 for ; Wed, 14 Sep 2022 15:07:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230121AbiINPHM (ORCPT ); Wed, 14 Sep 2022 11:07:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230141AbiINPG7 (ORCPT ); Wed, 14 Sep 2022 11:06:59 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBB2F74DF6 for ; Wed, 14 Sep 2022 08:06:57 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id h28so11108543qka.0 for ; Wed, 14 Sep 2022 08:06:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=3P/AekNJYsZWxa6S5TDggSXC0raPMXg5TWjb1YBQtds=; b=IJoN/Y3JeHArxWOT/HEnHiiReEvLEVrPIv4b48gd8B3LAiKldYsOyW+tuToZFIb6U5 T39lfxrpaTB1EqgS4b+7cppOcnddRxkrlcuKLi/CH3Fwv2weklCdXeyulE6Io7h+aFmm OBbLj8Sv3pLxJRsGlHXhBguHbNtlgRA5R5lKBIZX4tABQ1a0RHmU183qi4BoTrUZagAH MVdzkpy9cSTMhtXY9p5RfWgvkLzAsgyLXpoYxuiL3RHOJmmQhBshrXfE1iXOQiDcDaKU OFrtPy99k0wLFQq4B2VVLvOM3MtD53lydzuMYKDsYmFlMfzJ1BXu2WnLQofSelM+sA9E zyCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=3P/AekNJYsZWxa6S5TDggSXC0raPMXg5TWjb1YBQtds=; b=mcHMKbHDe8Pj29OJa18bOfw14cLR86ilntSgQnobDcBEwptIbo3hXXBrWrTcb7grXo JjUOh69Scgkf+8QIDteiVbq2LiadgnKfWRtkwwsRnpU7egLve5z8/85F2Ejqz637qny2 8mcxFbYCGFXN1EHslXe4hRkMrOKiAfxx9gEgWbJMskIlpRNpIUlZhT09S4wMHqLDTcgY 1VhIonUCZ2NKiOB5raRTt5XWsYpxCSAuREzvoH6oSlJ5l2CRwjmLYe4/m3QGcXcO8RSS TINzBK1tPZoR+QLuY2BPJki9B8FnbUqZoTnUTlINQBihHJdHLpr+8x/Ui+2aFYicKNRA SnSA== X-Gm-Message-State: ACgBeo16lD8s/DfjQLuLTCRI1APvQDbrDT+GeaNHdDw/FaE+MGhmTso0 MvFQA5jsV39LIbAYtFG/+x8i4B7hM/LEnA== X-Google-Smtp-Source: AA6agR5cDCemf4IEd33LV+IBvCnWLUr0QP+ayLlP/ksb81oJ99wIbx6t/E+c4kQ2ACkE4SPcsoLAHA== X-Received: by 2002:a05:620a:29c9:b0:6ce:7681:19e9 with SMTP id s9-20020a05620a29c900b006ce768119e9mr5221039qkp.297.1663168016344; Wed, 14 Sep 2022 08:06:56 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id bk34-20020a05620a1a2200b006baef6daa45sm2005708qkb.119.2022.09.14.08.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:06:55 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 09/17] btrfs: move btrfs_chunk_item_size out of ctree.h Date: Wed, 14 Sep 2022 11:06:33 -0400 Message-Id: <3744e0ae6f8087daa9608174aeee00c53732f8bb.1663167823.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This is more of a volumes related helper, additionally it has a BUG_ON() which isn't defined in the related header. Move the code to volumes.c, change the BUG_ON() to an ASSERT(), and move the prototype to volumes.h. Signed-off-by: Josef Bacik Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 7 ------- fs/btrfs/volumes.c | 7 +++++++ fs/btrfs/volumes.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 2e6a947a48de..60f8817f5b7c 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -58,13 +58,6 @@ struct btrfs_ioctl_encoded_io_args; #define BTRFS_MAX_EXTENT_SIZE SZ_128M -static inline unsigned long btrfs_chunk_item_size(int num_stripes) -{ - BUG_ON(num_stripes == 0); - return sizeof(struct btrfs_chunk) + - sizeof(struct btrfs_stripe) * (num_stripes - 1); -} - /* * Runtime (in-memory) states of filesystem */ diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 94ba46d57920..b4de4d5ed69f 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -160,6 +160,13 @@ const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = { }, }; +unsigned long btrfs_chunk_item_size(int num_stripes) +{ + ASSERT(num_stripes); + return sizeof(struct btrfs_chunk) + + sizeof(struct btrfs_stripe) * (num_stripes - 1); +} + /* * Convert block group flags (BTRFS_BLOCK_GROUP_*) to btrfs_raid_types, which * can be used as index to access btrfs_raid_array[]. diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index f19a1cd1bfcf..96a7b437ff20 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -730,5 +730,5 @@ int btrfs_bg_type_to_factor(u64 flags); const char *btrfs_bg_type_to_raid_name(u64 flags); int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info); bool btrfs_repair_one_zone(struct btrfs_fs_info *fs_info, u64 logical); - +unsigned long btrfs_chunk_item_size(int num_stripes); #endif From patchwork Wed Sep 14 15:06:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976289 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 A6D9CECAAD3 for ; Wed, 14 Sep 2022 15:07:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229704AbiINPHN (ORCPT ); Wed, 14 Sep 2022 11:07:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbiINPHA (ORCPT ); Wed, 14 Sep 2022 11:07:00 -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 2422E76970 for ; Wed, 14 Sep 2022 08:06:59 -0700 (PDT) Received: by mail-qv1-xf30.google.com with SMTP id z9so482999qvn.9 for ; Wed, 14 Sep 2022 08:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=YJGd43YBCsJcN2dMM+DJC3daD+h0HkWsEG+Qle5OZJg=; b=uSgsDPvesF6iIMIVvaFlAAGe4AkGk2jxUHEOxx5xy8BxA7iW3n7w3TdLI6Nk6C1Nls 9ZowDPjeH2tx7X7BmOiGOYKAMVgfQLsxyO8HsRwXYdEE5ibxTq59GG9ZF2jt+bq/dEt8 Iv5G53QE/GhQUIZAtJyPoTruEBHc9Cg2CpgG8PWQ9G3ESlnJysEu7sbVFmc6hIByzUnV 04+5Jo+ePZgF9B4qCuHyeaDSwlLJhLzVlr0LJvIu6/9KBueM6/HKkP7534W3igmNn4QU 1uphQ+1eW8hO+CfTbPcpgURZFm6sqdb1QKLwDDNs8ZUrH5Aa6bk8iaJYiszxptdINQ+4 fdOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=YJGd43YBCsJcN2dMM+DJC3daD+h0HkWsEG+Qle5OZJg=; b=34zigGPKZRUELr/U7oORSBYz3E5eD0AGMvggkt8y0JllCM7UTcbRrhGwxkJMBeNUma oHEQgT4KkXK7WtvkR58xWU+29k43SSi7hW+DtU7l2f/TLA3d2QuN8gVJUssWcZqw2m35 bdxJIz2A9McZpHFwIhalu2utJDmKJMi2/GYciLVezfC3TUNJ+psd2h2gDTFO8UkX6xm6 nAg61L9EpHaaCDcZzyLX8eANcmaapDJ6XD8griKVF3Yom6PvQsfQqZz3uFPl5DCgdNVg b+mCnU8STJCmvEvl+Dn38tfQdznMeyFpvDNmW7mVe8C0eKyNxpXcvt+3jOLoerLg2JlQ Buwg== X-Gm-Message-State: ACgBeo0SkrVCPy4fWzX3u5G2G2oBtSdO3TFoC0vTpVNy3Ts1/8Ty2S5H HuQxFf5rgTRNtJkEIyqiyVbJwx++p+KRFQ== X-Google-Smtp-Source: AA6agR5FR9dgNHNIa/Md/hl9JoTEvV5TccXPvblDTmp9X34OonS8JeMlpbA166HAh6i8OTh2StmMUA== X-Received: by 2002:a05:6214:c29:b0:4aa:b050:5ed7 with SMTP id a9-20020a0562140c2900b004aab0505ed7mr31380519qvd.15.1663168017804; Wed, 14 Sep 2022 08:06:57 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id l11-20020ac8148b000000b0035a691cec8esm1602042qtj.29.2022.09.14.08.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:06:57 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 10/17] btrfs: move btrfs_should_fragment_free_space into block-group.c Date: Wed, 14 Sep 2022 11:06:34 -0400 Message-Id: <50ba0e87399977ef84a5d3787666fc6ce6c5cf3a.1663167823.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This function uses functions that are not defined in block-group.h, move it into block-group.c in order to keep the header clean. Signed-off-by: Josef Bacik Reviewed-by: Qu Wenruo Reviewed-by: Johannes Thumshirn --- fs/btrfs/block-group.c | 12 ++++++++++++ fs/btrfs/block-group.h | 11 +---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index c52b6e245b9a..c91f47a45b06 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -18,6 +18,18 @@ #include "raid56.h" #include "zoned.h" +#ifdef CONFIG_BTRFS_DEBUG +int btrfs_should_fragment_free_space(struct btrfs_block_group *block_group) +{ + struct btrfs_fs_info *fs_info = block_group->fs_info; + + return (btrfs_test_opt(fs_info, FRAGMENT_METADATA) && + block_group->flags & BTRFS_BLOCK_GROUP_METADATA) || + (btrfs_test_opt(fs_info, FRAGMENT_DATA) && + block_group->flags & BTRFS_BLOCK_GROUP_DATA); +} +#endif + /* * Return target flags in extended format or 0 if restripe for this chunk_type * is not in progress diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h index 4d4d2e1f137b..e34cb80ffb25 100644 --- a/fs/btrfs/block-group.h +++ b/fs/btrfs/block-group.h @@ -242,16 +242,7 @@ static inline bool btrfs_is_block_group_data_only( } #ifdef CONFIG_BTRFS_DEBUG -static inline int btrfs_should_fragment_free_space( - struct btrfs_block_group *block_group) -{ - struct btrfs_fs_info *fs_info = block_group->fs_info; - - return (btrfs_test_opt(fs_info, FRAGMENT_METADATA) && - block_group->flags & BTRFS_BLOCK_GROUP_METADATA) || - (btrfs_test_opt(fs_info, FRAGMENT_DATA) && - block_group->flags & BTRFS_BLOCK_GROUP_DATA); -} +int btrfs_should_fragment_free_space(struct btrfs_block_group *block_group); #endif struct btrfs_block_group *btrfs_lookup_first_block_group( From patchwork Wed Sep 14 15:06:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976290 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 1786BC6FA8A for ; Wed, 14 Sep 2022 15:07:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230119AbiINPHP (ORCPT ); Wed, 14 Sep 2022 11:07:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230155AbiINPHB (ORCPT ); Wed, 14 Sep 2022 11:07:01 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7B0A7694D for ; Wed, 14 Sep 2022 08:07:00 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id d15so11069356qka.9 for ; Wed, 14 Sep 2022 08:07:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=WhDj7S4ZAtRZpe7QjuqEx84NdUSTMg4XxgEuAjzN58w=; b=uJwNzcJ4b34m2xHmZsulTW5hIFE1HDE92Lc7VW0c+4aw6RUcXOQl2qzz99nYcmaZ4o djniHVNNDkAaGawW/Hh5VYLaJ2F+HKJhCXaTOsBukRpFDCdFAhNks+Tq5MsvmPD5Diew odjx11yhSCk/KurXX1W29dEbdj+yZXEQwiLr9YLQKY89cUxRBFSPJ6/RMy9Dj4hqaA+q vDoUM+aRU3s+e/3LVkLlRp6t594MMDbqBi7RxFVYKu4ilbdYcdazaVFsWKJW3bOW73KL Z1xHDwILOQbsrhn99mt2vKKCK9G02ocXMuITqOBcj35dcRp022mMnQ4PBVl/DvfyAJe7 hsGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=WhDj7S4ZAtRZpe7QjuqEx84NdUSTMg4XxgEuAjzN58w=; b=UHxqItgK1tyXoRopdOnBICbHxZqgqqma5SsVBZ/BCuwpYwVFu8W+/9VNqTuFtNdTHi 7iN9W83L+H+rPEDP7HOTaeyLK2sodDIlrCkDdXBycUzQ/I+dJYVBfheU8/cJ0gi2TdcZ yBpQL0rLiOdPV4j+TChxPorQlQSWQGEWibQ5sVrCtzjO4nc8M45OD4OR5mFrJw/vbGH6 XIk3axfWKg1jmN4MxpVnfZ7JGwr8YRt7A/YwRfnd1jZ+rOHQ1mE75h0VNVH+iTf024r7 e2cPANT062LSoa7RewNANPqSE2UnPz2FGpifesQMvghneHxwiEzan/nlwsfMtCZxEoOB bCRg== X-Gm-Message-State: ACgBeo2KRNjSMgrGTD+CrflvTan6piUqxWL2v0RQGdJpmDbSiGdcEe0F 60DNc8ryWJ52vTEGeFSl8JCBsJJS9KlVNQ== X-Google-Smtp-Source: AA6agR5u3NoHsBbXRdqDmT1FHg3sIcGMrMMyhn1q7FyegkJoW7PTUrbVVlcatHWYGg0EHiDmsF2u0w== X-Received: by 2002:a05:620a:13cf:b0:6ce:3df8:5ccc with SMTP id g15-20020a05620a13cf00b006ce3df85cccmr10700816qkl.623.1663168019344; Wed, 14 Sep 2022 08:06:59 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id bl27-20020a05620a1a9b00b006bbc09af9f5sm1844441qkb.101.2022.09.14.08.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:06:58 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 11/17] btrfs: move flush related definitions to space-info.h Date: Wed, 14 Sep 2022 11:06:35 -0400 Message-Id: X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This code is used in space-info.c, move the definitions to space-info.h. Signed-off-by: Josef Bacik Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 59 ---------------------------------------- fs/btrfs/delayed-inode.c | 1 + fs/btrfs/inode-item.c | 1 + fs/btrfs/props.c | 1 + fs/btrfs/relocation.c | 1 + fs/btrfs/space-info.h | 59 ++++++++++++++++++++++++++++++++++++++++ fs/btrfs/super.c | 1 + 7 files changed, 64 insertions(+), 59 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 60f8817f5b7c..d99720cf4835 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2654,65 +2654,6 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, void btrfs_clear_space_info_full(struct btrfs_fs_info *info); -/* - * Different levels for to flush space when doing space reservations. - * - * The higher the level, the more methods we try to reclaim space. - */ -enum btrfs_reserve_flush_enum { - /* If we are in the transaction, we can't flush anything.*/ - BTRFS_RESERVE_NO_FLUSH, - - /* - * Flush space by: - * - Running delayed inode items - * - Allocating a new chunk - */ - BTRFS_RESERVE_FLUSH_LIMIT, - - /* - * Flush space by: - * - Running delayed inode items - * - Running delayed refs - * - Running delalloc and waiting for ordered extents - * - Allocating a new chunk - */ - BTRFS_RESERVE_FLUSH_EVICT, - - /* - * Flush space by above mentioned methods and by: - * - Running delayed iputs - * - Committing transaction - * - * Can be interrupted by a fatal signal. - */ - BTRFS_RESERVE_FLUSH_DATA, - BTRFS_RESERVE_FLUSH_FREE_SPACE_INODE, - BTRFS_RESERVE_FLUSH_ALL, - - /* - * Pretty much the same as FLUSH_ALL, but can also steal space from - * global rsv. - * - * Can be interrupted by a fatal signal. - */ - BTRFS_RESERVE_FLUSH_ALL_STEAL, -}; - -enum btrfs_flush_state { - FLUSH_DELAYED_ITEMS_NR = 1, - FLUSH_DELAYED_ITEMS = 2, - FLUSH_DELAYED_REFS_NR = 3, - FLUSH_DELAYED_REFS = 4, - FLUSH_DELALLOC = 5, - FLUSH_DELALLOC_WAIT = 6, - FLUSH_DELALLOC_FULL = 7, - ALLOC_CHUNK = 8, - ALLOC_CHUNK_FORCE = 9, - RUN_DELAYED_IPUTS = 10, - COMMIT_TRANS = 11, -}; - int btrfs_subvolume_reserve_metadata(struct btrfs_root *root, struct btrfs_block_rsv *rsv, int nitems, bool use_global_rsv); diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c index cac5169eaf8d..a411f04a7b97 100644 --- a/fs/btrfs/delayed-inode.c +++ b/fs/btrfs/delayed-inode.c @@ -14,6 +14,7 @@ #include "qgroup.h" #include "locking.h" #include "inode-item.h" +#include "space-info.h" #define BTRFS_DELAYED_WRITEBACK 512 #define BTRFS_DELAYED_BACKGROUND 128 diff --git a/fs/btrfs/inode-item.c b/fs/btrfs/inode-item.c index 0eeb5ea87894..366f3a788c6a 100644 --- a/fs/btrfs/inode-item.c +++ b/fs/btrfs/inode-item.c @@ -8,6 +8,7 @@ #include "disk-io.h" #include "transaction.h" #include "print-tree.h" +#include "space-info.h" struct btrfs_inode_ref *btrfs_find_name_in_backref(struct extent_buffer *leaf, int slot, const char *name, diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c index 055a631276ce..07f62e3ba6a5 100644 --- a/fs/btrfs/props.c +++ b/fs/btrfs/props.c @@ -10,6 +10,7 @@ #include "ctree.h" #include "xattr.h" #include "compression.h" +#include "space-info.h" #define BTRFS_PROP_HANDLERS_HT_BITS 8 static DEFINE_HASHTABLE(prop_handlers_ht, BTRFS_PROP_HANDLERS_HT_BITS); diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index d87020ae5810..41adbfa3a5f6 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -27,6 +27,7 @@ #include "subpage.h" #include "zoned.h" #include "inode-item.h" +#include "space-info.h" /* * Relocation overview diff --git a/fs/btrfs/space-info.h b/fs/btrfs/space-info.h index 8f5948740941..729820582fa7 100644 --- a/fs/btrfs/space-info.h +++ b/fs/btrfs/space-info.h @@ -5,6 +5,65 @@ #include "volumes.h" +/* + * Different levels for to flush space when doing space reservations. + * + * The higher the level, the more methods we try to reclaim space. + */ +enum btrfs_reserve_flush_enum { + /* If we are in the transaction, we can't flush anything.*/ + BTRFS_RESERVE_NO_FLUSH, + + /* + * Flush space by: + * - Running delayed inode items + * - Allocating a new chunk + */ + BTRFS_RESERVE_FLUSH_LIMIT, + + /* + * Flush space by: + * - Running delayed inode items + * - Running delayed refs + * - Running delalloc and waiting for ordered extents + * - Allocating a new chunk + */ + BTRFS_RESERVE_FLUSH_EVICT, + + /* + * Flush space by above mentioned methods and by: + * - Running delayed iputs + * - Committing transaction + * + * Can be interrupted by a fatal signal. + */ + BTRFS_RESERVE_FLUSH_DATA, + BTRFS_RESERVE_FLUSH_FREE_SPACE_INODE, + BTRFS_RESERVE_FLUSH_ALL, + + /* + * Pretty much the same as FLUSH_ALL, but can also steal space from + * global rsv. + * + * Can be interrupted by a fatal signal. + */ + BTRFS_RESERVE_FLUSH_ALL_STEAL, +}; + +enum btrfs_flush_state { + FLUSH_DELAYED_ITEMS_NR = 1, + FLUSH_DELAYED_ITEMS = 2, + FLUSH_DELAYED_REFS_NR = 3, + FLUSH_DELAYED_REFS = 4, + FLUSH_DELALLOC = 5, + FLUSH_DELALLOC_WAIT = 6, + FLUSH_DELALLOC_FULL = 7, + ALLOC_CHUNK = 8, + ALLOC_CHUNK_FORCE = 9, + RUN_DELAYED_IPUTS = 10, + COMMIT_TRANS = 11, +}; + struct btrfs_space_info { spinlock_t lock; diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index be7df8d1d5b8..2add5b23c476 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -49,6 +49,7 @@ #include "discard.h" #include "qgroup.h" #include "raid56.h" +#include "space-info.h" #define CREATE_TRACE_POINTS #include From patchwork Wed Sep 14 15:06:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976292 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 BFA03C6FA82 for ; Wed, 14 Sep 2022 15:07:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229906AbiINPHR (ORCPT ); Wed, 14 Sep 2022 11:07:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229602AbiINPHD (ORCPT ); Wed, 14 Sep 2022 11:07:03 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37E9B77EA9 for ; Wed, 14 Sep 2022 08:07:02 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id h28so11108738qka.0 for ; Wed, 14 Sep 2022 08:07:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=WE5yyR2/yyrY9ObqId9PLRQjaATSkEj8NZdExG30XmE=; b=f178a+48KCN2F2kbPvTOK8hWj9Sr8D7wZnMMLtgWHmCPI4Ey4OWRsKKLaZFR83x1RK fsH4n05/tAuKVGLSK/2SA074m/+JKPsew4yJ9BhNb5VmojHN6THKSvQvmzH5/KPHtloj dTe4I6YiURkB/1u3kf6ry5q1i+/Rd2lWyIL1A9vY8uPZjRSIRfSghBtYkOKXs4WCdXr5 Ryj4bq4zBHqhaBh9Slben07Vto4bRHMEPUhw/i1eqvCRVkjCC0Gptx1E6pRTTfo4zfpd HAwp7jNFhMQ+LlZmJm+Ld5NzJFxBwbnd8rUD2zzRysClxr3v49QIWsPtEas3FB9S4MeG xLgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=WE5yyR2/yyrY9ObqId9PLRQjaATSkEj8NZdExG30XmE=; b=iVHRiEAejwlyKZ2+ELmkB9gN00JAeAM6RejF19Op9Tji7qy2IktU9hBcA8nIu1H2ze piDFMNr0EF8CzcbIzSS/m7lxDOZHKZUZI7+gdekjMnqauyMVi7VmrNkA0a7HCwmMDagT m2zQHM9jnNzoLs+sL60zau8bJCu2W/AKPnAjwcS8LS+PHzXPk1w6d5wY6oE4UpWDfGaN q9Q/BHX5bol8GCX5JjlO4fLJ48+uY+kLksDeSmAdCS9Bt8wdwnCr0MBlbdQL09l30xe1 NOYw52a2zGIKzpBNcWDxuyCS1bk7txshUhDkyLsScn6C1SMo9d3l0mCAzum3BpE+/IPW 66qw== X-Gm-Message-State: ACgBeo3BF3N9S01DKXYUcSdZz7fy73t2LSvEiljJLrNjiQuQ9lLOnOG9 OAobDEtFjF4tsu5ql7rcQ/Ok5oO+kur8HQ== X-Google-Smtp-Source: AA6agR560Q6xCyuLClyT8YOB/szS39n0IdoRTajKz2Q6KzOzSrBt1xczdQF9oqI/DkV5UD+9nT8CaA== X-Received: by 2002:a05:620a:1189:b0:6cb:c4ae:9057 with SMTP id b9-20020a05620a118900b006cbc4ae9057mr22640954qkk.601.1663168021345; Wed, 14 Sep 2022 08:07:01 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id j22-20020ac85516000000b0035ba5af2a75sm1692340qtq.16.2022.09.14.08.07.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:07:00 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 12/17] btrfs: move btrfs_print_data_csum_error into inode.c Date: Wed, 14 Sep 2022 11:06:36 -0400 Message-Id: <95d99a944771363259f2de25de22dffd7867d127.1663167823.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This isn't used outside of inode.c, there's no reason to define it in btrfs_inode.h. Signed-off-by: Josef Bacik Reviewed-by: Qu Wenruo Reviewed-by: Johannes Thumshirn --- fs/btrfs/btrfs_inode.h | 26 -------------------------- fs/btrfs/inode.c | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index 108af52ba870..890c9f979a3d 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h @@ -426,30 +426,4 @@ static inline void btrfs_inode_split_flags(u64 inode_item_flags, /* Array of bytes with variable length, hexadecimal format 0x1234 */ #define CSUM_FMT "0x%*phN" #define CSUM_FMT_VALUE(size, bytes) size, bytes - -static inline void btrfs_print_data_csum_error(struct btrfs_inode *inode, - u64 logical_start, u8 *csum, u8 *csum_expected, int mirror_num) -{ - struct btrfs_root *root = inode->root; - const u32 csum_size = root->fs_info->csum_size; - - /* Output minus objectid, which is more meaningful */ - if (root->root_key.objectid >= BTRFS_LAST_FREE_OBJECTID) - btrfs_warn_rl(root->fs_info, -"csum failed root %lld ino %lld off %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d", - root->root_key.objectid, btrfs_ino(inode), - logical_start, - CSUM_FMT_VALUE(csum_size, csum), - CSUM_FMT_VALUE(csum_size, csum_expected), - mirror_num); - else - btrfs_warn_rl(root->fs_info, -"csum failed root %llu ino %llu off %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d", - root->root_key.objectid, btrfs_ino(inode), - logical_start, - CSUM_FMT_VALUE(csum_size, csum), - CSUM_FMT_VALUE(csum_size, csum_expected), - mirror_num); -} - #endif diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 6fde13f62c1d..998d1c7134ff 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -125,6 +125,31 @@ static struct extent_map *create_io_em(struct btrfs_inode *inode, u64 start, u64 ram_bytes, int compress_type, int type); +static inline void btrfs_print_data_csum_error(struct btrfs_inode *inode, + u64 logical_start, u8 *csum, u8 *csum_expected, int mirror_num) +{ + struct btrfs_root *root = inode->root; + const u32 csum_size = root->fs_info->csum_size; + + /* Output minus objectid, which is more meaningful */ + if (root->root_key.objectid >= BTRFS_LAST_FREE_OBJECTID) + btrfs_warn_rl(root->fs_info, +"csum failed root %lld ino %lld off %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d", + root->root_key.objectid, btrfs_ino(inode), + logical_start, + CSUM_FMT_VALUE(csum_size, csum), + CSUM_FMT_VALUE(csum_size, csum_expected), + mirror_num); + else + btrfs_warn_rl(root->fs_info, +"csum failed root %llu ino %llu off %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d", + root->root_key.objectid, btrfs_ino(inode), + logical_start, + CSUM_FMT_VALUE(csum_size, csum), + CSUM_FMT_VALUE(csum_size, csum_expected), + mirror_num); +} + /* * btrfs_inode_lock - lock inode i_rwsem based on arguments passed * From patchwork Wed Sep 14 15:06:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976291 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 18630ECAAD3 for ; Wed, 14 Sep 2022 15:07:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230140AbiINPHQ (ORCPT ); Wed, 14 Sep 2022 11:07:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbiINPHF (ORCPT ); Wed, 14 Sep 2022 11:07:05 -0400 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E613E77EB0 for ; Wed, 14 Sep 2022 08:07:03 -0700 (PDT) Received: by mail-qt1-x835.google.com with SMTP id y2so11382553qtv.5 for ; Wed, 14 Sep 2022 08:07:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=yChKzDuGkSJeaB68JMiVPP35OWAvh8MC5ifwtbkDGEE=; b=q/dJXf1kl0HxAiJ/dH3dVECqGxdAretzZj2gS4oezVwbk86rteqzhqS9nnNs0F8dw9 8Q0Iz1GPupbQd+zfAt61iMH1Y+fAl+XhcdtDuWitxhZuyZ+bxZTzz1eq9xVafPayo8PH 5K5a+OWSEi+1kZYkRn69whrB76v1FO6vPONLKKpZiaes+UnyzN6uZE/pWSerSD67+Bul LuLDj1JcIEjQyyuRZzF9HxYT/yQsx00t2mGB7Xx5Mctodv2VuvCdkhsWUxkDR3NwBxsS SB9vsAxKx96+TFelAeeOfUAIRTom1vv8HXKa6oNyWiRr+fVDRZj6Msaa3dYYpuez0w4S SApQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=yChKzDuGkSJeaB68JMiVPP35OWAvh8MC5ifwtbkDGEE=; b=3nGohGDx5nf7vWbNhERrLM+28zTBK42QNbbPCZvT+DOm9qeDnLSqz3LXVeUu0Vi3Vu 2cTr2nx1KhZwTH7fpUEISzXbP4nw0Wa6OgtGu67uz0IJzA2mSbULVq+39n8+z+ZW4yYa 9RNRAru8lt6PhTzeo/eGa/M0REeONHUjUzsK/x6HqB3ko3V7o/mDYlgmDys0QdYAeD54 t2VXzCilCk3nlpy3FlUWChRVH3ooKd0ZD28pm7JqESfeVNFsWDD9h3ec+AeO++QCr9Ie a+QjIJg/Fn1i+/65qsHB3a/f3Kjv0Or1R5ZgGLo+O3kVkZDNjRvSuEbvT4gMD/EUDei6 cPzA== X-Gm-Message-State: ACgBeo1Evz4/5loW49Vz21QGwulJZ61/TkqkvC1qsHrIEFHrFYla3+hA cSDXcaNxK2Z9utV9yeveUTO3csbUfRYTjw== X-Google-Smtp-Source: AA6agR5q3EZPFzygkEpz+X1v9HfO1zkxPF+WMQezPCwiKyCqfOBvOC+EWgE/vO+n3ll/UWEsz+2JKw== X-Received: by 2002:ac8:5885:0:b0:343:74df:9b26 with SMTP id t5-20020ac85885000000b0034374df9b26mr33924346qta.406.1663168022627; Wed, 14 Sep 2022 08:07:02 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id d21-20020a05620a205500b006b942f4ffe3sm1770741qka.18.2022.09.14.08.07.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:07:02 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 13/17] btrfs: move trans_handle_cachep out of ctree.h Date: Wed, 14 Sep 2022 11:06:37 -0400 Message-Id: <68e9b87432b738ef6547294d9e5d307cfbdaf13d.1663167823.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This is local to the transaction code, remove it from ctree.h and inode.c, create new helpers in the transaction to handle the init work and move the cachep locally to transaction.c. Signed-off-by: Josef Bacik Reviewed-by: Qu Wenruo Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 1 - fs/btrfs/inode.c | 8 -------- fs/btrfs/super.c | 9 ++++++++- fs/btrfs/transaction.c | 17 +++++++++++++++++ fs/btrfs/transaction.h | 2 ++ 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index d99720cf4835..439b205f4207 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -41,7 +41,6 @@ struct btrfs_pending_snapshot; struct btrfs_delayed_ref_root; struct btrfs_space_info; struct btrfs_block_group; -extern struct kmem_cache *btrfs_trans_handle_cachep; extern struct kmem_cache *btrfs_path_cachep; extern struct kmem_cache *btrfs_free_space_cachep; extern struct kmem_cache *btrfs_free_space_bitmap_cachep; diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 998d1c7134ff..78e7f5397d58 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -107,7 +107,6 @@ static const struct address_space_operations btrfs_aops; static const struct file_operations btrfs_dir_file_operations; static struct kmem_cache *btrfs_inode_cachep; -struct kmem_cache *btrfs_trans_handle_cachep; struct kmem_cache *btrfs_path_cachep; struct kmem_cache *btrfs_free_space_cachep; struct kmem_cache *btrfs_free_space_bitmap_cachep; @@ -8938,7 +8937,6 @@ void __cold btrfs_destroy_cachep(void) rcu_barrier(); bioset_exit(&btrfs_dio_bioset); kmem_cache_destroy(btrfs_inode_cachep); - kmem_cache_destroy(btrfs_trans_handle_cachep); kmem_cache_destroy(btrfs_path_cachep); kmem_cache_destroy(btrfs_free_space_cachep); kmem_cache_destroy(btrfs_free_space_bitmap_cachep); @@ -8953,12 +8951,6 @@ int __init btrfs_init_cachep(void) if (!btrfs_inode_cachep) goto fail; - btrfs_trans_handle_cachep = kmem_cache_create("btrfs_trans_handle", - sizeof(struct btrfs_trans_handle), 0, - SLAB_TEMPORARY | SLAB_MEM_SPREAD, NULL); - if (!btrfs_trans_handle_cachep) - goto fail; - btrfs_path_cachep = kmem_cache_create("btrfs_path", sizeof(struct btrfs_path), 0, SLAB_MEM_SPREAD, NULL); diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 2add5b23c476..9f7fc1c71148 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2737,10 +2737,14 @@ static int __init init_btrfs_fs(void) if (err) goto free_compress; - err = extent_state_init_cachep(); + err = btrfs_transaction_init(); if (err) goto free_cachep; + err = extent_state_init_cachep(); + if (err) + goto free_transaction; + err = extent_buffer_init_cachep(); if (err) goto free_extent_cachep; @@ -2809,6 +2813,8 @@ static int __init init_btrfs_fs(void) extent_buffer_free_cachep(); free_extent_cachep: extent_state_free_cachep(); +free_transaction: + btrfs_transaction_exit(); free_cachep: btrfs_destroy_cachep(); free_compress: @@ -2820,6 +2826,7 @@ static int __init init_btrfs_fs(void) static void __exit exit_btrfs_fs(void) { + btrfs_transaction_exit(); btrfs_destroy_cachep(); btrfs_delayed_ref_exit(); btrfs_auto_defrag_exit(); diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index d1f1da6820fb..ae7d4aca771d 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -24,6 +24,8 @@ #include "space-info.h" #include "zoned.h" +static struct kmem_cache *btrfs_trans_handle_cachep; + #define BTRFS_ROOT_TRANS_TAG 0 /* @@ -2600,3 +2602,18 @@ void btrfs_apply_pending_changes(struct btrfs_fs_info *fs_info) btrfs_warn(fs_info, "unknown pending changes left 0x%lx, ignoring", prev); } + +int __init btrfs_transaction_init(void) +{ + btrfs_trans_handle_cachep = kmem_cache_create("btrfs_trans_handle", + sizeof(struct btrfs_trans_handle), 0, + SLAB_TEMPORARY | SLAB_MEM_SPREAD, NULL); + if (!btrfs_trans_handle_cachep) + return -ENOMEM; + return 0; +} + +void __cold btrfs_transaction_exit(void) +{ + kmem_cache_destroy(btrfs_trans_handle_cachep); +} diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index 970ff316069d..b5651c372946 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h @@ -236,4 +236,6 @@ void btrfs_add_dropped_root(struct btrfs_trans_handle *trans, struct btrfs_root *root); void btrfs_trans_release_chunk_metadata(struct btrfs_trans_handle *trans); +int __init btrfs_transaction_init(void); +void __cold btrfs_transaction_exit(void); #endif From patchwork Wed Sep 14 15:06:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976293 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 39492C6FA8A for ; Wed, 14 Sep 2022 15:07:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229978AbiINPHT (ORCPT ); Wed, 14 Sep 2022 11:07:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229990AbiINPHH (ORCPT ); Wed, 14 Sep 2022 11:07:07 -0400 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DE5978218 for ; Wed, 14 Sep 2022 08:07:05 -0700 (PDT) Received: by mail-qv1-xf2d.google.com with SMTP id l14so3500987qvq.8 for ; Wed, 14 Sep 2022 08:07:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=vw2Fm/9gAI44uV/t8/cp6x8gY3GrT4SwYS1ONv7XFi0=; b=laYly4OjFheN/8OrN8ujTDW4UnLbuKccl5/TPCtPE6cZnCie1XhHunwPvdXz6txb9O wTAI4/1G+JRNys+sxrGk+cMVbmldlTQhEVTZg22dWxRadndYYLGNCG+rxS/uI9Vd5MvF DX+vKq4uQFvaAVFpsmdGY6q8Ouna0Yanq57/xzt5SEO0kB+LZoKD6mKmyuSaNLS8H6ED 9Vq3jV1WcEXGoGeXRtm7buA/io5B9RDuq+IAH9w9UJ0kRefF81+lXQFcAhRvrN24zUto S9Mj8mbWWGfUs4b65ENaLz/irZWzXDBr9/s7YuRAugXL5SOzYJ42RI8peNxZ5oCHyZXc 1MDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=vw2Fm/9gAI44uV/t8/cp6x8gY3GrT4SwYS1ONv7XFi0=; b=RkQxIUmkAp3se8NjKDZG8gaCFGxpJjd2bnJvroz2fHdRJce4J/rl1Jk/+K6YBUCgkR /eZVe1RaO/9OFfRVP2IxU1aeUN4N/GhsxKSCc+cV974BjkwFHrY8FTPJyYnn/6k3F28v MFTS5aerW523BiXtg33eea9VjK5AJfyhPmswsxc5D3IIOi91IBdEc72jbDLgNOZvVGxq cieopkeEIVicopHXidff6jIV6x2/r5r2V7WzYoJ7boTBgWLx7w5PpRH+B54Xuto82Tpo 8tBX/UpxJ0km3+B1cWHzWb155Z35tl+uAQbjZHOjU2zvmWGXyz1Zk9FDm8tBAz4Etwen PBNg== X-Gm-Message-State: ACgBeo0ZCEiOJRTt++PqQ4pCga1xWVLUAmVZVzmZ7qO3u5nJqpaWc/YF 778YUOTpAKWinIIm0Xvz9O1NUgs1i1g4wg== X-Google-Smtp-Source: AA6agR78pi4XxidTkujwHB1DzX9niEvyBAVFPipJA6zM+hOOyQZfHxgePXTCLg+BqPf3FLou5RC/fg== X-Received: by 2002:a05:6214:c83:b0:4ac:acbd:7efd with SMTP id r3-20020a0562140c8300b004acacbd7efdmr15355321qvr.29.1663168024378; Wed, 14 Sep 2022 08:07:04 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id s9-20020ac87589000000b0035cb93ba803sm1519589qtq.45.2022.09.14.08.07.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:07:03 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 14/17] btrfs: move btrfs_path_cachep out of ctree.h Date: Wed, 14 Sep 2022 11:06:38 -0400 Message-Id: X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This is local to the ctree code, remove it from ctree.h and inode.c, create new init/exit functions for the cachep, and move it locally to ctree.c. Signed-off-by: Josef Bacik Reviewed-by: Qu Wenruo Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.c | 17 +++++++++++++++++ fs/btrfs/ctree.h | 3 ++- fs/btrfs/inode.c | 8 -------- fs/btrfs/super.c | 9 ++++++++- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index ebfa35fe1c38..1f0355c74fe6 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -18,6 +18,8 @@ #include "tree-mod-log.h" #include "tree-checker.h" +static struct kmem_cache *btrfs_path_cachep; + static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, int level); static int split_leaf(struct btrfs_trans_handle *trans, struct btrfs_root *root, @@ -4856,3 +4858,18 @@ int btrfs_previous_extent_item(struct btrfs_root *root, } return 1; } + +int __init btrfs_ctree_init(void) +{ + btrfs_path_cachep = kmem_cache_create("btrfs_path", + sizeof(struct btrfs_path), 0, + SLAB_MEM_SPREAD, NULL); + if (!btrfs_path_cachep) + return -ENOMEM; + return 0; +} + +void __cold btrfs_ctree_exit(void) +{ + kmem_cache_destroy(btrfs_path_cachep); +} diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 439b205f4207..3a61f5c0ab5f 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -41,7 +41,6 @@ struct btrfs_pending_snapshot; struct btrfs_delayed_ref_root; struct btrfs_space_info; struct btrfs_block_group; -extern struct kmem_cache *btrfs_path_cachep; extern struct kmem_cache *btrfs_free_space_cachep; extern struct kmem_cache *btrfs_free_space_bitmap_cachep; struct btrfs_ordered_sum; @@ -2677,6 +2676,8 @@ void btrfs_end_write_no_snapshotting(struct btrfs_root *root); void btrfs_wait_for_snapshot_creation(struct btrfs_root *root); /* ctree.c */ +int __init btrfs_ctree_init(void); +void __cold btrfs_ctree_exit(void); int btrfs_bin_search(struct extent_buffer *eb, const struct btrfs_key *key, int *slot); int __pure btrfs_comp_cpu_keys(const struct btrfs_key *k1, const struct btrfs_key *k2); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 78e7f5397d58..1401e2da9284 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -107,7 +107,6 @@ static const struct address_space_operations btrfs_aops; static const struct file_operations btrfs_dir_file_operations; static struct kmem_cache *btrfs_inode_cachep; -struct kmem_cache *btrfs_path_cachep; struct kmem_cache *btrfs_free_space_cachep; struct kmem_cache *btrfs_free_space_bitmap_cachep; @@ -8937,7 +8936,6 @@ void __cold btrfs_destroy_cachep(void) rcu_barrier(); bioset_exit(&btrfs_dio_bioset); kmem_cache_destroy(btrfs_inode_cachep); - kmem_cache_destroy(btrfs_path_cachep); kmem_cache_destroy(btrfs_free_space_cachep); kmem_cache_destroy(btrfs_free_space_bitmap_cachep); } @@ -8951,12 +8949,6 @@ int __init btrfs_init_cachep(void) if (!btrfs_inode_cachep) goto fail; - btrfs_path_cachep = kmem_cache_create("btrfs_path", - sizeof(struct btrfs_path), 0, - SLAB_MEM_SPREAD, NULL); - if (!btrfs_path_cachep) - goto fail; - btrfs_free_space_cachep = kmem_cache_create("btrfs_free_space", sizeof(struct btrfs_free_space), 0, SLAB_MEM_SPREAD, NULL); diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 9f7fc1c71148..acd590bed579 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2741,10 +2741,14 @@ static int __init init_btrfs_fs(void) if (err) goto free_cachep; - err = extent_state_init_cachep(); + err = btrfs_ctree_init(); if (err) goto free_transaction; + err = extent_state_init_cachep(); + if (err) + goto free_ctree; + err = extent_buffer_init_cachep(); if (err) goto free_extent_cachep; @@ -2813,6 +2817,8 @@ static int __init init_btrfs_fs(void) extent_buffer_free_cachep(); free_extent_cachep: extent_state_free_cachep(); +free_ctree: + btrfs_ctree_exit(); free_transaction: btrfs_transaction_exit(); free_cachep: @@ -2826,6 +2832,7 @@ static int __init init_btrfs_fs(void) static void __exit exit_btrfs_fs(void) { + btrfs_ctree_exit(); btrfs_transaction_exit(); btrfs_destroy_cachep(); btrfs_delayed_ref_exit(); From patchwork Wed Sep 14 15:06:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976294 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 EA448C6FA8D for ; Wed, 14 Sep 2022 15:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230141AbiINPHV (ORCPT ); Wed, 14 Sep 2022 11:07:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230105AbiINPHH (ORCPT ); Wed, 14 Sep 2022 11:07:07 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 651D477E9A for ; Wed, 14 Sep 2022 08:07:06 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id b23so6461759qtr.13 for ; Wed, 14 Sep 2022 08:07:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=al9+AnyXUCeLyEiVoBI+wJ/piSc70KkHcNevdqkvIsI=; b=A+abR0xea29aRosezIQHOLfCOkdxr6EKqbz8VC9pzgrxraSPVjK3RTHVo8BkaC279t XHagmaoGLfCJndKLVxpUx9jxdLUYCz0aMdTtr2h/YWUcaijVUqpOLSCMy9ImJC2081Dd Smxn3obJ69apLdxl+gYazyt29Zf8QisaMTs7/B+Y0QKaJtxRa5KJFPdoFQdMKHjKAHtM kaNleH8rPdUM60fuq5pOBo3/kVsV4koiU5cZ2yhKnV0zh4956wsWpkzDr5t4cxXkBznn banTs4tEP46CzGJ56V9C0B/qiKn6gcXw6rUQX1P9B2Ltd0UO9jYDveCa7lns/WNTqRhV ipgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=al9+AnyXUCeLyEiVoBI+wJ/piSc70KkHcNevdqkvIsI=; b=yxb4o3Hr7OL65aCrUamn5lIAbby4nKITAPQQr8yI4YLMxUH/wW1Y0ZMVV1mhgjrSzj XTD4qfqgUtAmfoFd8cX+uNUZvsyft0IRCreFER3X9qy+bhOEcjgA/xVaMhmlnQi8v9NR nA+Zmb/8S5KWAx/zoGshbln3wpS7DI5pf03y4uyFajZdk2cDH72XWleRRZ7/EX7n/j08 32AE3y7VqHLYhNc2ScLbKIC9HK4dImqkEbFE50tJ3YEmHyRGgDE78wHl9KZKUeCv9Ggx p3853bS0OWv9WxzGjI1Kaik5IIvqkvo0NCZ6G67OqpjYD/X2P+34H2EDI8EfGYxGiy2z 78Ig== X-Gm-Message-State: ACgBeo0tZjnU0nl1GNESPjgPxYhzWaRlwEkXv2ClN2CEJatm07yOyPIk QL8ByC/JiyFqWpleYcL9jpIXUooojvlk1Q== X-Google-Smtp-Source: AA6agR69a3IrTmZlILVUgtMb1pdYyduwbzzmi2WZTaP1l4jBYY48qHTslmSyQ+J7a+nvK1NCdxLl8Q== X-Received: by 2002:ac8:7f0c:0:b0:35b:b013:3913 with SMTP id f12-20020ac87f0c000000b0035bb0133913mr16063057qtk.39.1663168025667; Wed, 14 Sep 2022 08:07:05 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id bl7-20020a05622a244700b0035a71a41645sm1732501qtb.37.2022.09.14.08.07.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:07:05 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 15/17] btrfs: move free space cachep's out of ctree.h Date: Wed, 14 Sep 2022 11:06:39 -0400 Message-Id: X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This is local to the free-space-cache.c code, remove it from ctree.h and inode.c, create new init/exit functions for the cachep, and move it locally to free-space-cache.c. Signed-off-by: Josef Bacik Reviewed-by: Qu Wenruo Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 2 -- fs/btrfs/free-space-cache.c | 28 ++++++++++++++++++++++++++++ fs/btrfs/free-space-cache.h | 2 ++ fs/btrfs/inode.c | 16 ---------------- fs/btrfs/super.c | 9 ++++++++- 5 files changed, 38 insertions(+), 19 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 3a61f5c0ab5f..af6f6764d9a4 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -41,8 +41,6 @@ struct btrfs_pending_snapshot; struct btrfs_delayed_ref_root; struct btrfs_space_info; struct btrfs_block_group; -extern struct kmem_cache *btrfs_free_space_cachep; -extern struct kmem_cache *btrfs_free_space_bitmap_cachep; struct btrfs_ordered_sum; struct btrfs_ref; struct btrfs_bio; diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 7859eeca484c..ee03c5e6db4c 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -29,6 +29,9 @@ #define MAX_CACHE_BYTES_PER_GIG SZ_64K #define FORCE_EXTENT_THRESHOLD SZ_1M +static struct kmem_cache *btrfs_free_space_cachep; +static struct kmem_cache *btrfs_free_space_bitmap_cachep; + struct btrfs_trim_range { u64 start; u64 bytes; @@ -4132,6 +4135,31 @@ int btrfs_set_free_space_cache_v1_active(struct btrfs_fs_info *fs_info, bool act return ret; } +int __init btrfs_free_space_init(void) +{ + btrfs_free_space_cachep = kmem_cache_create("btrfs_free_space", + sizeof(struct btrfs_free_space), 0, + SLAB_MEM_SPREAD, NULL); + if (!btrfs_free_space_cachep) + return -ENOMEM; + + btrfs_free_space_bitmap_cachep = kmem_cache_create("btrfs_free_space_bitmap", + PAGE_SIZE, PAGE_SIZE, + SLAB_MEM_SPREAD, NULL); + if (!btrfs_free_space_bitmap_cachep) { + kmem_cache_destroy(btrfs_free_space_cachep); + return -ENOMEM; + } + + return 0; +} + +void __cold btrfs_free_space_exit(void) +{ + kmem_cache_destroy(btrfs_free_space_cachep); + kmem_cache_destroy(btrfs_free_space_bitmap_cachep); +} + #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS /* * Use this if you need to make a bitmap or extent entry specifically, it diff --git a/fs/btrfs/free-space-cache.h b/fs/btrfs/free-space-cache.h index eaf30f6444dd..cab954a9d97b 100644 --- a/fs/btrfs/free-space-cache.h +++ b/fs/btrfs/free-space-cache.h @@ -88,6 +88,8 @@ struct btrfs_io_ctl { int bitmaps; }; +int __init btrfs_free_space_init(void); +void __cold btrfs_free_space_exit(void); struct inode *lookup_free_space_inode(struct btrfs_block_group *block_group, struct btrfs_path *path); int create_free_space_inode(struct btrfs_trans_handle *trans, diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 1401e2da9284..da5be8f23f68 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -107,8 +107,6 @@ static const struct address_space_operations btrfs_aops; static const struct file_operations btrfs_dir_file_operations; static struct kmem_cache *btrfs_inode_cachep; -struct kmem_cache *btrfs_free_space_cachep; -struct kmem_cache *btrfs_free_space_bitmap_cachep; static int btrfs_setsize(struct inode *inode, struct iattr *attr); static int btrfs_truncate(struct inode *inode, bool skip_writeback); @@ -8936,8 +8934,6 @@ void __cold btrfs_destroy_cachep(void) rcu_barrier(); bioset_exit(&btrfs_dio_bioset); kmem_cache_destroy(btrfs_inode_cachep); - kmem_cache_destroy(btrfs_free_space_cachep); - kmem_cache_destroy(btrfs_free_space_bitmap_cachep); } int __init btrfs_init_cachep(void) @@ -8949,18 +8945,6 @@ int __init btrfs_init_cachep(void) if (!btrfs_inode_cachep) goto fail; - btrfs_free_space_cachep = kmem_cache_create("btrfs_free_space", - sizeof(struct btrfs_free_space), 0, - SLAB_MEM_SPREAD, NULL); - if (!btrfs_free_space_cachep) - goto fail; - - btrfs_free_space_bitmap_cachep = kmem_cache_create("btrfs_free_space_bitmap", - PAGE_SIZE, PAGE_SIZE, - SLAB_MEM_SPREAD, NULL); - if (!btrfs_free_space_bitmap_cachep) - goto fail; - if (bioset_init(&btrfs_dio_bioset, BIO_POOL_SIZE, offsetof(struct btrfs_dio_private, bio), BIOSET_NEED_BVECS)) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index acd590bed579..c2e634de01e4 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2745,10 +2745,14 @@ static int __init init_btrfs_fs(void) if (err) goto free_transaction; - err = extent_state_init_cachep(); + err = btrfs_free_space_init(); if (err) goto free_ctree; + err = extent_state_init_cachep(); + if (err) + goto free_free_space; + err = extent_buffer_init_cachep(); if (err) goto free_extent_cachep; @@ -2817,6 +2821,8 @@ static int __init init_btrfs_fs(void) extent_buffer_free_cachep(); free_extent_cachep: extent_state_free_cachep(); +free_free_space: + btrfs_free_space_exit(); free_ctree: btrfs_ctree_exit(); free_transaction: @@ -2832,6 +2838,7 @@ static int __init init_btrfs_fs(void) static void __exit exit_btrfs_fs(void) { + btrfs_free_space_exit(); btrfs_ctree_exit(); btrfs_transaction_exit(); btrfs_destroy_cachep(); From patchwork Wed Sep 14 15:06:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976295 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 9A54EECAAD3 for ; Wed, 14 Sep 2022 15:07:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230030AbiINPHW (ORCPT ); Wed, 14 Sep 2022 11:07:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230126AbiINPHK (ORCPT ); Wed, 14 Sep 2022 11:07:10 -0400 Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D0F479A49 for ; Wed, 14 Sep 2022 08:07:08 -0700 (PDT) Received: by mail-qt1-x832.google.com with SMTP id b23so6461831qtr.13 for ; Wed, 14 Sep 2022 08:07:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=rx8NeG33Fl4q8q9d+yc1PuVafftTRjEnSflraFqsZUI=; b=0ffH4QpgElWLc0ibgoivHqZO6eUmUCeOpzY/fiwuYsFph3k9vgZWgwgDq87veIQCK5 nfh2/CBCFxmkDL8s6A8GhVjk21+qmprx09iq+phtctbeuDtLaw1p0F+HHXBdrfJwFKMD 5BcpCKfwUfigry/znnozVh7/KfGzeP9/dqzng2aO5sO3hgmp7ToT5/bhAbB5dLBQJE9c 1TjdUiKmRr6rU647C30O9bXGFqRMI6t+nKnC1BGBBzHmpPi2zsf1iUhQ/553LsUcm4Pp ihYQ7JG/e7mZt3E2NhQ+G3jMm8ITQXbuuPxDenTmVn+RO2Bg7tUMuHWekiA3p9oIfxF0 BFMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=rx8NeG33Fl4q8q9d+yc1PuVafftTRjEnSflraFqsZUI=; b=rAO7nkL8D/RoiKjfxgOwqiNHICT2bOfsCmn9v6uttq+QVhqHxPuw9SJkT+r8iu0Dmq iXMzovq0Mr7r/Z4X4Njl/nwXFCU3eq55sJtyHwCD1EVXnHgBpDy/HQUhIxRw5OsYYm4o v2Wk8cQwWRX1YAy0TTB9q2ybnl1AlNhm60g3WbscaDxP7Eiit9/pF+GfIBW/N1S3GGci s6wtrU4lqsePIrSiYUGdR52qpHuv2KFfSwXfyukb1AQIa7wpRA6kym9uOaMo34lbImnk SMGGVBXCiXyom8Vybrs9uV93OlZswdu0lRoST+2gHIcpr4xv9NPg83sL8mN0aBbAr+/p ENMQ== X-Gm-Message-State: ACgBeo0vqTOUvppo/eMD8M4yqaq0h+tfoZ+Pi0NlrBhLqbS4530sNvPs DPK1ZM+q8r6r5XCDSFc3mSK00pB6+jkUpQ== X-Google-Smtp-Source: AA6agR5fqWonoVDVoD+yBYC1xsTX2idy5uqzpZiUslSI9eMz4V2xorTyBXbv6t+mWc2K5GFZcE75CQ== X-Received: by 2002:a05:622a:138b:b0:35b:b619:b87d with SMTP id o11-20020a05622a138b00b0035bb619b87dmr12860787qtk.146.1663168027293; Wed, 14 Sep 2022 08:07:07 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id de42-20020a05620a372a00b006b945519488sm2117543qkb.88.2022.09.14.08.07.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:07:06 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 16/17] btrfs: move btrfs_next_old_item into ctree.c Date: Wed, 14 Sep 2022 11:06:40 -0400 Message-Id: <6b4e55458868b7d8f7b61be137fe9f9d7860dea1.1663167824.git.josef@toxicpanda.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This uses btrfs_header_nritems, which I will be moving out of ctree.h. In order to avoid needing to include the relevant header in ctree.h, simply move this helper function into ctree.c. Signed-off-by: Josef Bacik Reviewed-by: Qu Wenruo Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.c | 9 +++++++++ fs/btrfs/ctree.h | 10 ++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 1f0355c74fe6..0f7f93bc2582 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -4775,6 +4775,15 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path, return ret; } +int btrfs_next_old_item(struct btrfs_root *root, struct btrfs_path *p, + u64 time_seq) +{ + ++p->slots[0]; + if (p->slots[0] >= btrfs_header_nritems(p->nodes[0])) + return btrfs_next_old_leaf(root, p, time_seq); + return 0; +} + /* * this uses btrfs_prev_leaf to walk backwards in the tree, and keeps * searching until it gets past min_objectid or finds an item of 'type' diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index af6f6764d9a4..42dec21b3517 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2836,14 +2836,8 @@ int btrfs_get_next_valid_item(struct btrfs_root *root, struct btrfs_key *key, (path)->slots[0]++ \ ) -static inline int btrfs_next_old_item(struct btrfs_root *root, - struct btrfs_path *p, u64 time_seq) -{ - ++p->slots[0]; - if (p->slots[0] >= btrfs_header_nritems(p->nodes[0])) - return btrfs_next_old_leaf(root, p, time_seq); - return 0; -} +int btrfs_next_old_item(struct btrfs_root *root, struct btrfs_path *p, + u64 time_seq); /* * Search the tree again to find a leaf with greater keys. From patchwork Wed Sep 14 15:06:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 12976296 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 ABB97C6FA8A for ; Wed, 14 Sep 2022 15:07:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229898AbiINPHX (ORCPT ); Wed, 14 Sep 2022 11:07:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229614AbiINPHL (ORCPT ); Wed, 14 Sep 2022 11:07:11 -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 299E177E8B for ; Wed, 14 Sep 2022 08:07:10 -0700 (PDT) Received: by mail-qv1-xf30.google.com with SMTP id v15so11946884qvi.11 for ; Wed, 14 Sep 2022 08:07:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=hVeEiFzUBicWQNEtZbrGjc9hHCWmhrrlQQAcHIcKd0w=; b=dBtodQZ1eVn67+RUhtYAQXI/GoFJTTRilBQo/9GXiKlo0YNRc+ZJdNiyMjgMwQAEPF Z7px/yk2MRFrSHC3IdW8nA0hPGptGmmkW5JCHML0OSxkRlEkX56yb1+j3/xTcngh0G9s TygeYmF61oB2nR0ZKMb3yW2oOOIB8qqIaVz69uA47dj5ElieesjJMRR5C3WGdcUKQkqN 91R2V5uVG9Vpk69fEeBL0tbGQRau8vnx4tDKrhcC2mnmidSERUzwi3dsGuW+ROhXxWbJ bm3CBjc6wTsRLcGJzVJ9g2LquQ6GTNEmK3KxTZF4RoqIWO3thYxrsmQ+LHm/NV9lN3sa Odzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=hVeEiFzUBicWQNEtZbrGjc9hHCWmhrrlQQAcHIcKd0w=; b=s5/xbMqnspEm96jfqjdEkvjSwpeh0k7/ze4mT3a/2C1Ac8VtX7ebXZrMiOf/GpeGTR WuEdOPUpJw7sXluyAKW5aXKzrli6fqKDLqpi5r5k7l5HSJF+cGfW4HDM90UnGo5zTmtE +HTa/HToqcvyGx2PLqAWYJZhKnMAx4JpS53lGvmfk77YPylwJSvALqEc6bhxQDyKQBuY mssuiYIxTs1gmtQCzL6XH7+K1wIew/31mPM9kfCjRnSJYPx4uw1WRcEIdIc4mmK90pF5 +0nGR+iKlGYGfssiWiQbsndNJD/gNw4D0jmWLW1hIfgpqCLytbwR9dU4MEcMn3zgbXu0 R21w== X-Gm-Message-State: ACgBeo05MmhiyIoIGnJCJygXhhvUKnM6VFA4sYRTjE02lfkYQIdsE4hJ dtg23g/o5/Rr5+g+I6uEwQVwTmHcl67tFg== X-Google-Smtp-Source: AA6agR5t6oXeGVs+/2xwdDGUJeOVNGSTOaJ7jlNJ/vsQduoXpvVqyZlz4phVo8Gq16n0Pbtq7RDPyw== X-Received: by 2002:ad4:5bee:0:b0:4ac:d9d2:d630 with SMTP id k14-20020ad45bee000000b004acd9d2d630mr4401775qvc.65.1663168028673; Wed, 14 Sep 2022 08:07:08 -0700 (PDT) Received: from localhost (cpe-174-109-172-136.nc.res.rr.com. [174.109.172.136]) by smtp.gmail.com with ESMTPSA id bp12-20020a05620a458c00b006bb619a6a85sm1914324qkb.48.2022.09.14.08.07.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:07:08 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 17/17] btrfs: move the btrfs_verity_descriptor_item defs up in ctree.h Date: Wed, 14 Sep 2022 11:06:41 -0400 Message-Id: X-Mailer: git-send-email 2.26.3 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org These are wrapped in CONFIG_FS_VERITY, but we can have the definitions without verity enabled. Move these definitions up with the other accessor helpers. Signed-off-by: Josef Bacik Reviewed-by: Qu Wenruo Reviewed-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 42dec21b3517..cb1ae35c1095 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2499,6 +2499,16 @@ BTRFS_SETGET_STACK_FUNCS(stack_dev_replace_cursor_left, BTRFS_SETGET_STACK_FUNCS(stack_dev_replace_cursor_right, struct btrfs_dev_replace_item, cursor_right, 64); +/* btrfs_verity_descriptor_item */ +BTRFS_SETGET_FUNCS(verity_descriptor_encryption, struct btrfs_verity_descriptor_item, + encryption, 8); +BTRFS_SETGET_FUNCS(verity_descriptor_size, struct btrfs_verity_descriptor_item, + size, 64); +BTRFS_SETGET_STACK_FUNCS(stack_verity_descriptor_encryption, + struct btrfs_verity_descriptor_item, encryption, 8); +BTRFS_SETGET_STACK_FUNCS(stack_verity_descriptor_size, + struct btrfs_verity_descriptor_item, size, 64); + /* helper function to cast into the data area of the leaf. */ #define btrfs_item_ptr(leaf, slot, type) \ ((type *)(BTRFS_LEAF_DATA_OFFSET + \ @@ -3742,22 +3752,10 @@ static inline int btrfs_defrag_cancelled(struct btrfs_fs_info *fs_info) /* verity.c */ #ifdef CONFIG_FS_VERITY - extern const struct fsverity_operations btrfs_verityops; int btrfs_drop_verity_items(struct btrfs_inode *inode); int btrfs_get_verity_descriptor(struct inode *inode, void *buf, size_t buf_size); - -BTRFS_SETGET_FUNCS(verity_descriptor_encryption, struct btrfs_verity_descriptor_item, - encryption, 8); -BTRFS_SETGET_FUNCS(verity_descriptor_size, struct btrfs_verity_descriptor_item, - size, 64); -BTRFS_SETGET_STACK_FUNCS(stack_verity_descriptor_encryption, - struct btrfs_verity_descriptor_item, encryption, 8); -BTRFS_SETGET_STACK_FUNCS(stack_verity_descriptor_size, - struct btrfs_verity_descriptor_item, size, 64); - #else - static inline int btrfs_drop_verity_items(struct btrfs_inode *inode) { return 0; @@ -3768,7 +3766,6 @@ static inline int btrfs_get_verity_descriptor(struct inode *inode, void *buf, { return -EPERM; } - #endif /* Sanity test specific functions */