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

Added a NVME FS prototype #192

Merged
merged 20 commits into from
Aug 20, 2024
Merged

Conversation

CPTforever
Copy link
Contributor

I made one change to Xtask that will only open the nvme.img if it already exists then truncate it, otherwise create it then truncate.

I copied over the NVME driver code from the pager, and in the controller I detached the interrupt handler in the init_controller function in a thread pool since it seems that it doesn't work if it's solely async. I also commented out the part where it adds it to the interrupt task list. Otherwise it hangs and doesn't make any progress.

I made a quick IO handler on top of the NVME driver and then put Leo's Fat Filesystem on top of that to implement a basic file system in Twizzler.

@CPTforever CPTforever requested review from dbittman and gvnn3 as code owners July 8, 2024 17:43
@dbittman
Copy link
Contributor

Looks like it's missing the submodule for the fat crate. Add it, and I'll rerun the CI.

Copy link
Contributor

@dbittman dbittman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few questions and comments.

@CPTforever
Copy link
Contributor Author

I didn't intend to make it in the same PR but I also need to look at why the CICD failed.

But the changes made are adding 5 functions for the rust minimal runtime and reference runtime being and the corresponding functions within the std interface:
open()
read()
write()
close()
seek()

The two new functions planned will be truncate() and stat().

The way I implemented it similar to how the thread runtime was implemented with a file descriptor defined in a static map that can reference a file descriptor which contains the pos variable that points to a place in the file, and an object handle for the backed file.

The data stored within the file is the data itself and the File Metadata which holds a magic number, the size, and a direct pointer list to support extensible files. However extensible files aren't implemented at this time.

Some limitations is that open doesn't actually create a file.

Also there is no error checking like seeing if the object is overflowing which I'm planning to rectify very soon.

Copy link
Contributor

@gvnn3 gvnn3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the code looks good. I think you should add block comments to the main, visible, APIs that are used by others so they get put into the documentation by the Rust build system.


// specialization o_O

// impl<const N: usize> Decode for [u8; N] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't check in commented out code. We use a version control system so if you need old code, you can always restore it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I copied it over from Leo's repo since it's private, I didn't check it too closely, will do.

fn framed_size(&mut self) -> Result<u64, S::Error> {
Ok(#framed)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a lot of extra white space throuhout. Can we tighten this up? Perhaps @dbittman has thoughts on how the code looks as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing we need to do is setup a CI step that ensures that rustfmt is happy. @CPTforever is this code formatted with rustfmt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure I did, I ran cargo fmt in the crate's root but I'll double check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok today I found out it's not recursive, I'll commit the fix soon,

@CPTforever
Copy link
Contributor Author

Fixed a bug with the tests so the build system should pass it now.

I've also added changes that Daniel suggested including

Changed read and write in the runtime to accept slices instead of pointers

Defining ownedfd in std and defining a rawfd type=u32, which I implemented it by getting rid of OwnedFd and just having the file descriptor struct hold the rawfd.

Added display and error to the FsError type

Added a from impl for FsError to Io Error so that the ? operator works. I had to add a stable macro to do so, I'm not sure of another way to approach it.

Changed the Btree + atomic counter implementation to a stable vector for counting, I also added a feature that would choose a deleted fd slot before allocating a new one.

@gvnn3 gvnn3 requested a review from dbittman August 5, 2024 06:11

/// Runtime that implements std's FS support. Currently being implemented.
pub trait RustFsRuntime {
fn open(&self, path: &CStr) -> Result<RawFd, FsError>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document these.

Copy link
Contributor

@dbittman dbittman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the small comments I left. I will work on fixing CI for rust submodule.

@dbittman dbittman requested review from gvnn3 and dbittman August 13, 2024 23:32
PandaZ3D and others added 2 commits August 16, 2024 08:48
* Add support for CHERI QEMU

* Add Morello build target

* Implement basic GICv3 support

* Run cargo fmt

* Fix interrupt initialization

* Cleanup and comments
@CPTforever
Copy link
Contributor Author

I tried committing the latest branch in the rust submodule but I got a compilation error saying that a function in the rust runtime is missing. So I moved it back one commit.

Copy link
Contributor

@gvnn3 gvnn3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let's get this in.

@dbittman dbittman merged commit 66a561f into twizzler-operating-system:main Aug 20, 2024
1 check passed
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.

4 participants