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
librbd: managed lock refactoring #12922
Conversation
@dillaman This is still WIP, I have some questions:
|
|
@@ -9,6 +9,10 @@ | |||
|
|||
class Context; | |||
|
|||
namespace librados { | |||
class IoCtx; |
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: no indentation within namespaces. You could collapse to a single line, though.
Context *on_finish) { | ||
return new BreakRequest(image_ctx, locker, blacklist_locker, | ||
force_break_lock, on_finish); | ||
static BreakRequest* create(librados::IoCtx& ioctx, ContextWQ *work_queue, |
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: forward declare librados::IoCtx in this header as well?
@@ -13,6 +13,7 @@ | |||
#include <boost/optional.hpp> | |||
|
|||
class Context; | |||
class ContextWQ; | |||
|
|||
namespace librbd { | |||
|
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: can forward declare ImageCtx and move include to the CC file
@@ -8,6 +8,7 @@ | |||
#include "include/Context.h" | |||
#include "include/rados/librados.hpp" | |||
#include "cls/lock/cls_lock_types.h" | |||
#include "librbd/managed_lock/Types.h" |
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: forward declare managed_lock::Locker
{ | ||
RWLock::RLocker l(ictx->owner_lock); | ||
|
||
if (ictx->exclusive_lock == nullptr) { |
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 support getting the lock owner when opened in read-only mode, which implies that the exclusive lock won't be initialized.
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.
Then I suppose I can use ExclusiveLock(*ictx).get_locker(&locker, &get_owner_ctx)
for this case, still looks a little better.
Agree. There is a potential issue with this though. If a corresponding parameter in ImageCtx is updated by some reason, the exlusive_lock will still use the old value. Currently it looks like we don't update these params during ImageCtx life, this might be a surprise though when we want to do this in some future. |
@trociny There are a lot of parameters that, even if we eliminated the use of their ImageCtx replacement, would not function correctly w/ dynamic config updates. The blacklisting on lock break realistically should never be touched -- another example of way too many Ceph config options just to avoid hard-coding things. |
2fba46f
to
391e126
Compare
@dillaman Updated. Tested this locally and on subset of rbd suite (using --filter c_api_tests,python,fsx,cli,mirror and --filter-out bluestore,ec-data-pool) [1], there was only one failure for rbd_mirror_stress test [2], which does not look related. [1] http://pulpito.ceph.com/trociny-2017-01-15_08:17:14-rbd-wip-mgolub-testing---basic-smithi/ |
391e126
to
8d53d23
Compare
updated: forgot to remove unused headers from internal.cc |
librados::IoCtx &m_ioctx; | ||
CephContext *m_cct; | ||
ContextWQ *m_work_queue; | ||
std::string m_oid; | ||
const Locker &m_locker; |
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 Don't you think it would be safer to copy the locker in constructor? I just stepped on this in my LeaderWatcher, where I was calling break lock asynchronously and reset the locker not waiting for the request completed. No problem to change my code, but this was unexpected to me -- I had impression (may be wrong) we had a rule to copy input params like this.
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'd be fine if you changed it to support your use-case. W/ the original use-case, there was no race since the caller wouldn't be touching the memory while the call was in-progress.
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.
Can I just update this PR to include this change?
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
8d53d23
to
fd3e88e
Compare
@dillaman updated |
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
const std::string& oid, Watcher *watcher) { | ||
return new ManagedLock(ioctx, work_queue, oid, watcher); | ||
const std::string& oid, Watcher *watcher, | ||
bool blacklist_on_break_lock = true, |
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: can you remove the defaulted params here and below?
Signed-off-by: Mykola Golub <mgolub@mirantis.com>
fd3e88e
to
f810839
Compare
@dillaman updated |
No description provided.