-
Notifications
You must be signed in to change notification settings - Fork 55
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
framework for adding a filesystem to a pool / wrap internal members of dbus_context in Rc<RefCell<>> #102
Conversation
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]>
@agrover @mulkieran review please? |
There was a problem hiding this 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>> { |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@mulkieran am I good to merge after addressing those two issues? (I'll wait for agrover too) |
👍 |
use std::vec::Vec; | ||
|
||
use engine::EngineResult; | ||
use engine::Pool; | ||
|
||
use super::blockdev::SimDev; | ||
|
||
#[derive(Debug, Clone)] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()]); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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())]);
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]>
PR review comments have been addressed. |
Drop an unimplemented method
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]>
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]