From b2f752a9e1e69bc2c40fb60a2801b8d3531932a7 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 27 Dec 2013 15:41:47 -0800 Subject: [PATCH] osd/ReplicatedPG: construct appropriate snapc for flush/writeback Construct a snap context that will trigger the appropriate cloning (if any) on the base pool. Signed-off-by: Sage Weil --- src/osd/ReplicatedPG.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index c8b0eb54746..780bfd6f844 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -5331,7 +5331,22 @@ int ReplicatedPG::start_flush(OpContext *ctx, bool blocking) C_Flush *fin = new C_Flush(this, soid, get_last_peering_reset()); object_locator_t base_oloc(soid); base_oloc.pool = pool.info.tier_of; - SnapContext snapc; // FIXME + + // construct a SnapContext appropriate for this clone/head + SnapContext snapc; + if (soid.snap == CEPH_NOSNAP) { + snapc.seq = snapset.seq; + snapc.snaps = snapset.snaps; + } else { + // we want to only include snaps that are older than the oldest + // snap for which we are defined, so that the object appears to + // have been written before that. + vector::iterator p = snapset.snaps.begin(); + while (p != snapset.snaps.end() && *p >= oi.snaps.back()) + p++; + snapc.snaps = vector(p, snapset.snaps.end()); + snapc.seq = oi.snaps.back() - 1; + } osd->objecter_lock.Lock(); tid_t tid = osd->objecter->mutate(soid.oid, base_oloc, o, snapc, oi.mtime, -- 2.47.3