From patchwork Fri Mar 25 04:34:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dai Ngo X-Patchwork-Id: 12791281 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA8DFC433EF for ; Fri, 25 Mar 2022 04:35:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358251AbiCYEg4 (ORCPT ); Fri, 25 Mar 2022 00:36:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358239AbiCYEgq (ORCPT ); Fri, 25 Mar 2022 00:36:46 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2D30C682A; Thu, 24 Mar 2022 21:35:07 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22ONt9wt031408; Fri, 25 Mar 2022 04:35:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2021-07-09; bh=DfCgVf11hHgxmYEQSff9VcylBJ9pr6qMxuPxSjHVKLk=; b=oELgdVa8T6TgyCfO0x581Eb5/YRkVvYldrSWHDZVin8B11e7MPpm6NkOtHqXzTz+FWyD lF8IorpI1L/tc0kA3tK5SFJMq9+AD/lsMmlEOkh7VQwYw96rLk/lg+58iEmhsRDCrvhR Tt9lF72Z8jvFxkmWzCwI5vgkqA5aWoyr82uA1zrqx79FhsOEXnN+IY4IeaCz78JryQCJ xqXTjcbONL6DG1ezfuLv5j2zozWkFCorMNQCRYsEzX/h2oUX5zgWRQbcIh7VXc134nTK 8YRfWVqrK/abwktaKXX/TnhexCAnintfH7boZq/VKcfyyC7EJoCiokt3EOncYXUHme6g dQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com with ESMTP id 3ew7qtefcd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Mar 2022 04:35:05 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 22P4WDEU020751; Fri, 25 Mar 2022 04:35:03 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3ew6sc2brd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Mar 2022 04:35:03 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 22P4YsCk040479; Fri, 25 Mar 2022 04:35:03 GMT Received: from ca-common-hq.us.oracle.com (ca-common-hq.us.oracle.com [10.211.9.209]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3ew6sc2bmt-10; Fri, 25 Mar 2022 04:35:03 +0000 From: Dai Ngo To: chuck.lever@oracle.com, bfields@fieldses.org Cc: jlayton@redhat.com, viro@zeniv.linux.org.uk, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH RFC v18 09/11] NFSD: Refactor nfsd4_laundromat() Date: Thu, 24 Mar 2022 21:34:49 -0700 Message-Id: <1648182891-32599-10-git-send-email-dai.ngo@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1648182891-32599-1-git-send-email-dai.ngo@oracle.com> References: <1648182891-32599-1-git-send-email-dai.ngo@oracle.com> X-Proofpoint-GUID: B86KR6t0JOajB4QMr-ELVoR0DNM5QZ7I X-Proofpoint-ORIG-GUID: B86KR6t0JOajB4QMr-ELVoR0DNM5QZ7I Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Extract a bit of logic that is about to be expanded to handle courtesy clients. Signed-off-by: Dai Ngo --- fs/nfsd/nfs4state.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index fe34d6780713..4c3f14afb69a 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -5731,6 +5731,26 @@ static void nfsd4_ssc_expire_umount(struct nfsd_net *nn) } #endif +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; + + 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 (!state_expired(lt, clp->cl_time)) + break; + if (mark_client_expired_locked(clp)) + continue; + list_add(&clp->cl_lru, reaplist); + } + spin_unlock(&nn->client_lock); +} + static time64_t nfs4_laundromat(struct nfsd_net *nn) { @@ -5753,7 +5773,6 @@ nfs4_laundromat(struct nfsd_net *nn) goto out; } nfsd4_end_grace(nn); - INIT_LIST_HEAD(&reaplist); spin_lock(&nn->s2s_cp_lock); idr_for_each_entry(&nn->s2s_cp_stateids, cps_t, i) { @@ -5763,17 +5782,7 @@ nfs4_laundromat(struct nfsd_net *nn) _free_cpntf_state_locked(nn, cps); } spin_unlock(&nn->s2s_cp_lock); - - spin_lock(&nn->client_lock); - list_for_each_safe(pos, next, &nn->client_lru) { - clp = list_entry(pos, struct nfs4_client, cl_lru); - if (!state_expired(<, clp->cl_time)) - break; - if (mark_client_expired_locked(clp)) - continue; - list_add(&clp->cl_lru, &reaplist); - } - spin_unlock(&nn->client_lock); + nfs4_get_client_reaplist(nn, &reaplist, <); list_for_each_safe(pos, next, &reaplist) { clp = list_entry(pos, struct nfs4_client, cl_lru); trace_nfsd_clid_purged(&clp->cl_clientid);