osd/ECBackend: Send write message to peers first, then do local write

Like ReplicatedBackend did, this will improve write performance.

  Signed-off-by: huangjun <hjwsm1989@gmail.com>
This commit is contained in:
huangjun 2016-12-16 17:33:26 +08:00
parent 8d7d5ae3ff
commit 7858f7e355

View File

@ -1884,7 +1884,8 @@ bool ECBackend::try_reads_to_commit()
dout(10) << "onreadable_sync: " << op->on_local_applied_sync << dendl; dout(10) << "onreadable_sync: " << op->on_local_applied_sync << dendl;
ObjectStore::Transaction empty; ObjectStore::Transaction empty;
bool should_write_local = false;
ECSubWrite local_write_op;
for (set<pg_shard_t>::const_iterator i = for (set<pg_shard_t>::const_iterator i =
get_parent()->get_actingbackfill_shards().begin(); get_parent()->get_actingbackfill_shards().begin();
i != get_parent()->get_actingbackfill_shards().end(); i != get_parent()->get_actingbackfill_shards().end();
@ -1916,12 +1917,8 @@ bool ECBackend::try_reads_to_commit()
op->temp_cleared, op->temp_cleared,
!should_send); !should_send);
if (*i == get_parent()->whoami_shard()) { if (*i == get_parent()->whoami_shard()) {
handle_sub_write( should_write_local = true;
get_parent()->whoami_shard(), local_write_op.claim(sop);
op->client_op,
sop,
op->on_local_applied_sync);
op->on_local_applied_sync = 0;
} else { } else {
MOSDECSubOpWrite *r = new MOSDECSubOpWrite(sop); MOSDECSubOpWrite *r = new MOSDECSubOpWrite(sop);
r->pgid = spg_t(get_parent()->primary_spg_t().pgid, i->shard); r->pgid = spg_t(get_parent()->primary_spg_t().pgid, i->shard);
@ -1930,6 +1927,14 @@ bool ECBackend::try_reads_to_commit()
i->osd, r, get_parent()->get_epoch()); i->osd, r, get_parent()->get_epoch());
} }
} }
if (should_write_local) {
handle_sub_write(
get_parent()->whoami_shard(),
op->client_op,
local_write_op,
op->on_local_applied_sync);
op->on_local_applied_sync = 0;
}
for (auto i = op->on_write.begin(); for (auto i = op->on_write.begin();
i != op->on_write.end(); i != op->on_write.end();