Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2422758rwi; Tue, 11 Oct 2022 08:35:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Nq8M2yQOBPIo3MWZVM+KI0CMEh5MHsBFm4bo9Q43j+N2+LwlpyFnW1Zs7wk4HFb2wndkS X-Received: by 2002:a05:6a00:a22:b0:54e:6a90:fbef with SMTP id p34-20020a056a000a2200b0054e6a90fbefmr25398904pfh.53.1665502497651; Tue, 11 Oct 2022 08:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665502497; cv=none; d=google.com; s=arc-20160816; b=vB9QTmZFb+6B3Ijjy3AY0UL2CBgAChhM20N/UzPE69DtPFelRYT9a0K10gjtTTWDCb BbI2WEpfYk2xMkTLM8R/LgCJy/4IniYCQxfJrGJn0TuR7a6L7g4Qh0VDuxTIUr78ACbN zEjGsdf4b+uskl9p1NblX+4KRRhNelbi1T1RtWdne95dY2VHiJQsFHEFQacsUo9quie7 5BKmdNcMkAdFa3mroLwVwoVGm492CRhtbxIU49EoMrkQ/BVDuupng+TnbXymmqzIdt+3 ACyScivNPm4nQ4LcnYyBhADMIx/JlqlFRLJsax37yDB35Lk63+zUsjT2xXMrr97YISJW efVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Df6mM7GXEN1BI5X+/eORVCzNtN4s611wuDRwRKqniEE=; b=iHWJtISu6W9/7M+srHCWTrg1t76z5oU/qU7Gm7CU/hWp/lfKH8RaoAQZ/XL3QaGz4l mS2ZhcgLIruequtQZLqgl6VwidZAKnGLDTJr3wRuANafTptVn+g/VoLx37IjeyoichHx VjAIdOcj1KRJx22EAyUHm1bTFJSS1voAhQGCrqOll/HrS4f1wUHsFOY0x9bn2S+1OxVX ZK7oGpjrJ4KtrLyxTDYdQHwZBjfHJ9cs1fSijqPI6Sy0DCSkHUENhnemyMp+vaqjnWvH E46TPLhsl6IOa09es06n82PNwakiCTQNCfa11fqsKF4Dc4GTGWSH15jx9i0TWqkjcetk yBHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=asa3oU5K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q6-20020a056a00084600b005632e26e7ffsi11048500pfk.309.2022.10.11.08.34.23; Tue, 11 Oct 2022 08:34:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=asa3oU5K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230405AbiJKOy0 (ORCPT + 99 others); Tue, 11 Oct 2022 10:54:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230235AbiJKOxF (ORCPT ); Tue, 11 Oct 2022 10:53:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D18B39AFD7; Tue, 11 Oct 2022 07:51:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6EE60611AB; Tue, 11 Oct 2022 14:51:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 159A8C433D6; Tue, 11 Oct 2022 14:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665499877; bh=cLXgvj0T9awL6P216CPUddH+QuGc2O3OJqYE4x8E1Qs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=asa3oU5K/OcebMz9tpZksnyDDZte989bgI724hU3B62Aa1FKtN3sRGk7dUiDiG1jl Rr+7lXEl97iWsyPLh4T2Y93Er53r3tDp03VIMfy4AvKB0FjpSoBy+mE/z4e8vITe88 LPOtTGVtqWpB241t30lqflaX6RdobY7+w7684670F9MJjzECtUvy7f9FduCdhXLXqV 5PesWpm/hARE59EVm+2thW92kH6wxQ64UAJm9C28foaZEZiVJY/yawHl9kaC2iaOeS K5W0GGCKTQ4zT1UYNQMUciJc5CshEtFmKk3izIoWNqwbXkJxt2EL4X35upZNGoEl0O 4xLkDzmGcM2vQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Josef Bacik , David Sterba , Sasha Levin , clm@fb.com, linux-btrfs@vger.kernel.org Subject: [PATCH AUTOSEL 6.0 40/46] btrfs: separate out the eb and extent state leak helpers Date: Tue, 11 Oct 2022 10:50:08 -0400 Message-Id: <20221011145015.1622882-40-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221011145015.1622882-1-sashal@kernel.org> References: <20221011145015.1622882-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josef Bacik [ Upstream commit a40246e8afc0af3ffdee21854fb755c9364b8346 ] Currently we have the add/del functions generic so that we can use them for both extent buffers and extent states. We want to separate this code however, so separate these helpers into per-object helpers in anticipation of the split. Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/extent_io.c | 58 +++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index cf4f19e80e2f..d9d254b59bd1 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -44,25 +44,42 @@ static inline bool extent_state_in_tree(const struct extent_state *state) static LIST_HEAD(states); static DEFINE_SPINLOCK(leak_lock); -static inline void btrfs_leak_debug_add(spinlock_t *lock, - struct list_head *new, - struct list_head *head) +static inline void btrfs_leak_debug_add_eb(struct extent_buffer *eb) +{ + struct btrfs_fs_info *fs_info = eb->fs_info; + unsigned long flags; + + spin_lock_irqsave(&fs_info->eb_leak_lock, flags); + list_add(&eb->leak_list, &fs_info->allocated_ebs); + spin_unlock_irqrestore(&fs_info->eb_leak_lock, flags); +} + +static inline void btrfs_leak_debug_add_state(struct extent_state *state) { unsigned long flags; - spin_lock_irqsave(lock, flags); - list_add(new, head); - spin_unlock_irqrestore(lock, flags); + spin_lock_irqsave(&leak_lock, flags); + list_add(&state->leak_list, &states); + spin_unlock_irqrestore(&leak_lock, flags); +} + +static inline void btrfs_leak_debug_del_eb(struct extent_buffer *eb) +{ + struct btrfs_fs_info *fs_info = eb->fs_info; + unsigned long flags; + + spin_lock_irqsave(&fs_info->eb_leak_lock, flags); + list_del(&eb->leak_list); + spin_unlock_irqrestore(&fs_info->eb_leak_lock, flags); } -static inline void btrfs_leak_debug_del(spinlock_t *lock, - struct list_head *entry) +static inline void btrfs_leak_debug_del_state(struct extent_state *state) { unsigned long flags; - spin_lock_irqsave(lock, flags); - list_del(entry); - spin_unlock_irqrestore(lock, flags); + spin_lock_irqsave(&leak_lock, flags); + list_del(&state->leak_list); + spin_unlock_irqrestore(&leak_lock, flags); } void btrfs_extent_buffer_leak_debug_check(struct btrfs_fs_info *fs_info) @@ -126,9 +143,11 @@ static inline void __btrfs_debug_check_extent_io_range(const char *caller, } } #else -#define btrfs_leak_debug_add(lock, new, head) do {} while (0) -#define btrfs_leak_debug_del(lock, entry) do {} while (0) -#define btrfs_extent_state_leak_debug_check() do {} while (0) +#define btrfs_leak_debug_add_eb(eb) do {} while (0) +#define btrfs_leak_debug_add_state(state) do {} while (0) +#define btrfs_leak_debug_del_eb(eb) do {} while (0) +#define btrfs_leak_debug_del_state(state) do {} while (0) +#define btrfs_extent_state_leak_debug_check() do {} while (0) #define btrfs_debug_check_extent_io_range(c, s, e) do {} while (0) #endif @@ -353,7 +372,7 @@ static struct extent_state *alloc_extent_state(gfp_t mask) state->state = 0; state->failrec = NULL; RB_CLEAR_NODE(&state->rb_node); - btrfs_leak_debug_add(&leak_lock, &state->leak_list, &states); + btrfs_leak_debug_add_state(state); refcount_set(&state->refs, 1); init_waitqueue_head(&state->wq); trace_alloc_extent_state(state, mask, _RET_IP_); @@ -366,7 +385,7 @@ void free_extent_state(struct extent_state *state) return; if (refcount_dec_and_test(&state->refs)) { WARN_ON(extent_state_in_tree(state)); - btrfs_leak_debug_del(&leak_lock, &state->leak_list); + btrfs_leak_debug_del_state(state); trace_free_extent_state(state, _RET_IP_); kmem_cache_free(extent_state_cache, state); } @@ -5856,7 +5875,7 @@ static void btrfs_release_extent_buffer_pages(struct extent_buffer *eb) static inline void btrfs_release_extent_buffer(struct extent_buffer *eb) { btrfs_release_extent_buffer_pages(eb); - btrfs_leak_debug_del(&eb->fs_info->eb_leak_lock, &eb->leak_list); + btrfs_leak_debug_del_eb(eb); __free_extent_buffer(eb); } @@ -5873,8 +5892,7 @@ __alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 start, eb->bflags = 0; init_rwsem(&eb->lock); - btrfs_leak_debug_add(&fs_info->eb_leak_lock, &eb->leak_list, - &fs_info->allocated_ebs); + btrfs_leak_debug_add_eb(eb); INIT_LIST_HEAD(&eb->release_list); spin_lock_init(&eb->refs_lock); @@ -6342,7 +6360,7 @@ static int release_extent_buffer(struct extent_buffer *eb) spin_unlock(&eb->refs_lock); } - btrfs_leak_debug_del(&eb->fs_info->eb_leak_lock, &eb->leak_list); + btrfs_leak_debug_del_eb(eb); /* Should be safe to release our pages at this point */ btrfs_release_extent_buffer_pages(eb); #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS -- 2.35.1