Merge pull request #11151 from ceph/wip-bluestore-error-injection

os/bluestore: add error injection
This commit is contained in:
Sage Weil 2016-09-22 09:17:06 -05:00 committed by GitHub
commit 36ea571027
3 changed files with 57 additions and 1 deletions

View File

@ -1018,6 +1018,7 @@ OPTION(bluestore_debug_small_allocations, OPT_INT, 0)
OPTION(bluestore_debug_freelist, OPT_BOOL, false)
OPTION(bluestore_debug_prefill, OPT_FLOAT, 0)
OPTION(bluestore_debug_prefragment_max, OPT_INT, 1048576)
OPTION(bluestore_debug_inject_read_err, OPT_BOOL, false)
OPTION(bluestore_inject_wal_apply_delay, OPT_FLOAT, 0)
OPTION(bluestore_shard_finishers, OPT_BOOL, false)

View File

@ -2179,6 +2179,7 @@ BlueStore::BlueStore(CephContext *cct, const string& path)
kv_sync_thread(this),
kv_stop(false),
logger(NULL),
debug_read_error_lock("BlueStore::debug_read_error_lock"),
csum_type(bluestore_blob_t::CSUM_CRC32C),
sync_wal_apply(cct->_conf->bluestore_sync_wal_apply)
{
@ -4496,7 +4497,12 @@ int BlueStore::stat(
c->cache->trim(
g_conf->bluestore_onode_cache_size,
g_conf->bluestore_buffer_cache_size);
return 0;
int r = 0;
if (_debug_mdata_eio(oid)) {
r = -EIO;
derr << __func__ << " " << c->cid << " " << oid << " INJECT EIO" << dendl;
}
return r;
}
int BlueStore::read(
@ -4553,6 +4559,10 @@ int BlueStore::read(
c->cache->trim(
g_conf->bluestore_onode_cache_size,
g_conf->bluestore_buffer_cache_size);
if (r == 0 && _debug_data_eio(oid)) {
r = -EIO;
derr << __func__ << " " << c->cid << " " << oid << " INJECT EIO" << dendl;
}
dout(10) << __func__ << " " << cid << " " << oid
<< " 0x" << std::hex << offset << "~" << length << std::dec
<< " = " << r << dendl;
@ -4999,6 +5009,10 @@ int BlueStore::getattr(
c->cache->trim(
g_conf->bluestore_onode_cache_size,
g_conf->bluestore_buffer_cache_size);
if (r == 0 && _debug_mdata_eio(oid)) {
r = -EIO;
derr << __func__ << " " << c->cid << " " << oid << " INJECT EIO" << dendl;
}
dout(10) << __func__ << " " << c->cid << " " << oid << " " << name
<< " = " << r << dendl;
return r;
@ -5043,6 +5057,10 @@ int BlueStore::getattrs(
c->cache->trim(
g_conf->bluestore_onode_cache_size,
g_conf->bluestore_buffer_cache_size);
if (r == 0 && _debug_mdata_eio(oid)) {
r = -EIO;
derr << __func__ << " " << c->cid << " " << oid << " INJECT EIO" << dendl;
}
dout(10) << __func__ << " " << c->cid << " " << oid
<< " = " << r << dendl;
return r;
@ -7670,6 +7688,7 @@ int BlueStore::_do_remove(
txc->t->rmkey(PREFIX_OBJ, s.key);
}
txc->t->rmkey(PREFIX_OBJ, o->key);
_debug_obj_on_delete(o->oid);
return 0;
}

View File

@ -1332,6 +1332,10 @@ private:
std::mutex reap_lock;
list<CollectionRef> removed_collections;
RWLock debug_read_error_lock;
set<ghobject_t, ghobject_t::BitwiseComparator> debug_data_error_objects;
set<ghobject_t, ghobject_t::BitwiseComparator> debug_mdata_error_objects;
int csum_type;
uint64_t block_size; ///< block size of block device (power of 2)
@ -1671,6 +1675,38 @@ public:
TrackedOpRef op = TrackedOpRef(),
ThreadPool::TPHandle *handle = NULL) override;
// error injection
void inject_data_error(const ghobject_t& o) override {
RWLock::WLocker l(debug_read_error_lock);
debug_data_error_objects.insert(o);
}
void inject_mdata_error(const ghobject_t& o) override {
RWLock::WLocker l(debug_read_error_lock);
debug_mdata_error_objects.insert(o);
}
private:
bool _debug_data_eio(const ghobject_t& o) {
if (!g_conf->bluestore_debug_inject_read_err) {
return false;
}
RWLock::RLocker l(debug_read_error_lock);
return debug_data_error_objects.count(o);
}
bool _debug_mdata_eio(const ghobject_t& o) {
if (!g_conf->bluestore_debug_inject_read_err) {
return false;
}
RWLock::RLocker l(debug_read_error_lock);
return debug_mdata_error_objects.count(o);
}
void _debug_obj_on_delete(const ghobject_t& o) {
if (g_conf->bluestore_debug_inject_read_err) {
RWLock::WLocker l(debug_read_error_lock);
debug_data_error_objects.erase(o);
debug_mdata_error_objects.erase(o);
}
}
private:
// --------------------------------------------------------