Merge PR #23552 into master

* refs/pull/23552/head:
	ceph_test_objectstore: queue split on parent pg sequencer
	os/bluestore: fix split vs finish_write race

Reviewed-by: Igor Fedotov <ifedotov@suse.com>
Reviewed-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
This commit is contained in:
Sage Weil 2018-08-14 10:34:29 -05:00
commit 1ee7b8c6c2
3 changed files with 24 additions and 7 deletions

View File

@ -1367,10 +1367,8 @@ void BlueStore::BufferSpace::read(
cache->logger->inc(l_bluestore_buffer_miss_bytes, miss_bytes);
}
void BlueStore::BufferSpace::finish_write(Cache* cache, uint64_t seq)
void BlueStore::BufferSpace::_finish_write(Cache* cache, uint64_t seq)
{
std::lock_guard<std::recursive_mutex> l(cache->lock);
auto i = writing.begin();
while (i != writing.end()) {
if (i->seq > seq) {
@ -1641,6 +1639,23 @@ void BlueStore::SharedBlob::put_ref(uint64_t offset, uint32_t length,
unshare && !*unshare ? unshare : nullptr);
}
void BlueStore::SharedBlob::finish_write(uint64_t seq)
{
while (true) {
Cache *cache = coll->cache;
std::lock_guard<std::recursive_mutex> l(cache->lock);
if (coll->cache != cache) {
ldout(coll->store->cct, 20) << __func__
<< " raced with sb cache update, was " << cache
<< ", now " << coll->cache << ", retrying"
<< dendl;
continue;
}
bc._finish_write(cache, seq);
break;
}
}
// SharedBlobSet
#undef dout_prefix
@ -8884,7 +8899,7 @@ void BlueStore::_txc_finish(TransContext *txc)
assert(txc->state == TransContext::STATE_FINISHING);
for (auto& sb : txc->shared_blobs_written) {
sb->bc.finish_write(sb->get_cache(), txc->seq);
sb->finish_write(txc->seq);
}
txc->shared_blobs_written.clear();

View File

@ -336,7 +336,7 @@ public:
b->cache_private = _discard(cache, offset, bl.length());
_add_buffer(cache, b, (flags & Buffer::FLAG_NOCACHE) ? 0 : 1, nullptr);
}
void finish_write(Cache* cache, uint64_t seq);
void _finish_write(Cache* cache, uint64_t seq);
void did_read(Cache* cache, uint32_t offset, bufferlist& bl) {
std::lock_guard<std::recursive_mutex> l(cache->lock);
Buffer *b = new Buffer(this, Buffer::STATE_CLEAN, 0, offset, bl);
@ -412,6 +412,8 @@ public:
void put_ref(uint64_t offset, uint32_t length,
PExtentVector *r, bool *unshare);
void finish_write(uint64_t seq);
friend bool operator==(const SharedBlob &l, const SharedBlob &r) {
return l.get_sbid() == r.get_sbid();
}

View File

@ -5129,10 +5129,10 @@ void colsplittest(
ObjectStore::Transaction t;
t.create_collection(tid, common_suffix_size + 1);
t.split_collection(cid, common_suffix_size+1, 1<<common_suffix_size, tid);
r = queue_transaction(store, tch, std::move(t));
r = queue_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
tch->flush();
ch->flush();
ObjectStore::Transaction t;
vector<ghobject_t> objects;