Commit 89f84243 authored by Jeff Layton's avatar Jeff Layton Committed by Trond Myklebust

sunrpc: replace sunrpc_net->gssd_running flag with a more reliable check

Now that we have a more reliable method to tell if gssd is running, we
can replace the sn->gssd_running flag with a function that will query to
see if it's up and running.

There's also no need to attempt an upcall that we know will fail, so
just return -EACCES if gssd isn't running. Finally, fix the warn_gss()
message not to claim that that the upcall timed out since we don't
necesarily perform one now when gssd isn't running, and remove the
extraneous newline from the message.
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 4b9a445e
...@@ -131,5 +131,7 @@ extern int rpc_unlink(struct dentry *); ...@@ -131,5 +131,7 @@ extern int rpc_unlink(struct dentry *);
extern int register_rpc_pipefs(void); extern int register_rpc_pipefs(void);
extern void unregister_rpc_pipefs(void); extern void unregister_rpc_pipefs(void);
extern bool gssd_running(struct net *net);
#endif #endif
#endif #endif
...@@ -536,8 +536,7 @@ static void warn_gssd(void) ...@@ -536,8 +536,7 @@ static void warn_gssd(void)
unsigned long now = jiffies; unsigned long now = jiffies;
if (time_after(now, ratelimit)) { if (time_after(now, ratelimit)) {
printk(KERN_WARNING "RPC: AUTH_GSS upcall timed out.\n" pr_warn("RPC: AUTH_GSS upcall failed. Please check user daemon is running.\n");
"Please check user daemon is running.\n");
ratelimit = now + 15*HZ; ratelimit = now + 15*HZ;
} }
} }
...@@ -600,7 +599,6 @@ gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred) ...@@ -600,7 +599,6 @@ gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred)
struct rpc_pipe *pipe; struct rpc_pipe *pipe;
struct rpc_cred *cred = &gss_cred->gc_base; struct rpc_cred *cred = &gss_cred->gc_base;
struct gss_upcall_msg *gss_msg; struct gss_upcall_msg *gss_msg;
unsigned long timeout;
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
int err; int err;
...@@ -608,17 +606,16 @@ gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred) ...@@ -608,17 +606,16 @@ gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred)
__func__, from_kuid(&init_user_ns, cred->cr_uid)); __func__, from_kuid(&init_user_ns, cred->cr_uid));
retry: retry:
err = 0; err = 0;
/* Default timeout is 15s unless we know that gssd is not running */ /* if gssd is down, just skip upcalling altogether */
timeout = 15 * HZ; if (!gssd_running(net)) {
if (!sn->gssd_running) warn_gssd();
timeout = HZ >> 2; return -EACCES;
}
gss_msg = gss_setup_upcall(gss_auth, cred); gss_msg = gss_setup_upcall(gss_auth, cred);
if (PTR_ERR(gss_msg) == -EAGAIN) { if (PTR_ERR(gss_msg) == -EAGAIN) {
err = wait_event_interruptible_timeout(pipe_version_waitqueue, err = wait_event_interruptible_timeout(pipe_version_waitqueue,
sn->pipe_version >= 0, timeout); sn->pipe_version >= 0, 15 * HZ);
if (sn->pipe_version < 0) { if (sn->pipe_version < 0) {
if (err == 0)
sn->gssd_running = 0;
warn_gssd(); warn_gssd();
err = -EACCES; err = -EACCES;
} }
......
...@@ -33,8 +33,6 @@ struct sunrpc_net { ...@@ -33,8 +33,6 @@ struct sunrpc_net {
int pipe_version; int pipe_version;
atomic_t pipe_users; atomic_t pipe_users;
struct proc_dir_entry *use_gssp_proc; struct proc_dir_entry *use_gssp_proc;
unsigned int gssd_running;
}; };
extern int sunrpc_net_id; extern int sunrpc_net_id;
......
...@@ -216,14 +216,11 @@ rpc_destroy_inode(struct inode *inode) ...@@ -216,14 +216,11 @@ rpc_destroy_inode(struct inode *inode)
static int static int
rpc_pipe_open(struct inode *inode, struct file *filp) rpc_pipe_open(struct inode *inode, struct file *filp)
{ {
struct net *net = inode->i_sb->s_fs_info;
struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
struct rpc_pipe *pipe; struct rpc_pipe *pipe;
int first_open; int first_open;
int res = -ENXIO; int res = -ENXIO;
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
sn->gssd_running = 1;
pipe = RPC_I(inode)->pipe; pipe = RPC_I(inode)->pipe;
if (pipe == NULL) if (pipe == NULL)
goto out; goto out;
...@@ -1222,7 +1219,6 @@ int rpc_pipefs_init_net(struct net *net) ...@@ -1222,7 +1219,6 @@ int rpc_pipefs_init_net(struct net *net)
return PTR_ERR(sn->gssd_dummy); return PTR_ERR(sn->gssd_dummy);
mutex_init(&sn->pipefs_sb_lock); mutex_init(&sn->pipefs_sb_lock);
sn->gssd_running = 1;
sn->pipe_version = -1; sn->pipe_version = -1;
return 0; return 0;
} }
...@@ -1376,6 +1372,16 @@ rpc_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1376,6 +1372,16 @@ rpc_fill_super(struct super_block *sb, void *data, int silent)
return err; return err;
} }
bool
gssd_running(struct net *net)
{
struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
struct rpc_pipe *pipe = sn->gssd_dummy;
return pipe->nreaders || pipe->nwriters;
}
EXPORT_SYMBOL_GPL(gssd_running);
static struct dentry * static struct dentry *
rpc_mount(struct file_system_type *fs_type, rpc_mount(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data) int flags, const char *dev_name, void *data)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment