]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: guard collection_rename replay
authorSage Weil <sage.weil@dreamhost.com>
Thu, 8 Mar 2012 04:53:51 +0000 (20:53 -0800)
committerSage Weil <sage@newdream.net>
Sat, 10 Mar 2012 00:32:22 +0000 (16:32 -0800)
- check guard on replay
- set guard on apply

Signed-off-by: Sage Weil <sage@newdream.net>
src/os/FileStore.cc
src/os/FileStore.h

index c4b3bce6af6882c2ccba999afa20a52937692e16..6e4edab64ff4ea5d3bad8370d6e562d362350a09 100644 (file)
@@ -3980,15 +3980,27 @@ int FileStore::_collection_setattrs(coll_t cid, map<string,bufferptr>& aset)
   return r;
 }
 
-int FileStore::_collection_rename(const coll_t &cid, const coll_t &ncid)
+int FileStore::_collection_rename(const coll_t &cid, const coll_t &ncid,
+                                 const SequencerPosition& spos)
 {
   char new_coll[PATH_MAX], old_coll[PATH_MAX];
   get_cdir(cid, old_coll, sizeof(old_coll));
   get_cdir(ncid, new_coll, sizeof(new_coll));
+
+  if (!_check_replay_guard(ncid, spos))
+    return 0;
+
   int ret = 0;
   if (::rename(old_coll, new_coll)) {
     ret = -errno;
   }
+
+  if (ret >= 0) {
+    int fd = ::open(new_coll, O_RDONLY);
+    assert(fd >= 0);
+    _set_replay_guard(fd, NULL, NULL, spos);
+  }
+
   dout(10) << "collection_rename '" << cid << "' to '" << ncid << "'"
           << ": ret = " << ret << dendl;
   return ret;
index 1555c5b0e79458a59d09ca68f30ac8d60074240b..a633c31d8b414f8b6087b7bcfa3078191f5d9900 100644 (file)
@@ -391,7 +391,8 @@ public:
   int _collection_setattr(coll_t c, const char *name, const void *value, size_t size);
   int _collection_rmattr(coll_t c, const char *name);
   int _collection_setattrs(coll_t cid, map<string,bufferptr> &aset);
-  int _collection_rename(const coll_t &cid, const coll_t &ncid);
+  int _collection_rename(const coll_t &cid, const coll_t &ncid,
+                        const SequencerPosition& spos);
 
   // collections
   int list_collections(vector<coll_t>& ls);