add poll notification support#140
Draft
obbardc wants to merge 9 commits intolibfuse:mainfrom
Draft
Conversation
Expose libfuse low-level poll support through pyfuse3 so filesystems can implement poll(2), select(2) and epoll readiness notifications. Add bindings for struct fuse_pollhandle, fuse_reply_poll(), fuse_lowlevel_notify_poll() and fuse_pollhandle_destroy(). Introduce a Python PollHandle wrapper and a notify_poll() helper, allowing a filesystem to retain the poll handle provided by Operations.poll() and notify it later when readiness changes. Wire the low-level FUSE poll callback into Operations.poll(), returning the current readiness mask to the kernel. The default implementation continues to raise ENOSYS so existing filesystems keep the previous fallback behaviour unless they opt in. This is needed by filesystems that emulate pollable kernel interfaces, such as sysfs GPIO value files, where edge events must wake userspace processes waiting for POLLPRI. Fixes: libfuse#139 Signed-off-by: Christopher Obbard <christopher.obbard@linaro.org>
Add a pollable file to the test filesystem and exercise the new Operations.poll() and notify_poll() APIs. The test opens the synthetic file, starts a userspace poll(2) waiter, and waits until the filesystem has received and stored a PollHandle. It then triggers readiness through the existing setxattr command channel. The filesystem marks the file ready, calls notify_poll() and the test verifies that the blocked poller wakes with POLLPRI. This covers the notification path from the low-level FUSE poll callback, through the Python PollHandle wrapper, to fuse_lowlevel_notify_poll(). Signed-off-by: Christopher Obbard <christopher.obbard@linaro.org>
de00d33 to
66c617d
Compare
Nikratio
reviewed
May 5, 2026
Nikratio
reviewed
May 5, 2026
Nikratio
reviewed
May 5, 2026
Contributor
|
Thanks for the MR! I only just replied on the issue tracker :-). |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR exposes libfuse low-level poll(2) readiness support through pyfuse3, allowing filesystems to implement Operations.poll() and later wake blocked poll/select/epoll waiters via notify_poll().
Changes:
- Wire up the libfuse low-level
pollcallback and reply path (fuse_ops.poll→fuse_poll→Operations.poll→fuse_reply_poll). - Introduce a
PollHandleopaque type plusnotify_poll(handle)to deliver readiness notifications. - Add an integration test filesystem and test case covering poll notification behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
test/test_fs.py |
Adds a pollable test file and an integration test validating wakeup via notify_poll. |
src/pyfuse3/internal.pxi |
Registers the new low-level poll handler in fuse_lowlevel_ops. |
src/pyfuse3/handlers.pxi |
Implements fuse_poll/fuse_poll_async bridging to Operations.poll and replies with fuse_reply_poll. |
src/pyfuse3/_pyfuse3.py |
Adds the Operations.poll() API and its documentation. |
src/pyfuse3/__init__.pyx |
Adds PollHandle and the notify_poll() API. |
src/pyfuse3/__init__.pyi |
Updates typing stubs for PollHandle and notify_poll(). |
Include/fuse_lowlevel.pxd |
Declares low-level poll op, fuse_reply_poll, and fuse_lowlevel_notify_poll. |
Include/fuse_common.pxd |
Declares fuse_pollhandle and fuse_pollhandle_destroy. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+998
to
+1002
| A single notification is enough to clear all pending waiters; calling | ||
| this function again on the same handle is harmless but redundant. | ||
| The handle remains valid (and may be notified again) until its Python | ||
| reference is dropped, at which point the underlying ``fuse_pollhandle`` | ||
| is destroyed. |
Contributor
There was a problem hiding this comment.
@obbardc Could you take a look at this as well?
Expose libfuse low-level poll support through pyfuse3 so filesystems can implement poll(2), select(2) and epoll readiness notifications. Add bindings for struct fuse_pollhandle, fuse_reply_poll(), fuse_lowlevel_notify_poll() and fuse_pollhandle_destroy(). Introduce a Python PollHandle wrapper with a notify() method, allowing a filesystem to retain the handle provided by Operations.poll() and wake waiters later when readiness changes. Wire the low-level FUSE poll callback into Operations.poll(), returning the current readiness mask to the kernel. The default implementation continues to raise ENOSYS so existing filesystems keep the previous fallback behaviour unless they opt in. This is needed by filesystems that emulate pollable kernel interfaces, such as sysfs GPIO value files, where edge events must wake userspace processes waiting for POLLPRI. Signed-off-by: Christopher Obbard <christopher.obbard@linaro.org>
Nikratio
reviewed
May 5, 2026
Nikratio
requested changes
May 6, 2026
Signed-off-by: Christopher Obbard <christopher.obbard@linaro.org>
Signed-off-by: Christopher Obbard <christopher.obbard@linaro.org>
Signed-off-by: Christopher Obbard <christopher.obbard@linaro.org>
Signed-off-by: Christopher Obbard <christopher.obbard@linaro.org>
Nikratio
reviewed
May 8, 2026
| class PollTestFs(Fs): | ||
| def __init__(self, cross_process): | ||
| super().__init__(cross_process) | ||
| # TODO: not sure if need poll_name & poll_inode? |
Contributor
There was a problem hiding this comment.
I'd simply poll on hello_inode instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Expose libfuse low-level poll support through pyfuse3.