Merge pull request #11468 from xiexingguo/xxg-wip-bluestore-1013

os/bluestore: traverse buffer_map in reverse order when spliting BufferSpace

Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2016-10-13 14:21:10 -05:00 committed by GitHub
commit 3ad8ccc53a
2 changed files with 34 additions and 24 deletions

View File

@ -995,7 +995,6 @@ OPTION(bluestore_extent_map_inline_shard_prealloc_size, OPT_U32, 256)
OPTION(bluestore_cache_type, OPT_STR, "2q") // lru, 2q
OPTION(bluestore_onode_cache_size, OPT_U32, 4*1024)
OPTION(bluestore_buffer_cache_size, OPT_U32, 512*1024*1024)
OPTION(bluestore_shared_blob_hash_table_size_ratio, OPT_FLOAT, 2) // multiple of onode_cache_size
OPTION(bluestore_kvbackend, OPT_STR, "rocksdb")
OPTION(bluestore_allocator, OPT_STR, "bitmap") // stupid | bitmap
OPTION(bluestore_freelist_type, OPT_STR, "bitmap") // extent | bitmap
@ -1531,7 +1530,7 @@ OPTION(rgw_torrent_createby, OPT_STR, "") // torrent field created by
OPTION(rgw_torrent_comment, OPT_STR, "") // torrent field comment
OPTION(rgw_torrent_encoding, OPT_STR, "") // torrent field encoding
OPTION(rgw_torrent_origin, OPT_STR, "") // torrent origin
OPTION(rgw_torrent_sha_unit, OPT_INT, 512*1024) //torrent field piece length 521K
OPTION(rgw_torrent_sha_unit, OPT_INT, 512*1024) // torrent field piece length 512K
// This will be set to true when it is safe to start threads.
// Once it is true, it will never change.

View File

@ -612,7 +612,7 @@ void BlueStore::TwoQCache::_add_buffer(Buffer *b, int level, Buffer *near)
{
dout(20) << __func__ << " level " << level << " near " << near
<< " on " << *b
<< " which has level " << b->cache_private << dendl;
<< " which has cache_private " << b->cache_private << dendl;
if (near) {
b->cache_private = near->cache_private;
switch (b->cache_private) {
@ -650,7 +650,7 @@ void BlueStore::TwoQCache::_add_buffer(Buffer *b, int level, Buffer *near)
b->cache_private = BUFFER_HOT;
// move to hot. fall-thru
case BUFFER_HOT:
dout(20) << __func__ << " move to hot " << *b << dendl;
dout(20) << __func__ << " move to front of hot " << *b << dendl;
buffer_hot.push_front(*b);
break;
default:
@ -1050,13 +1050,14 @@ void BlueStore::BufferSpace::split(size_t pos, BlueStore::BufferSpace &r)
{
std::lock_guard<std::recursive_mutex> lk(cache->lock);
assert(r.cache == cache);
auto p = buffer_map.begin();
while (p != buffer_map.end() &&
p->second->end() <= pos) {
dout(30) << __func__ << " skip " << *p->second << dendl;
++p;
}
if (p != buffer_map.end()) {
if (buffer_map.empty())
return;
auto p = --buffer_map.end();
while (true) {
if (p->second->end() <= pos)
break;
if (p->second->offset < pos) {
dout(30) << __func__ << " cut " << *p->second << dendl;
size_t left = pos - p->second->offset;
@ -1071,20 +1072,25 @@ void BlueStore::BufferSpace::split(size_t pos, BlueStore::BufferSpace &r)
0, p->second.get());
}
p->second->truncate(left);
++p;
break;
}
while (p != buffer_map.end()) {
dout(30) << __func__ << " move " << *p->second << dendl;
if (p->second->data.length()) {
r._add_buffer(new Buffer(&r, p->second->state, p->second->seq,
p->second->offset - pos, p->second->data),
0, p->second.get());
} else {
r._add_buffer(new Buffer(&r, p->second->state, p->second->seq,
p->second->offset - pos, p->second->length),
0, p->second.get());
}
_rm_buffer(p++);
assert(p->second->end() > pos);
dout(30) << __func__ << " move " << *p->second << dendl;
if (p->second->data.length()) {
r._add_buffer(new Buffer(&r, p->second->state, p->second->seq,
p->second->offset - pos, p->second->data),
0, p->second.get());
} else {
r._add_buffer(new Buffer(&r, p->second->state, p->second->seq,
p->second->offset - pos, p->second->length),
0, p->second.get());
}
if (p == buffer_map.begin()) {
_rm_buffer(p);
break;
} else {
_rm_buffer(p--);
}
}
assert(writing.empty());
@ -2459,6 +2465,11 @@ void BlueStore::_set_compression()
<< ", reverting compression mode to 'none'"
<< dendl;
comp_mode = COMP_NONE;
} else {
derr << __func__ << " compression algorithm not specified, "
<< "reverting compression mode to 'none'"
<< dendl;
comp_mode = COMP_NONE;
}
if (alg) {