Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6157554rwi; Sun, 23 Oct 2022 19:29:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5dAD5XgPvhNaZsMJMDM++YQfzgllqMVYvLt7lBXxEly4tziZWVko3nSwwlFloMeLK3b9AT X-Received: by 2002:a17:902:d2c5:b0:186:afd7:56d3 with SMTP id n5-20020a170902d2c500b00186afd756d3mr1137677plc.142.1666578563167; Sun, 23 Oct 2022 19:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666578563; cv=none; d=google.com; s=arc-20160816; b=sggrc2G691qT+R6JTnM5WiW1LCPIQzxPWBO6ujtfv3CaBQz1GcGA0SMQxOTTNtAZ9p 6LjOAMQtU7iiqjuwDIQRIHEyopB3VIyFOk9njy/wzSZf+bAUI8dgHIbwHG6Z1mAMW/ms EaX02tuUpC7B6lkwtZidxm2Jjwwo0gWJbnSO5OmWtTHiPCIWNrQHcz02i5KNqi9TVek8 u7RBH+iU2Ifs75KM7DL/eZ/sC8assjItFEjBmvcIkonujkDkpzGpre5GKxoQGBFx8hjO oH2i18eIpvFAP1NY5JQc8ykO44fjeJeMiPKUNRtY6a+1dQbtLpDKsITB9npJmgivr7s7 Lt2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature; bh=ufJrwSckxs7bbC2kzHtfl61ywrGTI4JvCYYQP+dprA0=; b=H2LSW81oE30GXNRDrwGL7urGn4jm2Fm6/FAW/xPJkALFQckLta/0G4+qpM+6HYoE2m OfxtCFR9AEIFt3qHUxACJy7gY78nYt61AfMcQwY3obk6BMrQeU2HuSJZKH+UvpRsMvGv 1V93vLT9UpZtCwzgjVNu8dvfDbGEhpXi+81yyAZFcb85mCu7Z/5XMLwmxh1MgiOq4yc1 uSegmJvaLg8PvJybw66ayMTQMOTDKRj2wk8EtyvuZ4kMEc2WfRoj78pIXesP4BlK3oDD rUttemPV54bc7VFQkMF2ZbOcz6vtVXOCQ7+qETQfokVkJK8XzatrGoc02uHwepYYyfrS dxEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=UyH37NuG; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 184-20020a6301c1000000b00430b25c0134si34142648pgb.670.2022.10.23.19.29.01; Sun, 23 Oct 2022 19:29:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@suse.de header.s=susede2_rsa header.b=UyH37NuG; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229631AbiJXCHk (ORCPT + 99 others); Sun, 23 Oct 2022 22:07:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbiJXCHk (ORCPT ); Sun, 23 Oct 2022 22:07:40 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E2196FA31 for ; Sun, 23 Oct 2022 19:07:37 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D39DD2199A; Mon, 24 Oct 2022 02:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1666577255; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ufJrwSckxs7bbC2kzHtfl61ywrGTI4JvCYYQP+dprA0=; b=UyH37NuGY54PosnTlkmi/gga3y3azHZzXGEMeMqhvqeTD+U9Y7tzk8gesZh9j/CmBrHt/i ZBMOsqEmcAKtbkOfjst9MiwFZ+9BBC02AAMXu9S60PYOEw5LQmO5wDiQw/yMePKEF5Tqdl CBB4TAmMqFVlqHxTvDxljwUtoHEU2nI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1666577255; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ufJrwSckxs7bbC2kzHtfl61ywrGTI4JvCYYQP+dprA0=; b=UfyluQGVzkfIv9QHyJSibZe8oE4mo2ajDXX/AKGM6CxNhbUx9fJlHkK1pl+UCPLq+S03pB abPMfgAfHRroUFDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A2B7913357; Mon, 24 Oct 2022 02:07:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id rB5fFmbzVWPTLgAAMHmgww (envelope-from ); Mon, 24 Oct 2022 02:07:34 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 From: "NeilBrown" To: "Chuck Lever III" Cc: "Jeff Layton" , "Linux NFS Mailing List" Subject: Re: [PATCH v4 5/7] NFSD: Use rhashtable for managing nfs4_file objects In-reply-to: <1DE04392-E8C9-4D39-BF23-BD1A59DB4FE3@oracle.com> References: <166612295223.1291.11761205673682408148.stgit@manet.1015granger.net>, <166612313084.1291.5764156173845222109.stgit@manet.1015granger.net>, , <1DE04392-E8C9-4D39-BF23-BD1A59DB4FE3@oracle.com> Date: Mon, 24 Oct 2022 13:07:10 +1100 Message-id: <166657723034.12462.8422170607830380805@noble.neil.brown.name> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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-nfs@vger.kernel.org On Thu, 20 Oct 2022, Chuck Lever III wrote: > > > On Oct 19, 2022, at 7:39 AM, Jeff Layton wrote: > > > >> - fp = find_or_add_file(open->op_file, current_fh); > >> + rcu_read_lock(); > >> + fp = insert_nfs4_file(open->op_file, current_fh); > >> + rcu_read_unlock(); > > > > It'd probably be better to push this rcu_read_lock down into > > insert_nfs4_file. You don't need to hold it over the actual insertion, > > since that requires the state_lock. > > I used this arrangement because: > > insert_nfs4_file() invokes only find_nfs4_file() and the > insert_file() helper. Both find_nfs4_file() and the > insert_file() helper invoke rhltable_lookup(), which > must be called with the RCU read lock held. > > And this is the reason why put_nfs4_file() no longer takes > the state_lock: it would take the state_lock first and > then the RCU read lock (which is implicitly taken in > rhltable_remove()), which results in a lock inversion > relative to insert_nfs4_file(), which takes the RCU read > lock first, then the state_lock. It doesn't make any sense to talk about lock inversion with rcu_read_lock(). It isn't really a lock in any traditional sense in that it can never block (which is what cause lock-inversion problems). I prefer to think for rcu_read_lock() as taking a reference on some global state. > > > I'm certainly not an expert, so I'm willing to listen to > alternative approaches. Can we rely on only the RCU read > lock for exclusion on hash insertion? Probably we can. I'll read through all the patches now and provide some review. NeilBrown