aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorBryan Schumaker <bjschuma@netapp.com>2012-11-29 11:40:44 -0500
committerJ. Bruce Fields <bfields@redhat.com>2012-12-03 09:59:01 -0500
commit184c18471f7d0963ad5752692c4b441a546d88f1 (patch)
tree92dc8d2d5d7104888055741b6c2c6fca67795b05 /fs
parent8ce54e0d82730ece61737c9fd7b61b28ab8c3390 (diff)
NFSD: Reading a fault injection file prints a state count
I also log basic information that I can figure out about the type of state (such as number of locks for each client IP address). This can be useful for checking that state was actually dropped and later for checking if the client was able to recover. Signed-off-by: Bryan Schumaker <bjschuma@netapp.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfsd/fault_inject.c13
-rw-r--r--fs/nfsd/nfs4state.c42
-rw-r--r--fs/nfsd/state.h5
3 files changed, 58 insertions, 2 deletions
diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c
index bf6161adf663..545f8e4ed101 100644
--- a/fs/nfsd/fault_inject.c
+++ b/fs/nfsd/fault_inject.c
@@ -14,28 +14,34 @@
14struct nfsd_fault_inject_op { 14struct nfsd_fault_inject_op {
15 char *file; 15 char *file;
16 u64 (*forget)(struct nfs4_client *, u64); 16 u64 (*forget)(struct nfs4_client *, u64);
17 u64 (*print)(struct nfs4_client *, u64);
17}; 18};
18 19
19static struct nfsd_fault_inject_op inject_ops[] = { 20static struct nfsd_fault_inject_op inject_ops[] = {
20 { 21 {
21 .file = "forget_clients", 22 .file = "forget_clients",
22 .forget = nfsd_forget_client, 23 .forget = nfsd_forget_client,
24 .print = nfsd_print_client,
23 }, 25 },
24 { 26 {
25 .file = "forget_locks", 27 .file = "forget_locks",
26 .forget = nfsd_forget_client_locks, 28 .forget = nfsd_forget_client_locks,
29 .print = nfsd_print_client_locks,
27 }, 30 },
28 { 31 {
29 .file = "forget_openowners", 32 .file = "forget_openowners",
30 .forget = nfsd_forget_client_openowners, 33 .forget = nfsd_forget_client_openowners,
34 .print = nfsd_print_client_openowners,
31 }, 35 },
32 { 36 {
33 .file = "forget_delegations", 37 .file = "forget_delegations",
34 .forget = nfsd_forget_client_delegations, 38 .forget = nfsd_forget_client_delegations,
39 .print = nfsd_print_client_delegations,
35 }, 40 },
36 { 41 {
37 .file = "recall_delegations", 42 .file = "recall_delegations",
38 .forget = nfsd_recall_client_delegations, 43 .forget = nfsd_recall_client_delegations,
44 .print = nfsd_print_client_delegations,
39 }, 45 },
40}; 46};
41 47
@@ -59,9 +65,12 @@ static int nfsd_inject_set(void *op_ptr, u64 val)
59 return 0; 65 return 0;
60} 66}
61 67
62static int nfsd_inject_get(void *data, u64 *val) 68static int nfsd_inject_get(void *op_ptr, u64 *val)
63{ 69{
64 *val = 0; 70 struct nfsd_fault_inject_op *op = op_ptr;
71 nfs4_lock_state();
72 *val = nfsd_for_n_state(0, op->print);
73 nfs4_unlock_state();
65 return 0; 74 return 0;
66} 75}
67 76
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index ab45cdd7b3da..9fb8e52580f3 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -4611,6 +4611,22 @@ u64 nfsd_forget_client(struct nfs4_client *clp, u64 max)
4611 return 1; 4611 return 1;
4612} 4612}
4613 4613
4614u64 nfsd_print_client(struct nfs4_client *clp, u64 num)
4615{
4616 char buf[INET6_ADDRSTRLEN];
4617 rpc_ntop((struct sockaddr *)&clp->cl_addr, buf, 129);
4618 printk(KERN_INFO "NFS Client: %s\n", buf);
4619 return 1;
4620}
4621
4622static void nfsd_print_count(struct nfs4_client *clp, unsigned int count,
4623 const char *type)
4624{
4625 char buf[INET6_ADDRSTRLEN];
4626 rpc_ntop((struct sockaddr *)&clp->cl_addr, buf, 129);
4627 printk(KERN_INFO "NFS Client: %s has %u %s\n", buf, count, type);
4628}
4629
4614static u64 nfsd_foreach_client_lock(struct nfs4_client *clp, u64 max, void (*func)(struct nfs4_lockowner *)) 4630static u64 nfsd_foreach_client_lock(struct nfs4_client *clp, u64 max, void (*func)(struct nfs4_lockowner *))
4615{ 4631{
4616 struct nfs4_openowner *oop; 4632 struct nfs4_openowner *oop;
@@ -4637,6 +4653,13 @@ u64 nfsd_forget_client_locks(struct nfs4_client *clp, u64 max)
4637 return nfsd_foreach_client_lock(clp, max, release_lockowner); 4653 return nfsd_foreach_client_lock(clp, max, release_lockowner);
4638} 4654}
4639 4655
4656u64 nfsd_print_client_locks(struct nfs4_client *clp, u64 max)
4657{
4658 u64 count = nfsd_foreach_client_lock(clp, max, NULL);
4659 nfsd_print_count(clp, count, "locked files");
4660 return count;
4661}
4662
4640static u64 nfsd_foreach_client_open(struct nfs4_client *clp, u64 max, void (*func)(struct nfs4_openowner *)) 4663static u64 nfsd_foreach_client_open(struct nfs4_client *clp, u64 max, void (*func)(struct nfs4_openowner *))
4641{ 4664{
4642 struct nfs4_openowner *oop, *next; 4665 struct nfs4_openowner *oop, *next;
@@ -4657,6 +4680,13 @@ u64 nfsd_forget_client_openowners(struct nfs4_client *clp, u64 max)
4657 return nfsd_foreach_client_open(clp, max, release_openowner); 4680 return nfsd_foreach_client_open(clp, max, release_openowner);
4658} 4681}
4659 4682
4683u64 nfsd_print_client_openowners(struct nfs4_client *clp, u64 max)
4684{
4685 u64 count = nfsd_foreach_client_open(clp, max, NULL);
4686 nfsd_print_count(clp, count, "open files");
4687 return count;
4688}
4689
4660static u64 nfsd_find_all_delegations(struct nfs4_client *clp, u64 max, 4690static u64 nfsd_find_all_delegations(struct nfs4_client *clp, u64 max,
4661 struct list_head *victims) 4691 struct list_head *victims)
4662{ 4692{
@@ -4703,6 +4733,18 @@ u64 nfsd_recall_client_delegations(struct nfs4_client *clp, u64 max)
4703 return count; 4733 return count;
4704} 4734}
4705 4735
4736u64 nfsd_print_client_delegations(struct nfs4_client *clp, u64 max)
4737{
4738 u64 count = 0;
4739
4740 spin_lock(&recall_lock);
4741 count = nfsd_find_all_delegations(clp, max, NULL);
4742 spin_unlock(&recall_lock);
4743
4744 nfsd_print_count(clp, count, "delegations");
4745 return count;
4746}
4747
4706u64 nfsd_for_n_state(u64 max, u64 (*func)(struct nfs4_client *, u64)) 4748u64 nfsd_for_n_state(u64 max, u64 (*func)(struct nfs4_client *, u64))
4707{ 4749{
4708 struct nfs4_client *clp, *next; 4750 struct nfs4_client *clp, *next;
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
index 423ac64ceb74..4017f3553a63 100644
--- a/fs/nfsd/state.h
+++ b/fs/nfsd/state.h
@@ -508,6 +508,11 @@ u64 nfsd_forget_client_locks(struct nfs4_client*, u64);
508u64 nfsd_forget_client_openowners(struct nfs4_client *, u64); 508u64 nfsd_forget_client_openowners(struct nfs4_client *, u64);
509u64 nfsd_forget_client_delegations(struct nfs4_client *, u64); 509u64 nfsd_forget_client_delegations(struct nfs4_client *, u64);
510u64 nfsd_recall_client_delegations(struct nfs4_client *, u64); 510u64 nfsd_recall_client_delegations(struct nfs4_client *, u64);
511
512u64 nfsd_print_client(struct nfs4_client *, u64);
513u64 nfsd_print_client_locks(struct nfs4_client *, u64);
514u64 nfsd_print_client_openowners(struct nfs4_client *, u64);
515u64 nfsd_print_client_delegations(struct nfs4_client *, u64);
511#else /* CONFIG_NFSD_FAULT_INJECTION */ 516#else /* CONFIG_NFSD_FAULT_INJECTION */
512static inline int nfsd_fault_inject_init(void) { return 0; } 517static inline int nfsd_fault_inject_init(void) { return 0; }
513static inline void nfsd_fault_inject_cleanup(void) {} 518static inline void nfsd_fault_inject_cleanup(void) {}