c870ae8
Bugzilla: N/A
c870ae8
Upstream-status: queued in NFS git tree (for 3.13/3.14?)
6142d53
6142d53
Now that we have a more reliable method to tell if gssd is running, we
6142d53
can replace the sn->gssd_running flag with a function that will query to
6142d53
see if it's up and running.
6142d53
6142d53
There's also no need to attempt an upcall that we know will fail, so
6142d53
just return -EACCES if gssd isn't running. Finally, fix the warn_gss()
6142d53
message not to claim that that the upcall timed out since we don't
6142d53
necesarily perform one now when gssd isn't running, and remove the
6142d53
extraneous newline from the message.
6142d53
6142d53
Signed-off-by: Jeff Layton <jlayton@redhat.com>
6142d53
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
6142d53
---
bdb12fe
 Fixed up to apply to 3.12.1 by Josh Boyer <jwboyer@fedoraproject.org>
bdb12fe
6142d53
 include/linux/sunrpc/rpc_pipe_fs.h |    2 ++
6142d53
 net/sunrpc/auth_gss/auth_gss.c     |   17 +++++++----------
6142d53
 net/sunrpc/netns.h                 |    2 --
6142d53
 net/sunrpc/rpc_pipe.c              |   14 ++++++++++----
6142d53
 4 files changed, 19 insertions(+), 16 deletions(-)
6142d53
bdb12fe
diff --git a/include/linux/sunrpc/rpc_pipe_fs.h b/include/linux/sunrpc/rpc_pipe_fs.h
bdb12fe
index 85f1342..7f490be 100644
bdb12fe
--- a/include/linux/sunrpc/rpc_pipe_fs.h
bdb12fe
+++ b/include/linux/sunrpc/rpc_pipe_fs.h
bdb12fe
@@ -131,5 +131,7 @@ extern int rpc_unlink(struct dentry *);
6142d53
 extern int register_rpc_pipefs(void);
6142d53
 extern void unregister_rpc_pipefs(void);
6142d53
 
6142d53
+extern bool gssd_running(struct net *net);
6142d53
+
6142d53
 #endif
6142d53
 #endif
bdb12fe
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
bdb12fe
index 0846566..1ada878 100644
bdb12fe
--- a/net/sunrpc/auth_gss/auth_gss.c
bdb12fe
+++ b/net/sunrpc/auth_gss/auth_gss.c
bdb12fe
@@ -517,8 +517,7 @@ static void warn_gssd(void)
6142d53
 	unsigned long now = jiffies;
6142d53
 
6142d53
 	if (time_after(now, ratelimit)) {
6142d53
-		printk(KERN_WARNING "RPC: AUTH_GSS upcall timed out.\n"
6142d53
-				"Please check user daemon is running.\n");
6142d53
+		pr_warn("RPC: AUTH_GSS upcall failed. Please check user daemon is running.\n");
6142d53
 		ratelimit = now + 15*HZ;
6142d53
 	}
6142d53
 }
bdb12fe
@@ -581,7 +580,6 @@ gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred)
6142d53
 	struct rpc_pipe *pipe;
6142d53
 	struct rpc_cred *cred = &gss_cred->gc_base;
6142d53
 	struct gss_upcall_msg *gss_msg;
6142d53
-	unsigned long timeout;
6142d53
 	DEFINE_WAIT(wait);
6142d53
 	int err;
6142d53
 
bdb12fe
@@ -589,17 +587,16 @@ gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred)
6142d53
 		__func__, from_kuid(&init_user_ns, cred->cr_uid));
6142d53
 retry:
6142d53
 	err = 0;
6142d53
-	/* Default timeout is 15s unless we know that gssd is not running */
6142d53
-	timeout = 15 * HZ;
6142d53
-	if (!sn->gssd_running)
6142d53
-		timeout = HZ >> 2;
6142d53
+	/* if gssd is down, just skip upcalling altogether */
6142d53
+	if (!gssd_running(net)) {
6142d53
+		warn_gssd();
6142d53
+		return -EACCES;
6142d53
+	}
bdb12fe
 	gss_msg = gss_setup_upcall(gss_auth, cred);
6142d53
 	if (PTR_ERR(gss_msg) == -EAGAIN) {
6142d53
 		err = wait_event_interruptible_timeout(pipe_version_waitqueue,
6142d53
-				sn->pipe_version >= 0, timeout);
6142d53
+				sn->pipe_version >= 0, 15 * HZ);
6142d53
 		if (sn->pipe_version < 0) {
6142d53
-			if (err == 0)
6142d53
-				sn->gssd_running = 0;
6142d53
 			warn_gssd();
6142d53
 			err = -EACCES;
6142d53
 		}
bdb12fe
diff --git a/net/sunrpc/netns.h b/net/sunrpc/netns.h
bdb12fe
index 8a8e841..94e506f 100644
bdb12fe
--- a/net/sunrpc/netns.h
bdb12fe
+++ b/net/sunrpc/netns.h
6142d53
@@ -33,8 +33,6 @@ struct sunrpc_net {
6142d53
 	int pipe_version;
6142d53
 	atomic_t pipe_users;
6142d53
 	struct proc_dir_entry *use_gssp_proc;
6142d53
-
6142d53
-	unsigned int gssd_running;
6142d53
 };
6142d53
 
6142d53
 extern int sunrpc_net_id;
bdb12fe
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
bdb12fe
index 40aef18..ad444f3 100644
bdb12fe
--- a/net/sunrpc/rpc_pipe.c
bdb12fe
+++ b/net/sunrpc/rpc_pipe.c
6142d53
@@ -216,14 +216,11 @@ rpc_destroy_inode(struct inode *inode)
6142d53
 static int
6142d53
 rpc_pipe_open(struct inode *inode, struct file *filp)
6142d53
 {
6142d53
-	struct net *net = inode->i_sb->s_fs_info;
6142d53
-	struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
6142d53
 	struct rpc_pipe *pipe;
6142d53
 	int first_open;
6142d53
 	int res = -ENXIO;
6142d53
 
6142d53
 	mutex_lock(&inode->i_mutex);
6142d53
-	sn->gssd_running = 1;
6142d53
 	pipe = RPC_I(inode)->pipe;
6142d53
 	if (pipe == NULL)
6142d53
 		goto out;
bdb12fe
@@ -1231,7 +1228,6 @@ int rpc_pipefs_init_net(struct net *net)
6142d53
 		return PTR_ERR(sn->gssd_dummy);
6142d53
 
6142d53
 	mutex_init(&sn->pipefs_sb_lock);
6142d53
-	sn->gssd_running = 1;
6142d53
 	sn->pipe_version = -1;
6142d53
 	return 0;
6142d53
 }
bdb12fe
@@ -1385,6 +1381,16 @@ err_depopulate:
6142d53
 	return err;
6142d53
 }
6142d53
 
6142d53
+bool
6142d53
+gssd_running(struct net *net)
6142d53
+{
6142d53
+	struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
6142d53
+	struct rpc_pipe *pipe = sn->gssd_dummy;
6142d53
+
6142d53
+	return pipe->nreaders || pipe->nwriters;
6142d53
+}
6142d53
+EXPORT_SYMBOL_GPL(gssd_running);
6142d53
+
6142d53
 static struct dentry *
6142d53
 rpc_mount(struct file_system_type *fs_type,
6142d53
 		int flags, const char *dev_name, void *data)