From: Jeff Layton <jlayton@primarydata.com>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH v2 068/117] nfsd: clean up refcounting for lockowners
Date: Thu, 26 Jun 2014 15:12:48 -0400 [thread overview]
Message-ID: <1403810017-16062-69-git-send-email-jlayton@primarydata.com> (raw)
In-Reply-To: <1403810017-16062-1-git-send-email-jlayton@primarydata.com>
Ensure that lockowner references are only held by lockstateids and
operations that are in-progress. With this, we can get rid of
release_lockowner_if_empty, which will be racy once we remove
client_mutex protection.
Signed-off-by: Jeff Layton <jlayton@primarydata.com>
---
fs/nfsd/nfs4state.c | 29 +++++++----------------------
1 file changed, 7 insertions(+), 22 deletions(-)
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 649b2e829981..d8de65e0a457 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -926,7 +926,7 @@ static void put_generic_stateid(struct nfs4_ol_stateid *stp)
nfs4_put_stid(&stp->st_stid);
}
-static void __release_lock_stateid(struct nfs4_ol_stateid *stp)
+static void release_lock_stateid(struct nfs4_ol_stateid *stp)
{
struct nfs4_openowner *oo = openowner(stp->st_openstp->st_stateowner);
@@ -950,7 +950,7 @@ static void release_lockowner_stateids(struct nfs4_lockowner *lo)
while (!list_empty(&lo->lo_owner.so_stateids)) {
stp = list_first_entry(&lo->lo_owner.so_stateids,
struct nfs4_ol_stateid, st_perstateowner);
- __release_lock_stateid(stp);
+ release_lock_stateid(stp);
}
}
@@ -961,21 +961,6 @@ static void release_lockowner(struct nfs4_lockowner *lo)
nfs4_put_stateowner(&lo->lo_owner);
}
-static void release_lockowner_if_empty(struct nfs4_lockowner *lo)
-{
- if (list_empty(&lo->lo_owner.so_stateids))
- release_lockowner(lo);
-}
-
-static void release_lock_stateid(struct nfs4_ol_stateid *stp)
-{
- struct nfs4_lockowner *lo;
-
- lo = lockowner(stp->st_stateowner);
- __release_lock_stateid(stp);
- release_lockowner_if_empty(lo);
-}
-
static void release_open_stateid_locks(struct nfs4_ol_stateid *open_stp)
__releases(&open_stp->st_stateowner->so_client->cl_lock)
__acquires(&open_stp->st_stateowner->so_client->cl_lock)
@@ -4285,7 +4270,7 @@ nfsd4_free_lock_stateid(struct nfs4_ol_stateid *stp)
if (check_for_locks(stp->st_stid.sc_file, lo))
return nfserr_locks_held;
- release_lockowner_if_empty(lo);
+ release_lock_stateid(stp);
return nfs_ok;
}
@@ -4907,8 +4892,6 @@ static __be32 lookup_or_create_lock_state(struct nfsd4_compound_state *cstate,
lo = alloc_init_lock_stateowner(strhashval, cl, ost, lock);
if (lo == NULL)
return nfserr_jukebox;
- /* FIXME: extra reference for new lockowners for the client */
- atomic_inc(&lo->lo_owner.so_count);
} else {
/* with an existing lockowner, seqids must be the same */
status = nfserr_bad_seqid;
@@ -4919,7 +4902,6 @@ static __be32 lookup_or_create_lock_state(struct nfsd4_compound_state *cstate,
*lst = find_or_create_lock_stateid(lo, fi, ost, new);
if (*lst == NULL) {
- release_lockowner_if_empty(lo);
status = nfserr_jukebox;
goto out;
}
@@ -5341,6 +5323,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
continue;
if (same_owner_str(tmp, owner, clid)) {
sop = tmp;
+ atomic_inc(&sop->so_count);
break;
}
}
@@ -5354,8 +5337,10 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
lo = lockowner(sop);
/* see if there are still any locks associated with it */
list_for_each_entry(stp, &sop->so_stateids, st_perstateowner) {
- if (check_for_locks(stp->st_stid.sc_file, lo))
+ if (check_for_locks(stp->st_stid.sc_file, lo)) {
+ nfs4_put_stateowner(sop);
goto out;
+ }
}
status = nfs_ok;
--
1.9.3
next prev parent reply other threads:[~2014-06-26 19:15 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 ` Jeff Layton [this message]
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 ` [PATCH v2 098/117] nfsd: add nfsd_inject_forget_clients Jeff Layton
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=1403810017-16062-69-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