From: Samuel Just Date: Sat, 9 Mar 2013 06:14:37 +0000 (-0800) Subject: filestore: add debug option to verify split results X-Git-Tag: v0.60~78^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4ac16ec9b5ba3adf7bf58f83f59f3d9939fbba74;p=ceph.git filestore: add debug option to verify split results Signed-off-by: Samuel Just --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 09facc4c2d9..d18a1188c95 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -468,6 +468,7 @@ OPTION(filestore_kill_at, OPT_INT, 0) // inject a failure at the n'th OPTION(filestore_inject_stall, OPT_INT, 0) // artificially stall for N seconds in op queue thread OPTION(filestore_fail_eio, OPT_BOOL, true) // fail/crash on EIO OPTION(filestore_replica_fadvise, OPT_BOOL, true) +OPTION(filestore_debug_verify_split, OPT_BOOL, false) OPTION(journal_dio, OPT_BOOL, true) OPTION(journal_aio, OPT_BOOL, false) OPTION(journal_block_align, OPT_BOOL, true) diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index bd235586f90..7ebbe4bb707 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -4686,32 +4686,72 @@ int FileStore::_split_collection(coll_t cid, coll_t dest, const SequencerPosition &spos) { - dout(15) << __func__ << " " << cid << " bits: " << bits << dendl; - int dstcmp = _check_replay_guard(dest, spos); - if (dstcmp < 0) - return 0; - if (dstcmp > 0 && !collection_empty(dest)) - return -ENOTEMPTY; - - int srccmp = _check_replay_guard(cid, spos); - if (srccmp < 0) - return 0; - - _set_replay_guard(cid, spos, true); - _set_replay_guard(dest, spos, true); - - Index from; - int r = get_index(cid, &from); + int r; + { + dout(15) << __func__ << " " << cid << " bits: " << bits << dendl; + int dstcmp = _check_replay_guard(dest, spos); + if (dstcmp < 0) + return 0; + if (dstcmp > 0 && !collection_empty(dest)) + return -ENOTEMPTY; - Index to; - if (!r) - r = get_index(dest, &to); + int srccmp = _check_replay_guard(cid, spos); + if (srccmp < 0) + return 0; - if (!r) - r = from->split(rem, bits, to); + _set_replay_guard(cid, spos, true); + _set_replay_guard(dest, spos, true); - _close_replay_guard(cid, spos); - _close_replay_guard(dest, spos); + Index from; + r = get_index(cid, &from); + + Index to; + if (!r) + r = get_index(dest, &to); + + if (!r) + r = from->split(rem, bits, to); + + _close_replay_guard(cid, spos); + _close_replay_guard(dest, spos); + } + if (g_conf->filestore_debug_verify_split) { + vector objects; + hobject_t next; + while (1) { + collection_list_partial( + cid, + next, + get_ideal_list_min(), get_ideal_list_max(), 0, + &objects, + &next); + if (objects.empty()) + break; + for (vector::iterator i = objects.begin(); + i != objects.end(); + ++i) { + assert(!i->match(bits, rem)); + } + objects.clear(); + } + next = hobject_t(); + while (1) { + collection_list_partial( + dest, + next, + get_ideal_list_min(), get_ideal_list_max(), 0, + &objects, + &next); + if (objects.empty()) + break; + for (vector::iterator i = objects.begin(); + i != objects.end(); + ++i) { + assert(i->match(bits, rem)); + } + objects.clear(); + } + } return r; }