Commit 184c18471f7d0963ad5752692c4b441a546d88f1

Authored by Bryan Schumaker
Committed by J. Bruce Fields
1 parent 8ce54e0d82

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>

Showing 3 changed files with 58 additions and 2 deletions Side-by-side Diff

fs/nfsd/fault_inject.c
... ... @@ -14,28 +14,34 @@
14 14 struct nfsd_fault_inject_op {
15 15 char *file;
16 16 u64 (*forget)(struct nfs4_client *, u64);
  17 + u64 (*print)(struct nfs4_client *, u64);
17 18 };
18 19  
19 20 static struct nfsd_fault_inject_op inject_ops[] = {
20 21 {
21 22 .file = "forget_clients",
22 23 .forget = nfsd_forget_client,
  24 + .print = nfsd_print_client,
23 25 },
24 26 {
25 27 .file = "forget_locks",
26 28 .forget = nfsd_forget_client_locks,
  29 + .print = nfsd_print_client_locks,
27 30 },
28 31 {
29 32 .file = "forget_openowners",
30 33 .forget = nfsd_forget_client_openowners,
  34 + .print = nfsd_print_client_openowners,
31 35 },
32 36 {
33 37 .file = "forget_delegations",
34 38 .forget = nfsd_forget_client_delegations,
  39 + .print = nfsd_print_client_delegations,
35 40 },
36 41 {
37 42 .file = "recall_delegations",
38 43 .forget = nfsd_recall_client_delegations,
  44 + .print = nfsd_print_client_delegations,
39 45 },
40 46 };
41 47  
42 48  
... ... @@ -59,9 +65,12 @@
59 65 return 0;
60 66 }
61 67  
62   -static int nfsd_inject_get(void *data, u64 *val)
  68 +static 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 74 return 0;
66 75 }
67 76  
... ... @@ -4611,6 +4611,22 @@
4611 4611 return 1;
4612 4612 }
4613 4613  
  4614 +u64 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 +
  4622 +static 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 +
4614 4630 static u64 nfsd_foreach_client_lock(struct nfs4_client *clp, u64 max, void (*func)(struct nfs4_lockowner *))
4615 4631 {
4616 4632 struct nfs4_openowner *oop;
... ... @@ -4637,6 +4653,13 @@
4637 4653 return nfsd_foreach_client_lock(clp, max, release_lockowner);
4638 4654 }
4639 4655  
  4656 +u64 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 +
4640 4663 static u64 nfsd_foreach_client_open(struct nfs4_client *clp, u64 max, void (*func)(struct nfs4_openowner *))
4641 4664 {
4642 4665 struct nfs4_openowner *oop, *next;
... ... @@ -4657,6 +4680,13 @@
4657 4680 return nfsd_foreach_client_open(clp, max, release_openowner);
4658 4681 }
4659 4682  
  4683 +u64 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 +
4660 4690 static u64 nfsd_find_all_delegations(struct nfs4_client *clp, u64 max,
4661 4691 struct list_head *victims)
4662 4692 {
... ... @@ -4700,6 +4730,18 @@
4700 4730 nfsd_break_one_deleg(dp);
4701 4731 spin_unlock(&recall_lock);
4702 4732  
  4733 + return count;
  4734 +}
  4735 +
  4736 +u64 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");
4703 4745 return count;
4704 4746 }
4705 4747  
... ... @@ -508,6 +508,11 @@
508 508 u64 nfsd_forget_client_openowners(struct nfs4_client *, u64);
509 509 u64 nfsd_forget_client_delegations(struct nfs4_client *, u64);
510 510 u64 nfsd_recall_client_delegations(struct nfs4_client *, u64);
  511 +
  512 +u64 nfsd_print_client(struct nfs4_client *, u64);
  513 +u64 nfsd_print_client_locks(struct nfs4_client *, u64);
  514 +u64 nfsd_print_client_openowners(struct nfs4_client *, u64);
  515 +u64 nfsd_print_client_delegations(struct nfs4_client *, u64);
511 516 #else /* CONFIG_NFSD_FAULT_INJECTION */
512 517 static inline int nfsd_fault_inject_init(void) { return 0; }
513 518 static inline void nfsd_fault_inject_cleanup(void) {}