-
Notifications
You must be signed in to change notification settings - Fork 2
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
Falloc error checks and collapse #18
base: main
Are you sure you want to change the base?
Conversation
#[repr(i32)] | ||
#[allow(non_camel_case_types)] | ||
enum FALLOC_FLAG { | ||
FALLOC_FL_KEEP_SIZE = 0x01, | ||
FALLOC_FL_PUNCH_HOLE = 0x02, | ||
// FALLOC_FL_NO_HIDE_STALE = 0x04, | ||
FALLOC_FL_COLLAPSE_RANGE = 0x08, | ||
FALLOC_FL_ZERO_RANGE = 0x10, | ||
FALLOC_FL_INSERT_RANGE = 0x20, | ||
// FALLOC_FL_UNSHARE_RANGE = 0x40, | ||
} |
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.
We should be able to import these flags from rust/bindings/bindings_generated.rs
. If they aren't there, we probably have to add the file in which they are defined by the kernel to rust/bindings/bindings_helper.h
. The Rust build system incorporated with the kernel uses this .h file to set up Rust-friendly definitions of everything defined by files it includes.
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.
Actually, looks like they are defined as C macros for some reason, which makes our lives a little more difficult. The automatic binding generation doesn't work on C macros, sohe cleanest way to handle this at the moment would be to manually add a wrapper for each macro in rust/helpers.c
, following the same style as the existing functions in that file.
fs/hayleyfs/h_file.rs
Outdated
// truncate extends the flie size when the size is greater than the current size | ||
match hayleyfs_truncate(sbi, pi, final_file_size as i64){ | ||
Ok(_) => pr_info!("OK"), | ||
Err(e) => pr_info!("{:?}", e) | ||
} | ||
|
||
// size will be restored at the end of this function. | ||
} |
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.
Rather than calling hayleyfs_truncate
and then setting the size back to the original value, you should implement a function that adds the pages to the file but does not change its size at all. With the current design (which appears to not reset the inode size anyway?), if we crash after the hayleyfs_truncate
call completes but before fixing up the file size, the file size will end up incorrect.
source /home/rustfs/.bashrc | ||
source /home/rustfs/.profile |
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.
Looks like this references some files that are not part of the repo; if there is something defined in these files that is required for this script, you should copy it into the script or include it in a file that is part of the repo.
@@ -318,6 +174,115 @@ impl file::Operations for FileOps { | |||
} | |||
} | |||
|
|||
|
|||
fn hayleyfs_fallocate( |
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.
Looks good! Looks like the default mode for fallocate got lost when moving the code over to the new function though (or is it going to be replaced with something else?)
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.
Does this file do anything anymore? If not, let's remove it (or move it to the tests/ directory if it does help with something that I didn't see on a quick scan).
Just a progress check!