Index: trunk/server/common/patches/openafs-TryEvictVCache-crash.patch
===================================================================
--- trunk/server/common/patches/openafs-TryEvictVCache-crash.patch	(revision 2636)
+++ 	(revision )
@@ -1,88 +1,0 @@
-From eafc370c0eba7949d85547ebc27574aa106d3355 Mon Sep 17 00:00:00 2001
-From: Anders Kaseorg <andersk@mit.edu>
-Date: Tue, 7 May 2013 00:27:33 -0400
-Subject: [PATCH] =?UTF-8?q?Linux:=20osi=5FTryEvictVCache:=20Don=E2=80=99t?=
- =?UTF-8?q?=20skip=20the=20first=20dentry=20if=20D=5FALIAS=5FIS=5FHLIST?=
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-An hlist doesn’t begin with a sentinel like a list does, so the old
-code would skip the first dentry or crash with a NULL dereference if
-there wasn’t one.  Use the kernel’s list_for_each_entry or
-hlist_for_each_entry macros instead of trying to do it manually.
-
-Should fix a crash observed by Alex Chernyakhovsky on kernel 3.6 and
-newer.
-
-Change-Id: I6d7bd190013a0250ca896af8d5182df55a3376b0
-Signed-off-by: Anders Kaseorg <andersk@mit.edu>
----
- src/afs/LINUX/osi_vcache.c | 30 +++++++++---------------------
- 1 file changed, 9 insertions(+), 21 deletions(-)
-
-diff --git a/src/afs/LINUX/osi_vcache.c b/src/afs/LINUX/osi_vcache.c
-index dc3685b..99aab91 100644
---- a/src/afs/LINUX/osi_vcache.c
-+++ b/src/afs/LINUX/osi_vcache.c
-@@ -19,10 +19,8 @@ osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
- 
-     struct dentry *dentry;
-     struct inode *inode = AFSTOV(avc);
--#if defined(D_ALIAS_IS_HLIST)
--    struct hlist_node *cur, *head, *list_end;
--#else
--    struct list_head *cur, *head, *list_end;
-+#if defined(D_ALIAS_IS_HLIST) && !defined(HLIST_ITERATOR_NO_NODE)
-+    struct hlist_node *p;
- #endif
- 
-     /* First, see if we can evict the inode from the dcache */
-@@ -33,13 +31,9 @@ osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
- 
- #if defined(HAVE_DCACHE_LOCK)
-         spin_lock(&dcache_lock);
--	head = &inode->i_dentry;
- 
- restart:
--        cur = head;
--	while ((cur = cur->next) != head) {
--	    dentry = list_entry(cur, struct dentry, d_alias);
--
-+	list_for_each_entry(dentry, &inode->i_dentry, d_alias) {
- 	    if (d_unhashed(dentry))
- 		continue;
- 	    dget_locked(dentry);
-@@ -57,23 +51,17 @@ restart:
- 	spin_unlock(&dcache_lock);
- #else /* HAVE_DCACHE_LOCK */
- 	spin_lock(&inode->i_lock);
--#if defined(D_ALIAS_IS_HLIST)
--	head = inode->i_dentry.first;
--	list_end = NULL;
--#else
--	head = &inode->i_dentry;
--	list_end = head;
--#endif
- 
- restart:
--	cur = head;
--	while ((cur = cur->next) != list_end) {
- #if defined(D_ALIAS_IS_HLIST)
--	    dentry = hlist_entry(cur, struct dentry, d_alias);
-+# if defined(HLIST_ITERATOR_NO_NODE)
-+	hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) {
-+# else
-+	hlist_for_each_entry(dentry, p, &inode->i_dentry, d_alias) {
-+# endif
- #else
--	    dentry = list_entry(cur, struct dentry, d_alias);
-+	list_for_each_entry(dentry, &inode->i_dentry, d_alias) {
- #endif
--
- 	    spin_lock(&dentry->d_lock);
- 	    if (d_unhashed(dentry)) {
- 		spin_unlock(&dentry->d_lock);
--- 
-1.8.3.rc1
-
Index: trunk/server/common/patches/openafs-afs_lookup-return.patch
===================================================================
--- trunk/server/common/patches/openafs-afs_lookup-return.patch	(revision 2637)
+++ trunk/server/common/patches/openafs-afs_lookup-return.patch	(revision 2637)
@@ -0,0 +1,66 @@
+From 100e35ed19e2c255986cb330b0f56f706acc6e7b Mon Sep 17 00:00:00 2001
+From: Andrew Deason <adeason@sinenomine.net>
+Date: Thu, 24 Jul 2014 11:07:45 -0500
+Subject: [PATCH] LINUX: Check afs_lookup return code explicitly
+
+Checking if the returned vcache is NULL or not is a bit of an indirect
+way to check if an error occurred. Just check the return code itself,
+to make sure we notice if any kind of error is reported.
+
+Suggested by Chas Williams.
+
+Reviewed-on: http://gerrit.openafs.org/11321
+Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
+Tested-by: BuildBot <buildbot@rampaginggeek.com>
+Reviewed-by: D Brashear <shadow@your-file-system.com>
+(cherry picked from commit 2edf5c0382385f898a017fd8e0e2429f8b2b3520)
+
+Change-Id: I7e123ab1cf88570a6b18e438e01409ed7804e014
+---
+ src/afs/LINUX/osi_vnodeops.c | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c
+index 7e5cdd1..9ed6f01 100644
+--- a/src/afs/LINUX/osi_vnodeops.c
++++ b/src/afs/LINUX/osi_vnodeops.c
+@@ -943,6 +943,7 @@ check_bad_parent(struct dentry *dp)
+     cred_t *credp;
+     struct dentry *parent;
+     struct vcache *vcp, *pvc, *avc = NULL;
++    int code;
+ 
+     vcp = VTOAFS(dp->d_inode);
+     parent = dget_parent(dp);
+@@ -952,8 +953,8 @@ check_bad_parent(struct dentry *dp)
+ 	credp = crref();
+ 
+ 	/* force a lookup, so vcp->mvid is fixed up */
+-	afs_lookup(pvc, (char *)dp->d_name.name, &avc, credp);
+-	if (!avc || vcp != avc) {	/* bad, very bad.. */
++	code = afs_lookup(pvc, (char *)dp->d_name.name, &avc, credp);
++	if (code || vcp != avc) {	/* bad, very bad.. */
+ 	    afs_Trace4(afs_iclSetp, CM_TRACE_TMP_1S3L, ICL_TYPE_STRING,
+ 		       "check_bad_parent: bad pointer returned from afs_lookup origvc newvc dentry",
+ 		       ICL_TYPE_POINTER, vcp, ICL_TYPE_POINTER, avc,
+@@ -1233,7 +1234,7 @@ afs_linux_dentry_revalidate(struct dentry *dp, int flags)
+ 
+ 	    credp = crref();
+ 	    code = afs_lookup(pvcp, (char *)dp->d_name.name, &tvc, credp);
+-	    if (!tvc || tvc != vcp) {
++	    if (code || tvc != vcp) {
+ 		dput(parent);
+ 		/* Force unhash; the name doesn't point to this file
+ 		 * anymore. */
+@@ -1478,7 +1479,7 @@ afs_linux_lookup(struct inode *dip, struct dentry *dp)
+     AFS_GLOCK();
+     code = afs_lookup(VTOAFS(dip), (char *)comp, &vcp, credp);
+     
+-    if (vcp) {
++    if (!code) {
+ 	struct vattr *vattr = NULL;
+ 	struct vcache *parent_vc = VTOAFS(dip);
+ 
+-- 
+2.1.2
+
Index: trunk/server/common/patches/openafs-d_revalidate-mtpt.patch
===================================================================
--- trunk/server/common/patches/openafs-d_revalidate-mtpt.patch	(revision 2637)
+++ trunk/server/common/patches/openafs-d_revalidate-mtpt.patch	(revision 2637)
@@ -0,0 +1,92 @@
+From c9bbebe869acadd61abfa50656447429cde18aaf Mon Sep 17 00:00:00 2001
+From: Andrew Deason <adeason@sinenomine.net>
+Date: Tue, 28 Oct 2014 00:10:56 -0500
+Subject: [PATCH] LINUX: Avoid d_revalidate failure on mtpt mismatch
+
+Currently, if afs_linux_dentry_revalidate is given an inode that
+corresponds to a mtpt vcache ('vcp'), it resolves the mtpt to its root
+dir if it's easy to do so (mvid and CMValid are set). Later on, we run
+afs_lookup to see if looking up our dentry's name returns the same
+vcache that we got; afs_lookup presumably will also resolve the mtpt
+if it's easy to do so.
+
+However, it is possible that afs_linux_dentry_revalidate and
+afs_lookup will make different decisions as to whether or not they
+resolve a mtpt to a dir. Specifically, if CMValid is cleared after
+afs_linux_dentry_revalidate checks for it, but before afs_lookup does,
+then afs_lookup will return a different vcache than
+afs_linux_dentry_revalidate is expecting, even though the relevant
+directory entry has not changed. That is, tvc is not equal to vcp, but
+tvc could be a mtpt that resolves to vcp, or vice versa. CMValid can
+be cleared by another thread at virtually any time, since this is
+cleared in some situations when we're not sure if the mtpt resolution
+is still valid (callbacks are broken, vldb cache entries expire, etc).
+
+afs_linux_dentry_revalidate interprets this situation to mean that the
+directory entry has changed, and so it eventually d_drop's the
+associated dentry. The way that this manifests to users is that a
+"fakestatted" mtpt can appear to be deleted effectively randomly, even
+when nothing has changed. This can be a problem because this causes
+the getcwd() syscall to return ENOENT when the working directory
+involves such an affected directory.
+
+To fix this situation, we just detect if afs_lookup returned either
+'vcp' (our possibly-resolved vcache), or the original inode associated
+with the dentry we are revalidating. If the returned vcache matches
+either of these, then the entry is okay and we don't need to
+invalidate or drop anything.
+
+FIXES 131780
+
+Change-Id: Ide1dd224d1ea1e29a82eb7130a010877cf4e9fc7
+(cherry picked from commit 45d9ff86571cbe70fedd524266fac50bd2d4bc2d)
+---
+ src/afs/LINUX/osi_vnodeops.c | 29 ++++++++++++++++++++++++++++-
+ 1 file changed, 28 insertions(+), 1 deletion(-)
+
+diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c
+index 9ed6f01..8c63f96 100644
+--- a/src/afs/LINUX/osi_vnodeops.c
++++ b/src/afs/LINUX/osi_vnodeops.c
+@@ -1231,10 +1231,37 @@ afs_linux_dentry_revalidate(struct dentry *dp, int flags)
+ 	if (hgetlo(pvcp->f.m.DataVersion) > dp->d_time || !(vcp->f.states & CStatd)) {
+ 	    struct vattr *vattr = NULL;
+ 	    int code;
++	    int lookup_good;
+ 
+ 	    credp = crref();
+ 	    code = afs_lookup(pvcp, (char *)dp->d_name.name, &tvc, credp);
+-	    if (code || tvc != vcp) {
++
++	    if (code) {
++		/* We couldn't perform the lookup, so we're not okay. */
++		lookup_good = 0;
++
++	    } else if (tvc == vcp) {
++		/* We got back the same vcache, so we're good. */
++		lookup_good = 1;
++
++	    } else if (tvc == VTOAFS(dp->d_inode)) {
++		/* We got back the same vcache, so we're good. This is
++		 * different from the above case, because sometimes 'vcp' is
++		 * not the same as the vcache for dp->d_inode, if 'vcp' was a
++		 * mtpt and we evaluated it to a root dir. In rare cases,
++		 * afs_lookup might not evalute the mtpt when we do, or vice
++		 * versa, so the previous case will not succeed. But this is
++		 * still 'correct', so make sure not to mark the dentry as
++		 * invalid; it still points to the same thing! */
++		lookup_good = 1;
++
++	    } else {
++		/* We got back a different file, so we're definitely not
++		 * okay. */
++		lookup_good = 0;
++	    }
++
++	    if (!lookup_good) {
+ 		dput(parent);
+ 		/* Force unhash; the name doesn't point to this file
+ 		 * anymore. */
+-- 
+2.1.2
+
Index: trunk/server/common/patches/openafs-revert-d_drop-new-file.patch
===================================================================
--- trunk/server/common/patches/openafs-revert-d_drop-new-file.patch	(revision 2636)
+++ 	(revision )
@@ -1,47 +1,0 @@
-From 88f51eecfc5a5edb92b252b202c24e54298fe129 Mon Sep 17 00:00:00 2001
-From: Anders Kaseorg <andersk@mit.edu>
-Date: Sun, 12 Oct 2014 22:21:40 -0400
-Subject: [PATCH] Revert "LINUX: Drop dentry if lookup returns new file" and
- log differences
-
-This effectively reverts commit
-81f1814b566cb3b1cda97be4c48b9788cd7addd0, and adds a warning message
-whenever it would have taken effect.
-
-Change-Id: If470195b1eeb23d33693ade8d6fc79e903663529
----
- src/afs/LINUX/osi_vnodeops.c | 18 ++++++++++++++++++
- 1 file changed, 18 insertions(+)
-
-diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c
-index 2a8253e..e22f62a 100644
---- a/src/afs/LINUX/osi_vnodeops.c
-+++ b/src/afs/LINUX/osi_vnodeops.c
-@@ -1253,6 +1253,24 @@ afs_linux_dentry_revalidate(struct dentry *dp, int flags)
- 		     * we don't know if the name points to this file or not. */
- 		    force_drop = 0;
- 		}
-+		if (force_drop && tvc && tvc != vcp &&
-+		    !(dp->d_inode && S_ISREG(dp->d_inode->i_mode))) {
-+		    /* workaround and logging for GCO RT 131780 */
-+		    char buf[256];
-+		    char *path = dentry_path_raw(dp, buf, sizeof(buf));
-+		    afs_warn("afs: RT 131780: got back a different vcache for /afs%s: "
-+			     "vcp: %u.%u.%u mvstat %d, tvc: %u.%u.%u mvstat %d\n",
-+			     IS_ERR(path) ? "/(bad path)" : path,
-+			     (unsigned)vcp->f.fid.Fid.Volume,
-+			     (unsigned)vcp->f.fid.Fid.Vnode,
-+			     (unsigned)vcp->f.fid.Fid.Unique,
-+			     (int)vcp->mvstat,
-+			     (unsigned)tvc->f.fid.Fid.Volume,
-+			     (unsigned)tvc->f.fid.Fid.Vnode,
-+			     (unsigned)tvc->f.fid.Fid.Unique,
-+			     (int)tvc->mvstat);
-+		    force_drop = 0;
-+		}
- 		goto bad_dentry;
- 	    }
- 
--- 
-2.1.2
-
Index: trunk/server/fedora/Makefile
===================================================================
--- trunk/server/fedora/Makefile	(revision 2636)
+++ trunk/server/fedora/Makefile	(revision 2637)
@@ -41,5 +41,5 @@
 
 dload		= ${PWD}/.dload
-openafs_url	= "https://www.openafs.org/dl/openafs/candidate/1.6.10pre1/openafs-1.6.10-0.pre1.src.rpm"
+openafs_url	= "https://www.openafs.org/dl/openafs/1.6.10/openafs-1.6.10-2.src.rpm"
 #zephyr_url	= "http://zephyr.1ts.org/files/zephyr-3.0.2.tar.gz"
 
Index: trunk/server/fedora/specs/openafs.spec.patch
===================================================================
--- trunk/server/fedora/specs/openafs.spec.patch	(revision 2636)
+++ trunk/server/fedora/specs/openafs.spec.patch	(revision 2637)
@@ -5,10 +5,10 @@
  # for beta/rc releases make pkgrel 0.<tag>
  # for real releases make pkgrel 1 (or more for extra releases)
--%define pkgrel 0.pre1
-+%define pkgrel 0.pre1.99.scripts.%{scriptsversion}
+-%define pkgrel 2
++%define pkgrel 2.99.scripts.%{scriptsversion}
  
  %{!?fedorakmod: %define fedorakmod 1}
  %{!?build_dkmspkg: %define build_dkmspkg 1}
-@@ -249,9 +249,16 @@
+@@ -249,9 +249,17 @@
  %if %{build_modules}
  BuildRequires: kernel-devel
@@ -21,5 +21,6 @@
 +Patch1002: openafs-systemd-crond.patch
 +Patch1003: openafs-systemd-csdb.patch
-+Patch1004: openafs-revert-d_drop-new-file.patch
++Patch1004: openafs-afs_lookup-return.patch
++Patch1005: openafs-d_revalidate-mtpt.patch
 +%define _default_patch_fuzz 2
 +
@@ -92,5 +93,5 @@
  %else
  
-@@ -698,6 +712,12 @@
+@@ -698,6 +712,13 @@
  #%setup -q -n %{srcdir}
  %setup -q -b 1 -n %{srcdir}
@@ -100,5 +101,6 @@
 +%patch1002 -p1 -b .systemd-crond
 +%patch1003 -p1 -b .systemd-csdb
-+%patch1004 -p1 -b .revert-d_drop-new-file
++%patch1004 -p1 -b .afs_lookup-return
++%patch1005 -p1 -b ._revalidate-mtpt
 +
  ##############################################################################
