]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: add debug option to verify split results
authorSamuel Just <sam.just@inktank.com>
Sat, 9 Mar 2013 06:14:37 +0000 (22:14 -0800)
committerSamuel Just <sam.just@inktank.com>
Thu, 14 Mar 2013 02:45:12 +0000 (19:45 -0700)
Signed-off-by: Samuel Just <sam.just@inktank.com>
src/common/config_opts.h
src/os/FileStore.cc

index 09facc4c2d94c2a1a1b60b8f2389aad453dfe432..d18a1188c95204a892d6952ca810b1bbf4215c28 100644 (file)
@@ -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)
index bd235586f90ac091c07b00300ba7ef9cda10e383..7ebbe4bb707a16d74e6f0d100a97427a8c449d1b 100644 (file)
@@ -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<hobject_t> 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<hobject_t>::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<hobject_t>::iterator i = objects.begin();
+          i != objects.end();
+          ++i) {
+       assert(i->match(bits, rem));
+      }
+      objects.clear();
+    }
+  }
   return r;
 }