-
-
Notifications
You must be signed in to change notification settings - Fork 194
fix(fs): align post-write sync with Linux generic_write_sync #2147
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: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1010,6 +1010,18 @@ impl IndexNode for LoopDevice { | |
| self | ||
| } | ||
|
|
||
| fn supports_post_write_sync(&self, file_type: FileType) -> bool { | ||
| file_type == FileType::BlockDevice | ||
| } | ||
|
|
||
| fn sync_file( | ||
| &self, | ||
| _datasync: bool, | ||
| _data: MutexGuard<FilePrivateData>, | ||
| ) -> Result<(), SystemError> { | ||
| <Self as BlockDevice>::sync(self) | ||
|
Member
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. [P1] Retain and fsync the backing File, not only its inode LOOP_SET_FD currently stores only file.inode(), so after the setup fd is The new sync_file() activates BlockDevice::sync(), which calls inode.sync() Please retain an Arc for the backing object, use its file-level sync |
||
| } | ||
|
|
||
| fn read_at( | ||
| &self, | ||
| offset: usize, | ||
|
|
@@ -1330,6 +1342,8 @@ impl BlockDevice for LoopDevice { | |
| } | ||
|
|
||
| fn sync(&self) -> Result<(), SystemError> { | ||
| let _io_guard = IoGuard::new(self)?; | ||
|
|
||
| let inode = self.inner().file_inode.clone().ok_or(SystemError::ENODEV)?; | ||
| inode.sync()?; | ||
| inode.fs().sync_fs(true) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -587,6 +587,15 @@ pub trait IndexNode: Any + Sync + Send + Debug + CastFromSync { | |
| /// protocol flags. | ||
| fn adjust_file_mode_after_open(&self, _data: &FilePrivateData, _mode: &mut FileMode) {} | ||
|
|
||
| /// Whether the VFS write path should apply Linux `generic_write_sync()` | ||
| /// semantics after a successful positive-length write. | ||
| /// | ||
| /// This is intentionally opt-in: many pseudo files are reported as regular | ||
| /// files but their Linux write paths do not perform generic write syncing. | ||
| fn supports_post_write_sync(&self, _file_type: FileType) -> bool { | ||
|
Member
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. [P1] Model this as a write-operation policy, not a default-false inode capability Linux does not decide whether to run generic_write_sync() from an inode Making this a default-false IndexNode method creates a silent durability Please make the selected open-file/write operation own this decision. A |
||
| false | ||
| } | ||
|
|
||
| /// @brief 关闭文件 | ||
| /// | ||
| /// @return 成功:Ok() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.