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
rbd-nbd: warn when kernel parameters are ignored #13694
Conversation
src/tools/rbd_nbd/rbd-nbd.cc
Outdated
} | ||
nbd = open(path, O_RDWR); | ||
} | ||
|
||
if (nbds_max && try_load_module && !load_module) { | ||
cerr << "rbd-nbd: nbds_max param doesn't work, because nbd module already loaded." << std::endl; |
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 would prefer a message like "rbd-nbd: ignoring nbds_max option: nbd module already loaded" or "rbd-nbd: nbd module already loaded, ignoring nbds_max option". Or may be Jason will have a better suggestion as a native speaker.
Also, don't we have to do the same for max_part
?
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.
@liupan1111 @trociny How about something simple like "rbd-nbd: ignoring kernel module parameter options: nbd module already loaded" if either nbds_max
or max_part
are specified and the module is already open.
Also, can you open a bug tracker ticket for this 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.
+1
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.
@dillaman Sure, I will create a bug tracker ticket.
@trociny , max_part makes me dilemma, it is different from nbds_max:
the default value in our rbd-nbd is 0, and if(nbds_max) is false if the user not specify nbds_max, however, the default value of max_part is 255(in order to support max partition), and if(max_part) is true, even if the user not specify it...
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.
@liupan1111 You can use a bool to track whether or not the user specified "--max_part" on the CLI
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.
cool!
src/tools/rbd_nbd/rbd-nbd.cc
Outdated
} | ||
nbd = open(path, O_RDWR); | ||
} | ||
|
||
if ((nbds_max || set_max_part) && try_load_module && !load_module) { | ||
cerr << "rbd-nbd: ignoring kernel module parameter options: nbd module already loaded." << std::endl; |
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.
nit: could you consider breaking the line not to exceed 80 char length? Also the final '.' is not needed. Otherwise lgtm
src/tools/rbd_nbd/rbd-nbd.cc
Outdated
@@ -452,6 +453,7 @@ class NBDWatchCtx : public librbd::UpdateWatchCtx | |||
static int open_device(const char* path, bool try_load_module = false) | |||
{ | |||
int nbd = open(path, O_RDWR); | |||
bool load_module = false; |
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.
Nit: module_loaded
or loaded_module
probably better name given its use below
Modified, please take a look, thanks. |
@ceph-jenkins retest this please |
@trociny haha, it passed this time |
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.
lgtm
Sorry, I should have done this earlier. Anyway, when I tested this manually, I noticed that the message may repeat several times if you have several devices already mapped:
This is because when a devpath is not specified, rbd-nbd iterates over /dev/nbdX starting from 0, until open_device succeeds. Do we want to improve this? I think we can call |
@trociny Nice catch -- definitely only want to print it once |
right, i will fix it |
@liupan1111 ping |
new version, please take a look. |
src/tools/rbd_nbd/rbd-nbd.cc
Outdated
@@ -452,6 +453,9 @@ class NBDWatchCtx : public librbd::UpdateWatchCtx | |||
static int open_device(const char* path, bool try_load_module = false) | |||
{ | |||
int nbd = open(path, O_RDWR); | |||
bool loaded_module = false; | |||
static bool printed_ignore_info = false; |
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.
@liupan1111 I was proposing to call open_device()
with try_load_module = true
only once in do_map
, i.e. adding a var bool try_load_module = true
in do_map
, before while
loop, pass it to open_device(..., try_load_module)
and set to false
after the call. Why didn't you like this idea? This looks cleaner and more correct to me (no need to try load module more than one time).
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.
sounds a good solution, thanks. I will modify it.
@rhcs-jenkins retest please. |
@liupan1111 There is "`" character at the end of "Signed-off-by" line in the log message for your first comment. You might want to clean this. Otherwise LGTM. BTW, in case you are not aware, you can use |
@liupan1111 see my previous message. I accidentally addressed it to a wrong person. |
@trociny done. git commit -s is really helpful, Thanks! |
@liupan1111 There is no "Fixes: http://tracker.ceph.com/issues/19108" in the commit message now. |
Fixes: http://tracker.ceph.com/issues/19108 Signed-off-by: Pan Liu <liupan1111@gmail.com>
…g do_map operation. Signed-off-by: Pan Liu <liupan1111@gmail.com>
@trociny added, sorry for the trouble... |
@trociny @dillaman use this place to ask you a question: Could you give me some help? Thanks! |
@liupan1111 I think this is because the main thread is blocked on a kernel call:
And attach to a particular rbd-nbd thread (using id from LWP column)
This way you will need to attach to every thread you are interested in. And don't attach to the main thread! Not sure how helpful it is in your case. I suppose we could workaround this creating a separate thread for |
@trociny Thank you for great help. Let me try and let you know. |
…oaded.
when user specify --nbds_max, nbd-rbd will try to load nbd module, and set parm nbds_max. But if the nbd module is already loaded, new nbds_max would work. Prompt message should be dumped.
Fixes: http://tracker.ceph.com/issues/19108
Signed-off-by: Pan Liu liupan1111@gmail.com