From patchwork Wed Feb 23 18:16:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dai Ngo X-Patchwork-Id: 12757284 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 5359FC4321E for ; Wed, 23 Feb 2022 18:19:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243680AbiBWSRS (ORCPT ); Wed, 23 Feb 2022 13:17:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243730AbiBWSRP (ORCPT ); Wed, 23 Feb 2022 13:17:15 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F3573F8A2 for ; Wed, 23 Feb 2022 10:16:47 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21NIDn3I020614; Wed, 23 Feb 2022 18:16:46 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=ZjYcVpKCyxjIzJLdor0eBbh4428ealhnxBPt5hhRrnI=; b=QvqcXvYUHkWzgwnAh5xD73nSj5H1JdTLbgeFIWakUMKFIAidktFygrpUVdn5TTO3hqRB Fr/A59RQqcEluX7JfZO+BlSnS7G3Fp7BA6WQlySp2WIHhznrZ/FlVn/4MIlVori8BQDx ndWjC/jAlQ6NvVlMfTc1c1ihZx0q/blrrm3xdpu5W0wSHHqs/kBhcQ77qVPHCLkBifS+ fs3nVyQGNwyCoAdxKHAfPYZBCoGn3uPZwsDsOcmgySfPsbAxa+2OQHylomF5o6Lbx7b8 C90vYnWOFOr/uvEUaOm2hWto3LDhbbAoE72puockwoPqL2qqjcEc5j6rflYyRe+kvE/P ow== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3ecvar4r37-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Feb 2022 18:16:45 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21NIAtua155968; Wed, 23 Feb 2022 18:16:45 GMT Received: from pps.reinject (localhost [127.0.0.1]) by aserp3030.oracle.com with ESMTP id 3eapkj17sp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Feb 2022 18:16:45 +0000 Received: from aserp3030.oracle.com (aserp3030.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 21NICxfg162308; Wed, 23 Feb 2022 18:16:44 GMT Received: from ca-common-hq.us.oracle.com (ca-common-hq.us.oracle.com [10.211.9.209]) by aserp3030.oracle.com with ESMTP id 3eapkj17pe-9; Wed, 23 Feb 2022 18:16:44 +0000 From: Dai Ngo To: chuck.lever@oracle.com, bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH RFC v14 08/10] NFSD: Refactor nfsd4_laundromat() Date: Wed, 23 Feb 2022 10:16:35 -0800 Message-Id: <1645640197-1725-9-git-send-email-dai.ngo@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1645640197-1725-1-git-send-email-dai.ngo@oracle.com> References: <1645640197-1725-1-git-send-email-dai.ngo@oracle.com> X-Proofpoint-GUID: SXNI-D31ftWszAyRT2eTPTo75Srs7eVj X-Proofpoint-ORIG-GUID: SXNI-D31ftWszAyRT2eTPTo75Srs7eVj Precedence: bulk List-ID: X-Mailing-List: linux-nfs@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 6e3ca0ea4f28..01c51adf4873 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -5821,6 +5821,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) { @@ -5843,7 +5863,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) { @@ -5853,17 +5872,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);