-
Notifications
You must be signed in to change notification settings - Fork 0
✨ feat: add pending write/delete support and dummy write FUSE ops (experimental) #257
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
base: main
Are you sure you want to change the base?
Conversation
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.
Hello @ChanTsune, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
Hello! Gemini here, providing a summary of this pull request. This PR introduces initial, experimental support for write and delete operations within the FUSE filesystem implementation. The core idea is to track these changes in memory as 'pending' operations before potentially persisting them later. Dummy implementations for the create, write, and unlink FUSE operations have been added. These dummy implementations currently log the operation and update the in-memory pending state but do not yet modify the underlying archive file. This is a foundational step towards making the FUSE mount writable.
Highlights
- Pending Changes Tracking: A new
PendingChangesstruct is introduced to keep track of files that have been created, written to, or marked for deletion during the FUSE session. - Dummy Write FUSE Operations: Experimental, non-persisting implementations for the FUSE
create,write, andunlinkoperations have been added. These methods log their calls and update the in-memoryPendingChangesstate. - In-Memory State: Changes are currently only tracked in memory within the
PnaFSstruct's newpendingfield. There is no persistence to the archive file in this PR.
Changelog
- src/file_manager.rs
- Added an
empty()method to theLoadedEntrystruct (Lines 20-26) to easily create a new, empty file entry.
- Added an
- src/filesystem.rs
- Defined a new
PendingChangesstruct to hold maps/lists of created, written, and deleted file inodes and data (Lines 13-18). - Added a
pendingfield of typePendingChangesto thePnaFSstruct (Line 22). - Initialized the
pendingfield withDefault::default()in thePnaFS::newconstructor (Line 29). - Implemented a dummy
createFUSE operation that logs the call, generates a placeholder inode, creates a dummyFileentry, and adds it to thepending.createdmap (Lines 178-215). - Implemented a dummy
writeFUSE operation that logs the call, retrieves or creates an entry in thepending.writtenmap for the given inode, resizes the buffer if necessary, copies the provided data into the buffer at the specified offset, and reports the number of bytes written (Lines 217-239). - Implemented a dummy
unlinkFUSE operation that logs the call, attempts to find the file by name within the parent's children (using the manager), and if found, adds its inode to thepending.deletedlist (Lines 241-252).
- Defined a new
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Filesystem mount,
Read-only, now takes count,
Writes wait in mind.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request introduces experimental support for pending writes/deletes and dummy FUSE write operations (create, write, unlink). This is a significant step towards enabling write capabilities for the PNA filesystem.
The overall structure for managing pending changes seems like a good starting point. The code is generally clear and follows Rust idioms.
Given the experimental nature, the current dummy implementations are understandable. My review focuses on potential issues that might arise as these features are further developed and hardened, particularly around correctness and robustness.
It would be beneficial to consider adding tests for these new write operations in the future, similar to how read operations are tested, to ensure their behavior as they evolve from dummy implementations.
Summary of Findings
- Inode Generation Strategy in
create: The inode generation in thecreateFUSE operation uses arbitrary increments/fallbacks, which could lead to collisions. Addressed in a review comment. unlinkHandling of Pending Creations: TheunlinkFUSE operation may not correctly handle files that have been created but not yet persisted (i.e., exist only inpending.created). Addressed in a review comment.- Inconsistent Comment Language (Low Severity): Comments in
src/filesystem.rs(lines 16, 177, 243) are in Japanese, while the rest of the codebase primarily uses English. For consistency and broader maintainability, using a single language for comments is recommended. (Not commented inline due to review settings). - Hardcoded UID/GID in
create(Low Severity): Thecreateoperation hardcodesuid: 0, gid: 0(lines 205-206 insrc/filesystem.rs). For a production system, this should ideally reflect the UID/GID of the requesting user or be configurable. (Not commented inline due to review settings, acceptable for current experimental/dummy status).
Merge Readiness
This pull request introduces valuable experimental features. However, there are a couple of medium-severity issues identified concerning inode generation in create and the handling of pending files in unlink. It's recommended that these points be discussed and ideally addressed, or at least a clear plan for their resolution be established, before merging to ensure a more robust foundation for future development.
As a reviewer, I am not authorized to approve pull requests. Please ensure further review and approval from authorized maintainers before merging.
src/filesystem.rs
Outdated
| reply: fuser::ReplyCreate, | ||
| ) { | ||
| log::info!("[Experimental] create(parent: {:#x?}, name: {:?}, mode: {:#o}, flags: {:#x?})", parent, name, mode, flags); | ||
| let ino = self.manager.get_file(parent).map(|_| self.manager.get_file(parent).unwrap().attr.ino + 10000).unwrap_or(99999); |
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.
The current inode generation logic has a couple of aspects to consider for future robustness:
- Redundant Call: The original line calls
self.manager.get_file(parent)twice if the parent exists. This can be made more efficient. - Arbitrary Inode Assignment: The inode assignment logic (e.g.,
parent_ino + 10000or fallback to99999) seems arbitrary. This could potentially lead to inode collisions with those managed byFileManager::next_inode()or across multiple concurrentcreateoperations, especially as this feature moves beyond a dummy implementation. This could affect filesystem integrity.
For a more robust system, have you considered centralizing inode generation? Perhaps FileManager could be responsible for allocating all new inodes, including those for pending creations, or a different unique ID strategy could be employed to prevent collisions.
The suggestion below addresses the redundant call. The primary concern for discussion is the overall inode assignment strategy.
| let ino = self.manager.get_file(parent).map(|_| self.manager.get_file(parent).unwrap().attr.ino + 10000).unwrap_or(99999); | |
| let ino = self.manager.get_file(parent).map(|pf| pf.attr.ino + 10000).unwrap_or(99999); |
| if let Some(children) = self.manager.get_children(parent) { | ||
| if let Some(file) = children.iter().find(|f| f.name == name) { | ||
| self.pending.deleted.push(file.attr.ino); | ||
| reply.ok(); | ||
| return; | ||
| } | ||
| } |
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.
The unlink function currently attempts to find the file to be deleted by querying self.manager.get_children(parent). This is fine for files already persisted and known to the FileManager.
However, if a file is newly created (and thus exists only in self.pending.created) and then an unlink operation is performed on it before it's persisted to the main archive structure, will this unlink correctly identify and process it? It seems it might only find files already managed by self.manager.
To handle this scenario, should unlink also check self.pending.created? If a file is found there:
- It could be removed from
self.pending.created. - Its inode could be added to
self.pending.deletedto ensure it's not accidentally processed later if there's any intermediate state.
Consider a sequence like: create("newfile") -> unlink("newfile"). The unlink needs to effectively cancel out the pending creation.
How do you envision handling unlinking of files that are in a pending-creation state?
b187973 to
961685a
Compare
961685a to
4e8e750
Compare
No description provided.