From: David Zafman Date: Fri, 5 Apr 2013 21:03:18 +0000 (-0700) Subject: osd: Create new static function PG::_write_info() for use by PG import X-Git-Tag: v0.61~135^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=76505c28de2879bf8edf8a454baeae08ddebb538;p=ceph.git osd: Create new static function PG::_write_info() for use by PG import Signed-off-by: David Zafman --- diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 095e20738978..78c05246ea97 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -2493,11 +2493,17 @@ void PG::upgrade(ObjectStore *store, const interval_set &snapcolls) assert(r == 0); } -void PG::write_info(ObjectStore::Transaction& t) +int PG::_write_info(ObjectStore::Transaction& t, epoch_t epoch, + pg_info_t &info, coll_t coll, + map &past_intervals, + interval_set &snap_collections, + hobject_t &infos_oid, + __u8 info_struct_v, bool dirty_big_info) { // pg state - assert(info_struct_v <= cur_struct_v); + if (info_struct_v > cur_struct_v) + return -EINVAL; // Only need to write struct_v to attr when upgrading if (info_struct_v < cur_struct_v) { @@ -2511,7 +2517,7 @@ void PG::write_info(ObjectStore::Transaction& t) // info. store purged_snaps separately. interval_set purged_snaps; map v; - ::encode(get_osdmap()->get_epoch(), v[get_epoch_key(info.pgid)]); + ::encode(epoch, v[get_epoch_key(info.pgid)]); purged_snaps.swap(info.purged_snaps); ::encode(info, v[get_info_key(info.pgid)]); purged_snaps.swap(info.purged_snaps); @@ -2522,10 +2528,20 @@ void PG::write_info(ObjectStore::Transaction& t) ::encode(past_intervals, bigbl); ::encode(snap_collections, bigbl); ::encode(info.purged_snaps, bigbl); - dout(20) << "write_info bigbl " << bigbl.length() << dendl; + //dout(20) << "write_info bigbl " << bigbl.length() << dendl; } - t.omap_setkeys(coll_t::META_COLL, osd->infos_oid, v); + t.omap_setkeys(coll_t::META_COLL, infos_oid, v); + + return 0; +} + +void PG::write_info(ObjectStore::Transaction& t) +{ + int ret = _write_info(t, get_osdmap()->get_epoch(), info, coll, + past_intervals, snap_collections, osd->infos_oid, + info_struct_v, dirty_big_info); + assert(ret == 0); dirty_info = false; dirty_big_info = false; diff --git a/src/osd/PG.h b/src/osd/PG.h index f437bafbb16e..5ab9caa2ebe9 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -1831,6 +1831,12 @@ private: void write_log(ObjectStore::Transaction& t); public: + static int _write_info(ObjectStore::Transaction& t, epoch_t epoch, + pg_info_t &info, coll_t coll, + map &past_intervals, + interval_set &snap_collections, + hobject_t &infos_oid, + __u8 info_struct_v, bool dirty_big_info); void write_if_dirty(ObjectStore::Transaction& t); void add_log_entry(pg_log_entry_t& e, bufferlist& log_bl);