Skip to contentSkip to conversation

SUNRPC: wake poll waiters when an empty pipe is unlinked

PATCH In review Avi Weiss 3 participants 3 messages Oct 20

Subsystems (3)
lore
Share & tools
lore

Avi Weiss

author
#0 lore raw

PATCH 1/1 SUNRPC: wake poll waiters when an empty pipe is unlinked

When an empty rpc_pipefs pipe is unlinked, rpc_purge_list() returns without waking the pipe wait queue. An existing epoll waiter can remain blocked even though rpc_pipe_poll() reports EPOLLHUP and EPOLLERR for the disconnected pipe.

Wake the wait queue after clearing RPC_I(inode)->pipe so existing poll waiters are notified regardless of whether messages were purged.

Fixes 9842ef3557ab ("SUNRPC: rpc_timeout_upcall_queue should not sleep")

---

Tested with an empty rpc_pipefs pipe in QEMU:
- 7.3.0 baseline: fresh poll() reports HUP/ERR (0x18), but an existing epoll_wait() times out.
- 7.3.0 with this patch: fresh poll() reports HUP/ERR (0x18), and epoll_wait() returns events=0x18.

 net/sunrpc/rpc_pipe.c | 1 +
 1 file changed, 1 insertion(+)
net/sunrpc/rpc_pipe.c +1 -0
index 9d349cfbc4831..68b4e040a77d9 100644
@@ -191,6 +191,7 @@ rpc_close_pipes(struct dentry *dentry)
 	cancel_delayed_work_sync(&pipe->queue_timeout);
 	rpc_inode_setowner(inode, NULL);
 	RPC_I(inode)->pipe = NULL;
+	wake_up(&RPC_I(inode)->waitq);
 	inode_unlock(inode);
 }
 

base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222

Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Avi Weiss

When an empty rpc_pipefs pipe is unlinked, rpc_purge_list() returns without waking the pipe wait queue. An existing epoll waiter can remain blocked even though rpc_pipe_poll() reports EPOLLHUP and EPOLLERR for the disconnected pipe.

Wake the wait queue after clearing RPC_I(inode)->pipe so existing poll waiters are notified regardless of whether messages were purged.

The wake doesn't strictly need to be *after* clearing ->pipe, only before unlocking the inode. But after clearing is a good place to put it.

Thanks,
NeilBrown

Quoted 32 lines
Fixes 9842ef3557ab ("SUNRPC: rpc_timeout_upcall_queue should not sleep")

---

Tested with an empty rpc_pipefs pipe in QEMU:
- 7.3.0 baseline: fresh poll() reports HUP/ERR (0x18), but an existing epoll_wait() times out.
- 7.3.0 with this patch: fresh poll() reports HUP/ERR (0x18), and epoll_wait() returns events=0x18.

 net/sunrpc/rpc_pipe.c | 1 +
 1 file changed, 1 insertion(+)
net/sunrpc/rpc_pipe.c +1 -0
index 9d349cfbc4831..68b4e040a77d9 100644
@@ -191,6 +191,7 @@ rpc_close_pipes(struct dentry *dentry)
 	cancel_delayed_work_sync(&pipe->queue_timeout);
 	rpc_inode_setowner(inode, NULL);
 	RPC_I(inode)->pipe = NULL;
+	wake_up(&RPC_I(inode)->waitq);
 	inode_unlock(inode);
 }
 

base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222

Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Avi Weiss
Quoted 34 lines · Avi Weiss

When an empty rpc_pipefs pipe is unlinked, rpc_purge_list() returns without waking the pipe wait queue. An existing epoll waiter can remain blocked even though rpc_pipe_poll() reports EPOLLHUP and EPOLLERR for the disconnected pipe.

Wake the wait queue after clearing RPC_I(inode)->pipe so existing poll waiters are notified regardless of whether messages were purged.

Fixes 9842ef3557ab ("SUNRPC: rpc_timeout_upcall_queue should not sleep")

---

Tested with an empty rpc_pipefs pipe in QEMU:
- 7.3.0 baseline: fresh poll() reports HUP/ERR (0x18), but an existing epoll_wait() times out.
- 7.3.0 with this patch: fresh poll() reports HUP/ERR (0x18), and epoll_wait() returns events=0x18.

 net/sunrpc/rpc_pipe.c | 1 +
 1 file changed, 1 insertion(+)
net/sunrpc/rpc_pipe.c +1 -0
index 9d349cfbc4831..68b4e040a77d9 100644
@@ -191,6 +191,7 @@ rpc_close_pipes(struct dentry *dentry)
 	cancel_delayed_work_sync(&pipe->queue_timeout);
 	rpc_inode_setowner(inode, NULL);
 	RPC_I(inode)->pipe = NULL;
+	wake_up(&RPC_I(inode)->waitq);
 	inode_unlock(inode);
 }
 
Quoted 1 line

base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222