Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5243380imw; Wed, 20 Jul 2022 01:44:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t/agI5sauJsTFM08qvtcPUDQ3DO0AuBNSEM78tL+zb84AjnmVNF0J38C/WDztbH6MpWtw4 X-Received: by 2002:a05:6402:4511:b0:43b:a182:8a0a with SMTP id ez17-20020a056402451100b0043ba1828a0amr7568294edb.410.1658306653833; Wed, 20 Jul 2022 01:44:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658306653; cv=none; d=google.com; s=arc-20160816; b=iQ4XpnyT9CgzUvAVbRdhTsASBxojBYLQDDLZu9hfFhm7xaH7t7n05JmsdDkK+RBWG9 wjyz3H048P98wkKRSXfKk297B6p/7FrfOYqmPJobG0uOuiPS9fTEcGNFXRaO27lepvZv /vBRO4+jMpDv6Qnmpk/uqEa3gyO0C53IC/XBHM3KOl4gLwoYpEGXrEzXpdS9U4Mx5tTX y+4tixwmlY7Ehjezy4BwfR7l+FDT7bRFy1FqInTZIF+LhntYg1ME/07reGHNDF8DXbbm +WZBxqeI5B+gjXH30eZhMBAh1O2R0cHqXSYeTWMKN6XaPUCHA0lSPvRgJ1c4XioYU/kN PfYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=kM8ukTR5POi65FwtoTmA8l8y0RmXuMMTcMLebhiJucM=; b=upRXbBbMLqqiO0dDFXtTfmY7oJ4sqoKUAb5N3sRitBH7QfYeltW0NlZ94DxmJSGyYx nXhePU1Do0Ty+n+dl0HguyzAa18880ZzHwKJxj9vUAR2ak78qdNxJCW6zPZMu/hq2IEy Omsyl9OHcjArYRKm16cV7BCuY69QHhbnyWlC+5771cNgaIqIWpodCV02am4J+baGlrcN HyvMoXMFYG+eQfLZb2QoVJekXgOYkJSWgPal6TyRk8/GeHETtp4Cn1DcC4SXcge2Rk6z Qq+50zGlD7xDf43lGPrPXj3hs4/EIuveufUTd7RGdxZrtxw1rdeYLP1WV8shygSSZjHg zbow== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c20-20020a056402121400b0043ae18edf05si13903413edw.613.2022.07.20.01.43.48; Wed, 20 Jul 2022 01:44:13 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235993AbiGTI0m (ORCPT + 99 others); Wed, 20 Jul 2022 04:26:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235039AbiGTI0l (ORCPT ); Wed, 20 Jul 2022 04:26:41 -0400 Received: from smtp.smtpout.orange.fr (smtp-23.smtpout.orange.fr [80.12.242.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3439B66AF9 for ; Wed, 20 Jul 2022 01:26:40 -0700 (PDT) Received: from [192.168.1.18] ([90.11.190.129]) by smtp.orange.fr with ESMTPA id E52RoVdt2xFTAE52Ro9pAL; Wed, 20 Jul 2022 10:26:38 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Wed, 20 Jul 2022 10:26:38 +0200 X-ME-IP: 90.11.190.129 Message-ID: Date: Wed, 20 Jul 2022 10:26:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH 2/3] ocfs2: Remove a useless spinlock Content-Language: en-US To: Joseph Qi Cc: David.Laight@ACULAB.COM, christophe.jaillet@wanadoo.fr, jlbec@evilplan.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, mark@fasheh.com, ocfs2-devel@oss.oracle.com References: <8ba7004d330cbe5f626539a8a3bff696d0c4285e.1658224839.git.christophe.jaillet@wanadoo.fr> <7b644e5d32d74d3d90dfc5b1786ae5b9@AcuMS.aculab.com> <29c3fbdd-7695-46c5-bb75-fe358c574ab3@wanadoo.fr> <07c924de-78bf-c993-ce73-635af71f4edd@linux.alibaba.com> From: Marion & Christophe JAILLET In-Reply-To: <07c924de-78bf-c993-ce73-635af71f4edd@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Le 20/07/2022 à 03:59, Joseph Qi a écrit : > > On 7/19/22 9:25 PM, Christophe JAILLET wrote: >> Le 19/07/2022 à 12:24, David Laight a écrit : >>> From: Christophe JAILLET >>>> Sent: 19 July 2022 11:02 >>>> >>>> 'node_map_lock' is a spinlock only used to protect calls to set_bit(), >>>> clear_bit() and test_bit(). >>>> >>>> {set|clear}_bit() are already atomic and don't need this extra spinlock. >>>> test_bit() only reads the bitmap for a given bit. >>>> >>>> Remove this useless spinlock. >>> It looks to me like the calling code is racy >>> unless there is another lock in the callers. >> The call chains are: >>   ocfs2_recover_orphans() >>     ocfs2_mark_recovering_orphan_dir() >>       spin_lock(&osb->osb_lock);        <-- osb_lock spinlock >>       ocfs2_node_map_set_bit()            <-- uses node_map_lock >>       ... >>       spin_unlock(&osb->osb_lock); >>     ... >>     ocfs2_clear_recovering_orphan_dir() >>       ocfs2_node_map_clear_bit()        <-- uses node_map_lock >>                             osb_lock is NOT taken >> >> >>   ocfs2_check_orphan_recovery_state() >>     spin_lock(&osb->osb_lock);            <-- osb_lock spinlock >>     ... >>     ocfs2_node_map_test_bit()            <-- uses node_map_lock >>     ... >>     spin_unlock(&osb->osb_lock); >> >> >> So the code looks already protected by the 'osb_lock' spinlock, but I don't know this code and ocfs2_mark_recovering_orphan_dir() looks tricky to me. (so some other eyes are much welcome) > > osb_lock is to protect osb filed such as 'osb_orphan_wipes', while > node_map_lock is to protect the node map 'osb_recovering_orphan_dirs' > specifically. Thanks for this explanation. But does "node_map_lock" really protects anything? It is just around some atomic function calls which shouldn't need any, right? test_bit() is not documented as atomic, but {clear|set}_bit() could be executed just before or just after it with the current locking mechanism, so I don't really see how it would make a difference. I don't understand the logic of this lock here. Can you elaborate? CJ > Thanks, > Joseph >