Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp692334rwi; Mon, 31 Oct 2022 06:32:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6SAXOeg+Y/P4IOHjwDp+7CBPf5scwWfKhQIIZRE7q9a1X5PagNqvvqlOFzttGmUWOVVr3w X-Received: by 2002:a63:4307:0:b0:464:a24d:8201 with SMTP id q7-20020a634307000000b00464a24d8201mr12874076pga.116.1667223153524; Mon, 31 Oct 2022 06:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667223153; cv=none; d=google.com; s=arc-20160816; b=v7FnTtQAZkZFF5htUXkuxAmpS7NCmsM8jsuMKXuuhhsDw/UjvV1gWYj0lEUsI0H4WX Z2GylNtsacAYTLiIkegl9dOh3NVLp58172AohmAPDSf7IHN4rRg347+1l69DfAPACSUC EkjVAhbDUxYolAKIah3jwaeJN0aZeb63H8H1xxTdkjchU3YSIUwd0R9Mx9BgEsw47yOn WHbfipg5UGp3LM20/9RPXM5eflvdbVvnJd58ZgF5VgfY3vf44N7wYvpCTqCpP1IdGAat k5TpUlXAa+XUgjeSFiZzEzOT39PsyZbD8pdpGr23hTQ7sMCu8+ZUN9sszmW8EvSsxQXb UJlQ== 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=mK+L+uUF8ZjJcFgl9wjwsAEgN3PG+XwEHbTHdwikw+k=; b=JmDFnKlcBZV+ZVrmkkDwjTmRysoDCtA2Cmh67DWfkpDlg8TfUH1RIryIwbryjyzg3V TT4V1kXeZzvH3Y+SKoSQT/6J8q7ub9bgydtyunzuoXQaV97g1TJ9ddv9xLjnU9v2V+Gp v6XaQvrT3JTR2tx25T3+VV80hIMM96hY1pdQpCovpIQTSqcEchvhA+YmZyBRg9QWZQMW v6yYqE3TkXMiWSaERZPVTgl6yXI5sDJa0WZeJRkqAsuQanl+7oyextUFoPzMA94qf7X6 LAUGFMo6nZg5443shYkpL0UnMsz5vRxsf0NRJi3ooSBMZBX82iVz5GUmnAZaKZXCLWJl nTJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lmKkZjAj; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e6-20020aa798c6000000b0056d789ba707si3286735pfm.294.2022.10.31.06.32.19; Mon, 31 Oct 2022 06:32:33 -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=@kernel.org header.s=k20201202 header.b=lmKkZjAj; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229870AbiJaN2f (ORCPT + 99 others); Mon, 31 Oct 2022 09:28:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229839AbiJaN2e (ORCPT ); Mon, 31 Oct 2022 09:28:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E745AE72 for ; Mon, 31 Oct 2022 06:28:30 -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 ams.source.kernel.org (Postfix) with ESMTPS id B25BBB8112E for ; Mon, 31 Oct 2022 13:28:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F32D9C433C1; Mon, 31 Oct 2022 13:28:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667222907; bh=mK+L+uUF8ZjJcFgl9wjwsAEgN3PG+XwEHbTHdwikw+k=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=lmKkZjAjiNHrhY38tIjo8C+jATE63AZb8VpDhUD0dBMNYdGk/KK8EFm81F3s3BnMA GfSt2pKdMrAZErCYALF8iVpb13Pf/3ZCfchdJuJ4boov2w8TQGyhBdQLTxwv4pw5Ng eN1OZDl8pqFQvSgH+HJPvqiloGAynzafC408Ka0DINd0c715knEaqLkybhnG1wCuAu xlSkdaeMSuj4jdnswdDcDlKIJZx51SZ7HadK6Hekc6M741kyCRzcLLSB0GSNLIh2yw X/sUHUKSrlrRx1iV+sdvJOidQ6D1b4PxZBVw56fxrK7NBBYli1ZqBhTaa7wrIBX8ox llt8F7AohboEw== Message-ID: <014cde00a44c7240414049ac5d179320e96df6c8.camel@kernel.org> Subject: Re: [PATCH v3 3/4] nfsd: close race between unhashing and LRU addition From: Jeff Layton To: Chuck Lever III Cc: Neil Brown , Linux NFS Mailing List Date: Mon, 31 Oct 2022 09:28:25 -0400 In-Reply-To: <202AD086-4F1F-41D6-ABDC-BA6C91DA5BBF@oracle.com> References: <20221028185712.79863-1-jlayton@kernel.org> <20221028185712.79863-4-jlayton@kernel.org> <08778EE0-CBDC-467B-ACA6-9D8E6719E1BB@oracle.com> <166716630911.13915.14442550645061536898@noble.neil.brown.name> <1737B8C1-5B93-4887-A673-F9AFA6ED32C0@oracle.com> <202AD086-4F1F-41D6-ABDC-BA6C91DA5BBF@oracle.com> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Spam-Status: No, score=-8.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-nfs@vger.kernel.org On Mon, 2022-10-31 at 13:14 +0000, Chuck Lever III wrote: >=20 > > On Oct 31, 2022, at 6:08 AM, Jeff Layton wrote: > >=20 > > On Mon, 2022-10-31 at 02:51 +0000, Chuck Lever III wrote: > > >=20 > > > > On Oct 30, 2022, at 5:45 PM, NeilBrown wrote: > > > >=20 > > > > On Sat, 29 Oct 2022, Chuck Lever III wrote: > > > > >=20 > > > > > > On Oct 28, 2022, at 2:57 PM, Jeff Layton w= rote: > > > > > >=20 > > > > > > The list_lru_add and list_lru_del functions use list_empty chec= ks to see > > > > > > whether the object is already on the LRU. That's fine in most c= ases, but > > > > > > we occasionally repurpose nf_lru after unhashing. It's possible= for an > > > > > > LRU removal to remove it from a different list altogether if we= lose a > > > > > > race. > > >=20 > > > Can that issue be resolved by simply adding a "struct list_head nf_di= spose" > > > field? That might be more straightforward than adding conditional log= ic. > > >=20 > >=20 > > Yes, though that would take more memory. >=20 > Not really. pahole says struct nfsd_file is currently 40 bytes short > of two cache lines. So adding a list_head field should not push the > size of nfsd_file to the point where kmalloc would have to allocate > more memory per object. >=20 > I'm wondering if a separate list_head field would help simplify > nfsd_file_put() ? >=20 Probably not. It wouldn't need the flag anymore, but the logic would still be roughly the same. We still have to check for the race between unhashing and adding to the LRU either way. =20 --=20 Jeff Layton