From 7f87cf1b1d710f76539291ff66ec0616851f0a7d Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Wed, 24 Sep 2014 13:55:47 -0700 Subject: [PATCH] ReplicatedPG: clean out completed trimmed objects as we go Also, explicitely maintain a max number of concurrently trimming objects. Fixes: 9113 Backport: dumpling, firefly, giant Signed-off-by: Samuel Just --- src/common/config_opts.h | 3 ++ src/osd/ReplicatedPG.cc | 61 ++++++++++++++++++++++++---------------- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index a065a772f9b13..f9a4a5929e59d 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -480,6 +480,9 @@ OPTION(osd_heartbeat_interval, OPT_INT, 6) // (seconds) how often we ping OPTION(osd_heartbeat_grace, OPT_INT, 20) // (seconds) how long before we decide a peer has failed OPTION(osd_heartbeat_min_peers, OPT_INT, 10) // minimum number of peers +// max number of parallel snap trims/pg +OPTION(osd_pg_max_concurrent_snap_trims, OPT_U64, 2) + // minimum number of peers tha tmust be reachable to mark ourselves // back up after being wrongly marked down. OPTION(osd_heartbeat_min_healthy_ratio, OPT_FLOAT, .33) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 95b61a3112246..de58ebefc58a1 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -11889,32 +11889,45 @@ boost::statechart::result ReplicatedPG::TrimmingObjects::react(const SnapTrim&) dout(10) << "TrimmingObjects: trimming snap " << snap_to_trim << dendl; - // Get next - hobject_t old_pos = pos; - int r = pg->snap_mapper.get_next_object_to_trim(snap_to_trim, &pos); - if (r != 0 && r != -ENOENT) { - derr << __func__ << ": get_next returned " << cpp_strerror(r) << dendl; - assert(0); - } else if (r == -ENOENT) { - // Done! - dout(10) << "TrimmingObjects: got ENOENT" << dendl; - post_event(SnapTrim()); - return transit< WaitingOnReplicas >(); + for (set::iterator i = repops.begin(); + i != repops.end(); + ) { + if ((*i)->all_applied && (*i)->all_committed) { + (*i)->put(); + repops.erase(i++); + } else { + ++i; + } } - dout(10) << "TrimmingObjects react trimming " << pos << dendl; - RepGather *repop = pg->trim_object(pos); - if (!repop) { - dout(10) << __func__ << " could not get write lock on obj " - << pos << dendl; - pos = old_pos; - return discard_event(); - } - assert(repop); - repop->queue_snap_trimmer = true; + while (repops.size() < g_conf->osd_pg_max_concurrent_snap_trims) { + // Get next + hobject_t old_pos = pos; + int r = pg->snap_mapper.get_next_object_to_trim(snap_to_trim, &pos); + if (r != 0 && r != -ENOENT) { + derr << __func__ << ": get_next returned " << cpp_strerror(r) << dendl; + assert(0); + } else if (r == -ENOENT) { + // Done! + dout(10) << "TrimmingObjects: got ENOENT" << dendl; + post_event(SnapTrim()); + return transit< WaitingOnReplicas >(); + } + + dout(10) << "TrimmingObjects react trimming " << pos << dendl; + RepGather *repop = pg->trim_object(pos); + if (!repop) { + dout(10) << __func__ << " could not get write lock on obj " + << pos << dendl; + pos = old_pos; + return discard_event(); + } + assert(repop); + repop->queue_snap_trimmer = true; - repops.insert(repop->get()); - pg->simple_repop_submit(repop); + repops.insert(repop->get()); + pg->simple_repop_submit(repop); + } return discard_event(); } /* WaitingOnReplicasObjects */ @@ -11948,7 +11961,7 @@ boost::statechart::result ReplicatedPG::WaitingOnReplicas::react(const SnapTrim& for (set::iterator i = repops.begin(); i != repops.end(); repops.erase(i++)) { - if (!(*i)->all_applied) { + if (!(*i)->all_applied || !(*i)->all_committed) { return discard_event(); } else { (*i)->put(); -- 2.39.5