]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
FileStore: _split_collection should not create the collection
authorSamuel Just <sam.just@inktank.com>
Mon, 11 Feb 2013 20:24:14 +0000 (12:24 -0800)
committerSamuel Just <sam.just@inktank.com>
Tue, 12 Feb 2013 18:15:03 +0000 (10:15 -0800)
This will simplify adding a replay guard to create_collection.

Backport: bobtail
Signed-off-by: Samuel Just <sam.just@inktank.com>
src/os/FileStore.cc
src/os/FileStore.h
src/os/ObjectStore.cc
src/os/ObjectStore.h
src/osd/OSD.cc

index bfd9137c99ed31e7968591df3a00fc51b6bd4cce..ba23563a82a89e319722fa40c93b18c63bab3163 100644 (file)
@@ -2591,6 +2591,15 @@ unsigned FileStore::_do_transaction(Transaction& t, uint64_t op_seq, int trans_n
       }
       break;
     case Transaction::OP_SPLIT_COLLECTION:
+      {
+       coll_t cid(i.get_cid());
+       uint32_t bits(i.get_u32());
+       uint32_t rem(i.get_u32());
+       coll_t dest(i.get_cid());
+       r = _split_collection_create(cid, bits, rem, dest, spos);
+      }
+      break;
+    case Transaction::OP_SPLIT_COLLECTION2:
       {
        coll_t cid(i.get_cid());
        uint32_t bits(i.get_u32());
@@ -4611,6 +4620,43 @@ int FileStore::_split_collection(coll_t cid,
                                 uint32_t rem,
                                 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);
+
+  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);
+  return r;
+}
+
+// DEPRECATED: remove once we are sure there won't be any such transactions
+// replayed
+int FileStore::_split_collection_create(coll_t cid,
+                                       uint32_t bits,
+                                       uint32_t rem,
+                                       coll_t dest,
+                                       const SequencerPosition &spos)
 {
   dout(15) << __func__ << " " << cid << " bits: " << bits << dendl;
   int r = _create_collection(dest);
index b781de2b432b58ddb55c11d2535d13cfe34b47ee..7e450ceb82c0405a9ea3e5960e6dd28cfe551a31 100644 (file)
@@ -475,6 +475,9 @@ private:
                      const SequencerPosition &spos);
   int _split_collection(coll_t cid, uint32_t bits, uint32_t rem, coll_t dest,
                         const SequencerPosition &spos);
+  int _split_collection_create(coll_t cid, uint32_t bits, uint32_t rem,
+                              coll_t dest,
+                              const SequencerPosition &spos);
 
   virtual const char** get_tracked_conf_keys() const;
   virtual void handle_conf_change(const struct md_config_t *conf,
index 70e8b6ed19eac77ca973f7f6df90c433eb5297ad..813356f33ed9d2a377255c0a14c827355e4b623f 100644 (file)
@@ -414,6 +414,19 @@ void ObjectStore::Transaction::dump(ceph::Formatter *f)
       break;
 
     case Transaction::OP_SPLIT_COLLECTION:
+      {
+       coll_t cid(i.get_cid());
+       uint32_t bits(i.get_u32());
+       uint32_t rem(i.get_u32());
+       coll_t dest(i.get_cid());
+       f->dump_string("op_name", "op_split_collection_create");
+       f->dump_stream("collection") << cid;
+       f->dump_stream("bits") << bits;
+       f->dump_stream("rem") << rem;
+       f->dump_stream("dest") << dest;
+      }
+
+    case Transaction::OP_SPLIT_COLLECTION2:
       {
        coll_t cid(i.get_cid());
        uint32_t bits(i.get_u32());
index 504422981f48dca2beb1990a77986c7d8b04bdf8..e88a67fe66b133bd542adac12f0767d8dbf3f1fd 100644 (file)
@@ -153,6 +153,8 @@ public:
       OP_OMAP_RMKEYS = 33,  // cid, keyset
       OP_OMAP_SETHEADER = 34, // cid, header
       OP_SPLIT_COLLECTION = 35, // cid, bits, destination
+      OP_SPLIT_COLLECTION2 = 36, /* cid, bits, destination
+                                   doesn't create the destination */
     };
 
   private:
@@ -555,7 +557,7 @@ public:
       uint32_t bits,
       uint32_t rem,
       coll_t destination) {
-      __u32 op = OP_SPLIT_COLLECTION;
+      __u32 op = OP_SPLIT_COLLECTION2;
       ::encode(op, tbl);
       ::encode(cid, tbl);
       ::encode(bits, tbl);
index 1785678ced4bef7f4a68b264bbb97ae61f97fdb1..fe85532db0b2ee7d4f56ad690941b1d5df86b678 100644 (file)
@@ -4732,6 +4732,8 @@ void OSD::split_pgs(
     dout(10) << "m_seed " << i->ps() << dendl;
     dout(10) << "split_bits is " << split_bits << dendl;
 
+    rctx->transaction->create_collection(
+      coll_t(*i));
     rctx->transaction->split_collection(
       coll_t(parent->info.pgid),
       split_bits,
@@ -4742,6 +4744,8 @@ void OSD::split_pgs(
         ++k) {
       for (snapid_t j = k.get_start(); j < k.get_start() + k.get_len();
           ++j) {
+       rctx->transaction->create_collection(
+         coll_t(*i, j));
        rctx->transaction->split_collection(
          coll_t(parent->info.pgid, j),
          split_bits,