sunrpc: don't wait for write before allowing reads from use-gss-proxy file

It doesn't make much sense to make reads from this procfile hang. As
far as I can tell, only gssproxy itself will open this file and it
never reads from it. Change it to just give the present setting of
sn->use_gss_proxy without waiting for anything.

Note that we do not want to call use_gss_proxy() in this codepath
since an inopportune read of this file could cause it to be disabled
prematurely.

Cc: stable@vger.kernel.org
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
Jeff Layton 2014-01-04 07:18:03 -05:00 committed by J. Bruce Fields
parent 73ca65904c
commit 1654a04cd7
3 changed files with 2 additions and 34 deletions

View File

@ -137,7 +137,6 @@ void init_gssp_clnt(struct sunrpc_net *sn)
{ {
mutex_init(&sn->gssp_lock); mutex_init(&sn->gssp_lock);
sn->gssp_clnt = NULL; sn->gssp_clnt = NULL;
init_waitqueue_head(&sn->gssp_wq);
} }
int set_gssp_clnt(struct net *net) int set_gssp_clnt(struct net *net)
@ -154,7 +153,6 @@ int set_gssp_clnt(struct net *net)
sn->gssp_clnt = clnt; sn->gssp_clnt = clnt;
} }
mutex_unlock(&sn->gssp_lock); mutex_unlock(&sn->gssp_lock);
wake_up(&sn->gssp_wq);
return ret; return ret;
} }

View File

@ -1295,34 +1295,9 @@ static int set_gss_proxy(struct net *net, int type)
else else
ret = -EBUSY; ret = -EBUSY;
spin_unlock(&use_gssp_lock); spin_unlock(&use_gssp_lock);
wake_up(&sn->gssp_wq);
return ret; return ret;
} }
static inline bool gssp_ready(struct sunrpc_net *sn)
{
switch (sn->use_gss_proxy) {
case -1:
return false;
case 0:
return true;
case 1:
return sn->gssp_clnt;
}
WARN_ON_ONCE(1);
return false;
}
static int wait_for_gss_proxy(struct net *net, struct file *file)
{
struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
if (file->f_flags & O_NONBLOCK && !gssp_ready(sn))
return -EAGAIN;
return wait_event_interruptible(sn->gssp_wq, gssp_ready(sn));
}
static ssize_t write_gssp(struct file *file, const char __user *buf, static ssize_t write_gssp(struct file *file, const char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
@ -1355,16 +1330,12 @@ static ssize_t read_gssp(struct file *file, char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct net *net = PDE_DATA(file_inode(file)); struct net *net = PDE_DATA(file_inode(file));
struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
unsigned long p = *ppos; unsigned long p = *ppos;
char tbuf[10]; char tbuf[10];
size_t len; size_t len;
int ret;
ret = wait_for_gss_proxy(net, file); snprintf(tbuf, sizeof(tbuf), "%d\n", sn->use_gss_proxy);
if (ret)
return ret;
snprintf(tbuf, sizeof(tbuf), "%d\n", use_gss_proxy(net));
len = strlen(tbuf); len = strlen(tbuf);
if (p >= len) if (p >= len)
return 0; return 0;

View File

@ -26,7 +26,6 @@ struct sunrpc_net {
unsigned int rpcb_is_af_local : 1; unsigned int rpcb_is_af_local : 1;
struct mutex gssp_lock; struct mutex gssp_lock;
wait_queue_head_t gssp_wq;
struct rpc_clnt *gssp_clnt; struct rpc_clnt *gssp_clnt;
int use_gss_proxy; int use_gss_proxy;
int pipe_version; int pipe_version;