Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4834624ioa; Wed, 27 Apr 2022 12:09:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzpt1T/KkuHLcVr9sslE3rDl1MyICwvqulvN8VfO1jwXFotVbLiP3gf79/XNFjEyDVkCG6 X-Received: by 2002:a05:6402:1d4a:b0:425:e356:36e7 with SMTP id dz10-20020a0564021d4a00b00425e35636e7mr19384502edb.172.1651086542192; Wed, 27 Apr 2022 12:09:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651086542; cv=none; d=google.com; s=arc-20160816; b=kHmTgAx8quNaJodgQt4jieqzD1s8bI2ZXvu12hEsIn0pqV28oQueryNjAMEmOoN5ux s2a/QVvqFBH+eIYLo3M2TyjBavAEOqwbIFt8j+ve2lnULEiREmPedBACUo27j7vm/a8d 94RGq4kr5XWQdxHb99ytsD9oSKA7T2VM9izL02l9JVur2COB115juGFM90cL9iLsN/9W XUdStKwLtauAFsosaUfm7JEEdJc3Oalb3/dTnBem/CcoDE2LBdIzrHbSD5YmiMOsteNt qZ7fL/UhO6uEFyMIvG9yQQxczIWVeIS9XBpHNgl0l9DdVz6BdNIb1rXRHwFNxW2Cgy2o lQwg== 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=WFHDoz9ZGDasBe6df2WBhiIrFz/NkNbSxRjaHWeeCfk=; b=ToKmHNa22LVSY2csAekImLSVD2Z9myi0S4+XGTssvA20k63+yulzaho284/rN5qsQV zN91YH+ILAvIEqftNHpFaguGD1Yxv4fuXZ0IUS+Y8lSex615dUMoy1Q/gaPA25O9NsW1 q4k27DrZB1Ar5iejuzyR32q/pjckH0OjZA55MOsaRkReWfm8gRv2KYibpSL+62Z3i/Ot o63Fu3x3bA8WUVtRZWhSfuemq+VBvvottrJ8oQMiYITaoRcstmDBuAPleErVtmgY2aML YwuZDaSX3ynQjd8jGq4ubHsHPkwe4Hof+n+ZdabAMtbqLmYrLj5uAl0abrT4EtDAkm08 bWaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=HBZKvrkm; 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 i1-20020a170906250100b006efe5500eb7si2026365ejb.399.2022.04.27.12.08.20; Wed, 27 Apr 2022 12:09:02 -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=HBZKvrkm; 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 S232086AbiD0TB1 (ORCPT + 99 others); Wed, 27 Apr 2022 15:01:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232172AbiD0TBH (ORCPT ); Wed, 27 Apr 2022 15:01:07 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84A4762BCE; Wed, 27 Apr 2022 11:46:54 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id CCEB8713D; Wed, 27 Apr 2022 14:46:53 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org CCEB8713D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1651085213; bh=WFHDoz9ZGDasBe6df2WBhiIrFz/NkNbSxRjaHWeeCfk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HBZKvrkmy+zNusBjk98XDp9kzx17FI176brvUBdi7Nxnu193vCq9Q7ttpk5i/8Zar Sv5UiQOZnOSS+afLPfjHcHD7m2OMQr3N5ZTWopwmMk8HKTMM67w5qrHs9nJOjzhcxt 1jYRVZvmdtirsr//krYAGt+mHltGv+lL37jxhxr4= Date: Wed, 27 Apr 2022 14:46:53 -0400 From: "J. Bruce Fields" To: Dai Ngo 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 v22 1/7] NFSD: add courteous server support for thread with only delegation Message-ID: <20220427184653.GE13471@fieldses.org> References: <1651049573-29552-1-git-send-email-dai.ngo@oracle.com> <1651049573-29552-2-git-send-email-dai.ngo@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1651049573-29552-2-git-send-email-dai.ngo@oracle.com> 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 Wed, Apr 27, 2022 at 01:52:47AM -0700, Dai Ngo wrote: > diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c > index 234e852fcdfa..216bd77a8764 100644 > --- a/fs/nfsd/nfs4state.c > +++ b/fs/nfsd/nfs4state.c > @@ -125,6 +125,8 @@ static void free_session(struct nfsd4_session *); > static const struct nfsd4_callback_ops nfsd4_cb_recall_ops; > static const struct nfsd4_callback_ops nfsd4_cb_notify_lock_ops; > > +static struct workqueue_struct *laundry_wq; > + > static bool is_session_dead(struct nfsd4_session *ses) > { > return ses->se_flags & NFS4_SESSION_DEAD; > @@ -152,6 +154,7 @@ static __be32 get_client_locked(struct nfs4_client *clp) > if (is_client_expired(clp)) > return nfserr_expired; > atomic_inc(&clp->cl_rpc_users); > + clp->cl_state = NFSD4_ACTIVE; > return nfs_ok; > } > > @@ -172,6 +175,7 @@ renew_client_locked(struct nfs4_client *clp) > > list_move_tail(&clp->cl_lru, &nn->client_lru); > clp->cl_time = ktime_get_boottime_seconds(); > + clp->cl_state = NFSD4_ACTIVE; > } We shouldn't need that assignment in both places. The laundromat really shouldn't let a client go to COURTESY while there are rpc's in process for that client. So, let's just add that check to the laundromat (see below), and then the assignment in renew_client_locked becomes unnecessary. > +static void > +nfs4_get_client_reaplist(struct nfsd_net *nn, struct list_head *reaplist, > + struct laundry_time *lt) > +{ > + struct list_head *pos, *next; > + struct nfs4_client *clp; > + bool cour; > + > + INIT_LIST_HEAD(reaplist); > + spin_lock(&nn->client_lock); > + list_for_each_safe(pos, next, &nn->client_lru) { > + clp = list_entry(pos, struct nfs4_client, cl_lru); > + if (clp->cl_state == NFSD4_EXPIRABLE) > + goto exp_client; > + if (!state_expired(lt, clp->cl_time)) > + break; > + if (!client_has_state_tmp(clp)) > + goto exp_client; > + cour = (clp->cl_state == NFSD4_COURTESY); > + if (cour && ktime_get_boottime_seconds() >= > + (clp->cl_time + NFSD_COURTESY_CLIENT_TIMEOUT)) { > + goto exp_client; > + } > + if (nfs4_anylock_blockers(clp)) { > +exp_client: > + if (mark_client_expired_locked(clp)) > + continue; > + list_add(&clp->cl_lru, reaplist); > + continue; > + } > + if (!cour) > + cmpxchg(&clp->cl_state, NFSD4_ACTIVE, NFSD4_COURTESY); So, as in mark_client_expired_locked, we should only be doing this if clp_cl_rpc_users is 0. Also, it should just be a simple assignment, the cmpxchg isn't necessary here. --b.