PG,ReplicatedPG: move write_blocked_by_scrub logic into a helper

Signed-off-by: Samuel Just <sam.just@inktank.com>
This commit is contained in:
Samuel Just 2012-12-11 22:19:09 -08:00
parent 54618afab2
commit 64cefe2c60
2 changed files with 20 additions and 9 deletions

View File

@ -875,6 +875,21 @@ public:
bool is_chunky_scrub_active() const { return state != INACTIVE; }
// classic (non chunk) scrubs block all writes
// chunky scrubs only block writes to a range
bool write_blocked_by_scrub(const hobject_t &soid) {
if (!block_writes)
return false;
if (!is_chunky)
return true;
if (soid >= start && soid < end)
return true;
return false;
}
// clear all state
void reset() {
finalizing = false;

View File

@ -628,15 +628,11 @@ void ReplicatedPG::do_op(OpRequestRef op)
CEPH_NOSNAP, m->get_pg().ps(),
info.pgid.pool());
if (scrubber.block_writes && m->may_write()) {
// classic (non chunk) scrubs block all writes
// chunky scrubs only block writes to a range
if (!scrubber.is_chunky || (head >= scrubber.start && head < scrubber.end)) {
dout(20) << __func__ << ": waiting for scrub" << dendl;
waiting_for_active.push_back(op);
op->mark_delayed();
return;
}
if (m->may_write() && scrubber.write_blocked_by_scrub(head)) {
dout(20) << __func__ << ": waiting for scrub" << dendl;
waiting_for_active.push_back(op);
op->mark_delayed();
return;
}
// missing object?