c476786
Bugzilla: N/A
c476786
Upstream-status: queued in NFS git tree (for 3.13/3.14?)
7306d34
7306d34
Now that we have a more reliable method to tell if gssd is running, we
7306d34
can replace the sn->gssd_running flag with a function that will query to
7306d34
see if it's up and running.
7306d34
7306d34
There's also no need to attempt an upcall that we know will fail, so
7306d34
just return -EACCES if gssd isn't running. Finally, fix the warn_gss()
7306d34
message not to claim that that the upcall timed out since we don't
7306d34
necesarily perform one now when gssd isn't running, and remove the
7306d34
extraneous newline from the message.
7306d34
7306d34
Signed-off-by: Jeff Layton <jlayton@redhat.com>
7306d34
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
7306d34
---
7306d34
 include/linux/sunrpc/rpc_pipe_fs.h |    2 ++
7306d34
 net/sunrpc/auth_gss/auth_gss.c     |   17 +++++++----------
7306d34
 net/sunrpc/netns.h                 |    2 --
7306d34
 net/sunrpc/rpc_pipe.c              |   14 ++++++++++----
7306d34
 4 files changed, 19 insertions(+), 16 deletions(-)
7306d34
7306d34
diff -up linux-3.11.9-200.fc19.x86_64/include/linux/sunrpc/rpc_pipe_fs.h.orig linux-3.11.9-200.fc19.x86_64/include/linux/sunrpc/rpc_pipe_fs.h
7306d34
--- linux-3.11.9-200.fc19.x86_64/include/linux/sunrpc/rpc_pipe_fs.h.orig	2013-11-21 10:11:17.893026000 -0500
7306d34
+++ linux-3.11.9-200.fc19.x86_64/include/linux/sunrpc/rpc_pipe_fs.h	2013-11-21 10:14:17.709348000 -0500
7306d34
@@ -94,5 +94,7 @@ extern int rpc_unlink(struct dentry *);
7306d34
 extern int register_rpc_pipefs(void);
7306d34
 extern void unregister_rpc_pipefs(void);
7306d34
 
7306d34
+extern bool gssd_running(struct net *net);
7306d34
+
7306d34
 #endif
7306d34
 #endif
7306d34
diff -up linux-3.11.9-200.fc19.x86_64/net/sunrpc/auth_gss/auth_gss.c.orig linux-3.11.9-200.fc19.x86_64/net/sunrpc/auth_gss/auth_gss.c
7306d34
--- linux-3.11.9-200.fc19.x86_64/net/sunrpc/auth_gss/auth_gss.c.orig	2013-09-02 16:46:10.000000000 -0400
7306d34
+++ linux-3.11.9-200.fc19.x86_64/net/sunrpc/auth_gss/auth_gss.c	2013-11-21 10:18:33.681923000 -0500
7306d34
@@ -507,8 +507,7 @@ static void warn_gssd(void)
7306d34
 	unsigned long now = jiffies;
7306d34
 
7306d34
 	if (time_after(now, ratelimit)) {
7306d34
-		printk(KERN_WARNING "RPC: AUTH_GSS upcall timed out.\n"
7306d34
-				"Please check user daemon is running.\n");
7306d34
+		pr_warn("RPC: AUTH_GSS upcall failed. Please check user daemon is running.\n");
7306d34
 		ratelimit = now + 15*HZ;
7306d34
 	}
7306d34
 }
