summaryrefslogtreecommitdiff
path: root/src/osd/OSD.cc
diff options
context:
space:
mode:
authorLoic Dachary <loic@dachary.org>2013-05-22 14:14:26 +0200
committerSamuel Just <sam.just@inktank.com>2013-05-30 15:44:57 -0700
commitec7731f737bcd061d4d1189c391ccff2661ca7ee (patch)
treee651ac8ffbe3a13326822c41cfcb5be9d1aa675c /src/osd/OSD.cc
parentd1b3eebdedae0196d79fd18b4dc68f0b735d169f (diff)
downloadceph-ec7731f737bcd061d4d1189c391ccff2661ca7ee.tar.gz
move log, ondisklog, missing from PG to PGLog
PG::log, PG::ondisklog, PG::missing are moved from PG to a new PGLog class and are made protected data members. It is a preliminary step before writing unit tests to cover the methods that have side effects on these data members and define a clean PGLog API. It improves encapsulation and does not change any of the logic already in place. Possible issues : * an additional reference (PG->PGLog->IndexedLog instead of PG->IndexedLog for instance) is introduced : is it optimized ? * rewriting log.log into pg_log.get_log().log affects the readability but should be optimized and have no impact on performances The guidelines followed for this patch are: * const access to the data members are preserved, no attempt is made to define accessors * all non const methods are in PGLog, no access to non const methods of PGLog::log, PGLog::logondisk and PGLog::missing are provided * when methods are moved from PG to PGLog the change to their implementation is restricted to the minimum. * the PG::OndiskLog and PG::IndexedLog sub classes are moved to PGLog sub classes unmodified and remain public A const version of the pg_log_t::find_entry method was added. A const accessor is provided for PGLog::get_log, PGLog::get_missing, PGLog::get_ondisklog but no non-const accessor. Arguments are added to most of the methods moved from PG to PGLog so that they can get access to PG data members such as info or log_oid. The PGLog method are sorted according to the data member they modify. //////////////////// missing //////////////////// * The pg_missing_t::{got,have,need,add,rm} methods are wrapped as PGLog::missing_{got,have,need,add,rm} //////////////////// log //////////////////// * PGLog::get_tail, PGLog::get_head getters are created * PGLog::set_tail, PGLog::set_head, PGLog::set_last_requested setters are created * PGLog::index, PGLog::unindex, PGLog::add wrappers, PGLog::reset_recovery_pointers are created * PGLog::clear_info_log replaces PG::clear_info_log * PGLog::trim replaces PG::trim //////////////////// log & missing //////////////////// * PGLog::claim_log is created with code extracted from PG::RecoveryState::Stray::react. * PGLog::split_into is created with code extracted from PG::split_into. * PGLog::recover_got is created with code extracted from ReplicatedPG::recover_got. * PGLog::activate_not_complete is created with code extracted from PG::active * PGLog:proc_replica_log is created with code extracted from PG::proc_replica_log * PGLog:write_log is created with code extracted from PG::write_log * PGLog::merge_old_entry replaces PG::merge_old_entry The remove_snap argument is used to collect hobject_t * PGLog::rewind_divergent_log replaces PG::rewind_divergent_log The remove_snap argument is used to collect hobject_t A new PG::rewind_divergent_log method is added to call remove_snap_mapped_object on each of the remove_snap elements * PGLog::merge_log replaces PG::merge_log The remove_snap argument is used to collect hobject_t A new PG::merge_log method is added to call remove_snap_mapped_object on each of the remove_snap elements * PGLog:write_log is created with code extracted from PG::write_log. A non-static version is created for convenience but is a simple wrapper. * PGLog:read_log replaces PG::read_log. A non-static version is created for convenience but is a simple wrapper. * PGLog:read_log_old replaces PG::read_log_old. http://tracker.ceph.com/issues/5046 refs #5046 Signed-off-by: Loic Dachary <loic@dachary.org>
Diffstat (limited to 'src/osd/OSD.cc')
-rw-r--r--src/osd/OSD.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc
index 0ca3092372f..b6bdf2de409 100644
--- a/src/osd/OSD.cc
+++ b/src/osd/OSD.cc
@@ -1829,7 +1829,7 @@ void OSD::load_pgs()
PG::RecoveryCtx rctx(0, 0, 0, 0, 0, 0);
pg->handle_loaded(&rctx);
- dout(10) << "load_pgs loaded " << *pg << " " << pg->log << dendl;
+ dout(10) << "load_pgs loaded " << *pg << " " << pg->pg_log.get_log() << dendl;
pg->unlock();
}
dout(10) << "load_pgs done" << dendl;
@@ -3034,7 +3034,7 @@ void OSD::RemoveWQ::_process(pair<PGRef, DeletingStateRef> item)
return;
ObjectStore::Transaction *t = new ObjectStore::Transaction;
- PG::clear_info_log(
+ PGLog::clear_info_log(
pg->info.pgid,
OSD::make_infos_oid(),
pg->log_oid,
@@ -3645,8 +3645,10 @@ void OSD::do_command(Connection *con, tid_t tid, vector<string>& cmd, bufferlist
pg->lock();
fout << *pg << std::endl;
- std::map<hobject_t, pg_missing_t::item>::iterator mend = pg->missing.missing.end();
- std::map<hobject_t, pg_missing_t::item>::iterator mi = pg->missing.missing.begin();
+ std::map<hobject_t, pg_missing_t::item>::const_iterator mend =
+ pg->pg_log.get_missing().missing.end();
+ std::map<hobject_t, pg_missing_t::item>::const_iterator mi =
+ pg->pg_log.get_missing().missing.begin();
for (; mi != mend; ++mi) {
fout << mi->first << " -> " << mi->second << std::endl;
map<hobject_t, set<int> >::const_iterator mli =
@@ -5756,7 +5758,7 @@ void OSD::handle_pg_trim(OpRequestRef op)
} else {
// primary is instructing us to trim
ObjectStore::Transaction *t = new ObjectStore::Transaction;
- pg->trim(*t, m->trim_to);
+ pg->pg_log.trim(*t, m->trim_to, pg->info, pg->log_oid);
pg->dirty_info = true;
pg->write_if_dirty(*t);
int tr = store->queue_transaction(pg->osr.get(), t,