Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3302777ioa; Tue, 26 Apr 2022 00:26:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzv3ijBtHk1C7OZyZCgRfLGzJ7HXtmUmeQz3zi2/ONXZmHVQcHEl+gUvMzN3nmaqgsenGNJ X-Received: by 2002:a63:4a23:0:b0:39c:c255:11ef with SMTP id x35-20020a634a23000000b0039cc25511efmr18180450pga.569.1650957970273; Tue, 26 Apr 2022 00:26:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650957970; cv=none; d=google.com; s=arc-20160816; b=AiXVFMaO9AUJ6CaxBxEIpxVeJDY+/gC+SD5wOMIWeqbhz5u2x6s0wHuzYvMi2ymyRL 97iU54LSvsln6ug1CA0FW49GpJNGgtK7HDK+69bfahO5d06S2EpAIyxDcQo+g4ZDJy6C vHhpCkaMl8stTh+U2C6UMIFUl+LtN4v1oQbaX6MupAtZhZOZXO1RQdav3Dtx0uyIOfqu eTgMEUOXbFVxg4lQHNXzTbkTEahWT9Pjmj9xcmxr+rC57h2gJAVoJ2c6Ly7OpFODOYdE /luU6R37sI+hVsf6k5TjNP5lA3uXX4GrsMpLXOQYgAHnwIRukZTsBgE2uljWgp7xQMS2 cDzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=RyenE7yrp7GIARVYNzUsKD5sXq0hXyL1GIQN4oy/Eug=; b=a89HSq6nAZGEc/n3h5JALVHjk0OvXJ66CJlre0VaM88ixo6+zrs3O4Fv4GQAX+Y3Rh Xz9ETMeABDPIR9lbBrBUkP9qTaeuTKm9495NHyqeBL0YPDJKa4wjxBE5JyW5hOBXNFyz WqvFdGkmKohGK7o3WSx4C+Nbx2YUz6Ak9IvGNKeOkEMbksxfZ8KRyuyLvFFO0Hv2xJxO GoHfQFnytFIuBbqmktcUH+4KUWf6cHQq68Ru4jwduS/OuiAR/pSiJkTemUYWww8XUzvr xFtQQgw0dljXMzo/57JrF8FaGdaWUsr8BGWiG19w44Dqz90BZ6sYlYp7/zBAJNterHMQ EhFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=GVORqH5C; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17-20020a63f251000000b003aad07ba5c7si11273949pgk.13.2022.04.26.00.25.47; Tue, 26 Apr 2022 00:26:09 -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=@fieldses.org header.s=default header.b=GVORqH5C; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236824AbiDYXU0 (ORCPT + 99 others); Mon, 25 Apr 2022 19:20:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236178AbiDYXUZ (ORCPT ); Mon, 25 Apr 2022 19:20:25 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 339FE1AF3D; Mon, 25 Apr 2022 16:17:20 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id BD7586F33; Mon, 25 Apr 2022 19:17:19 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org BD7586F33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1650928639; bh=RyenE7yrp7GIARVYNzUsKD5sXq0hXyL1GIQN4oy/Eug=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GVORqH5CKxoOa0TQ6im2P1gParMefUfgfTu6QjNx4JsItaeMKVp/gc3uBcWalO9SK j862mhzVFpeg5pm1vfeRs9MWPcVx+lQ7o5cgU9adUK/BQ5vqMUB29fX0/DJpnlF96j /pXFGzxBNAQZEgeKtGfCrrPb4AOB3NhhNIl5gpBU= Date: Mon, 25 Apr 2022 19:17:19 -0400 From: "J. Bruce Fields" To: dai.ngo@oracle.com Cc: chuck.lever@oracle.com, jlayton@redhat.com, viro@zeniv.linux.org.uk, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH RFC v21 1/7] NFSD: add courteous server support for thread with only delegation Message-ID: <20220425231719.GB3188@fieldses.org> References: <1650739455-26096-1-git-send-email-dai.ngo@oracle.com> <1650739455-26096-2-git-send-email-dai.ngo@oracle.com> <20220425185121.GE24825@fieldses.org> <90f5ec04-deff-38d0-2b6f-8b2f48b72d9d@oracle.com> <20220425204006.GI24825@fieldses.org> <20220425214850.GK24825@fieldses.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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_PASS,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, Apr 25, 2022 at 03:24:49PM -0700, dai.ngo@oracle.com wrote: > > On 4/25/22 2:48 PM, J. Bruce Fields wrote: > >On Mon, Apr 25, 2022 at 02:35:27PM -0700, dai.ngo@oracle.com wrote: > >>On 4/25/22 1:40 PM, J. Bruce Fields wrote: > >>>On Mon, Apr 25, 2022 at 12:42:58PM -0700, dai.ngo@oracle.com wrote: > >>>>static inline bool try_to_expire_client(struct nfs4_client *clp) > >>>>{ > >>>> bool ret; > >>>> > >>>> spin_lock(&clp->cl_cs_lock); > >>>> if (clp->cl_state == NFSD4_EXPIRABLE) { > >>>> spin_unlock(&clp->cl_cs_lock); > >>>> return false; <<<====== was true > >>>> } > >>>> ret = NFSD4_COURTESY == > >>>> cmpxchg(&clp->cl_state, NFSD4_COURTESY, NFSD4_EXPIRABLE); > >>>> spin_unlock(&clp->cl_cs_lock); > >>>> return ret; > >>>>} > >>>So, try_to_expire_client(), as I said, should be just > >>> > >>> static bool try_to_expire_client(struct nfs4_client *clp) > >>> { > >>> return COURTESY == cmpxchg(clp->cl_state, COURTESY, EXPIRABLE); > >>> } > >>> > >>>Except, OK, I did forget that somebody else could have already set > >>>EXPIRABLE, and we still want to tell the caller to retry in that case, > >>>so, oops, let's make it: > >>> > >>> return ACTIVE != cmpxchg(clp->cl_state, COURTESY, EXPIRABLE); > >>So functionally this is the same as what i have in the patch, except this > >>makes it simpler? > >Right. > > > >And my main complaint is still about the code that fails lookups of > >EXPIRABLE clients. We shouldn't need to modify find_in_sessionid_hastbl > >or other client lookups. > > > >>Do we need to make any change in try_to_activate_client to work with > >>this change in try_to_expire_client? > >> > >>>In other words: set EXPIRABLE if and only if the state is COURTESY, and > >>>then tell the caller to retry the operation if and only if the state was > >>>previously COURTESY or EXPIRABLE. > >>> > >>>But we shouldn't need the cl_cs_lock, > >>The cl_cs_lock is to synchronize between COURTESY client trying to > >>reconnect (try_to_activate_client) and another thread is trying to > >>resolve a delegation/share/lock conflict (try_to_expire_client). > >>So you don't think this is necessary? > >Correct, it's not necessary. > > > >The only synchronization is provided by mark_client_expired_locked and > >get_client_locked. > > > >We don't need try_to_activate_client. Just set cl_state to ACTIVE in > >get_client_locked. > > ok, what you suggested seems to work. I will remove try_to_activate_client > and just set cl_state to ACTIVE and test it to see if there is any problems > that we haven't thought of with this scheme. Thanks! --b.