Skip to content

Commit

Permalink
Merge branch 'wip-16654' into wip-mgolub-testing
Browse files Browse the repository at this point in the history
 librbd: cache was not switching to writeback after first flush #10762
  • Loading branch information
Mykola Golub committed Aug 18, 2016
2 parents 68e6b4e + 2d9840a commit bc517fc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/librbd/AioImageRequest.cc
Expand Up @@ -563,6 +563,8 @@ void AioImageDiscard<I>::update_stats(size_t length) {
template <typename I>
void AioImageFlush<I>::send_request() {
I &image_ctx = this->m_image_ctx;
image_ctx.user_flushed();

bool journaling = false;
{
RWLock::RLocker snap_locker(image_ctx.snap_lock);
Expand Down
6 changes: 6 additions & 0 deletions src/test/librbd/journal/test_Replay.cc
Expand Up @@ -687,6 +687,12 @@ TEST_F(TestJournalReplay, ObjectPosition) {
ASSERT_EQ(0, aio_comp->wait_for_complete());
aio_comp->release();

{
// user flush requests are ignored when journaling + cache are enabled
RWLock::RLocker owner_lock(ictx->owner_lock);
ictx->flush();
}

// check the commit position updated
get_journal_commit_position(ictx, &current_tag, &current_entry);
ASSERT_EQ(initial_tag + 1, current_tag);
Expand Down
1 change: 1 addition & 0 deletions src/test/librbd/mock/MockImageCtx.h
Expand Up @@ -148,6 +148,7 @@ struct MockImageCtx {
uint8_t protection_status, uint64_t flags));
MOCK_METHOD2(rm_snap, void(std::string in_snap_name, librados::snap_t id));

MOCK_METHOD0(user_flushed, void());
MOCK_METHOD1(flush, void(Context *));
MOCK_METHOD1(flush_async_operations, void(Context *));
MOCK_METHOD1(flush_copyup, void(Context *));
Expand Down
5 changes: 5 additions & 0 deletions src/test/librbd/test_mock_AioImageRequest.cc
Expand Up @@ -169,6 +169,10 @@ struct TestMockAioImageRequest : public TestMockFixture {
}));
}

void expect_user_flushed(MockImageCtx &mock_image_ctx) {
EXPECT_CALL(mock_image_ctx, user_flushed());
}

void expect_flush(MockImageCtx &mock_image_ctx, int r) {
EXPECT_CALL(mock_image_ctx, flush(_))
.WillOnce(CompleteContext(r, mock_image_ctx.image_ctx->op_work_queue));
Expand Down Expand Up @@ -240,6 +244,7 @@ TEST_F(TestMockAioImageRequest, AioFlushJournalAppendDisabled) {
mock_image_ctx.journal = &mock_journal;

InSequence seq;
expect_user_flushed(mock_image_ctx);
expect_is_journal_appending(mock_journal, false);
expect_flush(mock_image_ctx, 0);

Expand Down

0 comments on commit bc517fc

Please sign in to comment.