Linux NFS development
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@primarydata.com>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH v2 098/117] nfsd: add nfsd_inject_forget_clients
Date: Thu, 26 Jun 2014 15:21:06 -0400	[thread overview]
Message-ID: <1403810485-16497-15-git-send-email-jlayton@primarydata.com> (raw)
In-Reply-To: <1403810017-16062-1-git-send-email-jlayton@primarydata.com>

...which uses the client_lock for protection instead of client_mutex.
Also remove nfsd_forget_client as there are no more callers.

Signed-off-by: Jeff Layton <jlayton@primarydata.com>
---
 fs/nfsd/fault_inject.c |  3 +--
 fs/nfsd/nfs4state.c    | 42 ++++++++++++++++++++++++++++--------------
 fs/nfsd/state.h        |  2 +-
 3 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c
index 5f3ead0c72fb..76ecdff37ea2 100644
--- a/fs/nfsd/fault_inject.c
+++ b/fs/nfsd/fault_inject.c
@@ -135,9 +135,8 @@ static struct nfsd_fault_inject_op inject_ops[] = {
 	{
 		.file     = "forget_clients",
 		.get	  = nfsd_inject_print_clients,
-		.set_val  = nfsd_inject_set,
+		.set_val  = nfsd_inject_forget_clients,
 		.set_clnt = nfsd_inject_forget_client,
-		.forget   = nfsd_forget_client,
 	},
 	{
 		.file     = "forget_locks",
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index b12a36e71fee..9feb219e8699 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -5713,20 +5713,6 @@ nfsd_inject_print_clients(struct nfsd_fault_inject_op *op)
 	return count;
 }
 
-u64 nfsd_forget_client(struct nfs4_client *clp, u64 max)
-{
-	__be32 ret;
-	struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
-
-	spin_lock(&nn->client_lock);
-	ret = mark_client_expired_locked(clp);
-	spin_unlock(&nn->client_lock);
-	if (ret != nfs_ok)
-		return 0;
-	expire_client(clp);
-	return 1;
-}
-
 u64
 nfsd_inject_forget_client(struct nfsd_fault_inject_op *op,
 			  struct sockaddr_storage *addr, size_t addr_size)
@@ -5755,6 +5741,34 @@ nfsd_inject_forget_client(struct nfsd_fault_inject_op *op,
 	return count;
 }
 
+u64
+nfsd_inject_forget_clients(struct nfsd_fault_inject_op *op, u64 max)
+{
+	u64 count = 0;
+	struct nfs4_client *clp, *next;
+	struct nfsd_net *nn = net_generic(current->nsproxy->net_ns,
+						nfsd_net_id);
+	LIST_HEAD(reaplist);
+
+	if (!nfsd_netns_ready(nn))
+		return count;
+
+	spin_lock(&nn->client_lock);
+	list_for_each_entry_safe(clp, next, &nn->client_lru, cl_lru) {
+		if (mark_client_expired_locked(clp) == nfs_ok) {
+			list_add(&clp->cl_lru, &reaplist);
+			if (max != 0 && ++count >= max)
+				break;
+		}
+	}
+	spin_unlock(&nn->client_lock);
+
+	list_for_each_entry_safe(clp, next, &reaplist, cl_lru)
+		expire_client(clp);
+
+	return count;
+}
+
 static void nfsd_print_count(struct nfs4_client *clp, unsigned int count,
 			     const char *type)
 {
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
index a644a9f628d6..4fe973bbb68f 100644
--- a/fs/nfsd/state.h
+++ b/fs/nfsd/state.h
@@ -474,9 +474,9 @@ u64 nfsd_for_n_state(u64, u64 (*)(struct nfs4_client *, u64));
 struct nfs4_client *nfsd_find_client(struct sockaddr_storage *, size_t);
 
 u64 nfsd_inject_print_clients(struct nfsd_fault_inject_op *op);
-u64 nfsd_forget_client(struct nfs4_client *, u64);
 u64 nfsd_inject_forget_client(struct nfsd_fault_inject_op *,
 			      struct sockaddr_storage *, size_t);
+u64 nfsd_inject_forget_clients(struct nfsd_fault_inject_op *, u64);
 
 u64 nfsd_forget_client_locks(struct nfs4_client*, u64);
 u64 nfsd_forget_client_openowners(struct nfs4_client *, u64);
-- 
1.9.3


  parent reply	other threads:[~2014-06-26 19:21 UTC|newest]

Thread overview: 162+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-26 19:11 [PATCH v2 000/117] nfsd: eliminate the client_mutex Jeff Layton
2014-06-26 19:11 ` [PATCH v2 001/117] nfsd: fix file access refcount leak when nfsd4_truncate fails Jeff Layton
2014-06-26 19:24   ` Jeff Layton
2014-06-28 11:00     ` Christoph Hellwig
2014-06-26 19:11 ` [PATCH v2 002/117] nfsd: fix return of nfs4_acl_write_who Jeff Layton
2014-06-26 19:11 ` [PATCH v2 003/117] nfsd: add __force to opaque verifier field casts Jeff Layton
2014-06-26 19:11 ` [PATCH v2 004/117] nfsd: clean up sparse endianness warnings in nfscache.c Jeff Layton
2014-06-26 19:11 ` [PATCH v2 005/117] nfsd: nfsd_splice_read and nfsd_readv should return __be32 Jeff Layton
2014-06-26 19:11 ` [PATCH v2 006/117] nfsd: add appropriate __force directives to filehandle generation code Jeff Layton
2014-06-26 19:11 ` [PATCH v2 007/117] nfsd: properly handle embedded newlines in fault_injection input Jeff Layton
2014-06-28 11:01   ` Christoph Hellwig
2014-06-26 19:11 ` [PATCH v2 008/117] nfsd: Protect addition to the file_hashtbl Jeff Layton
2014-06-26 19:11 ` [PATCH v2 009/117] nfsd: wait to initialize work struct just prior to using it Jeff Layton
2014-06-28 11:02   ` Christoph Hellwig
2014-06-26 19:11 ` [PATCH v2 010/117] nfsd: Avoid taking state_lock while holding inode lock in nfsd_break_one_deleg Jeff Layton
2014-06-28 11:06   ` Christoph Hellwig
2014-06-28 12:18     ` Jeff Layton
2014-06-26 19:11 ` [PATCH v2 011/117] nfsd: nfs4_preprocess_seqid_op should only set *stpp on success Jeff Layton
2014-06-26 19:11 ` [PATCH v2 012/117] nfsd: Cleanup nfs4svc_encode_compoundres Jeff Layton
2014-06-26 19:11 ` [PATCH v2 013/117] nfsd: Don't get a session reference without a client reference Jeff Layton
2014-06-26 19:11 ` [PATCH v2 014/117] nfsd: Allow struct nfsd4_compound_state to cache the nfs4_client Jeff Layton
2014-06-29 12:05   ` Christoph Hellwig
2014-06-26 19:11 ` [PATCH v2 015/117] nfsd: lock owners are not per open stateid Jeff Layton
2014-06-28 11:07   ` Christoph Hellwig
2014-06-26 19:11 ` [PATCH v2 016/117] nfsd: Allow lockowners to hold several stateids Jeff Layton
2014-06-26 19:11 ` [PATCH v2 017/117] nfsd: NFSv4 lock-owners are not associated to a specific file Jeff Layton
2014-06-26 19:11 ` [PATCH v2 018/117] nfsd: clean up nfs4_release_lockowner Jeff Layton
2014-06-29  6:47   ` Christoph Hellwig
2014-06-29 11:08     ` Jeff Layton
2014-06-30 11:02       ` Jeff Layton
2014-06-30 11:04         ` Christoph Hellwig
2014-06-26 19:11 ` [PATCH v2 019/117] nfsd: declare v4.1+ openowners confirmed on creation Jeff Layton
2014-06-29  6:48   ` Christoph Hellwig
2014-06-26 19:12 ` [PATCH v2 020/117] nfsd: Cleanup - Let nfsd4_lookup_stateid() take a cstate argument Jeff Layton
2014-06-29  6:49   ` Christoph Hellwig
2014-06-26 19:12 ` [PATCH v2 021/117] nfsd: clean up nfsd4_close_open_stateid Jeff Layton
2014-06-29 12:00   ` Christoph Hellwig
2014-06-26 19:12 ` [PATCH v2 022/117] nfsd: Cache the client that was looked up in lookup_clientid() Jeff Layton
2014-06-29 12:14   ` Christoph Hellwig
2014-06-29 14:57     ` Jeff Layton
2014-06-30 10:34       ` Christoph Hellwig
2014-06-30 10:59         ` Jeff Layton
2014-06-30 11:03           ` Christoph Hellwig
2014-06-30 11:23             ` Jeff Layton
2014-06-26 19:12 ` [PATCH v2 023/117] nfsd: Convert nfsd4_process_open1() to work with lookup_clientid() Jeff Layton
2014-06-29 12:16   ` Christoph Hellwig
2014-06-29 15:08     ` Jeff Layton
2014-06-30 10:35       ` Christoph Hellwig
2014-06-26 19:12 ` [PATCH v2 024/117] nfsd: Always use lookup_clientid() in nfsd4_process_open1 Jeff Layton
2014-06-29 12:16   ` Christoph Hellwig
2014-06-26 19:12 ` [PATCH v2 025/117] nfsd: Convert nfs4_check_open_reclaim() to work with lookup_clientid() Jeff Layton
2014-06-29 12:17   ` Christoph Hellwig
2014-06-26 19:12 ` [PATCH v2 026/117] nfsd: Move the delegation reference counter into the struct nfs4_stid Jeff Layton
2014-06-26 19:12 ` [PATCH v2 027/117] nfsd4: use cl_lock to synchronize all stateid idr calls Jeff Layton
2014-06-26 19:12 ` [PATCH v2 028/117] nfsd: Add fine grained protection for the nfs4_file->fi_stateids list Jeff Layton
2014-06-26 19:12 ` [PATCH v2 029/117] nfsd: Add a mutex to protect the NFSv4.0 open owner replay cache Jeff Layton
2014-06-26 19:12 ` [PATCH v2 030/117] nfsd: Add locking to the nfs4_file->fi_fds[] array Jeff Layton
2014-06-26 19:12 ` [PATCH v2 031/117] nfsd: refactor nfs4_file_get_access and nfs4_file_put_access Jeff Layton
2014-06-26 19:12 ` [PATCH v2 032/117] nfsd: remove nfs4_file_put_fd Jeff Layton
2014-06-26 19:12 ` [PATCH v2 033/117] nfsd: ensure that nfs4_file_get_access enforces deny modes Jeff Layton
2014-06-27 19:59   ` Jeff Layton
2014-06-26 19:12 ` [PATCH v2 034/117] nfsd: cleanup nfs4_check_open Jeff Layton
2014-06-26 19:12 ` [PATCH v2 035/117] locks: add file_has_lease to prevent delegation break races Jeff Layton
2014-06-26 19:12 ` [PATCH v2 036/117] nfsd: Protect the nfs4_file delegation fields using the fi_lock Jeff Layton
2014-06-26 19:12 ` [PATCH v2 037/117] nfsd: clean up helper __release_lock_stateid Jeff Layton
2014-06-30 10:40   ` Christoph Hellwig
2014-06-30 10:53     ` Jeff Layton
2014-06-26 19:12 ` [PATCH v2 038/117] nfsd: Simplify stateid management Jeff Layton
2014-06-26 19:12 ` [PATCH v2 039/117] nfsd: Fix delegation revocation Jeff Layton
2014-06-26 19:12 ` [PATCH v2 040/117] nfsd: Add reference counting to the lock and open stateids Jeff Layton
2014-06-26 19:12 ` [PATCH v2 041/117] nfsd: Add a struct nfs4_file field to struct nfs4_stid Jeff Layton
2014-06-26 19:12 ` [PATCH v2 042/117] nfsd: Replace nfs4_ol_stateid->st_file with the st_stid.sc_file Jeff Layton
2014-06-26 19:12 ` [PATCH v2 043/117] nfsd: Ensure stateids remain unique until they are freed Jeff Layton
2014-06-26 19:12 ` [PATCH v2 044/117] nfsd: Ensure atomicity of stateid destruction and idr tree removal Jeff Layton
2014-06-26 19:12 ` [PATCH v2 045/117] nfsd: Cleanup the freeing of stateids Jeff Layton
2014-06-26 19:12 ` [PATCH v2 046/117] nfsd: do filp_close in sc_free callback for lock stateids Jeff Layton
2014-06-26 19:12 ` [PATCH v2 047/117] nfsd: Add locking to protect the state owner lists Jeff Layton
2014-06-26 19:12 ` [PATCH v2 048/117] nfsd: clean up races in lock stateid searching and creation Jeff Layton
2014-06-26 19:12 ` [PATCH v2 049/117] nfsd: Convert delegation counter to an atomic_long_t type Jeff Layton
2014-06-26 19:12 ` [PATCH v2 050/117] nfsd: Slight cleanup of find_stateid() Jeff Layton
2014-06-26 19:12 ` [PATCH v2 051/117] nfsd: ensure atomicity in nfsd4_free_stateid and nfsd4_validate_stateid Jeff Layton
2014-06-26 19:12 ` [PATCH v2 052/117] nfsd: Add reference counting to lock stateids Jeff Layton
2014-06-26 19:12 ` [PATCH v2 053/117] nfsd: nfsd4_locku() must reference the lock stateid Jeff Layton
2014-06-26 19:12 ` [PATCH v2 054/117] nfsd: Ensure that nfs4_open_delegation() references the delegation stateid Jeff Layton
2014-06-26 19:12 ` [PATCH v2 055/117] nfsd: nfsd4_process_open2() must reference " Jeff Layton
2014-06-26 19:12 ` [PATCH v2 056/117] nfsd: nfsd4_process_open2() must reference the open stateid Jeff Layton
2014-06-26 19:12 ` [PATCH v2 057/117] nfsd: Prepare nfsd4_close() for open stateid referencing Jeff Layton
2014-06-26 19:12 ` [PATCH v2 058/117] nfsd: nfsd4_open_confirm() must reference the open stateid Jeff Layton
2014-06-26 19:12 ` [PATCH v2 059/117] nfsd: Add reference counting to nfs4_preprocess_confirmed_seqid_op Jeff Layton
2014-06-26 19:12 ` [PATCH v2 060/117] nfsd: Migrate the stateid reference into nfs4_preprocess_seqid_op Jeff Layton
2014-06-26 19:12 ` [PATCH v2 061/117] nfsd: Migrate the stateid reference into nfs4_lookup_stateid() Jeff Layton
2014-06-26 19:12 ` [PATCH v2 062/117] nfsd: Migrate the stateid reference into nfs4_find_stateid_by_type() Jeff Layton
2014-06-26 19:12 ` [PATCH v2 063/117] nfsd: Add reference counting to state owners Jeff Layton
2014-06-26 19:12 ` [PATCH v2 064/117] nfsd: Keep a reference to the open stateid for the NFSv4.0 replay cache Jeff Layton
2014-06-26 19:12 ` [PATCH v2 065/117] nfsd: clean up lockowner refcounting when finding them Jeff Layton
2014-06-26 19:12 ` [PATCH v2 066/117] nfsd: add an operation for unhashing a stateowner Jeff Layton
2014-06-26 19:12 ` [PATCH v2 067/117] nfsd: Make lock stateid take a reference to the lockowner Jeff Layton
2014-06-26 19:12 ` [PATCH v2 068/117] nfsd: clean up refcounting for lockowners Jeff Layton
2014-06-26 19:12 ` [PATCH v2 069/117] nfsd: make openstateids hold references to their openowners Jeff Layton
2014-06-26 19:12 ` [PATCH v2 070/117] nfsd: don't allow CLOSE to proceed until refcount on stateid drops Jeff Layton
2014-06-26 19:12 ` [PATCH v2 071/117] nfsd: Protect adding/removing open state owners using client_lock Jeff Layton
2014-06-26 19:12 ` [PATCH v2 072/117] nfsd: Protect adding/removing lock " Jeff Layton
2014-06-26 19:12 ` [PATCH v2 073/117] nfsd: Move the open owner hash table into struct nfs4_client Jeff Layton
2014-06-26 19:12 ` [PATCH v2 074/117] lockdep: add lockdep_assert_not_held Jeff Layton
2014-06-26 19:12 ` [PATCH v2 075/117] nfsd: add locking to stateowner release Jeff Layton
2014-06-26 19:12 ` [PATCH v2 076/117] nfsd: optimize destroy_lockowner cl_lock thrashing Jeff Layton
2014-06-26 19:12 ` [PATCH v2 077/117] nfsd: close potential race in nfsd4_free_stateid Jeff Layton
2014-06-26 19:12 ` [PATCH v2 078/117] nfsd: reduce cl_lock thrashing in release_openowner Jeff Layton
2014-06-26 19:12 ` [PATCH v2 079/117] nfsd: don't thrash the cl_lock while freeing an open stateid Jeff Layton
2014-06-26 19:13 ` [PATCH v2 080/117] nfsd: Ensure struct nfs4_client is unhashed before we try to destroy it Jeff Layton
2014-06-26 19:13 ` [PATCH v2 081/117] nfsd: Ensure that the laundromat unhashes the client before releasing locks Jeff Layton
2014-06-26 19:13 ` [PATCH v2 082/117] nfsd: Don't require client_lock in free_client Jeff Layton
2014-06-26 19:13 ` [PATCH v2 083/117] nfsd: Move create_client() call outside the lock Jeff Layton
2014-06-26 19:20 ` [PATCH v2 084/117] nfsd: Protect unconfirmed client creation using client_lock Jeff Layton
2014-06-26 19:20 ` [PATCH v2 085/117] nfsd: Protect session creation and client confirm " Jeff Layton
2014-06-26 19:20 ` [PATCH v2 086/117] nfsd: Protect nfsd4_destroy_clientid " Jeff Layton
2014-06-26 19:20 ` [PATCH v2 087/117] nfsd: Ensure lookup_clientid() takes client_lock Jeff Layton
2014-06-26 19:20 ` [PATCH v2 088/117] nfsd: Add lockdep assertions to document the nfs4_client/session locking Jeff Layton
2014-06-26 19:20 ` [PATCH v2 089/117] nfsd: protect the close_lru list and oo_last_closed_stid with client_lock Jeff Layton
2014-06-26 19:20 ` [PATCH v2 090/117] nfsd: ensure that clp->cl_revoked list is protected by clp->cl_lock Jeff Layton
2014-06-26 19:20 ` [PATCH v2 091/117] nfsd: move unhash_client_locked call into mark_client_expired_locked Jeff Layton
2014-06-26 19:21 ` [PATCH v2 092/117] nfsd: don't destroy client if mark_client_expired_locked fails Jeff Layton
2014-06-26 19:21 ` [PATCH v2 093/117] nfsd: don't destroy clients that are busy Jeff Layton
2014-06-26 19:21 ` [PATCH v2 094/117] nfsd: protect clid and verifier generation with client_lock Jeff Layton
2014-06-26 19:21 ` [PATCH v2 095/117] nfsd: abstract out the get and set routines into the fault injection ops Jeff Layton
2014-06-26 19:21 ` [PATCH v2 096/117] nfsd: add a forget_clients "get" routine with proper locking Jeff Layton
2014-06-26 19:21 ` [PATCH v2 097/117] nfsd: add a forget_client set_clnt routine Jeff Layton
2014-06-26 19:21 ` Jeff Layton [this message]
2014-06-26 19:21 ` [PATCH v2 099/117] nfsd: add a list_head arg to nfsd_foreach_client_lock Jeff Layton
2014-06-26 19:21 ` [PATCH v2 100/117] nfsd: add more granular locking to forget_locks fault injector Jeff Layton
2014-06-26 19:21 ` [PATCH v2 101/117] nfsd: add more granular locking to forget_openowners " Jeff Layton
2014-06-26 19:21 ` [PATCH v2 102/117] nfsd: add more granular locking to *_delegations fault injectors Jeff Layton
2014-06-26 19:21 ` [PATCH v2 103/117] nfsd: remove old fault injection infrastructure Jeff Layton
2014-06-26 19:21 ` [PATCH v2 104/117] nfsd: Remove nfs4_lock_state(): nfs4_preprocess_stateid_op() Jeff Layton
2014-06-26 19:21 ` [PATCH v2 105/117] nfsd: Remove nfs4_lock_state(): nfsd4_test_stateid/nfsd4_free_stateid Jeff Layton
2014-06-26 19:21 ` [PATCH v2 106/117] nfsd: Remove nfs4_lock_state(): nfsd4_release_lockowner Jeff Layton
2014-06-26 19:21 ` [PATCH v2 107/117] nfsd: Remove nfs4_lock_state(): nfsd4_lock/locku/lockt() Jeff Layton
2014-06-26 19:21 ` [PATCH v2 108/117] nfsd: Remove nfs4_lock_state(): nfsd4_open_downgrade + nfsd4_close Jeff Layton
2014-06-26 19:21 ` [PATCH v2 109/117] nfsd: Remove nfs4_lock_state(): nfsd4_delegreturn() Jeff Layton
2014-06-26 19:21 ` [PATCH v2 110/117] nfsd: Remove nfs4_lock_state(): nfsd4_open and nfsd4_open_confirm Jeff Layton
2014-06-26 19:21 ` [PATCH v2 111/117] nfsd: Remove nfs4_lock_state(): exchange_id, create/destroy_session() Jeff Layton
2014-06-26 19:21 ` [PATCH v2 112/117] nfsd: Remove nfs4_lock_state(): setclientid, setclientid_confirm, renew Jeff Layton
2014-06-26 19:21 ` [PATCH v2 113/117] nfsd: Remove nfs4_lock_state(): reclaim_complete() Jeff Layton
2014-06-26 19:21 ` [PATCH v2 114/117] nfsd: remove nfs4_lock_state: nfs4_laundromat Jeff Layton
2014-06-26 19:21 ` [PATCH v2 115/117] nfsd: remove nfs4_lock_state: nfs4_state_shutdown_net Jeff Layton
2014-06-26 19:21 ` [PATCH v2 116/117] nfsd: remove the client_mutex and the nfs4_lock/unlock_state wrappers Jeff Layton
2014-06-26 19:21 ` [PATCH v2 117/117] nfsd: add file documenting new state object model Jeff Layton
2014-06-27 16:22 ` [PATCH v2 000/117] nfsd: eliminate the client_mutex J. Bruce Fields
2014-06-27 19:08   ` Jeff Layton
2014-06-30 12:51 ` Christoph Hellwig
2014-06-30 12:59   ` Jeff Layton
2014-06-30 19:32     ` J. Bruce Fields
2014-06-30 19:39       ` Jeff Layton
2014-06-30 20:20       ` Jeff Layton
2014-06-30 20:31         ` Trond Myklebust
2014-06-30 20:36           ` Jeff Layton
2014-07-01 14:10             ` Jeff Layton
2014-07-01 14:21               ` Trond Myklebust
2014-07-01 18:46                 ` Jeff Layton
2014-07-01 20:01                   ` J. Bruce Fields
2014-07-01 20:13                     ` Jeff Layton
2014-07-01 20:24                       ` J. Bruce Fields

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=1403810485-16497-15-git-send-email-jlayton@primarydata.com \
    --to=jlayton@primarydata.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox