Skip to contentSkip to conversation

svcrpc: implement O_NONBLOCK behavior for use-gss-proxy

PATCH In review J. Bruce Fields 2 participants 2 messages May 24, 2013 – May 26, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 svcrpc: implement O_NONBLOCK behavior for use-gss-proxy

From: "J. Bruce Fields" <[email protected]>

Somebody noticed LTP was complaining about O_NONBLOCK opens of /proc/net/rpc/use-gss-proxy succeeding and then a following read hanging.

I'm not convinced LTP really has any business opening random proc files and expecting them to behave a certain way. And I don't really know if this is really a bug.

But in any case perhaps the O_NONBLOCK behavior could be useful for someone that wants to test whether gss-proxy is up without waiting.

---
 net/sunrpc/auth_gss/svcauth_gss.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Considering for 3.10.

net/sunrpc/auth_gss/svcauth_gss.c +4 -2
index 9f0f017..618ccf5 100644
@@ -1313,10 +1313,12 @@ static inline bool gssp_ready(struct sunrpc_net *sn)
 	return false;
 }
 
-static int wait_for_gss_proxy(struct net *net)
+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));
 }
 
@@ -1358,7 +1360,7 @@ static ssize_t read_gssp(struct file *file, char __user *buf,
 	size_t len;
 	int ret;
 
-	ret = wait_for_gss_proxy(net);
+	ret = wait_for_gss_proxy(net, file);
 	if (ret)
 		return ret;
 
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 10 lines · J. Bruce Fields

From: "J. Bruce Fields" <[email protected]>

Somebody noticed LTP was complaining about O_NONBLOCK opens of /proc/net/rpc/use-gss-proxy succeeding and then a following read hanging.

I'm not convinced LTP really has any business opening random proc files and expecting them to behave a certain way. And I don't really know if this is really a bug.

Quoted 5 lines

But in any case perhaps the O_NONBLOCK behavior could be useful for someone that wants to test whether gss-proxy is up without waiting.

Ack by me.

Simo.

Quoted 33 lines
---
 net/sunrpc/auth_gss/svcauth_gss.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Considering for 3.10.

net/sunrpc/auth_gss/svcauth_gss.c +4 -2
index 9f0f017..618ccf5 100644
@@ -1313,10 +1313,12 @@ static inline bool gssp_ready(struct sunrpc_net *sn)
 	return false;
 }
 
-static int wait_for_gss_proxy(struct net *net)
+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));
 }
 
@@ -1358,7 +1360,7 @@ static ssize_t read_gssp(struct file *file, char __user *buf,
 	size_t len;
 	int ret;
 
-	ret = wait_for_gss_proxy(net);
+	ret = wait_for_gss_proxy(net, file);
 	if (ret)
 		return ret;
 
Signature · 1 line
Simo Sorce * Red Hat, Inc * New York