-
Notifications
You must be signed in to change notification settings - Fork 54
add poll notification support #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
obbardc
wants to merge
5
commits into
libfuse:main
Choose a base branch
from
obbardc:wip/obbardc/add-notify-poll
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ | |
| EntryAttributes, | ||
| FileInfo, | ||
| FUSEError, | ||
| PollHandle, | ||
| ReaddirToken, | ||
| RequestContext, | ||
| SetattrFields, | ||
|
|
@@ -451,6 +452,44 @@ async def fsync(self, fh: FileHandleT, datasync: bool) -> None: | |
|
|
||
| raise FUSEError(errno.ENOSYS) | ||
|
|
||
| async def poll( | ||
| self, | ||
| inode: InodeT, | ||
| fh: FileHandleT, | ||
| poll_handle: Optional["PollHandle"], | ||
| ctx: "RequestContext", | ||
| ) -> int: | ||
| '''Check IO readiness on an open file. | ||
|
|
||
| This method is called when a process performs :manpage:`poll(2)`, | ||
| :manpage:`select(2)` or :manpage:`epoll_wait(2)` on a file descriptor | ||
| backed by *fh* (returned by a prior `open` or `create` call). *inode* | ||
| identifies the inode that *fh* refers to. | ||
|
|
||
| The method must return the bitwise-or of the currently active poll | ||
| events (e.g. ``select.POLLIN``, ``select.POLLOUT``, ``select.POLLPRI``). | ||
| If no events are currently ready, return ``0``. | ||
|
|
||
| If *poll_handle* is ``None``, the kernel is only asking for the | ||
| current readiness mask -- no process is queued waiting for a | ||
| notification. The filesystem should just return the current event | ||
| bitmask without storing anything. | ||
|
|
||
| If *poll_handle* is not ``None``, the kernel is requesting to be | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are the semantics when |
||
| notified the next time readiness changes. The filesystem should | ||
| store the handle and later call `PollHandle.notify` exactly once | ||
| when a relevant event becomes available. Each `~Operations.poll` | ||
| call produces a fresh handle; storing a new handle implicitly | ||
| drops any previously held one (which destroys the underlying | ||
| libfuse object). | ||
|
|
||
| If this method raises ``FUSEError(errno.ENOSYS)`` (the default), | ||
| the kernel will fall back to a default poll implementation and | ||
| will not call this handler again for the lifetime of the mount. | ||
| ''' | ||
|
|
||
| raise FUSEError(errno.ENOSYS) | ||
|
|
||
| async def opendir(self, inode: InodeT, ctx: "RequestContext") -> FileHandleT: | ||
| '''Open the directory with inode *inode*. | ||
|
|
||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -836,6 +836,40 @@ async def fuse_access_async (_Container c): | |
|
|
||
|
|
||
|
|
||
| cdef void fuse_poll (fuse_req_t req, fuse_ino_t ino, fuse_file_info *fi, | ||
| fuse_pollhandle *ph): | ||
| cdef _Container c = _Container() | ||
| cdef PollHandle py_ph | ||
| c.req = req | ||
| c.ino = ino | ||
| if fi is NULL: | ||
| c.fh = 0 | ||
| else: | ||
| c.fh = fi.fh | ||
| if ph is NULL: | ||
| py_ph = None | ||
| else: | ||
| py_ph = PollHandle.__new__(PollHandle) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just |
||
| py_ph._ph = ph | ||
| save_retval(fuse_poll_async(c, py_ph)) | ||
|
|
||
| async def fuse_poll_async (_Container c, PollHandle py_ph): | ||
| cdef int ret | ||
| cdef unsigned revents | ||
|
|
||
| ctx = get_request_context(c.req) | ||
| try: | ||
| result = await operations.poll(c.ino, c.fh, py_ph, ctx) | ||
| except FUSEError as e: | ||
| ret = fuse_reply_err(c.req, e.errno) | ||
| else: | ||
| revents = <unsigned> (result if result is not None else 0) | ||
| ret = fuse_reply_poll(c.req, revents) | ||
|
|
||
| if ret != 0: | ||
| log.error('fuse_poll(): fuse_reply_* failed with %s', strerror(-ret)) | ||
|
|
||
|
|
||
| cdef void fuse_create (fuse_req_t req, fuse_ino_t parent, const_char *name, | ||
| mode_t mode, fuse_file_info *fi): | ||
| cdef _Container c = _Container() | ||
|
|
||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Looking at https://cython.readthedocs.io/en/latest/src/userguide/special_methods.html#finalization-methods-dealloc-and-del, nothing can possibly access the object after
__dealloc__has run, so there's no need to reset the pointer.