Skip to content

Commit

Permalink
Merge pull request #10050 from dachary/wip-16459-jewel
Browse files Browse the repository at this point in the history
jewel: rbd-mirror should disable proxied maintenance ops for non-primary image

Reviewed-by: Mykola Golub <mgolub@mirantis.com>
  • Loading branch information
Loic Dachary committed Aug 9, 2016
2 parents 64d5ff9 + db28ddc commit 8fb4121
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 123 deletions.
23 changes: 13 additions & 10 deletions src/librbd/ExclusiveLock.cc
Expand Up @@ -75,33 +75,36 @@ bool ExclusiveLock<I>::is_lock_owner() const {
}

template <typename I>
bool ExclusiveLock<I>::accept_requests() const {
bool ExclusiveLock<I>::accept_requests(int *ret_val) const {
Mutex::Locker locker(m_lock);

bool accept_requests = (!is_shutdown() && m_state == STATE_LOCKED &&
m_request_blockers == 0);
!m_request_blocked);
*ret_val = m_request_blocked_ret_val;

ldout(m_image_ctx.cct, 20) << this << " " << __func__ << "="
<< accept_requests << dendl;
return accept_requests;
}

template <typename I>
void ExclusiveLock<I>::block_requests() {
void ExclusiveLock<I>::block_requests(int r) {
Mutex::Locker locker(m_lock);
++m_request_blockers;
assert(!m_request_blocked);
m_request_blocked = true;
m_request_blocked_ret_val = r;

ldout(m_image_ctx.cct, 20) << this << " " << __func__ << "="
<< m_request_blockers << dendl;
ldout(m_image_ctx.cct, 20) << this << " " << __func__ << dendl;
}

template <typename I>
void ExclusiveLock<I>::unblock_requests() {
Mutex::Locker locker(m_lock);
assert(m_request_blockers > 0);
--m_request_blockers;
assert(m_request_blocked);
m_request_blocked = false;
m_request_blocked_ret_val = 0;

ldout(m_image_ctx.cct, 20) << this << " " << __func__ << "="
<< m_request_blockers << dendl;
ldout(m_image_ctx.cct, 20) << this << " " << __func__ << dendl;
}

template <typename I>
Expand Down
7 changes: 4 additions & 3 deletions src/librbd/ExclusiveLock.h
Expand Up @@ -30,9 +30,9 @@ class ExclusiveLock {
~ExclusiveLock();

bool is_lock_owner() const;
bool accept_requests() const;
bool accept_requests(int *ret_val) const;

void block_requests();
void block_requests(int r);
void unblock_requests();

void init(uint64_t features, Context *on_init);
Expand Down Expand Up @@ -130,7 +130,8 @@ class ExclusiveLock {

ActionsContexts m_actions_contexts;

uint32_t m_request_blockers = 0;
bool m_request_blocked = false;
int m_request_blocked_ret_val = 0;

std::string encode_lock_cookie() const;

Expand Down

0 comments on commit 8fb4121

Please sign in to comment.