diff options
author | Samuel Just <sam.just@inktank.com> | 2013-02-11 12:52:07 -0800 |
---|---|---|
committer | Samuel Just <sam.just@inktank.com> | 2013-03-21 12:25:18 -0700 |
commit | 9f7c6ad395653b1039ea957cfaa7689699f510e7 (patch) | |
tree | 0c9427a55d0809b3f260725b5db393c77e87a8fd | |
parent | 9932c9f0a0503f1902549a3c39e5d51488fff3ef (diff) | |
download | ceph-9f7c6ad395653b1039ea957cfaa7689699f510e7.tar.gz |
FileStore: set replay guard on create_collection
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)
-rw-r--r-- | src/os/FileStore.cc | 26 | ||||
-rw-r--r-- | src/os/FileStore.h | 1 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 6e002d39468..cc2001fa086 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -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]; diff --git a/src/os/FileStore.h b/src/os/FileStore.h index 7e450ceb82c..3336e59378e 100644 --- a/src/os/FileStore.h +++ b/src/os/FileStore.h @@ -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); |