Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6094604rwr; Tue, 9 May 2023 10:06:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6X7QN4b+4r+lfDSKG5EDm8BO4mD9FCw5MY5LGrTAl6hYe00WvPbtIkalXQgo/aPKXKHQgx X-Received: by 2002:a05:6a21:920b:b0:f0:3e78:715b with SMTP id tl11-20020a056a21920b00b000f03e78715bmr15241843pzb.40.1683652013408; Tue, 09 May 2023 10:06:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683652013; cv=none; d=google.com; s=arc-20160816; b=QAIbyCJRyspCnh+f1xRSTmgUav/x9gmq4YTs/PHwurWULwBIr3BVQf3GdBgQCw5jyV LvV4yfEWO1vroKkGweRJ7wnWliua9ahl3YnWpez4G8xmiQe0wygxbnYFntU/qzlzT+Mf deb3flDP6CpGn4ce4nCyNR5jKdUfgTreuwFDogfnWam3rXJQy4eCYcgPrIS1TFEUCYJe T4w2MwdI5KvvxerblbJrsuvIMPRIsbCCUEKwcjeQcHWyOwJ5NYFfHKu3bpXvxKZxSJfa BfpgwV9WACs0ZwWTBjhJFddlrlkVOGISFJmlYbEiSCkfbtB/tpSmz03d/vCuWb4JjjoY yf9A== 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=4+qUD9R+DcetQOvg5f3GpMxzPZzmlaA8sue3bNTAfVo=; b=HoO2Zn3y5DzsClWxHJSTc47kpi0ywcvmZ69RP9tMumHxRV2t4vHKnLTq2rWLVSN+4N ebnKvJdwiWum7Ydf/wl7KH75JphbdL0W5+im3STZ1JFBf98tPfInhkyxnGYD2w2vz6o5 uR0Pb1B//6uEEVlu5RlKVeer5swoqCmN1r7U7CLeep4AOBHP9XWXTxKR2ZYYnd7KMQZE +468Z6o90pIA8+J4EnfHoxnrfSo7BgHYnvNcKsT5aWKawxUrzUIj5Izl/zZ/VlUVVZWC EvMxhjjlKNfT7pfktdpqDKLHMGtBoOxLkvXNRC29awXMZn93MmNJ1c2JTTaHq4iV0QsD sImw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ENkhviM7; 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=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r28-20020a638f5c000000b0052cbf3e8b78si1313938pgn.72.2023.05.09.10.06.39; Tue, 09 May 2023 10:06:53 -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=@linux.dev header.s=key1 header.b=ENkhviM7; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235238AbjEIQ7k (ORCPT + 99 others); Tue, 9 May 2023 12:59:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235034AbjEIQ6W (ORCPT ); Tue, 9 May 2023 12:58:22 -0400 Received: from out-6.mta1.migadu.com (out-6.mta1.migadu.com [95.215.58.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52D6B5FDD for ; Tue, 9 May 2023 09:57:32 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1683651450; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4+qUD9R+DcetQOvg5f3GpMxzPZzmlaA8sue3bNTAfVo=; b=ENkhviM7etnE84ZkD+4vtkRiiNspqxA/lNrO4RXNZ8yeN8c2YKqtbDxJAr9NJIhBYV8UsZ z6ktImL6+6VKYmFBJ10zEUcmqyFXw/Yt2IsylmWIqyAO9H8c6nRJDKPTxx9R8kf0Vj47zL WpWU+qb0j2vNs8POnr1oLPMdpMcv0Nc= From: Kent Overstreet To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-bcachefs@vger.kernel.org Cc: Dave Chinner , Kent Overstreet Subject: [PATCH 21/32] hlist-bl: add hlist_bl_fake() Date: Tue, 9 May 2023 12:56:46 -0400 Message-Id: <20230509165657.1735798-22-kent.overstreet@linux.dev> In-Reply-To: <20230509165657.1735798-1-kent.overstreet@linux.dev> References: <20230509165657.1735798-1-kent.overstreet@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: Dave Chinner in preparation for switching the VFS inode cache over the hlist_bl lists, we nee dto be able to fake a list node that looks like it is hased for correct operation of filesystems that don't directly use the VFS indoe cache. Signed-off-by: Dave Chinner Signed-off-by: Kent Overstreet --- include/linux/list_bl.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/linux/list_bl.h b/include/linux/list_bl.h index ae1b541446..8ee2bf5af1 100644 --- a/include/linux/list_bl.h +++ b/include/linux/list_bl.h @@ -143,6 +143,28 @@ static inline void hlist_bl_del_init(struct hlist_bl_node *n) } } +/** + * hlist_bl_add_fake - create a fake list consisting of a single headless node + * @n: Node to make a fake list out of + * + * This makes @n appear to be its own predecessor on a headless hlist. + * The point of this is to allow things like hlist_bl_del() to work correctly + * in cases where there is no list. + */ +static inline void hlist_bl_add_fake(struct hlist_bl_node *n) +{ + n->pprev = &n->next; +} + +/** + * hlist_fake: Is this node a fake hlist_bl? + * @h: Node to check for being a self-referential fake hlist. + */ +static inline bool hlist_bl_fake(struct hlist_bl_node *n) +{ + return n->pprev == &n->next; +} + static inline void hlist_bl_lock(struct hlist_bl_head *b) { bit_spin_lock(0, (unsigned long *)b); -- 2.40.1