All of lore.kernel.org
 help / color / mirror / Atom feed
From: bjschuma@netapp.com
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH v2 07/10] NFSD: Fault injection operations take a per-client forget function
Date: Tue, 30 Oct 2012 16:50:51 -0400	[thread overview]
Message-ID: <1351630254-26166-8-git-send-email-bjschuma@netapp.com> (raw)
In-Reply-To: <1351630254-26166-1-git-send-email-bjschuma@netapp.com>

From: Bryan Schumaker <bjschuma@netapp.com>

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>
---
 fs/nfsd/fault_inject.c | 16 +++++++++-------
 fs/nfsd/nfs4state.c    | 42 ++++++------------------------------------
 fs/nfsd/state.h        | 12 +++++++-----
 3 files changed, 22 insertions(+), 48 deletions(-)

diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c
index 4b385a1..bf6161a 100644
--- a/fs/nfsd/fault_inject.c
+++ b/fs/nfsd/fault_inject.c
@@ -13,29 +13,29 @@
 
 struct nfsd_fault_inject_op {
 	char *file;
-	void (*func)(u64);
+	u64 (*forget)(struct nfs4_client *, u64);
 };
 
 static struct nfsd_fault_inject_op inject_ops[] = {
 	{
 		.file   = "forget_clients",
-		.func   = nfsd_forget_clients,
+		.forget = nfsd_forget_client,
 	},
 	{
 		.file   = "forget_locks",
-		.func   = nfsd_forget_locks,
+		.forget = nfsd_forget_client_locks,
 	},
 	{
 		.file   = "forget_openowners",
-		.func   = nfsd_forget_openowners,
+		.forget = nfsd_forget_client_openowners,
 	},
 	{
 		.file   = "forget_delegations",
-		.func   = nfsd_forget_delegations,
+		.forget = nfsd_forget_client_delegations,
 	},
 	{
 		.file   = "recall_delegations",
-		.func   = nfsd_recall_delegations,
+		.forget = nfsd_recall_client_delegations,
 	},
 };
 
@@ -44,6 +44,7 @@ static struct dentry *debug_dir;
 
 static int nfsd_inject_set(void *op_ptr, u64 val)
 {
+	u64 count = 0;
 	struct nfsd_fault_inject_op *op = op_ptr;
 
 	if (val == 0)
@@ -52,8 +53,9 @@ static int nfsd_inject_set(void *op_ptr, u64 val)
 		printk(KERN_INFO "NFSD Fault Injection: %s (n = %llu)", op->file, val);
 
 	nfs4_lock_state();
-	op->func(val);
+	count = nfsd_for_n_state(val, op->forget);
 	nfs4_unlock_state();
+	printk(KERN_INFO "NFSD: %s: found %llu", op->file, count);
 	return 0;
 }
 
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 49ab5c4..3c64dbc 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -4556,14 +4556,14 @@ nfs4_check_open_reclaim(clientid_t *clid, bool sessions)
 
 #ifdef CONFIG_NFSD_FAULT_INJECTION
 
-static u64 nfsd_forget_client(struct nfs4_client *clp, u64 max)
+u64 nfsd_forget_client(struct nfs4_client *clp, u64 max)
 {
 	nfsd4_client_record_remove(clp);
 	expire_client(clp);
 	return 1;
 }
 
-static u64 nfsd_forget_client_locks(struct nfs4_client *clp, u64 max)
+u64 nfsd_forget_client_locks(struct nfs4_client *clp, u64 max)
 {
 	struct nfs4_stateowner *sop, *next;
 	u64 count = 0;
@@ -4581,7 +4581,7 @@ static u64 nfsd_forget_client_locks(struct nfs4_client *clp, u64 max)
 	return count;
 }
 
