From: Benny Halevy <bhalevy@primarydata.com>
To: bfields@redhat.com
Cc: linux-nfs@vger.kernel.org, Benny Halevy <bhalevy@primarydata.com>
Subject: [PATCH 3/7] nfsd4: properly hash delegation in nfs4_setlease
Date: Tue, 29 Oct 2013 11:39:16 +0200 [thread overview]
Message-ID: <1383039556-27257-1-git-send-email-bhalevy@primarydata.com> (raw)
In-Reply-To: <526F81DE.6060704@primarydata.com>
keep all accesses via dl_perclnt under the recall_lock.
Signed-off-by: Benny Halevy <bhalevy@primarydata.com>
---
fs/nfsd/nfs4state.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index a66b0ad..405649f 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -432,6 +432,13 @@ static void unhash_stid(struct nfs4_stid *s)
s->sc_type = 0;
}
+static void
+hash_delegation_locked(struct nfs4_delegation *dp, struct nfs4_file *fp)
+{
+ list_add(&dp->dl_perfile, &fp->fi_delegations);
+ list_add(&dp->dl_perclnt, &dp->dl_stid.sc_client->cl_delegations);
+}
+
/* Called under the state lock. */
static void
unhash_delegation(struct nfs4_delegation *dp)
@@ -3035,17 +3042,17 @@ static int nfs4_setlease(struct nfs4_delegation *dp)
if (!fl)
return -ENOMEM;
fl->fl_file = find_readable_file(fp);
- list_add(&dp->dl_perclnt, &dp->dl_stid.sc_client->cl_delegations);
status = vfs_setlease(fl->fl_file, fl->fl_type, &fl);
if (status) {
- list_del_init(&dp->dl_perclnt);
locks_free_lock(fl);
return status;
}
fp->fi_lease = fl;
fp->fi_deleg_file = get_file(fl->fl_file);
atomic_set(&fp->fi_delegees, 1);
- list_add(&dp->dl_perfile, &fp->fi_delegations);
+ spin_lock(&recall_lock);
+ hash_delegation_locked(dp, fp);
+ spin_unlock(&recall_lock);
return 0;
}
@@ -3070,9 +3077,8 @@ static int nfs4_set_delegation(struct nfs4_delegation *dp, struct nfs4_file *fp)
goto out_free;
}
atomic_inc(&fp->fi_delegees);
- list_add(&dp->dl_perfile, &fp->fi_delegations);
+ hash_delegation_locked(dp, fp);
spin_unlock(&recall_lock);
- list_add(&dp->dl_perclnt, &dp->dl_stid.sc_client->cl_delegations);
return 0;
out_free:
put_nfs4_file(fp);
@@ -4871,6 +4877,7 @@ static u64 nfsd_find_all_delegations(struct nfs4_client *clp, u64 max,
struct nfs4_delegation *dp, *next;
u64 count = 0;
+ lockdep_assert_held(&recall_lock);
list_for_each_entry_safe(dp, next, &clp->cl_delegations, dl_perclnt) {
if (victims)
list_move(&dp->dl_recall_lru, victims);
--
1.8.3.1
next prev parent reply other threads:[~2013-10-29 9:39 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-29 9:37 [PATCH 0/7] delegation state fixes and cleanups for 3.13 Benny Halevy
2013-10-29 9:39 ` [PATCH 1/7] nfsd4: fix recall_lock use in unhash_delegation Benny Halevy
2013-10-29 14:46 ` J. Bruce Fields
2013-10-30 14:02 ` Benny Halevy
2013-10-30 14:35 ` J. Bruce Fields
2013-10-30 14:43 ` Benny Halevy
2013-10-30 22:19 ` J. Bruce Fields
2013-10-29 9:39 ` [PATCH 2/7] nfsd4: need to destroy revoked delegations in destroy_client Benny Halevy
2013-10-29 15:04 ` J. Bruce Fields
2013-10-29 16:02 ` J. Bruce Fields
2013-10-30 14:07 ` Benny Halevy
2013-10-29 9:39 ` Benny Halevy [this message]
2013-10-29 9:39 ` [PATCH 4/7] nfsd4: hash deleg stateid only on successful nfs4_set_delegation Benny Halevy
2013-10-29 15:54 ` J. Bruce Fields
2013-10-30 14:10 ` Benny Halevy
2013-10-29 9:39 ` [PATCH 5/7] nfsd4: cleanup hash and unhash delegation Benny Halevy
2013-10-29 9:39 ` [PATCH 6/7] nfsd4: move nfs4_put_file from unhash to put delegation Benny Halevy
2013-10-29 15:59 ` J. Bruce Fields
2013-10-30 14:16 ` Benny Halevy
2013-10-29 9:39 ` [PATCH 7/7] nfsd4: hold recall_lock while accessing nfs4_delegation.dl_recall_lru Benny Halevy
2013-10-29 16:06 ` [PATCH 0/7] delegation state fixes and cleanups for 3.13 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=1383039556-27257-1-git-send-email-bhalevy@primarydata.com \
--to=bhalevy@primarydata.com \
--cc=bfields@redhat.com \
--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;
as well as URLs for NNTP newsgroup(s).