diff options
author | Bryan Schumaker <bjschuma@netapp.com> | 2012-11-29 11:40:39 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-12-03 09:58:55 -0500 |
commit | 44e34da60b24ca14666534b61cc9579aa4e1eac5 (patch) | |
tree | 98f0bf7d8eb060df59dcb72b5813d5b2f915afc1 /fs/nfsd/nfs4state.c | |
parent | 043958395a6b91863046b0cd7cae9c67fa845144 (diff) |
NFSD: Clean up forgetting clients
I added in a generic for-each loop that takes a pass over the client_lru
list for the current net namespace and calls some function. The next few
patches will update other operations to use this function as well. A value
of 0 still means "forget everything that is found".
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r-- | fs/nfsd/nfs4state.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 8e19c692649c..2478c8996bda 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -4605,19 +4605,34 @@ nfs4_check_open_reclaim(clientid_t *clid, bool sessions, struct nfsd_net *nn) | |||
4605 | 4605 | ||
4606 | #ifdef CONFIG_NFSD_FAULT_INJECTION | 4606 | #ifdef CONFIG_NFSD_FAULT_INJECTION |
4607 | 4607 | ||
4608 | void nfsd_forget_clients(u64 num) | 4608 | u64 nfsd_forget_client(struct nfs4_client *clp, u64 max) |
4609 | { | ||
4610 | expire_client(clp); | ||
4611 | return 1; | ||
4612 | } | ||
4613 | |||
4614 | u64 nfsd_for_n_state(u64 max, u64 (*func)(struct nfs4_client *, u64)) | ||
4609 | { | 4615 | { |
4610 | struct nfs4_client *clp, *next; | 4616 | struct nfs4_client *clp, *next; |
4611 | int count = 0; | 4617 | u64 count = 0; |
4612 | struct nfsd_net *nn = net_generic(current->nsproxy->net_ns, nfsd_net_id); | 4618 | struct nfsd_net *nn = net_generic(current->nsproxy->net_ns, nfsd_net_id); |
4613 | 4619 | ||
4620 | if (!nfsd_netns_ready(nn)) | ||
4621 | return 0; | ||
4622 | |||
4614 | list_for_each_entry_safe(clp, next, &nn->client_lru, cl_lru) { | 4623 | list_for_each_entry_safe(clp, next, &nn->client_lru, cl_lru) { |
4615 | expire_client(clp); | 4624 | count += func(clp, max - count); |
4616 | if (++count == num) | 4625 | if ((max != 0) && (count >= max)) |
4617 | break; | 4626 | break; |
4618 | } | 4627 | } |
4619 | 4628 | ||
4620 | printk(KERN_INFO "NFSD: Forgot %d clients", count); | 4629 | return count; |
4630 | } | ||
4631 | |||
4632 | void nfsd_forget_clients(u64 num) | ||
4633 | { | ||
4634 | u64 count = nfsd_for_n_state(num, nfsd_forget_client); | ||
4635 | printk(KERN_INFO "NFSD: Forgot %llu clients", count); | ||
4621 | } | 4636 | } |
4622 | 4637 | ||
4623 | static void release_lockowner_sop(struct nfs4_stateowner *sop) | 4638 | static void release_lockowner_sop(struct nfs4_stateowner *sop) |