diff options
author | Bryan Schumaker <bjschuma@netapp.com> | 2012-11-29 11:40:43 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-12-03 09:59:00 -0500 |
commit | 8ce54e0d82730ece61737c9fd7b61b28ab8c3390 (patch) | |
tree | 7a3cc8c0fea766d99cb93539ed3953b232767fc4 /fs/nfsd | |
parent | 269de30f10604710dde8d544748b5b6c748b7de8 (diff) |
NFSD: Fault injection operations take a per-client forget function
The eventual goal is to forget state based on ip address, so it makes
sense to call this function in a for-each-client loop until the correct
amount of state is forgotten. I also use this patch as an opportunity
to rename the forget function from "func()" to "forget()".
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/fault_inject.c | 16 | ||||
-rw-r--r-- | fs/nfsd/nfs4state.c | 30 | ||||
-rw-r--r-- | fs/nfsd/state.h | 12 |
3 files changed, 16 insertions, 42 deletions
diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c index 4b385a14cf96..bf6161adf663 100644 --- a/fs/nfsd/fault_inject.c +++ b/fs/nfsd/fault_inject.c | |||
@@ -13,29 +13,29 @@ | |||
13 | 13 | ||
14 | struct nfsd_fault_inject_op { | 14 | struct nfsd_fault_inject_op { |
15 | char *file; | 15 | char *file; |
16 | void (*func)(u64); | 16 | u64 (*forget)(struct nfs4_client *, u64); |
17 | }; | 17 | }; |
18 | 18 | ||
19 | static struct nfsd_fault_inject_op inject_ops[] = { | 19 | static struct nfsd_fault_inject_op inject_ops[] = { |
20 | { | 20 | { |
21 | .file = "forget_clients", | 21 | .file = "forget_clients", |
22 | .func = nfsd_forget_clients, | 22 | .forget = nfsd_forget_client, |
23 | }, | 23 | }, |
24 | { | 24 | { |
25 | .file = "forget_locks", | 25 | .file = "forget_locks", |
26 | .func = nfsd_forget_locks, | 26 | .forget = nfsd_forget_client_locks, |
27 | }, | 27 | }, |
28 | { | 28 | { |
29 | .file = "forget_openowners", | 29 | .file = "forget_openowners", |
30 | .func = nfsd_forget_openowners, | 30 | .forget = nfsd_forget_client_openowners, |
31 | }, | 31 | }, |
32 | { | 32 | { |
33 | .file = "forget_delegations", | 33 | .file = "forget_delegations", |
34 | .func = nfsd_forget_delegations, | 34 | .forget = nfsd_forget_client_delegations, |
35 | }, | 35 | }, |
36 | { | 36 | { |
37 | .file = "recall_delegations", | 37 | .file = "recall_delegations", |
38 | .func = nfsd_recall_delegations, | 38 | .forget = nfsd_recall_client_delegations, |
39 | }, | 39 | }, |
40 | }; | 40 | }; |
41 | 41 | ||
@@ -44,6 +44,7 @@ static struct dentry *debug_dir; | |||
44 | 44 | ||
45 | static int nfsd_inject_set(void *op_ptr, u64 val) | 45 | static int nfsd_inject_set(void *op_ptr, u64 val) |
46 | { | 46 | { |
47 | u64 count = 0; | ||
47 | struct nfsd_fault_inject_op *op = op_ptr; | 48 | struct nfsd_fault_inject_op *op = op_ptr; |
48 | 49 | ||
49 | if (val == 0) | 50 | if (val == 0) |
@@ -52,8 +53,9 @@ static int nfsd_inject_set(void *op_ptr, u64 val) | |||
52 | printk(KERN_INFO "NFSD Fault Injection: %s (n = %llu)", op->file, val); | 53 | printk(KERN_INFO "NFSD Fault Injection: %s (n = %llu)", op->file, val); |
53 | 54 | ||
54 | nfs4_lock_state(); | 55 | nfs4_lock_state(); |
55 | op->func(val); | 56 | count = nfsd_for_n_state(val, op->forget); |
56 | nfs4_unlock_state(); | 57 | nfs4_unlock_state(); |
58 | printk(KERN_INFO "NFSD: %s: found %llu", op->file, count); | ||
57 | return 0; | 59 | return 0; |
58 | } | 60 | } |
59 | 61 | ||
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index dc7c22f14fef..ab45cdd7b3da 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -4721,36 +4721,6 @@ u64 nfsd_for_n_state(u64 max, u64 (*func)(struct nfs4_client *, u64)) | |||
4721 | return count; | 4721 | return count; |
4722 | } | 4722 | } |
4723 | 4723 | ||
4724 | void nfsd_forget_clients(u64 num) | ||
4725 | { | ||
4726 | u64 count = nfsd_for_n_state(num, nfsd_forget_client); | ||
4727 | printk(KERN_INFO "NFSD: Forgot %llu clients", count); | ||
4728 | } | ||
4729 | |||
4730 | void nfsd_forget_locks(u64 num) | ||
4731 | { | ||
4732 | u64 count = nfsd_for_n_state(num, nfsd_forget_client_locks); | ||
4733 | printk(KERN_INFO "NFSD: Forgot %llu locks", count); | ||
4734 | } | ||
4735 | |||
4736 | void nfsd_forget_openowners(u64 num) | ||
4737 | { | ||
4738 | u64 count = nfsd_for_n_state(num, nfsd_forget_client_openowners); | ||
4739 | printk(KERN_INFO "NFSD: Forgot %llu open owners", count); | ||
4740 | } | ||
4741 | |||
4742 | void nfsd_forget_delegations(u64 num) | ||
4743 | { | ||
4744 | u64 count = nfsd_for_n_state(num, nfsd_forget_client_delegations); | ||
4745 | printk(KERN_INFO "NFSD: Forgot %llu delegations", count); | ||
4746 | } | ||
4747 | |||
4748 | void nfsd_recall_delegations(u64 num) | ||
4749 | { | ||
4750 | u64 count = nfsd_for_n_state(num, nfsd_recall_client_delegations); | ||
4751 | printk(KERN_INFO "NFSD: Recalled %llu delegations", count); | ||
4752 | } | ||
4753 | |||
4754 | #endif /* CONFIG_NFSD_FAULT_INJECTION */ | 4724 | #endif /* CONFIG_NFSD_FAULT_INJECTION */ |
4755 | 4725 | ||
4756 | /* initialization to perform at module load time: */ | 4726 | /* initialization to perform at module load time: */ |
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index b542bf2c0fe7..423ac64ceb74 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h | |||
@@ -501,11 +501,13 @@ extern void nfsd4_record_grace_done(struct nfsd_net *nn, time_t boot_time); | |||
501 | #ifdef CONFIG_NFSD_FAULT_INJECTION | 501 | #ifdef CONFIG_NFSD_FAULT_INJECTION |
502 | int nfsd_fault_inject_init(void); | 502 | int nfsd_fault_inject_init(void); |
503 | void nfsd_fault_inject_cleanup(void); | 503 | void nfsd_fault_inject_cleanup(void); |
504 | void nfsd_forget_clients(u64); | 504 | u64 nfsd_for_n_state(u64, u64 (*)(struct nfs4_client *, u64)); |
505 | void nfsd_forget_locks(u64); | 505 | |
506 | void nfsd_forget_openowners(u64); | 506 | u64 nfsd_forget_client(struct nfs4_client *, u64); |
507 | void nfsd_forget_delegations(u64); | 507 | u64 nfsd_forget_client_locks(struct nfs4_client*, u64); |
508 | void nfsd_recall_delegations(u64); | 508 | u64 nfsd_forget_client_openowners(struct nfs4_client *, u64); |
509 | u64 nfsd_forget_client_delegations(struct nfs4_client *, u64); | ||
510 | u64 nfsd_recall_client_delegations(struct nfs4_client *, u64); | ||
509 | #else /* CONFIG_NFSD_FAULT_INJECTION */ | 511 | #else /* CONFIG_NFSD_FAULT_INJECTION */ |
510 | static inline int nfsd_fault_inject_init(void) { return 0; } | 512 | static inline int nfsd_fault_inject_init(void) { return 0; } |
511 | static inline void nfsd_fault_inject_cleanup(void) {} | 513 | static inline void nfsd_fault_inject_cleanup(void) {} |