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

os/bluestore: enlarege aligned_size avoid too many vector(> IOV_MAX) #18828

Merged
merged 1 commit into from
Nov 13, 2017
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
8 changes: 7 additions & 1 deletion src/common/buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1756,9 +1756,15 @@ using namespace ceph;
}

bool buffer::list::rebuild_aligned_size_and_memory(unsigned align_size,
unsigned align_memory)
unsigned align_memory,
unsigned max_buffers)
{
unsigned old_memcopy_count = _memcopy_count;

if (max_buffers && _buffers.size() > max_buffers
&& _len > (max_buffers * align_size)) {
align_size = ROUND_UP_TO(ROUND_UP_TO(_len, max_buffers) / max_buffers, align_size);
}
std::list<ptr>::iterator p = _buffers.begin();
while (p != _buffers.end()) {
// keep anything that's already align and sized aligned
Expand Down
5 changes: 4 additions & 1 deletion src/include/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,11 @@ namespace buffer CEPH_BUFFER_API {
void rebuild();
void rebuild(ptr& nb);
bool rebuild_aligned(unsigned align);
// max_buffers = 0 mean don't care _buffers.size(), other
// must make _buffers.size() <= max_buffers after rebuilding.
bool rebuild_aligned_size_and_memory(unsigned align_size,
unsigned align_memory);
unsigned align_memory,
unsigned max_buffers = 0);
bool rebuild_page_aligned();

void reserve(size_t prealloc);
Expand Down
4 changes: 2 additions & 2 deletions src/os/bluestore/KernelDevice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ int KernelDevice::write(
assert(is_valid_io(off, len));

if ((!buffered || bl.get_num_buffers() >= IOV_MAX) &&
bl.rebuild_aligned_size_and_memory(block_size, block_size)) {
bl.rebuild_aligned_size_and_memory(block_size, block_size, IOV_MAX)) {
dout(20) << __func__ << " rebuilding buffer to be aligned" << dendl;
}
dout(40) << "data: ";
Expand All @@ -620,7 +620,7 @@ int KernelDevice::aio_write(
assert(off + len <= size);

if ((!buffered || bl.get_num_buffers() >= IOV_MAX) &&
bl.rebuild_aligned_size_and_memory(block_size, block_size)) {
bl.rebuild_aligned_size_and_memory(block_size, block_size, IOV_MAX)) {
dout(20) << __func__ << " rebuilding buffer to be aligned" << dendl;
}
dout(40) << "data: ";
Expand Down