7306d34
@@ -571,7 +570,6 @@ gss_create_upcall(struct gss_auth *gss_a
7306d34
 	struct rpc_pipe *pipe;
7306d34
 	struct rpc_cred *cred = &gss_cred->gc_base;
7306d34
 	struct gss_upcall_msg *gss_msg;
7306d34
-	unsigned long timeout;
7306d34
 	DEFINE_WAIT(wait);
7306d34
 	int err;
7306d34
 
7306d34
@@ -579,17 +577,16 @@ gss_create_upcall(struct gss_auth *gss_a
7306d34
 		__func__, from_kuid(&init_user_ns, cred->cr_uid));
7306d34
 retry:
7306d34
 	err = 0;
7306d34
-	/* Default timeout is 15s unless we know that gssd is not running */
7306d34
-	timeout = 15 * HZ;
7306d34
-	if (!sn->gssd_running)
7306d34
-		timeout = HZ >> 2;
7306d34
+	/* if gssd is down, just skip upcalling altogether */
7306d34
+	if (!gssd_running(net)) {
7306d34
+		warn_gssd();
7306d34
+		return -EACCES;
7306d34
+	}
7306d34
 	gss_msg = gss_setup_upcall(gss_auth->client, gss_auth, cred);
7306d34
 	if (PTR_ERR(gss_msg) == -EAGAIN) {
7306d34
 		err = wait_event_interruptible_timeout(pipe_version_waitqueue,
7306d34
-				sn->pipe_version >= 0, timeout);
7306d34
+				sn->pipe_version >= 0, 15 * HZ);
7306d34
 		if (sn->pipe_version < 0) {
7306d34
-			if (err == 0)
7306d34
-				sn->gssd_running = 0;
7306d34
 			warn_gssd();
7306d34
 			err = -EACCES;
7306d34
 		}
7306d34
diff -up linux-3.11.9-200.fc19.x86_64/net/sunrpc/netns.h.orig linux-3.11.9-200.fc19.x86_64/net/sunrpc/netns.h
7306d34
--- linux-3.11.9-200.fc19.x86_64/net/sunrpc/netns.h.orig	2013-11-21 10:11:17.897029000 -0500
7306d34
+++ linux-3.11.9-200.fc19.x86_64/net/sunrpc/netns.h	2013-11-21 10:14:17.722351000 -0500
7306d34
@@ -33,8 +33,6 @@ struct sunrpc_net {
7306d34
 	int pipe_version;
7306d34
 	atomic_t pipe_users;
7306d34
 	struct proc_dir_entry *use_gssp_proc;
7306d34
-
7306d34
-	unsigned int gssd_running;
7306d34
 };
7306d34
 
7306d34
 extern int sunrpc_net_id;
7306d34
diff -up linux-3.11.9-200.fc19.x86_64/net/sunrpc/rpc_pipe.c.orig linux-3.11.9-200.fc19.x86_64/net/sunrpc/rpc_pipe.c
7306d34
--- linux-3.11.9-200.fc19.x86_64/net/sunrpc/rpc_pipe.c.orig	2013-11-21 10:11:17.903026000 -0500
7306d34
+++ linux-3.11.9-200.fc19.x86_64/net/sunrpc/rpc_pipe.c	2013-11-21 10:14:17.727348000 -0500
7306d34
@@ -216,14 +216,11 @@ rpc_destroy_inode(struct inode *inode)
7306d34
 static int
7306d34
 rpc_pipe_open(struct inode *inode, struct file *filp)
7306d34
 {
7306d34
-	struct net *net = inode->i_sb->s_fs_info;
7306d34
-	struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
7306d34
 	struct rpc_pipe *pipe;
7306d34
 	int first_open;
7306d34
 	int res = -ENXIO;
7306d34
 
7306d34
 	mutex_lock(&inode->i_mutex);
7306d34
-	sn->gssd_running = 1;
7306d34
 	pipe = RPC_I(inode)->pipe;
7306d34
 	if (pipe == NULL)
7306d34
 		goto out;
7306d34
@@ -1082,7 +1079,6 @@ int rpc_pipefs_init_net(struct net *net)
7306d34
 		return PTR_ERR(sn->gssd_dummy);
7306d34
 
7306d34
 	mutex_init(&sn->pipefs_sb_lock);
7306d34
-	sn->gssd_running = 1;
7306d34
 	sn->pipe_version = -1;
7306d34
 	return 0;
7306d34
 }
7306d34
@@ -1236,6 +1232,16 @@ err_depopulate:
7306d34
 	return err;
7306d34
 }
7306d34
 
7306d34
+bool
7306d34
+gssd_running(struct net *net)
7306d34
+{
7306d34
+	struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
7306d34
+	struct rpc_pipe *pipe = sn->gssd_dummy;
7306d34
+
7306d34
+	return pipe->nreaders || pipe->nwriters;
7306d34
+}
7306d34
+EXPORT_SYMBOL_GPL(gssd_running);
7306d34
+
7306d34
 static struct dentry *
7306d34
 rpc_mount(struct file_system_type *fs_type,
7306d34
 		int flags, const char *dev_name, void *data)
7306d34