Skip to content
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: remove image header lock assertions #12472

Merged
merged 1 commit into from Dec 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/librbd/ExclusiveLock.cc
Expand Up @@ -244,13 +244,6 @@ void ExclusiveLock<I>::handle_peer_notification() {
execute_next_action();
}

template <typename I>
void ExclusiveLock<I>::assert_header_locked(librados::ObjectWriteOperation *op) {
Mutex::Locker locker(m_lock);
rados::cls::lock::assert_locked(op, RBD_LOCK_NAME, LOCK_EXCLUSIVE,
m_cookie, WATCHER_LOCK_TAG);
}

template <typename I>
std::string ExclusiveLock<I>::encode_lock_cookie() const {
assert(m_lock.is_locked());
Expand Down
2 changes: 0 additions & 2 deletions src/librbd/ExclusiveLock.h
Expand Up @@ -45,8 +45,6 @@ class ExclusiveLock {

void handle_peer_notification();

void assert_header_locked(librados::ObjectWriteOperation *op);

static bool decode_lock_cookie(const std::string &cookie, uint64_t *handle);

private:
Expand Down
4 changes: 0 additions & 4 deletions src/librbd/object_map/InvalidateRequest.cc
Expand Up @@ -59,10 +59,6 @@ void InvalidateRequest<I>::send() {

lderr(cct) << this << " invalidating object map on-disk" << dendl;
librados::ObjectWriteOperation op;
if (image_ctx.exclusive_lock != nullptr &&
m_snap_id == CEPH_NOSNAP && !m_force) {
image_ctx.exclusive_lock->assert_header_locked(&op);
}
cls_client::set_flags(&op, m_snap_id, flags, flags);

librados::AioCompletion *rados_completion =
Expand Down
3 changes: 0 additions & 3 deletions src/librbd/operation/FlattenRequest.cc
Expand Up @@ -140,9 +140,6 @@ bool FlattenRequest<I>::send_update_header() {

// remove parent from this (base) image
librados::ObjectWriteOperation op;
if (image_ctx.exclusive_lock != nullptr) {
image_ctx.exclusive_lock->assert_header_locked(&op);
}
cls_client::remove_parent(&op);

librados::AioCompletion *rados_completion = this->create_callback_completion();
Expand Down
3 changes: 0 additions & 3 deletions src/librbd/operation/RebuildObjectMapRequest.cc
Expand Up @@ -215,9 +215,6 @@ void RebuildObjectMapRequest<I>::send_update_header() {
m_state = STATE_UPDATE_HEADER;

librados::ObjectWriteOperation op;
if (m_image_ctx.exclusive_lock != nullptr) {
m_image_ctx.exclusive_lock->assert_header_locked(&op);
}

uint64_t flags = RBD_FLAG_OBJECT_MAP_INVALID | RBD_FLAG_FAST_DIFF_INVALID;
cls_client::set_flags(&op, m_image_ctx.snap_id, 0, flags);
Expand Down
3 changes: 0 additions & 3 deletions src/librbd/operation/ResizeRequest.cc
Expand Up @@ -388,9 +388,6 @@ void ResizeRequest<I>::send_update_header() {
bl.append(reinterpret_cast<const char*>(&m_new_size), sizeof(m_new_size));
op.write(offsetof(rbd_obj_header_ondisk, image_size), bl);
} else {
if (image_ctx.exclusive_lock != nullptr) {
image_ctx.exclusive_lock->assert_header_locked(&op);
}
cls_client::set_size(&op, m_new_size);
}

Expand Down
3 changes: 0 additions & 3 deletions src/librbd/operation/SnapshotCreateRequest.cc
Expand Up @@ -210,9 +210,6 @@ void SnapshotCreateRequest<I>::send_create_snap() {
if (image_ctx.old_format) {
cls_client::old_snapshot_add(&op, m_snap_id, m_snap_name);
} else {
if (image_ctx.exclusive_lock != nullptr) {
image_ctx.exclusive_lock->assert_header_locked(&op);
}
cls_client::snapshot_add(&op, m_snap_id, m_snap_name, m_snap_namespace);
}

Expand Down
4 changes: 0 additions & 4 deletions src/librbd/operation/SnapshotRemoveRequest.cc
Expand Up @@ -180,10 +180,6 @@ void SnapshotRemoveRequest<I>::send_remove_snap() {
if (image_ctx.old_format) {
cls_client::old_snapshot_remove(&op, m_snap_name);
} else {
if (image_ctx.exclusive_lock != nullptr &&
image_ctx.exclusive_lock->is_lock_owner()) {
image_ctx.exclusive_lock->assert_header_locked(&op);
}
cls_client::snapshot_remove(&op, m_snap_id);
}

Expand Down
4 changes: 0 additions & 4 deletions src/librbd/operation/SnapshotRenameRequest.cc
Expand Up @@ -89,10 +89,6 @@ void SnapshotRenameRequest<I>::send_rename_snap() {
if (image_ctx.old_format) {
cls_client::old_snapshot_rename(&op, m_snap_id, m_snap_name);
} else {
if (image_ctx.exclusive_lock != nullptr &&
image_ctx.exclusive_lock->is_lock_owner()) {
image_ctx.exclusive_lock->assert_header_locked(&op);
}
cls_client::snapshot_rename(&op, m_snap_id, m_snap_name);
}

Expand Down
2 changes: 0 additions & 2 deletions src/test/librbd/mock/MockExclusiveLock.h
Expand Up @@ -15,8 +15,6 @@ namespace librbd {
struct MockExclusiveLock {
MOCK_CONST_METHOD0(is_lock_owner, bool());

MOCK_METHOD1(assert_header_locked, void(librados::ObjectWriteOperation *));

MOCK_METHOD2(init, void(uint64_t features, Context*));
MOCK_METHOD1(shut_down, void(Context*));

Expand Down
9 changes: 0 additions & 9 deletions src/test/librbd/object_map/test_mock_InvalidateRequest.cc
Expand Up @@ -55,9 +55,6 @@ TEST_F(TestMockObjectMapInvalidateRequest, UpdatesHeadOnDiskFlag) {
C_SaferCond cond_ctx;
AsyncRequest<> *request = new InvalidateRequest<>(*ictx, CEPH_NOSNAP, false, &cond_ctx);

EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
exec(ictx->header_oid, _, StrEq("lock"), StrEq("assert_locked"), _, _, _))
.WillOnce(DoDefault());
EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
exec(ictx->header_oid, _, StrEq("rbd"), StrEq("set_flags"), _, _, _))
.WillOnce(DoDefault());
Expand Down Expand Up @@ -85,9 +82,6 @@ TEST_F(TestMockObjectMapInvalidateRequest, UpdatesSnapOnDiskFlag) {
AsyncRequest<> *request = new InvalidateRequest<>(*ictx, ictx->snap_id, false,
&cond_ctx);

EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
exec(ictx->header_oid, _, StrEq("lock"), StrEq("assert_locked"), _, _, _))
.Times(0);
EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
exec(ictx->header_oid, _, StrEq("rbd"), StrEq("set_flags"), _, _, _))
.WillOnce(DoDefault());
Expand Down Expand Up @@ -133,9 +127,6 @@ TEST_F(TestMockObjectMapInvalidateRequest, IgnoresOnDiskUpdateFailure) {
C_SaferCond cond_ctx;
AsyncRequest<> *request = new InvalidateRequest<>(*ictx, CEPH_NOSNAP, false, &cond_ctx);

EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
exec(ictx->header_oid, _, StrEq("lock"), StrEq("assert_locked"), _, _, _))
.WillOnce(DoDefault());
EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
exec(ictx->header_oid, _, StrEq("rbd"), StrEq("set_flags"), _, _, _))
.WillOnce(Return(-EINVAL));
Expand Down
2 changes: 0 additions & 2 deletions src/test/librbd/object_map/test_mock_ResizeRequest.cc
Expand Up @@ -41,8 +41,6 @@ class TestMockObjectMapResizeRequest : public TestMockFixture {
}

void expect_invalidate(librbd::ImageCtx *ictx) {
EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
exec(ictx->header_oid, _, StrEq("lock"), StrEq("assert_locked"), _, _, _)).Times(0);
EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
exec(ictx->header_oid, _, StrEq("rbd"), StrEq("set_flags"), _, _, _))
.WillOnce(DoDefault());
Expand Down
3 changes: 0 additions & 3 deletions src/test/librbd/object_map/test_mock_SnapshotRemoveRequest.cc
Expand Up @@ -63,9 +63,6 @@ class TestMockObjectMapSnapshotRemoveRequest : public TestMockFixture {
}

void expect_invalidate(librbd::ImageCtx *ictx) {
EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
exec(ictx->header_oid, _, StrEq("lock"), StrEq("assert_locked"), _, _, _))
.Times(0);
EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
exec(ictx->header_oid, _, StrEq("rbd"), StrEq("set_flags"), _, _, _))
.WillOnce(DoDefault());
Expand Down
Expand Up @@ -52,9 +52,6 @@ class TestMockObjectMapSnapshotRollbackRequest : public TestMockFixture {
}

void expect_invalidate(librbd::ImageCtx *ictx, uint32_t times) {
EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
exec(ictx->header_oid, _, StrEq("lock"), StrEq("assert_locked"), _, _, _))
.Times(0);
EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
exec(ictx->header_oid, _, StrEq("rbd"), StrEq("set_flags"), _, _, _))
.Times(times)
Expand Down
3 changes: 0 additions & 3 deletions src/test/librbd/object_map/test_mock_UpdateRequest.cc
Expand Up @@ -42,9 +42,6 @@ class TestMockObjectMapUpdateRequest : public TestMockFixture {
}

void expect_invalidate(librbd::ImageCtx *ictx) {
EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
exec(ictx->header_oid, _, StrEq("lock"), StrEq("assert_locked"), _, _, _))
.Times(0);
EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
exec(ictx->header_oid, _, StrEq("rbd"), StrEq("set_flags"), _, _, _))
.WillOnce(DoDefault());
Expand Down
3 changes: 0 additions & 3 deletions src/test/librbd/operation/test_mock_ResizeRequest.cc
Expand Up @@ -101,9 +101,6 @@ class TestMockOperationResizeRequest : public TestMockFixture {
.WillOnce(Return(r));
} else {
expect_is_lock_owner(mock_image_ctx);
if (mock_image_ctx.exclusive_lock != nullptr) {
EXPECT_CALL(*mock_image_ctx.exclusive_lock, assert_header_locked(_));
}
EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.md_ctx),
exec(mock_image_ctx.header_oid, _, StrEq("rbd"), StrEq("set_size"), _, _, _))
.WillOnce(Return(r));
Expand Down
6 changes: 0 additions & 6 deletions src/test/librbd/operation/test_mock_SnapshotCreateRequest.cc
Expand Up @@ -63,12 +63,6 @@ class TestMockOperationSnapshotCreateRequest : public TestMockFixture {
}

void expect_snap_create(MockImageCtx &mock_image_ctx, int r) {
if (!mock_image_ctx.old_format &&
mock_image_ctx.exclusive_lock != nullptr) {
EXPECT_CALL(*mock_image_ctx.exclusive_lock, assert_header_locked(_))
.Times(r == -ESTALE ? 2 : 1);
}

auto &expect = EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.md_ctx),
exec(mock_image_ctx.header_oid, _, StrEq("rbd"),
StrEq(mock_image_ctx.old_format ? "snap_add" :
Expand Down