summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zafman <david.zafman@inktank.com>2013-04-05 14:03:18 -0700
committerDavid Zafman <david.zafman@inktank.com>2013-04-19 11:29:18 -0700
commit76505c28de2879bf8edf8a454baeae08ddebb538 (patch)
tree995801da27423f35e8cd9d176e25cc490bf363bf
parent52d8240adf87fb969b5928d045ab0526f6a942db (diff)
downloadceph-76505c28de2879bf8edf8a454baeae08ddebb538.tar.gz
osd: Create new static function PG::_write_info() for use by PG import
Signed-off-by: David Zafman <david.zafman@inktank.com>
-rw-r--r--src/osd/PG.cc26
-rw-r--r--src/osd/PG.h6
2 files changed, 27 insertions, 5 deletions
diff --git a/src/osd/PG.cc b/src/osd/PG.cc
index 095e2073897..78c05246ea9 100644
--- a/src/osd/PG.cc
+++ b/src/osd/PG.cc
@@ -2493,11 +2493,17 @@ void PG::upgrade(ObjectStore *store, const interval_set<snapid_t> &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<epoch_t,pg_interval_t> &past_intervals,
+ interval_set<snapid_t> &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<snapid_t> purged_snaps;
map<string,bufferlist> 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 f437bafbb16..5ab9caa2ebe 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<epoch_t,pg_interval_t> &past_intervals,
+ interval_set<snapid_t> &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);