SUNRPC: wake poll waiters when an empty pipe is unlinked
Subsystems (3)
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.
---
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
@@ -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
Quoted 7 lines · Avi Weiss
When an empty
rpc_pipefspipe is unlinked,rpc_purge_list()returns without waking the pipe wait queue. An existing epoll waiter can remain blocked even thoughrpc_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")Signed-off-by Avi Weiss <[email protected]>---
Tested with an empty
rpc_pipefspipe in QEMU:
- 7.3.0 baseline: freshpoll()reports HUP/ERR (0x18), but an existingepoll_wait()times out.
- 7.3.0 with this patch: freshpoll()reports HUP/ERR (0x18), andepoll_wait()returns events=0x18.net/sunrpc/rpc_pipe.c | 1 + 1 file changed, 1 insertion(+)net/sunrpc/rpc_pipe.c +1
-0@@ -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:
c03c1a14507dfaf8b856c2608f9ac216021fc222Signature · 1 line
2.43.0
Quoted 34 lines · Avi Weiss
When an empty
rpc_pipefspipe is unlinked,rpc_purge_list()returns without waking the pipe wait queue. An existing epoll waiter can remain blocked even thoughrpc_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")Signed-off-by Avi Weiss <[email protected]>---
Tested with an empty
rpc_pipefspipe in QEMU:
- 7.3.0 baseline: freshpoll()reports HUP/ERR (0x18), but an existingepoll_wait()times out.
- 7.3.0 with this patch: freshpoll()reports HUP/ERR (0x18), andepoll_wait()returns events=0x18.net/sunrpc/rpc_pipe.c | 1 + 1 file changed, 1 insertion(+)net/sunrpc/rpc_pipe.c +1
-0@@ -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