From: Sage Weil Date: Mon, 15 Jun 2015 20:49:18 +0000 (-0700) Subject: osd: clear temp objects in the OSD, not FileStore X-Git-Tag: v9.0.3~52^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b4ce84bf42168359a2f609ce801305beab4f179c;p=ceph.git osd: clear temp objects in the OSD, not FileStore 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 --- diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 3e5ea55c63a1..cd0a11306396 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -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 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::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; diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 17367e820424..5e60b0fb7f50 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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 ls; + store->list_collections(ls); + for (vector::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 temps; + ghobject_t next; + while (1) { + vector 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::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::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) { diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 970e2d5327cd..7ce7d6a30658 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -1151,6 +1151,8 @@ private: void write_superblock(ObjectStore::Transaction& t); int read_superblock(); + void clear_temp_objects(); + CompatSet osd_compat; // -- state --