From: Greg Farnum Date: Fri, 15 Nov 2013 23:16:20 +0000 (-0800) Subject: osd/PG: factor out get_next_version() X-Git-Tag: v0.75~98^2~43 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9776e97af2d72fd62a278fa8fa04367895eb015b;p=ceph.git osd/PG: factor out get_next_version() Signed-off-by: Sage Weil Signed-off-by: Greg Farnum --- diff --git a/src/osd/PG.h b/src/osd/PG.h index a1f1d2c1a69c..b59392848496 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -1702,6 +1702,14 @@ public: __u8 info_struct_v, bool dirty_big_info, bool force_ver = false); void write_if_dirty(ObjectStore::Transaction& t); + eversion_t get_next_version() const { + eversion_t at_version(get_osdmap()->get_epoch(), + pg_log.get_head().version+1); + assert(at_version > info.last_update); + assert(at_version > pg_log.get_head()); + return at_version; + } + void add_log_entry(pg_log_entry_t& e, bufferlist& log_bl); void append_log( vector& logv, eversion_t trim_to, ObjectStore::Transaction &t); diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 19592a64cea7..0fb3da07afb9 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -1272,13 +1272,7 @@ void ReplicatedPG::execute_ctx(OpContext *ctx) } // version - ctx->at_version = pg_log.get_head(); - - ctx->at_version.epoch = get_osdmap()->get_epoch(); - ctx->at_version.version++; - assert(ctx->at_version > info.last_update); - assert(ctx->at_version > pg_log.get_head()); - + ctx->at_version = get_next_version(); ctx->mtime = m->get_mtime(); dout(10) << "do_op " << soid << " " << ctx->ops @@ -1853,9 +1847,7 @@ ReplicatedPG::RepGather *ReplicatedPG::trim_object(const hobject_t &coid) obc->ssc, this); ctx->mtime = ceph_clock_now(cct); - - ctx->at_version.epoch = get_osdmap()->get_epoch(); - ctx->at_version.version = pg_log.get_head().version + 1; + ctx->at_version = get_next_version(); RepGather *repop = new_repop(ctx, obc, rep_tid); @@ -5167,9 +5159,7 @@ void ReplicatedPG::handle_watch_timeout(WatchRef watch) OpContext *ctx = new OpContext(OpRequestRef(), reqid, ops, &obc->obs, obc->ssc, this); ctx->mtime = ceph_clock_now(cct); - - ctx->at_version.epoch = get_osdmap()->get_epoch(); - ctx->at_version.version = pg_log.get_head().version + 1; + ctx->at_version = get_next_version(); entity_inst_t nobody;