Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp649839ybf; Fri, 28 Feb 2020 05:10:19 -0800 (PST) X-Google-Smtp-Source: APXvYqy14/jAUXIlpE5WlBGSpK5T55D2ArEKxMzqa3Wyti7qbf9LebU+S3I0EhZLnubwovUsCv2+ X-Received: by 2002:aca:5844:: with SMTP id m65mr3079491oib.136.1582895419028; Fri, 28 Feb 2020 05:10:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582895419; cv=none; d=google.com; s=arc-20160816; b=TIEsKrs1P2iZfC8/mqD1hALAtc7k7T3UVg4d5v2XamxM+3eRt9pohOvJWUeyETcyuw mYmsqmw81fR8Zd9gKCTpbtn8yNGYHjIdCAvdLqeRH5sOE68mCEkEE0Bg3tT/xXAqimPl 98Ugmvi0FMZKYCXCuseKg5/hj/dGQyhUZErXfYWj0SK1Jf4kBlcGj2tFGxVFYf4+Zx25 7kbW9uaFRSuaCL6tUdjdgnBk0JeIZIvjzpT8MvIX7ZF/f1F8I+V/QfXxoixe/MkKLevC kr3Ynlir4R0mMYM0RzVLGKubWuxvcXrnvoU+kAQ715ZSzLi5yHODiTCwfXm2EM9xmNcr /pAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=mQDvmIQpdISPBTLKH7Zwt20QFU0Xr0bFsaEwty4sRlU=; b=LppaLL41KwqU0szXw+JDaLEPDyYMF+Tu/0nJpV+RVuT/vf1r9UH9Eih/JscDcAh3d7 tJIUOOUG0lUNxGH3XC36uaRp3s07brxditzyRF0YSWF7RenMpVDD0L/GDBHPBmLOcUMo dZdplqFeZA9zb82N1LJR50dn6P3fPOTOG8VVcNln+y42cTaDIEv8R2qLO3Pwm6rzJUgO 0Zj3zAwxUmt1GEhvLer/FH2EdmxmMnbpRtMJrg5x5jtpDhwBUgyXxoDrkD1ZonYD7abY GW+zbzkOzHiI5bUY4eLt51tkAuMiEGbu7sDTZRQ/tqUG1FWSGDkGWe/ePPyYa9Fe1/Ag xPHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FhsxDHbq; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9si1955333ois.90.2020.02.28.05.10.05; Fri, 28 Feb 2020 05:10:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FhsxDHbq; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725805AbgB1NJj (ORCPT + 99 others); Fri, 28 Feb 2020 08:09:39 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:35867 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725906AbgB1NJj (ORCPT ); Fri, 28 Feb 2020 08:09:39 -0500 Received: by mail-yw1-f68.google.com with SMTP id y72so3221063ywg.3 for ; Fri, 28 Feb 2020 05:09:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=mQDvmIQpdISPBTLKH7Zwt20QFU0Xr0bFsaEwty4sRlU=; b=FhsxDHbqA5CkSuHr1h3OgwK/xCZ2pp7KZDONzT5CT+0T1gulhWPBSgnn4rfCFhja0p mFlD92lbE88bwqhMUdkigK0EALEsuGLBVYjYCTvNECIMLuvyLkoT1QHetVgkSKXN3EzE sToCm2sx/41WRr6PTPh+Qq/waiETgSlHe+jIcWkGOsjeSiHFy9WKQtpXcJ815SLomE4J xiZqsYA7UDu1z/vUPyz3xZCy/QL6bOmLTKOZ4ZNZ1oVwqukYYqXAqEbmcXMJZdxGyFPZ QTdVtSs8oFlzrSC3hJuEGauBc7ffhAVNHw6zSDct4QFG7lvLjSp2Xmra6SnwG9g24ME+ H8YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mQDvmIQpdISPBTLKH7Zwt20QFU0Xr0bFsaEwty4sRlU=; b=dtNCks40DaHhwuaP+V/un1VEajEES01/NS7vi1GEXCM3C8vrs/DdeA6VYDzaLS9NFL 7aPSqHIWbgVXlVJxovSQxBSPEUmU+6DnPo3OW9VOw7j0CMk6FoWgzgnEyGtLB25riEhu DX3RjoqELHGejtWZLxNhHOLvZrv+g9TaSWJuE27m6GndiZKHyz/RNRpMJO28O2wWhtrQ UQOgU4e599H0wSsOajZdZ7I0ubuTvepDtC9yzKmZn03IDZFFrlHvB1aTAoHx9TOGmHNl YGdS+v86RQ8y92qbwBnqwVKtM6ics73cyZqQDJVt0tEsYiYzClOoYmdWopkguTuLxqdg HeQg== X-Gm-Message-State: APjAAAUFosc8u0JxOPOttxq0/l2/1DOrOZv0uQyTBLJ978hf7TQpVfqL y2P7eFUlVl/mkxArcHAwoG6bt18hCg== X-Received: by 2002:a25:6ac1:: with SMTP id f184mr3408679ybc.469.1582895378330; Fri, 28 Feb 2020 05:09:38 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id j23sm3925150ywb.93.2020.02.28.05.09.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 05:09:37 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 5/7] NFSv4: Clean up nfs_delegation_reap_unclaimed() Date: Fri, 28 Feb 2020 08:07:23 -0500 Message-Id: <20200228130725.1330705-5-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200228130725.1330705-4-trond.myklebust@hammerspace.com> References: <20200228130725.1330705-1-trond.myklebust@hammerspace.com> <20200228130725.1330705-2-trond.myklebust@hammerspace.com> <20200228130725.1330705-3-trond.myklebust@hammerspace.com> <20200228130725.1330705-4-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Convert nfs_delegation_reap_unclaimed() to use nfs_client_for_each_server() for efficiency. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 76 ++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 19f66d3e58e8..cb03ba99ae51 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -1092,53 +1092,51 @@ void nfs_delegation_mark_reclaim(struct nfs_client *clp) rcu_read_unlock(); } -/** - * nfs_delegation_reap_unclaimed - reap unclaimed delegations after reboot recovery is done - * @clp: nfs_client to process - * - */ -void nfs_delegation_reap_unclaimed(struct nfs_client *clp) +static int nfs_server_reap_unclaimed_delegations(struct nfs_server *server, + void __always_unused *data) { struct nfs_delegation *delegation; - struct nfs_server *server; struct inode *inode; - restart: rcu_read_lock(); - list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) { - list_for_each_entry_rcu(delegation, &server->delegations, - super_list) { - if (test_bit(NFS_DELEGATION_INODE_FREEING, - &delegation->flags) || - test_bit(NFS_DELEGATION_RETURNING, - &delegation->flags) || - test_bit(NFS_DELEGATION_NEED_RECLAIM, - &delegation->flags) == 0) - continue; - if (!nfs_sb_active(server->super)) - break; /* continue in outer loop */ - inode = nfs_delegation_grab_inode(delegation); - if (inode == NULL) { - rcu_read_unlock(); - nfs_sb_deactive(server->super); - goto restart; - } - delegation = nfs_start_delegation_return_locked(NFS_I(inode)); - rcu_read_unlock(); - if (delegation != NULL) { - if (nfs_detach_delegation(NFS_I(inode), delegation, - server) != NULL) - nfs_free_delegation(delegation); - /* Match nfs_start_delegation_return_locked */ - nfs_put_delegation(delegation); - } - iput(inode); - nfs_sb_deactive(server->super); - cond_resched(); - goto restart; +restart_locked: + list_for_each_entry_rcu(delegation, &server->delegations, super_list) { + if (test_bit(NFS_DELEGATION_INODE_FREEING, + &delegation->flags) || + test_bit(NFS_DELEGATION_RETURNING, + &delegation->flags) || + test_bit(NFS_DELEGATION_NEED_RECLAIM, + &delegation->flags) == 0) + continue; + inode = nfs_delegation_grab_inode(delegation); + if (inode == NULL) + goto restart_locked; + delegation = nfs_start_delegation_return_locked(NFS_I(inode)); + rcu_read_unlock(); + if (delegation != NULL) { + if (nfs_detach_delegation(NFS_I(inode), delegation, + server) != NULL) + nfs_free_delegation(delegation); + /* Match nfs_start_delegation_return_locked */ + nfs_put_delegation(delegation); } + iput(inode); + cond_resched(); + goto restart; } rcu_read_unlock(); + return 0; +} + +/** + * nfs_delegation_reap_unclaimed - reap unclaimed delegations after reboot recovery is done + * @clp: nfs_client to process + * + */ +void nfs_delegation_reap_unclaimed(struct nfs_client *clp) +{ + nfs_client_for_each_server(clp, nfs_server_reap_unclaimed_delegations, + NULL); } static inline bool nfs4_server_rebooted(const struct nfs_client *clp) -- 2.24.1