Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3670123lfo; Mon, 23 May 2022 10:55:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeNF8MFwqSGhPEC0a3xnoMm+jZP7YlaXZjWxVjZa/nOLRvqFS+m//UlJPoXzVQtZXd2Sz9 X-Received: by 2002:a17:902:9b93:b0:15f:17ce:3b97 with SMTP id y19-20020a1709029b9300b0015f17ce3b97mr23949270plp.174.1653328545540; Mon, 23 May 2022 10:55:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653328545; cv=none; d=google.com; s=arc-20160816; b=sLtvCpFv/COoAjDqMQlLoD8NWeb7lR5LBbJWW+pQ82HxowgidQ+rHjOeHVFZ2hbeiv O7KcqsuKNhsVFqsoATfusYrL/+Q9VUsI47Iz4Y0bdYgvAFJ7dN4L3Ro6BCCyrSS0nTzd BOd5X8EDKkulMjcuL4jgF9ldjamRab5pGRuWHpdV4n04gg8kcsChcDC9HsIeDrpVIfNw lNzSfUN1+JONxwBxlGvzlsR+lZEsMU44QPKi+JBZpTCS0t47TeAyRcjn/gSNIojuRRYQ riWsLtGrJdFNoX0+ahF2ZoK+tVy7GSpd/hVBoFME7qJ8VcJ66CqEHCxvG1hfbH7/Z1e+ Ah6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=BFVX97brsKjO7zF4MALWKW92GX/6ajqMIAFTscveHVw=; b=DyvK3qYfUoCpf/arAL3Af/Wn5Cd5+kq+UyGCftMDnWQASBUS/gA1CofSgODEb+Z5oB +3o7YS9pTvaaqwkF+Hg+mrWvIJ14Vd0y+UqGVNuGUmEXIbm+ovMQe0wz9uCiIP3Va8CQ Eq5LTIDkorYiIv9GuGicp3s7GgLDJQlPCcIiozlndv+Zhg2dbAXUefVX0P/BxGzNTfkX +CNVjS8/+QsxjZKzY62+dayrhqu0Y1E2EwVT6bQAQSSrX8Dureceg6HnELzwv/YRfVkj Y7IgSg4xh7imGxTT0HjQsbz2q8YTYusFKw+Q1T4c1fbykv6NRZkcsGWgaN3CVA+86XPX K5zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=I5GOan8J; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t20-20020a63dd14000000b003db48a0c6ecsi9063967pgg.792.2022.05.23.10.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 10:55:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=I5GOan8J; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1B25011CA09; Mon, 23 May 2022 10:55:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242203AbiEWRxN (ORCPT + 99 others); Mon, 23 May 2022 13:53:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244310AbiEWRv7 (ORCPT ); Mon, 23 May 2022 13:51:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D0926D3A7 for ; Mon, 23 May 2022 10:39:07 -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 6955960BD3 for ; Mon, 23 May 2022 17:39:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BE22C385A9; Mon, 23 May 2022 17:39:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653327541; bh=7qgSf/5NH4N7+Rd1yZrHkdcdD3D13iNxU/v08hdbVGA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=I5GOan8J16X5vP4ruS4TNkjO8glJKaladNJtGUkMuwa0CbWLV+Ksd3D1nSCrN9FsN Nb7iVwLSJR/aiIJAw4CviRfJw2+y00QjIh7pHvpx2qMkyNhPidO/dDIlpLga5mZ4Is HVci/qSre9fHFPAXToKofSo+pLi42ldsIimlBYtWAR6Q0niTAOrjmmh9XXWTfki5K3 Nklgm7Cpcdnmfh5SVqmeECqmEOM+KWDV+foiRJ0VUVX8vcHHXfwfWPfixP5g3Yddg3 QQ5NhOQP6qe/im0ylEGZWCbTIPlJkULs50cfyik2I8NYXlnmKiag5pkOowM5zO9ftf z+MdmEFVs8DGg== Message-ID: Subject: Re: [PATCH RFC] NFSD: Fix possible sleep during nfsd4_release_lockowner() From: Jeff Layton To: Chuck Lever III Cc: Linux NFS Mailing List Date: Mon, 23 May 2022 13:38:59 -0400 In-Reply-To: References: <165323344948.2381.7808135229977810927.stgit@bazille.1015granger.net> <510282CB-38D3-438A-AF8A-9AC2519FCEF7@oracle.com> <1A37E2B5-8113-48D6-AF7C-5381F364D99E@oracle.com> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.1 (3.44.1-1.fc36) MIME-Version: 1.0 X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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-nfs@vger.kernel.org On Mon, 2022-05-23 at 17:25 +0000, Chuck Lever III wrote: >=20 > > On May 23, 2022, at 12:37 PM, Jeff Layton wrote: > >=20 > > On Mon, 2022-05-23 at 15:41 +0000, Chuck Lever III wrote: > > >=20 > > > > On May 23, 2022, at 11:26 AM, Jeff Layton wrot= e: > > > >=20 > > > > What I was going to suggest is a nfsd_file_put variant that takes a > > > > list_head. If the refcount goes to zero and the thing ends up being > > > > unhashed, then you put it on the dispose list rather than doing the > > > > blocking operations, and then clean it up later. > > >=20 > > > Trond doesn't like that approach; see the e-mail thread. > >=20 > > I didn't see him saying that that would be wrong, per-se, but the > > initial implementation was racy. >=20 > I proposed this for check_for_locks() to use: >=20 > > void nfsd_file_put_async(struct nfsd_file *nf) > > { > > if (refcount_dec_and_test(&nf->nf_ref)) > > nfsd_file_close_inode(nf->nf_inode); > > } >=20 >=20 > Trond's response was: >=20 > > That approach moves the sync to the garbage collector, which was > > exactly what we're trying to avoid in the first place. >=20 > Basically he's opposed to any flush work being done by > the garbage collector because that has a known negative > performance impact. >=20 >=20 Fair enough. I like his other suggestion better anyway. > > His suggestion was just to keep a counter in the lockowner of how many > > locks are associated with it. That seems like a good suggestion, though > > you'd probably need to add a parameter to lm_get_owner to indicate > > whether you were adding a new lock or just doing a conflock copy. >=20 > locks_copy_conflock() would need to take a boolean parameter > that callers would set when they actually manipulate a lock. >=20 Yep. You'd also have to add a bool arg to lm_put_owner so that you know whether you need to decrement the counter. > I would feel more comfortable with that approach if > locks_copy_conflock() was a private API used only in fs/locks.c > so we can audit its usage to ensure that callers are managing > the lock count correctly. >=20 >=20 It basically is. In fact, I'm not sure why it's exported since nothing outside of locks.c calls it. Looking at the git history, it probably got exported by mistake when we split up locks_copy_lock and locks_copy_conflock, as the former was exported. I think this approach is quite doable... --=20 Jeff Layton