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: cache was not switching to writeback after first flush #10762

Merged
merged 1 commit into from Aug 19, 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
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