aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Schumaker <bjschuma@netapp.com>2012-11-29 11:40:38 -0500
committerJ. Bruce Fields <bfields@redhat.com>2012-12-03 09:58:54 -0500
commit043958395a6b91863046b0cd7cae9c67fa845144 (patch)
tree192d24b14d09394b92ffb7298b2df60695097126
parente5f9570319771bb0a5afc792b34fbd5564b935c8 (diff)
NFSD: Lock state before calling fault injection function
Each function touches state in some way, so getting the lock earlier can help simplify code. Signed-off-by: Bryan Schumaker <bjschuma@netapp.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r--fs/nfsd/fault_inject.c2
-rw-r--r--fs/nfsd/nfs4state.c18
2 files changed, 4 insertions, 16 deletions
diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c
index 02781121c6b0..4b385a14cf96 100644
--- a/fs/nfsd/fault_inject.c
+++ b/fs/nfsd/fault_inject.c
@@ -51,7 +51,9 @@ static int nfsd_inject_set(void *op_ptr, u64 val)
51 else 51 else
52 printk(KERN_INFO "NFSD Fault Injection: %s (n = %llu)", op->file, val); 52 printk(KERN_INFO "NFSD Fault Injection: %s (n = %llu)", op->file, val);
53 53
54 nfs4_lock_state();
54 op->func(val); 55 op->func(val);
56 nfs4_unlock_state();
55 return 0; 57 return 0;
56} 58}
57 59
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index b1aa577dd869..8e19c692649c 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -4611,13 +4611,11 @@ void nfsd_forget_clients(u64 num)
4611 int count = 0; 4611 int count = 0;
4612 struct nfsd_net *nn = net_generic(current->nsproxy->net_ns, nfsd_net_id); 4612 struct nfsd_net *nn = net_generic(current->nsproxy->net_ns, nfsd_net_id);
4613 4613
4614 nfs4_lock_state();
4615 list_for_each_entry_safe(clp, next, &nn->client_lru, cl_lru) { 4614 list_for_each_entry_safe(clp, next, &nn->client_lru, cl_lru) {
4616 expire_client(clp); 4615 expire_client(clp);
4617 if (++count == num) 4616 if (++count == num)
4618 break; 4617 break;
4619 } 4618 }
4620 nfs4_unlock_state();
4621 4619
4622 printk(KERN_INFO "NFSD: Forgot %d clients", count); 4620 printk(KERN_INFO "NFSD: Forgot %d clients", count);
4623} 4621}
@@ -4653,25 +4651,15 @@ static int nfsd_release_n_owners(u64 num, bool is_open_owner,
4653 4651
4654void nfsd_forget_locks(u64 num) 4652void nfsd_forget_locks(u64 num)
4655{ 4653{
4656 int count;
4657 struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id); 4654 struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id);
4658 4655 int count = nfsd_release_n_owners(num, false, release_lockowner_sop, nn);
4659 nfs4_lock_state();
4660 count = nfsd_release_n_owners(num, false, release_lockowner_sop, nn);
4661 nfs4_unlock_state();
4662
4663 printk(KERN_INFO "NFSD: Forgot %d locks", count); 4656 printk(KERN_INFO "NFSD: Forgot %d locks", count);
4664} 4657}
4665 4658
4666void nfsd_forget_openowners(u64 num) 4659void nfsd_forget_openowners(u64 num)
4667{ 4660{
4668 int count;
4669 struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id); 4661 struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id);
4670 4662 int count = nfsd_release_n_owners(num, true, release_openowner_sop, nn);
4671 nfs4_lock_state();
4672 count = nfsd_release_n_owners(num, true, release_openowner_sop, nn);
4673 nfs4_unlock_state();
4674
4675 printk(KERN_INFO "NFSD: Forgot %d open owners", count); 4663 printk(KERN_INFO "NFSD: Forgot %d open owners", count);
4676} 4664}
4677 4665
@@ -4704,10 +4692,8 @@ void nfsd_forget_delegations(u64 num)
4704 count = nfsd_process_n_delegations(num, &victims); 4692 count = nfsd_process_n_delegations(num, &victims);
4705 spin_unlock(&recall_lock); 4693 spin_unlock(&recall_lock);
4706 4694
4707 nfs4_lock_state();
4708 list_for_each_entry_safe(dp, dnext, &victims, dl_recall_lru) 4695 list_for_each_entry_safe(dp, dnext, &victims, dl_recall_lru)
4709 unhash_delegation(dp); 4696 unhash_delegation(dp);
4710 nfs4_unlock_state();
4711 4697
4712 printk(KERN_INFO "NFSD: Forgot %d delegations", count); 4698 printk(KERN_INFO "NFSD: Forgot %d delegations", count);
4713} 4699}