Skip to content

Falloc error checks and collapse#18

Open
CharanSriramUni wants to merge 4 commits intomainfrom
falloc-error-checks-and-collapse
Open

Falloc error checks and collapse#18
CharanSriramUni wants to merge 4 commits intomainfrom
falloc-error-checks-and-collapse

Conversation

@CharanSriramUni
Copy link
Copy Markdown
Collaborator

Just a progress check!

Comment thread fs/hayleyfs/h_file.rs
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
Copy Markdown
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
Copy Markdown
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.

Comment thread fs/hayleyfs/h_file.rs Outdated
Comment thread fs/hayleyfs/h_file.rs Outdated
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
Copy Markdown
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.

Comment thread fs/hayleyfs/h_file.rs
Comment thread fs/hayleyfs/defs.rs
Comment thread fs/hayleyfs/update_fs.sh
Comment on lines +2 to +3
source /home/rustfs/.bashrc
source /home/rustfs/.profile
Copy link
Copy Markdown
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.

Comment thread fs/hayleyfs/test_fs.sh
Comment thread fs/hayleyfs/test_fs.sh
Comment thread fs/hayleyfs/h_file.rs
}


fn hayleyfs_fallocate(
Copy link
Copy Markdown
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?)

Comment thread fs/hayleyfs/update_fs.sh
Copy link
Copy Markdown
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