Falloc error checks and collapse#18
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.
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.
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.
| // 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.
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.
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.
| } | ||
|
|
||
|
|
||
| fn hayleyfs_fallocate( |
There was a problem hiding this comment.
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.
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!