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

framework for adding a filesystem to a pool / wrap internal members of dbus_context in Rc<RefCell<>> #102

Merged
merged 5 commits into from
Oct 25, 2016
Merged

Conversation

trgill
Copy link
Contributor

@trgill trgill commented Oct 20, 2016

added NotFound to ErrorEnum
added code to create track a filesystem associated with a pool in the SimEngine
added initial code for the filesystem interface (parameters)
added BTreeMap to track filesystems in the SimPool
changed internal memebers of dbus_context to be wrapped in a Rc<RefCell<>> to simplify borrowing issues
surpressed compiler warnings by adding _ to variable names in stubbed out prototypes
added stubs for pool interface

Signed-off-by: Todd Gill [email protected]

added NotFound to ErrorEnum
added code to create track a filesystem associated with a pool in the SimEngine
added initial code for the filesystem interface (parameters)
added BTreeMap to track filesystems in the SimPool

Signed-off-by: Todd Gill <[email protected]>
Having a Rc<RefCell<>> wrapper avoids having to borrow_mut() of the
dbus_context - which simplifies acess to the mutable fields.
Change dbus_context to implement Clone

Signed-off-by: Todd Gill <[email protected]>
@trgill trgill changed the title Initial framework for adding a filesystem to a pool framework for adding a filesystem to a pool / wrap internal members of dbus_context in Rc<RefCell<>> Oct 21, 2016
@trgill
Copy link
Contributor Author

trgill commented Oct 21, 2016

@agrover @mulkieran review please?

Copy link
Member

@mulkieran mulkieran left a comment

Choose a reason for hiding this comment

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

I can't really comment on the changes to the DbusContext. Other than the changes I've requested, it looks good to me.

fn create_filesystem(&mut self,
_filesystem_name: &str,
_mount_point: &str,
_size: &str)
Copy link
Member

Choose a reason for hiding this comment

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

Change _size to a u64. This is certainly better than a string, although not ideal.

Copy link
Contributor

Choose a reason for hiding this comment

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

We do have a Sectors type, how about that?

Copy link
Member

Choose a reason for hiding this comment

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

We should take the opportunity to define exactly what Sectors represent in that case and why it is suitable or adequate for this method. Right now, our design document does not use the word "sector" at all.

It looks like we can get rid of SumSectors pretty soon, based on progress of rust-lang/rust#34529.

I am actually the world's leading expert in the representation of and computation with allocated address ranges for block storage, see: https://github.com/mulkieran/justbytes, and https://mojo.redhat.com/docs/DOC-1089158. (It's like being on the North Korean Olympic curling team). But, it would be a shame to waste my expertise in this area, if it would be useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@agrover ok if I change _size to u64 and we tackle this topic in another PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

yup.

@@ -89,6 +89,15 @@ impl Engine for SimEngine {

Ok(())
}
fn get_pool(&mut self, name: &str) -> EngineResult<&mut Box<Pool>> {
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to drop the &mut?

Copy link
Contributor

Choose a reason for hiding this comment

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

no, because of the return type. I think we tried this and compiler caught it. It's returning a mutable reference into the Engine, so it needs to start with a mutable reference to the Engine.

Copy link
Member

Choose a reason for hiding this comment

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

I'm puzzled by the fact that it has to return a mutable reference to a Box.

Copy link
Member

Choose a reason for hiding this comment

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

But, the more I look, the more it looks like it has to be. OK.

@trgill
Copy link
Contributor Author

trgill commented Oct 21, 2016

@mulkieran am I good to merge after addressing those two issues? (I'll wait for agrover too)

@agrover
Copy link
Contributor

agrover commented Oct 21, 2016

👍

use std::vec::Vec;

use engine::EngineResult;
use engine::Pool;

use super::blockdev::SimDev;

#[derive(Debug, Clone)]
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you could break this currently tiny definition and implementation out to a separate file. It will get bigger.

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 if we do that on next PR?

Copy link
Member

Choose a reason for hiding this comment

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

Sure.

let object_path = m.path.get_name();
let return_message = message.method_return();

println!("Object Path {}", object_path);
Copy link
Member

Choose a reason for hiding this comment

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

Drop the println! for final commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


let pool_name = match dbus_context.pools.borrow_mut().get(&object_path.to_string()) {
Some(pool) => pool.clone(),
None => return Err(MethodErr::invalid_arg(&0)),
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be a return message with an Err result on the dbus.

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 changed to:

    return Err(MethodErr::invalid_arg(&format!("object path not found {}",
                                                   object_path.to_string())))

Ok?

Err(x) => {
let (rc, rs) = engine_to_dbus_err(&x);
let (rc, rs) = code_to_message_items(rc, rs);
let entry = MessageItem::Struct(vec!["o".into(), "q".into(), "s".into()]);
Copy link
Member

Choose a reason for hiding this comment

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

I think it is necessary to use specific correct MessageItem constructors for the components of the message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the rc indicates an error, the client shouldn't look at the array contents, but I think you are right. I changed it to:


            let entry = MessageItem::Struct(vec![MessageItem::ObjectPath(object_path.to_owned()),
                                                 MessageItem::UInt16(0),
                                                 MessageItem::Str("".to_string())]);

@mulkieran
Copy link
Member

There are more changes I'm requesting. I realize now I could probably have done that as a second review.

changed filesystem size to u64
in the case of pool name lookup failure, format the return entry with
MessageItem::x constructors

Signed-off-by: Todd Gill <[email protected]>
when there is an error, return an empty Array of the proper type
corrected stubs for rename, set_mountpoint and set_quota
reformatted some code so rustfmt would complete

Signed-off-by: Todd Gill <[email protected]>
Reformatted some code so that rustfmt would work
Use vec![] for empty array

Signed-off-by: Todd Gill <[email protected]>
@trgill
Copy link
Contributor Author

trgill commented Oct 25, 2016

PR review comments have been addressed.

@trgill trgill merged commit cb0375f into stratis-storage:master Oct 25, 2016
@trgill trgill deleted the create_filesystem_in_pool branch January 19, 2017 19:51
mulkieran pushed a commit that referenced this pull request Oct 24, 2021
mulkieran pushed a commit to mulkieran/stratisd that referenced this pull request May 24, 2022
We have not yet stabilized the API, so make this clear in this document.

Also, use 1/1/1.5/1.5 margins and update to LyX 2.3.0.

fixes stratis-storage#102

Signed-off-by: Andy Grover <[email protected]>
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.

3 participants