Skip to content

Commit

Permalink
PG: update PGPool to detect map gaps and reset cached_removed_snaps
Browse files Browse the repository at this point in the history
Fixes: http://tracker.ceph.com/issues/15943
Signed-off-by: Samuel Just <sjust@redhat.com>
  • Loading branch information
athanatos committed May 23, 2016
1 parent ca9d87d commit 5798fb3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
8 changes: 1 addition & 7 deletions src/osd/OSD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2986,14 +2986,8 @@ PGPool OSD::_get_pool(int id, OSDMapRef createmap)
assert(0);
}

PGPool p = PGPool(id, createmap->get_pool_name(id),
createmap->get_pg_pool(id)->auid);
PGPool p = PGPool(createmap, id);

const pg_pool_t *pi = createmap->get_pg_pool(id);
p.info = *pi;
p.snapc = pi->get_snap_context();

pi->build_removed_snaps(p.cached_removed_snaps);
dout(10) << "_get_pool " << p.id << dendl;
return p;
}
Expand Down
9 changes: 6 additions & 3 deletions src/osd/PG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ void PGPool::update(OSDMapRef map)
info = *pi;
auid = pi->auid;
name = map->get_pool_name(id);
if (pi->get_snap_epoch() == map->get_epoch()) {
bool updated = false;
if ((map->get_epoch() == cached_epoch + 1) &&
(pi->get_snap_epoch() == map->get_epoch())) {
updated = true;
pi->build_removed_snaps(newly_removed_snaps);
interval_set<snapid_t> intersection;
intersection.intersection_of(newly_removed_snaps, cached_removed_snaps);
Expand All @@ -180,14 +183,14 @@ void PGPool::update(OSDMapRef map)
} else {
newly_removed_snaps.clear();
}
cached_epoch = map->get_epoch();
lgeneric_subdout(g_ceph_context, osd, 20)
<< "PGPool::update cached_removed_snaps "
<< cached_removed_snaps
<< " newly_removed_snaps "
<< newly_removed_snaps
<< " snapc " << snapc
<< (pi->get_snap_epoch() == map->get_epoch() ?
" (updated)":" (no change)")
<< (updated ? " (updated)":" (no change)")
<< dendl;
}

Expand Down
14 changes: 12 additions & 2 deletions src/osd/PG.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ struct PGRecoveryStats {
};

struct PGPool {
epoch_t cached_epoch;
int64_t id;
string name;
uint64_t auid;
Expand All @@ -171,8 +172,17 @@ struct PGPool {
interval_set<snapid_t> cached_removed_snaps; // current removed_snaps set
interval_set<snapid_t> newly_removed_snaps; // newly removed in the last epoch

PGPool(int64_t i, const string& _name, uint64_t au)
: id(i), name(_name), auid(au) { }
PGPool(OSDMapRef map, int64_t i)
: cached_epoch(map->get_epoch()),
id(i),
name(map->get_pool_name(id)),
auid(map->get_pg_pool(id)->auid) {
const pg_pool_t *pi = map->get_pg_pool(id);
assert(pi);
info = *pi;
snapc = pi->get_snap_context();
pi->build_removed_snaps(cached_removed_snaps);
}

void update(OSDMapRef map);
};
Expand Down

0 comments on commit 5798fb3

Please sign in to comment.