]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
FileStore: set replay guard on create_collection
authorSamuel Just <sam.just@inktank.com>
Mon, 11 Feb 2013 20:52:07 +0000 (12:52 -0800)
committerSamuel Just <sam.just@inktank.com>
Thu, 21 Mar 2013 19:25:18 +0000 (12:25 -0700)
This should prevent sequences like:

rmcoll a
mkcoll a
touch a foo
<crash>

from causing trouble by preventing the rmcoll
and mkcoll from being replayed.

Fixes: 4064
Backport: bobtail
Signed-off-by: Samuel Just <sam.just@inktank.com>
(cherry picked from commit 411770c45734c9827745ddc4018d86c14f2858a6)

src/os/FileStore.cc
src/os/FileStore.h

index 6e002d39468dbacc90a176ffcbd5fe51eb5ffb33..cc2001fa086b914755110853ea167175fbb7fc40 100644 (file)
@@ -2481,7 +2481,7 @@ unsigned FileStore::_do_transaction(Transaction& t, uint64_t op_seq, int trans_n
       {
        coll_t cid = i.get_cid();
        if (_check_replay_guard(cid, spos) > 0)
-         r = _create_collection(cid);
+         r = _create_collection(cid, spos);
       }
       break;
 
@@ -4470,6 +4470,30 @@ ObjectMap::ObjectMapIterator FileStore::get_omap_iterator(coll_t c,
   return object_map->get_iterator(hoid);
 }
 
+int FileStore::_create_collection(
+  coll_t c,
+  const SequencerPosition &spos)
+{
+  char fn[PATH_MAX];
+  get_cdir(c, fn, sizeof(fn));
+  dout(15) << "create_collection " << fn << dendl;
+  int r = ::mkdir(fn, 0755);
+  if (r < 0)
+    r = -errno;
+  if (r == -EEXIST && replaying)
+    r = 0;
+  dout(10) << "create_collection " << fn << " = " << r << dendl;
+
+  if (r < 0)
+    return r;
+  r = init_index(c);
+  if (r < 0)
+    return r;
+  _set_replay_guard(c, spos);
+  return 0;
+}
+
+// DEPRECATED -- remove with _split_collection_create
 int FileStore::_create_collection(coll_t c) 
 {
   char fn[PATH_MAX];
index 7e450ceb82c0405a9ea3e5960e6dd28cfe551a31..3336e59378ee96ff9367ed25cd8e6416269ab064 100644 (file)
@@ -453,6 +453,7 @@ public:
   ObjectMap::ObjectMapIterator get_omap_iterator(coll_t c, const hobject_t &hoid);
 
   int _create_collection(coll_t c);
+  int _create_collection(coll_t c, const SequencerPosition &spos);
   int _destroy_collection(coll_t c);
   int _collection_add(coll_t c, coll_t ocid, const hobject_t& o,
                      const SequencerPosition& spos);