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

buffer: fix internal iterator invalidation on rebuild, get_contiguous #6962

Merged
merged 2 commits into from Dec 31, 2015
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
4 changes: 4 additions & 0 deletions src/common/buffer.cc
Expand Up @@ -1402,6 +1402,7 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
if (nb.length())
_buffers.push_back(nb);
invalidate_crc();
last_p = begin();
}

void buffer::list::rebuild_aligned(unsigned align)
Expand Down Expand Up @@ -1449,6 +1450,7 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
}
_buffers.insert(p, unaligned._buffers.front());
}
last_p = begin();
}

void buffer::list::rebuild_page_aligned()
Expand Down Expand Up @@ -1693,6 +1695,8 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
return tmp.c_str() + off;
}

last_p = begin(); // we modified _buffers

return curbuf->c_str() + off;
}

Expand Down
11 changes: 11 additions & 0 deletions src/test/bufferlist.cc
Expand Up @@ -876,6 +876,17 @@ TEST(BufferListIterator, constructors) {
}
}

TEST(BufferListIterator, empty_create_append_copy) {
bufferlist bl, bl2, bl3, out;
bl2.append("bar");
bl.swap(bl2);
bl2.append("xxx");
bl.append(bl2);
bl.rebuild();
bl.copy(0, 6, out);
ASSERT_TRUE(out.contents_equal(bl));
}

TEST(BufferListIterator, operator_equal) {
bufferlist bl;
bl.append("ABC", 3);
Expand Down