Skip to content

Commit

Permalink
Merge pull request #10053: jewel: Close journal and object map before…
Browse files Browse the repository at this point in the history
… flagging exclusive lock as released

Reviewed-by: Loic Dachary <ldachary@redhat.com>
  • Loading branch information
Loic Dachary committed Jul 1, 2016
2 parents 48249cb + d9c3f28 commit 270c08e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/librbd/exclusive_lock/ReleaseRequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,6 @@ Context *ReleaseRequest<I>::handle_block_writes(int *ret_val) {
return m_on_finish;
}

if (m_on_releasing != nullptr) {
// alert caller that we no longer own the exclusive lock
m_on_releasing->complete(0);
m_on_releasing = nullptr;
}

send_flush_notifies();
return nullptr;
}
Expand Down Expand Up @@ -211,6 +205,12 @@ void ReleaseRequest<I>::send_unlock() {
CephContext *cct = m_image_ctx.cct;
ldout(cct, 10) << __func__ << dendl;

if (m_on_releasing != nullptr) {
// alert caller that we no longer own the exclusive lock
m_on_releasing->complete(0);
m_on_releasing = nullptr;
}

librados::ObjectWriteOperation op;
rados::cls::lock::unlock(&op, RBD_LOCK_NAME, m_cookie);

Expand Down
20 changes: 17 additions & 3 deletions src/test/librbd/exclusive_lock/test_mock_ReleaseRequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ template class librbd::exclusive_lock::ReleaseRequest<librbd::MockImageCtx>;
namespace librbd {
namespace exclusive_lock {

namespace {

struct MockContext : public Context {
MOCK_METHOD1(complete, void(int));
MOCK_METHOD1(finish, void(int));
};

} // anonymous namespace

using ::testing::_;
using ::testing::InSequence;
using ::testing::Return;
Expand All @@ -30,6 +39,10 @@ class TestMockExclusiveLockReleaseRequest : public TestMockFixture {
public:
typedef ReleaseRequest<MockImageCtx> MockReleaseRequest;

void expect_complete_context(MockContext &mock_context, int r) {
EXPECT_CALL(mock_context, complete(r));
}

void expect_test_features(MockImageCtx &mock_image_ctx, uint64_t features,
bool enabled) {
EXPECT_CALL(mock_image_ctx, test_features(features))
Expand Down Expand Up @@ -105,15 +118,16 @@ TEST_F(TestMockExclusiveLockReleaseRequest, Success) {
mock_image_ctx.object_map = mock_object_map;
expect_close_object_map(mock_image_ctx, *mock_object_map);

MockContext mock_releasing_ctx;
expect_complete_context(mock_releasing_ctx, 0);
expect_unlock(mock_image_ctx, 0);

C_SaferCond release_ctx;
C_SaferCond ctx;
MockReleaseRequest *req = MockReleaseRequest::create(mock_image_ctx,
TEST_COOKIE,
&release_ctx, &ctx);
&mock_releasing_ctx,
&ctx);
req->send();
ASSERT_EQ(0, release_ctx.wait());
ASSERT_EQ(0, ctx.wait());
}

Expand Down

0 comments on commit 270c08e

Please sign in to comment.