Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp649500ybf; Fri, 28 Feb 2020 05:09:59 -0800 (PST) X-Google-Smtp-Source: APXvYqyzUeZMZFxm+yfnlyHHMqxxj6xcOsAyvvEul1GNwh+NHREu1GRdeO8GbCdKKq69prbheFco X-Received: by 2002:a9d:4541:: with SMTP id p1mr3264374oti.199.1582895398942; Fri, 28 Feb 2020 05:09:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582895398; cv=none; d=google.com; s=arc-20160816; b=kqJVsc+8OFAoMYQWvKTQ4LTLxHgFvL+1yuVYZx3tVPnjF0jjEk2wGuQYt2PKgc4VCm 3HMbOYUxpkdBDdLMS24xGedPoivcP3HQYoFVuTd3t2Lj7DakzHfqaabkA9uMD+mXA8r3 TbpyZyCxMp3lL+tQqXVHe50XUk2cvs0PmJq2CXbTTqea1Ztq9r2h/KERipOIP6/MfysJ s7WL/T8/WLAqNQMXXL4SSorzemFFw1T87QXzYQnRbdFm8EqPFZ5NhsEOcbOpBXwJ5HD0 NFzW/ikCnyVjl8+WX29E56kxJ9u+Rbt353QLZJeNFs2ByfePIIRIbCplrZPD2BR+hrWn jifg== 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=cqZyln7uV8TFcW9bdiJi2KV/o+kRCqQ/8cTYkZ0Z8tU=; b=z5Pw0yKdWzC3ha0ocjbxHCfjFuetjBqKg1mANzTLWPOOp6nfDoEGCmKqfvortDOG2+ HCdON5NrqKsajpifORd0GW16S37mCSSGbCg7RNxNqlKc01NoYGhDN4Tz51hR7VwqJbK2 GmZ1mNc2IxMYzsKz+0/IFBqdY2xcqncEfU37oJHJo+4J0xDDgvcgDPa3wYGTKwuIUJQA OOrCGlKNxkRL4E8cchQmTyoeE4AV9HLT6KiiTV59WxB8PWOHELTshZh9jfCCIMSMwNGq wdJv7E/KRZV0etb0fVXQx5yNRcCMV7SYqbLmRv4TQwZGDJhgP8whlvKAXOA4J1ivGfSQ ED5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="tt+/yDMf"; 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 n2si1503636otq.315.2020.02.28.05.09.43; Fri, 28 Feb 2020 05:09:58 -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="tt+/yDMf"; 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 S1725906AbgB1NJl (ORCPT + 99 others); Fri, 28 Feb 2020 08:09:41 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:33481 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbgB1NJl (ORCPT ); Fri, 28 Feb 2020 08:09:41 -0500 Received: by mail-yw1-f67.google.com with SMTP id j186so3243436ywe.0 for ; Fri, 28 Feb 2020 05:09:40 -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=cqZyln7uV8TFcW9bdiJi2KV/o+kRCqQ/8cTYkZ0Z8tU=; b=tt+/yDMfHaR7GjaB9VV58+ni6ImtTpzDYd4cSKKJXgGJ6e3r9M2jUVfVx3Ug4F05UH /rltE5Ejuy4l0t+1NOT0cRQg5ysZavgxuMGEaeaBtqdS2AuRKPe/atQ5y60f/SPL31Uq SX+XJ5+UejqcbSOblQakNAGZyVWcjrU7AaYT/AhKJD03HyhZ4MIevu7H/MpfUdlSZPEK J7PjyNs4SucZZLH2SIYD23qqHXhltEqyIcNmB7VNo3R+QFc500MTv12HbXcwt7UTO7Co xW7a5zduC04EnSUxuXSHInr9sE1H5ruL/eSnqZFh8iUki7vxMeIajip3fJFJDzIUEKTl YjYw== 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=cqZyln7uV8TFcW9bdiJi2KV/o+kRCqQ/8cTYkZ0Z8tU=; b=swOJ+9gZe/c5a/FwHaPFFsUCd/6UZGdF9LtEn89N39MkZ5KbFfI/umf69mk4CBPH+I o8Bcx87I8LdYY/J9t69khF0fYG4SAD3SM04UYIEswzhfqWqTYnYhIQ7B7iYJLJQ4SgUO 91YHDUyJE74+jjj6ezf6uOFjuEvGIIlzspOe28dILi2uT2u99qPja839fy+oQS8/grr0 9GYO9l5JjHMT8KWaf43UqCaUWFduQJOjJ1apC3URYNDDIazziSbyWZ3Oi2KS5CpuxJtJ sa1WubVIRfqJqm30CSZTLaledHLY72JflART6Jxy/5rxtiGPlcEWmBOM0cKMqrQTwLWF 18CA== X-Gm-Message-State: APjAAAXoTNjQ2UxWPViK+PaQuwTqYQll90u33ZRP/LX+oUYvq+DzGdXz 49x9ZvHVWdGFBLZgVh7hdac664JmSw== X-Received: by 2002:a25:d20f:: with SMTP id j15mr3678135ybg.74.1582895379332; Fri, 28 Feb 2020 05:09:39 -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.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 05:09:38 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 6/7] NFSv4: Clean up nfs_delegation_reap_expired() Date: Fri, 28 Feb 2020 08:07:24 -0500 Message-Id: <20200228130725.1330705-6-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200228130725.1330705-5-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> <20200228130725.1330705-5-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 to use nfs_client_for_each_server() for efficiency. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 83 ++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index cb03ba99ae51..01974f17afc9 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -1222,62 +1222,59 @@ nfs_delegation_test_free_expired(struct inode *inode, nfs_remove_bad_delegation(inode, stateid); } -/** - * nfs_reap_expired_delegations - reap expired delegations - * @clp: nfs_client to process - * - * Iterates through all the delegations associated with this server and - * checks if they have may have been revoked. This function is usually - * expected to be called in cases where the server may have lost its - * lease. - */ -void nfs_reap_expired_delegations(struct nfs_client *clp) +static int nfs_server_reap_expired_delegations(struct nfs_server *server, + void __always_unused *data) { struct nfs_delegation *delegation; - struct nfs_server *server; struct inode *inode; const struct cred *cred; nfs4_stateid stateid; - 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_TEST_EXPIRED, - &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; - } - cred = get_cred_rcu(delegation->cred); - nfs4_stateid_copy(&stateid, &delegation->stateid); - clear_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags); - rcu_read_unlock(); - nfs_delegation_test_free_expired(inode, &stateid, cred); - put_cred(cred); - if (nfs4_server_rebooted(clp)) { - nfs_inode_mark_test_expired_delegation(server,inode); - iput(inode); - nfs_sb_deactive(server->super); - return; - } +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_TEST_EXPIRED, + &delegation->flags) == 0) + continue; + inode = nfs_delegation_grab_inode(delegation); + if (inode == NULL) + goto restart_locked; + cred = get_cred_rcu(delegation->cred); + nfs4_stateid_copy(&stateid, &delegation->stateid); + clear_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags); + rcu_read_unlock(); + nfs_delegation_test_free_expired(inode, &stateid, cred); + put_cred(cred); + if (!nfs4_server_rebooted(server->nfs_client)) { iput(inode); - nfs_sb_deactive(server->super); cond_resched(); goto restart; } + nfs_inode_mark_test_expired_delegation(server,inode); + iput(inode); + return -EAGAIN; } rcu_read_unlock(); + return 0; +} + +/** + * nfs_reap_expired_delegations - reap expired delegations + * @clp: nfs_client to process + * + * Iterates through all the delegations associated with this server and + * checks if they have may have been revoked. This function is usually + * expected to be called in cases where the server may have lost its + * lease. + */ +void nfs_reap_expired_delegations(struct nfs_client *clp) +{ + nfs_client_for_each_server(clp, nfs_server_reap_expired_delegations, + NULL); } void nfs_inode_find_delegation_state_and_recover(struct inode *inode, -- 2.24.1