]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: clear temp objects in the OSD, not FileStore
authorSage Weil <sage@redhat.com>
Mon, 15 Jun 2015 20:49:18 +0000 (13:49 -0700)
committerSage Weil <sage@redhat.com>
Fri, 19 Jun 2015 00:02:49 +0000 (17:02 -0700)
This is really an OSD level behavior, and one that we want to apply to all
other backends--not just FileStore.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/FileStore.cc
src/osd/OSD.cc
src/osd/OSD.h

index 3e5ea55c63a14573fca8a7b82b9250820b48e5e6..cd0a11306396aa806f1d179495353806e19895a0 100644 (file)
@@ -1651,21 +1651,6 @@ void FileStore::init_temp_collections()
       continue;
     coll_t temp = p->get_temp();
     if (temps.count(temp)) {
-      // yay, it exists.  make sure it is empty.
-      vector<ghobject_t> oids;
-      r = collection_list(temp, oids);
-      assert(r == 0);
-      if (!oids.empty()) {
-       dout(10) << __func__ << " clearing " << oids.size()
-                << " objects from " << temp << dendl;
-       Transaction t;
-       for (vector<ghobject_t>::iterator q = oids.begin();
-            q != oids.end();
-            ++q)
-         t.remove(temp, *q);
-       r = _do_transaction(t, 0, 0, NULL);
-       assert(r == 0);
-      }
       temps.erase(temp);
     } else {
       dout(10) << __func__ << " creating " << temp << dendl;
index 17367e820424a1aad4c18d47084a34c0d6f312ea..5e60b0fb7f5049e5883ecf5069a2d42a11eafebf 100644 (file)
@@ -1843,6 +1843,8 @@ int OSD::init()
     service.set_epochs(NULL, NULL, &bind_epoch);
   }
 
+  clear_temp_objects();
+
   // load up pgs (as they previously existed)
   load_pgs();
 
@@ -2459,7 +2461,50 @@ int OSD::read_superblock()
   return 0;
 }
 
+void OSD::clear_temp_objects()
+{
+  dout(10) << __func__ << dendl;
+  vector<coll_t> ls;
+  store->list_collections(ls);
+  for (vector<coll_t>::iterator p = ls.begin(); p != ls.end(); ++p) {
+    spg_t pgid;
+    if (!p->is_pg(&pgid))
+      continue;
 
+    // list temp objects
+    dout(20) << " clearing temps in " << *p << " pgid " << pgid << dendl;
+
+    vector<ghobject_t> temps;
+    ghobject_t next;
+    while (1) {
+      vector<ghobject_t> objects;
+      store->collection_list_partial(*p, next,
+                                    store->get_ideal_list_min(),
+                                    store->get_ideal_list_max(),
+                                    0, &objects, &next);
+      if (objects.empty())
+       break;
+      for (vector<ghobject_t>::iterator q = objects.begin(); q != objects.end();
+          ++q) {
+       if (q->hobj.is_temp()) {
+         temps.push_back(*q);
+       } else {
+         break;
+       }
+      }
+      if (!objects.empty())
+       break;
+    }
+    if (!temps.empty()) {
+      ObjectStore::Transaction t;
+      for (vector<ghobject_t>::iterator q = temps.begin(); q != temps.end(); ++q) {
+       dout(20) << "  removing " << *p << " object " << *q << dendl;
+       t.remove(*p, *q);
+      }
+      store->apply_transaction(t);
+    }
+  }
+}
 
 void OSD::recursive_remove_collection(ObjectStore *store, spg_t pgid, coll_t tmp)
 {
index 970e2d5327cd23f8508afdd873914541913cdb50..7ce7d6a30658625aff126e9aa5bbba76bf683160 100644 (file)
@@ -1151,6 +1151,8 @@ private:
   void write_superblock(ObjectStore::Transaction& t);
   int read_superblock();
 
+  void clear_temp_objects();
+
   CompatSet osd_compat;
 
   // -- state --