aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4state.c
diff options
context:
space:
mode:
authorBryan Schumaker <bjschuma@netapp.com>2012-11-29 11:40:41 -0500
committerJ. Bruce Fields <bfields@redhat.com>2012-12-03 09:58:58 -0500
commit4dbdbda84f963312e0b5dfdf2dfbf64de047dd44 (patch)
tree8c6ade8cfe1b2fc07372ce6dae8c4779150f8af0 /fs/nfsd/nfs4state.c
parentfc29171f5b3257694bf508cf4ae51970c97af78c (diff)
NFSD: Clean up forgetting openowners
Using "forget_n_state()" forces me to implement the code needed to forget a specific client's openowners. 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.c49
1 files changed, 22 insertions, 27 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 46bece40b1ce..00d4398e2324 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -4637,6 +4637,26 @@ u64 nfsd_forget_client_locks(struct nfs4_client *clp, u64 max)
4637 return nfsd_foreach_client_lock(clp, max, release_lockowner); 4637 return nfsd_foreach_client_lock(clp, max, release_lockowner);
4638} 4638}
4639 4639
4640static u64 nfsd_foreach_client_open(struct nfs4_client *clp, u64 max, void (*func)(struct nfs4_openowner *))
4641{
4642 struct nfs4_openowner *oop, *next;
4643 u64 count = 0;
4644
4645 list_for_each_entry_safe(oop, next, &clp->cl_openowners, oo_perclient) {
4646 if (func)
4647 func(oop);
4648 if (++count == max)
4649 break;
4650 }
4651
4652 return count;
4653}
4654
4655u64 nfsd_forget_client_openowners(struct nfs4_client *clp, u64 max)
4656{
4657 return nfsd_foreach_client_open(clp, max, release_openowner);
4658}
4659
4640u64 nfsd_for_n_state(u64 max, u64 (*func)(struct nfs4_client *, u64)) 4660u64 nfsd_for_n_state(u64 max, u64 (*func)(struct nfs4_client *, u64))
4641{ 4661{
4642 struct nfs4_client *clp, *next; 4662 struct nfs4_client *clp, *next;
@@ -4661,30 +4681,6 @@ void nfsd_forget_clients(u64 num)
4661 printk(KERN_INFO "NFSD: Forgot %llu clients", count); 4681 printk(KERN_INFO "NFSD: Forgot %llu clients", count);
4662} 4682}
4663 4683
4664static void release_openowner_sop(struct nfs4_stateowner *sop)
4665{
4666 release_openowner(openowner(sop));
4667}
4668
4669static int nfsd_release_n_owners(u64 num, bool is_open_owner,
4670 void (*release_sop)(struct nfs4_stateowner *),
4671 struct nfsd_net *nn)
4672{
4673 int i, count = 0;
4674 struct nfs4_stateowner *sop, *next;
4675
4676 for (i = 0; i < OWNER_HASH_SIZE; i++) {
4677 list_for_each_entry_safe(sop, next, &nn->ownerstr_hashtbl[i], so_strhash) {
4678 if (sop->so_is_open_owner != is_open_owner)
4679 continue;
4680 release_sop(sop);
4681 if (++count == num)
4682 return count;
4683 }
4684 }
4685 return count;
4686}
4687
4688void nfsd_forget_locks(u64 num) 4684void nfsd_forget_locks(u64 num)
4689{ 4685{
4690 u64 count = nfsd_for_n_state(num, nfsd_forget_client_locks); 4686 u64 count = nfsd_for_n_state(num, nfsd_forget_client_locks);
@@ -4693,9 +4689,8 @@ void nfsd_forget_locks(u64 num)
4693 4689
4694void nfsd_forget_openowners(u64 num) 4690void nfsd_forget_openowners(u64 num)
4695{ 4691{
4696 struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id); 4692 u64 count = nfsd_for_n_state(num, nfsd_forget_client_openowners);
4697 int count = nfsd_release_n_owners(num, true, release_openowner_sop, nn); 4693 printk(KERN_INFO "NFSD: Forgot %llu open owners", count);
4698 printk(KERN_INFO "NFSD: Forgot %d open owners", count);
4699} 4694}
4700 4695
4701static int nfsd_process_n_delegations(u64 num, struct list_head *list) 4696static int nfsd_process_n_delegations(u64 num, struct list_head *list)