File 0006-Perform-recovery-on-both-inodes-for-rename.patch of Package vfh-kernel-test

From ee9db43d5ce3bb4ba756568efb4dd8917c6b97b2 Mon Sep 17 00:00:00 2001
From: Matthew Treinish <treinish@linux.vnet.ibm.com>
Date: Fri, 11 Nov 2011 15:22:23 -0500
Subject: [PATCH/RFC 6/7] Perform recovery on both inodes for rename.

Rename is a special case because it passes 2 file handles to the server. If the
server replies with NFS4ERR_FHEXPIRED we can't tell which of the to file handles
are expired.

To remedy this, on receiving FHEXPIRED, rename will first call
nfs4_fhexpired_recovery() with the old_dir inode. If this succeeds it will then
call nfs4_fhexpired_recovery() with the new_dir inode. This will bypass
nfs4_handle_exception() on FHEXPIRED errors for renames. Allow us to run
recovery on each of the inodes.

Signed-off-by: Matthew Treinish <treinish@linux.vnet.ibm.com>
---
 fs/nfs/nfs4proc.c |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 50bb823..ebc5ee9 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2907,13 +2907,26 @@ out:
 static int nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name,
 		struct inode *new_dir, struct qstr *new_name)
 {
-	struct nfs4_exception exception = { };
+	struct nfs4_exception exception = {
+		.inode = old_dir,
+		.dentry = NULL,
+	};
 	int err;
 	do {
-		err = nfs4_handle_exception(NFS_SERVER(old_dir),
-				_nfs4_proc_rename(old_dir, old_name,
-					new_dir, new_name),
-				&exception);
+		err = _nfs4_proc_rename(old_dir, old_name, new_dir, new_name);
+		if (err == -NFS4ERR_FHEXPIRED) {
+			err = nfs4_fhexpired_recovery(NFS_SERVER(old_dir),
+					&exception);
+			if (err == -EAGAIN) {
+				exception.inode = new_dir;
+				err = nfs4_fhexpired_recovery(
+						NFS_SERVER(old_dir),
+						&exception);
+			}
+			return err;
+		}
+		err = nfs4_handle_exception(NFS_SERVER(old_dir), err,
+					&exception);
 	} while (exception.retry);
 	return err;
 }
-- 
1.7.4.4