Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

CharanSriramUni
Copy link
Collaborator

Just a progress check!

Comment on lines +27 to +37
#[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,
}
Copy link
Collaborator

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.

Copy link
Collaborator

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 Show resolved Hide resolved
Comment on lines 274 to 281
// 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.
}
Copy link
Collaborator

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.

fs/hayleyfs/h_file.rs Show resolved Hide resolved
fs/hayleyfs/defs.rs Show resolved Hide resolved
Comment on lines +2 to +3
source /home/rustfs/.bashrc
source /home/rustfs/.profile
Copy link
Collaborator

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.

fs/hayleyfs/test_fs.sh Outdated Show resolved Hide resolved
fs/hayleyfs/test_fs.sh Outdated Show resolved Hide resolved
@@ -318,6 +174,115 @@ impl file::Operations for FileOps {
}
}


fn hayleyfs_fallocate(
Copy link
Collaborator

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?)

Copy link
Collaborator

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants