[kernel] r20206 - in dists/wheezy/linux/debian: . patches patches/bugfix/all
Ben Hutchings
benh at alioth.debian.org
Sat Jun 8 16:28:11 UTC 2013
Author: benh
Date: Sat Jun 8 16:28:11 2013
New Revision: 20206
Log:
nfsd4: Fix performance problem with RELEASE_LOCKOWNER (Closes: #699361)
Added:
dists/wheezy/linux/debian/patches/bugfix/all/nfsd4-hash-lockowners-to-simplify-RELEASE_LOCKOWNER.patch
dists/wheezy/linux/debian/patches/bugfix/all/nfsd4-maintain-one-seqid-stream-per-lockowner-file.patch
Modified:
dists/wheezy/linux/debian/changelog
dists/wheezy/linux/debian/patches/series
Modified: dists/wheezy/linux/debian/changelog
==============================================================================
--- dists/wheezy/linux/debian/changelog Sat Jun 8 16:24:46 2013 (r20205)
+++ dists/wheezy/linux/debian/changelog Sat Jun 8 16:28:11 2013 (r20206)
@@ -189,6 +189,9 @@
* iscsi-target: fix heap buffer overflow on error (CVE-2013-2850)
* ath9k: Disable PowerSave by default (Closes: #695968)
* dlm: Do not allocate a fd for peeloff (Closes: #706010)
+ * nfsd4: Fix performance problem with RELEASE_LOCKOWNER (Closes: #699361)
+ - hash lockowners to simplify RELEASE_LOCKOWNER
+ - maintain one seqid stream per (lockowner, file)
-- Ben Hutchings <ben at decadent.org.uk> Wed, 27 Mar 2013 14:10:40 +0000
Added: dists/wheezy/linux/debian/patches/bugfix/all/nfsd4-hash-lockowners-to-simplify-RELEASE_LOCKOWNER.patch
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ dists/wheezy/linux/debian/patches/bugfix/all/nfsd4-hash-lockowners-to-simplify-RELEASE_LOCKOWNER.patch Sat Jun 8 16:28:11 2013 (r20206)
@@ -0,0 +1,105 @@
+From: "J. Bruce Fields" <bfields at redhat.com>
+Date: Mon, 7 Nov 2011 16:58:18 -0500
+Subject: nfsd4: hash lockowners to simplify RELEASE_LOCKOWNER
+
+commit 06f1f864d4ae5804e83785308d41f14a08e4b980 upstream.
+
+Hash lockowners on just the owner string rather than on (owner, inode).
+This makes the owner-string lookup needed for RELEASE_LOCKOWNER simpler
+(currently it's doing at a linear search through the entire hash
+table!). That may come at the expense of making (owner, inode) lookups
+more expensive if a client reuses the same lockowner across multiple
+files. We might add a separate lookup for that.
+
+Signed-off-by: J. Bruce Fields <bfields at redhat.com>
+---
+ fs/nfsd/nfs4state.c | 42 ++++++++++++++----------------------------
+ 1 file changed, 14 insertions(+), 28 deletions(-)
+
+--- a/fs/nfsd/nfs4state.c
++++ b/fs/nfsd/nfs4state.c
+@@ -3743,15 +3743,6 @@ last_byte_offset(u64 start, u64 len)
+ return end > start ? end - 1: NFS4_MAX_UINT64;
+ }
+
+-static inline unsigned int
+-lock_ownerstr_hashval(struct inode *inode, u32 cl_id,
+- struct xdr_netobj *ownername)
+-{
+- return (file_hashval(inode) + cl_id
+- + opaque_hashval(ownername->data, ownername->len))
+- & LOCK_HASH_MASK;
+-}
+-
+ static struct list_head lock_ownerstr_hashtbl[LOCK_HASH_SIZE];
+
+ /*
+@@ -3821,7 +3812,7 @@ static struct nfs4_lockowner *
+ find_lockowner_str(struct inode *inode, clientid_t *clid,
+ struct xdr_netobj *owner)
+ {
+- unsigned int hashval = lock_ownerstr_hashval(inode, clid->cl_id, owner);
++ unsigned int hashval = open_ownerstr_hashval(clid->cl_id, owner);
+ struct nfs4_lockowner *lo;
+ struct nfs4_stateowner *op;
+
+@@ -3844,7 +3835,7 @@ static void hash_lockowner(struct nfs4_l
+ * Called in nfsd4_lock - therefore, OPEN and OPEN_CONFIRM (if needed) has
+ * occurred.
+ *
+- * strhashval = lock_ownerstr_hashval
++ * strhashval = open_ownerstr_hashval
+ */
+
+ static struct nfs4_lockowner *
+@@ -3919,7 +3910,7 @@ __be32 lookup_or_create_lock_state(struc
+ struct nfs4_ol_stateid, st_perstateowner);
+ return nfs_ok;
+ }
+- strhashval = lock_ownerstr_hashval(fi->fi_inode, cl->cl_clientid.cl_id,
++ strhashval = open_ownerstr_hashval(cl->cl_clientid.cl_id,
+ &lock->v.new.owner);
+ lo = alloc_init_lock_stateowner(strhashval, cl, ost, lock);
+ if (lo == NULL)
+@@ -4274,7 +4265,7 @@ nfsd4_release_lockowner(struct svc_rqst
+ struct nfs4_ol_stateid *stp;
+ struct xdr_netobj *owner = &rlockowner->rl_owner;
+ struct list_head matches;
+- int i;
++ unsigned int hashval = open_ownerstr_hashval(clid->cl_id, owner);
+ __be32 status;
+
+ dprintk("nfsd4_release_lockowner clientid: (%08x/%08x):\n",
+@@ -4289,22 +4280,17 @@ nfsd4_release_lockowner(struct svc_rqst
+ nfs4_lock_state();
+
+ status = nfserr_locks_held;
+- /* XXX: we're doing a linear search through all the lockowners.
+- * Yipes! For now we'll just hope clients aren't really using
+- * release_lockowner much, but eventually we have to fix these
+- * data structures. */
+ INIT_LIST_HEAD(&matches);
+- for (i = 0; i < LOCK_HASH_SIZE; i++) {
+- list_for_each_entry(sop, &lock_ownerstr_hashtbl[i], so_strhash) {
+- if (!same_owner_str(sop, owner, clid))
+- continue;
+- list_for_each_entry(stp, &sop->so_stateids,
+- st_perstateowner) {
+- lo = lockowner(sop);
+- if (check_for_locks(stp->st_file, lo))
+- goto out;
+- list_add(&lo->lo_list, &matches);
+- }
++
++ list_for_each_entry(sop, &lock_ownerstr_hashtbl[hashval], so_strhash) {
++ if (!same_owner_str(sop, owner, clid))
++ continue;
++ list_for_each_entry(stp, &sop->so_stateids,
++ st_perstateowner) {
++ lo = lockowner(sop);
++ if (check_for_locks(stp->st_file, lo))
++ goto out;
++ list_add(&lo->lo_list, &matches);
+ }
+ }
+ /* Clients probably won't expect us to return with some (but not all)
Added: dists/wheezy/linux/debian/patches/bugfix/all/nfsd4-maintain-one-seqid-stream-per-lockowner-file.patch
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ dists/wheezy/linux/debian/patches/bugfix/all/nfsd4-maintain-one-seqid-stream-per-lockowner-file.patch Sat Jun 8 16:28:11 2013 (r20206)
@@ -0,0 +1,111 @@
+From: "J. Bruce Fields" <bfields at redhat.com>
+Date: Thu, 20 Oct 2011 06:57:46 -0400
+Subject: nfsd4: maintain one seqid stream per (lockowner, file)
+
+commit 64a284d07c7d84299a90826950079a8ef11e8204 upstream.
+
+Instead of creating a new lockowner and stateid for every
+open_to_lockowner call, reuse the existing lockowner if it exists.
+
+Reported-by: Trond Myklebust <Trond.Myklebust at netapp.com>
+Signed-off-by: J. Bruce Fields <bfields at redhat.com>
+---
+ fs/nfsd/nfs4state.c | 58 +++++++++++++++++++++++++++++++++------------------
+ 1 file changed, 38 insertions(+), 20 deletions(-)
+
+--- a/fs/nfsd/nfs4state.c
++++ b/fs/nfsd/nfs4state.c
+@@ -3902,6 +3902,37 @@ static void get_lock_access(struct nfs4_
+ __set_bit(access, &lock_stp->st_access_bmap);
+ }
+
++__be32 lookup_or_create_lock_state(struct nfsd4_compound_state *cstate, struct nfs4_ol_stateid *ost, struct nfsd4_lock *lock, struct nfs4_ol_stateid **lst, bool *new)
++{
++ struct nfs4_file *fi = ost->st_file;
++ struct nfs4_openowner *oo = openowner(ost->st_stateowner);
++ struct nfs4_client *cl = oo->oo_owner.so_client;
++ struct nfs4_lockowner *lo;
++ unsigned int strhashval;
++
++ lo = find_lockowner_str(fi->fi_inode, &cl->cl_clientid, &lock->v.new.owner);
++ if (lo) {
++ if (!cstate->minorversion)
++ return nfserr_bad_seqid;
++ /* XXX: a lockowner always has exactly one stateid: */
++ *lst = list_first_entry(&lo->lo_owner.so_stateids,
++ struct nfs4_ol_stateid, st_perstateowner);
++ return nfs_ok;
++ }
++ strhashval = lock_ownerstr_hashval(fi->fi_inode, cl->cl_clientid.cl_id,
++ &lock->v.new.owner);
++ lo = alloc_init_lock_stateowner(strhashval, cl, ost, lock);
++ if (lo == NULL)
++ return nfserr_jukebox;
++ *lst = alloc_init_lock_stateid(lo, fi, ost);
++ if (*lst == NULL) {
++ release_lockowner(lo);
++ return nfserr_jukebox;
++ }
++ *new = true;
++ return nfs_ok;
++}
++
+ /*
+ * LOCK operation
+ */
+@@ -3917,7 +3948,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struc
+ struct file_lock file_lock;
+ struct file_lock conflock;
+ __be32 status = 0;
+- unsigned int strhashval;
++ bool new_state = false;
+ int lkflg;
+ int err;
+
+@@ -3962,21 +3993,9 @@ nfsd4_lock(struct svc_rqst *rqstp, struc
+ !same_clid(&open_sop->oo_owner.so_client->cl_clientid,
+ &lock->v.new.clientid))
+ goto out;
+- /* create lockowner and lock stateid */
+- fp = open_stp->st_file;
+- strhashval = lock_ownerstr_hashval(fp->fi_inode,
+- open_sop->oo_owner.so_client->cl_clientid.cl_id,
+- &lock->v.new.owner);
+- /* XXX: Do we need to check for duplicate stateowners on
+- * the same file, or should they just be allowed (and
+- * create new stateids)? */
+- status = nfserr_jukebox;
+- lock_sop = alloc_init_lock_stateowner(strhashval,
+- open_sop->oo_owner.so_client, open_stp, lock);
+- if (lock_sop == NULL)
+- goto out;
+- lock_stp = alloc_init_lock_stateid(lock_sop, fp, open_stp);
+- if (lock_stp == NULL)
++ status = lookup_or_create_lock_state(cstate, open_stp, lock,
++ &lock_stp, &new_state);
++ if (status)
+ goto out;
+ } else {
+ /* lock (lock owner + lock stateid) already exists */
+@@ -3986,10 +4005,9 @@ nfsd4_lock(struct svc_rqst *rqstp, struc
+ NFS4_LOCK_STID, &lock_stp);
+ if (status)
+ goto out;
+- lock_sop = lockowner(lock_stp->st_stateowner);
+- fp = lock_stp->st_file;
+ }
+- /* lock_sop and lock_stp have been created or found */
++ lock_sop = lockowner(lock_stp->st_stateowner);
++ fp = lock_stp->st_file;
+
+ lkflg = setlkflg(lock->lk_type);
+ status = nfs4_check_openmode(lock_stp, lkflg);
+@@ -4064,7 +4082,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struc
+ break;
+ }
+ out:
+- if (status && lock->lk_is_new && lock_sop)
++ if (status && new_state)
+ release_lockowner(lock_sop);
+ if (!cstate->replay_owner)
+ nfs4_unlock_state();
Modified: dists/wheezy/linux/debian/patches/series
==============================================================================
--- dists/wheezy/linux/debian/patches/series Sat Jun 8 16:24:46 2013 (r20205)
+++ dists/wheezy/linux/debian/patches/series Sat Jun 8 16:28:11 2013 (r20206)
@@ -637,3 +637,5 @@
bugfix/all/ath9k-Disable-PowerSave-by-default.patch
bugfix/all/sctp-Export-sctp_do_peeloff.patch
bugfix/all/dlm-Do-not-allocate-a-fd-for-peeloff.patch
+bugfix/all/nfsd4-maintain-one-seqid-stream-per-lockowner-file.patch
+bugfix/all/nfsd4-hash-lockowners-to-simplify-RELEASE_LOCKOWNER.patch
More information about the Kernel-svn-changes
mailing list