-static u64 nfsd_forget_client_openowners(struct nfs4_client *clp, u64 max)
+u64 nfsd_forget_client_openowners(struct nfs4_client *clp, u64 max)
 {
 	struct nfs4_openowner *oop, *next;
 	u64 count = 0;
@@ -4609,7 +4609,7 @@ static u64 nfsd_find_n_delegations(struct nfs4_client *clp, u64 max,
 	return count;
 }
 
-static u64 nfsd_forget_client_delegations(struct nfs4_client *clp, u64 max)
+u64 nfsd_forget_client_delegations(struct nfs4_client *clp, u64 max)
 {
 	struct nfs4_delegation *dp, *next;
 	LIST_HEAD(victims);
@@ -4625,7 +4625,7 @@ static u64 nfsd_forget_client_delegations(struct nfs4_client *clp, u64 max)
 	return count;
 }
 
-static u64 nfsd_recall_client_delegations(struct nfs4_client *clp, u64 max)
+u64 nfsd_recall_client_delegations(struct nfs4_client *clp, u64 max)
 {
 	struct nfs4_delegation *dp, *next;
 	LIST_HEAD(victims);
@@ -4641,7 +4641,7 @@ static u64 nfsd_recall_client_delegations(struct nfs4_client *clp, u64 max)
 	return count;
 }
 
-static u64 nfsd_for_n_state(u64 max, u64 (*func)(struct nfs4_client *, u64))
+u64 nfsd_for_n_state(u64 max, u64 (*func)(struct nfs4_client *, u64))
 {
 	struct nfs4_client *clp, *next;
 	u64 count = 0;
@@ -4655,36 +4655,6 @@ static u64 nfsd_for_n_state(u64 max, u64 (*func)(struct nfs4_client *, u64))
 	return count;
 }
 
-void nfsd_forget_clients(u64 num)
-{
-	u64 count = nfsd_for_n_state(num, nfsd_forget_client);
-	printk(KERN_INFO "NFSD: Forgot %llu clients", count);
-}
-
-void nfsd_forget_locks(u64 num)
-{
-	u64 count = nfsd_for_n_state(num, nfsd_forget_client_locks);
-	printk(KERN_INFO "NFSD: Forgot %llu locks", count);
-}
-
-void nfsd_forget_openowners(u64 num)
-{
-	u64 count = nfsd_for_n_state(num, nfsd_forget_client_openowners);
-	printk(KERN_INFO "NFSD: Forgot %llu open owners", count);
-}
-
-void nfsd_forget_delegations(u64 num)
-{
-	u64 count = nfsd_for_n_state(num, nfsd_forget_client_delegations);
-	printk(KERN_INFO "NFSD: Forgot %llu delegations", count);
-}
-
-void nfsd_recall_delegations(u64 num)
-{
-	u64 count = nfsd_for_n_state(num, nfsd_recall_client_delegations);
-	printk(KERN_INFO "NFSD: Recalled %llu delegations", count);
-}
-
 #endif /* CONFIG_NFSD_FAULT_INJECTION */
 
 /* initialization to perform at module load time: */
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
index d2f52a1..9e133e5 100644
--- a/fs/nfsd/state.h
+++ b/fs/nfsd/state.h
@@ -486,11 +486,13 @@ extern void nfsd4_record_grace_done(struct net *net, time_t boot_time);
 #ifdef CONFIG_NFSD_FAULT_INJECTION
 int nfsd_fault_inject_init(void);
 void nfsd_fault_inject_cleanup(void);
-void nfsd_forget_clients(u64);
-void nfsd_forget_locks(u64);
-void nfsd_forget_openowners(u64);
-void nfsd_forget_delegations(u64);
-void nfsd_recall_delegations(u64);
+u64 nfsd_for_n_state(u64, u64 (*)(struct nfs4_client *, u64));
+
+u64 nfsd_forget_client(struct nfs4_client *, u64);
+u64 nfsd_forget_client_locks(struct nfs4_client*, u64);
+u64 nfsd_forget_client_openowners(struct nfs4_client *, u64);
+u64 nfsd_forget_client_delegations(struct nfs4_client *, u64);
+u64 nfsd_recall_client_delegations(struct nfs4_client *, u64);
 #else /* CONFIG_NFSD_FAULT_INJECTION */
 static inline int nfsd_fault_inject_init(void) { return 0; }
 static inline void nfsd_fault_inject_cleanup(void) {}
-- 
1.8.0


  parent reply	other threads:[~2012-10-30 20:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-30 20:50 [PATCH v2 00/10] NFSD: Improve fault injection bjschuma
2012-10-30 20:50 ` [PATCH v2 01/10] NFSD: Fold fault_inject.h into state.h bjschuma
2012-10-30 20:50 ` [PATCH v2 02/10] NFSD: Lock state before calling fault injection function bjschuma
2012-10-30 20:50 ` [PATCH v2 03/10] NFSD: Clean up forgetting clients bjschuma
2012-10-30 20:50 ` [PATCH v2 04/10] NFSD: Clean up forgetting locks bjschuma
2012-10-30 20:50 ` [PATCH v2 05/10] NFSD: Clean up forgetting openowners bjschuma
2012-10-30 20:50 ` [PATCH v2 06/10] NFSD: Clean up forgetting and recalling delegations bjschuma
2012-10-30 20:50 ` bjschuma [this message]
2012-10-30 20:50 ` [PATCH v2 08/10] NFSD: Reading a fault injection file prints a state count bjschuma
2012-10-30 20:50 ` [PATCH v2 09/10] NFSD: Add a custom file operations structure for fault injection bjschuma
2012-10-30 20:50 ` [PATCH v2 10/10] NFSD: Forget state for a specific client bjschuma
2012-11-14 22:48 ` [PATCH v2 00/10] NFSD: Improve fault injection J. Bruce Fields
2012-11-15 14:55   ` Bryan Schumaker
2012-11-15 15:00     ` J. Bruce Fields
2012-11-26 15:17       ` Bryan Schumaker
2012-11-26 16:10         ` J. Bruce Fields
2012-11-26 16:26           ` Bryan Schumaker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1351630254-26166-8-git-send-email-bjschuma@netapp.com \
    --to=bjschuma@netapp.com \
    --cc=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.