Skip to content

Commit

Permalink
Merge pull request #8254 from xiexingguo/xxg-wip-osd
Browse files Browse the repository at this point in the history
osd: fix reference count, rare race condition etc.

Reviewed-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
liewegas committed Mar 26, 2016
2 parents c972d0c + 03c5a93 commit 77cec5d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 47 deletions.
78 changes: 37 additions & 41 deletions src/osd/OSD.cc
Expand Up @@ -5061,7 +5061,6 @@ void OSD::handle_pg_stats_ack(MPGStatsAck *ack)
dout(10) << "handle_pg_stats_ack " << dendl;

if (!require_mon_peer(ack)) {
ack->put();
return;
}

Expand Down Expand Up @@ -7832,40 +7831,39 @@ void OSD::handle_pg_trim(OpRequestRef op)

op->mark_started();

if (!_have_pg(m->pgid)) {
PG *pg = _lookup_lock_pg(m->pgid);
if(!pg) {
dout(10) << " don't have pg " << m->pgid << dendl;
} else {
PG *pg = _lookup_lock_pg(m->pgid);
assert(pg);
if (m->epoch < pg->info.history.same_interval_since) {
dout(10) << *pg << " got old trim to " << m->trim_to << ", ignoring" << dendl;
pg->unlock();
return;
}
return;
}

if (pg->is_primary()) {
// peer is informing us of their last_complete_ondisk
dout(10) << *pg << " replica osd." << from << " lcod " << m->trim_to << dendl;
pg->peer_last_complete_ondisk[pg_shard_t(from, m->pgid.shard)] =
m->trim_to;
if (pg->calc_min_last_complete_ondisk()) {
dout(10) << *pg << " min lcod now " << pg->min_last_complete_ondisk << dendl;
pg->trim_peers();
}
} else {
// primary is instructing us to trim
ObjectStore::Transaction t;
PG::PGLogEntryHandler handler;
pg->pg_log.trim(&handler, m->trim_to, pg->info);
handler.apply(pg, &t);
pg->dirty_info = true;
pg->write_if_dirty(t);
int tr = store->queue_transaction(
pg->osr.get(), std::move(t), NULL);
assert(tr == 0);
}
if (m->epoch < pg->info.history.same_interval_since) {
dout(10) << *pg << " got old trim to " << m->trim_to << ", ignoring" << dendl;
pg->unlock();
return;
}

if (pg->is_primary()) {
// peer is informing us of their last_complete_ondisk
dout(10) << *pg << " replica osd." << from << " lcod " << m->trim_to << dendl;
pg->peer_last_complete_ondisk[pg_shard_t(from, m->pgid.shard)] =
m->trim_to;
if (pg->calc_min_last_complete_ondisk()) {
dout(10) << *pg << " min lcod now " << pg->min_last_complete_ondisk << dendl;
pg->trim_peers();
}
} else {
// primary is instructing us to trim
ObjectStore::Transaction t;
PG::PGLogEntryHandler handler;
pg->pg_log.trim(&handler, m->trim_to, pg->info);
handler.apply(pg, &t);
pg->dirty_info = true;
pg->write_if_dirty(t);
int tr = store->queue_transaction(pg->osr.get(), std::move(t), NULL);
assert(tr == 0);
}
pg->unlock();
}

void OSD::handle_pg_backfill_reserve(OpRequestRef op)
Expand Down Expand Up @@ -7906,12 +7904,11 @@ void OSD::handle_pg_backfill_reserve(OpRequestRef op)
return;
}

PG *pg = 0;
if (!_have_pg(m->pgid))
PG *pg = _lookup_lock_pg(m->pgid);
if (!pg) {
dout(10) << " don't have pg " << m->pgid << dendl;
return;

pg = _lookup_lock_pg(m->pgid);
assert(pg);
}

pg->queue_peering_event(evt);
pg->unlock();
Expand Down Expand Up @@ -7955,12 +7952,11 @@ void OSD::handle_pg_recovery_reserve(OpRequestRef op)
return;
}

PG *pg = 0;
if (!_have_pg(m->pgid))
PG *pg = _lookup_lock_pg(m->pgid);
if (!pg) {
dout(10) << " don't have pg " << m->pgid << dendl;
return;

pg = _lookup_lock_pg(m->pgid);
assert(pg);
}

pg->queue_peering_event(evt);
pg->unlock();
Expand Down
7 changes: 1 addition & 6 deletions src/osd/PG.cc
Expand Up @@ -2009,12 +2009,7 @@ void PG::_activate_committed(epoch_t epoch, epoch_t activation_epoch)
}
}

if (dirty_info) {
ObjectStore::Transaction t;
write_if_dirty(t);
int tr = osd->store->queue_transaction(osr.get(), std::move(t), NULL);
assert(tr == 0);
}
assert(!dirty_info);

unlock();
}
Expand Down

0 comments on commit 77cec5d

Please sign in to comment.