Skip to content

Commit

Permalink
osd/PG: clean up fastinfo key when last_update does not increase
Browse files Browse the repository at this point in the history
If the last_update field goes backwards, we write a full info instead of
the fastinfo key. However, a stale fastinfo key may still be present, and
it may have a last_update that looks valid to a restarting OSD.

Fixes: https://tracker.ceph.com/issues/43580
Reported-by: song <jinglesong0814@163.com>
Signed-off-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Jan 13, 2020
1 parent f996db6 commit 1de6111
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/osd/PG.cc
Expand Up @@ -949,10 +949,12 @@ void PG::prepare_write(
info.stats.stats.add(unstable_stats);
unstable_stats.clear();
map<string,bufferlist> km;
set<string> kd;
if (dirty_big_info || dirty_info) {
int ret = prepare_info_keymap(
cct,
&km,
&kd,
get_osdmap_epoch(),
info,
last_written_info,
Expand All @@ -968,6 +970,8 @@ void PG::prepare_write(
t, &km, coll, pgmeta_oid, pool.info.require_rollback());
if (!km.empty())
t.omap_setkeys(coll, pgmeta_oid, km);
if (!kd.empty())
t.omap_rmkeys(coll, pgmeta_oid, kd);
}

#pragma GCC diagnostic ignored "-Wpragmas"
Expand Down
5 changes: 5 additions & 0 deletions src/osd/osd_types.cc
Expand Up @@ -6840,6 +6840,7 @@ void OSDOp::clear_data(vector<OSDOp>& ops)
int prepare_info_keymap(
CephContext* cct,
map<string,bufferlist> *km,
set<string> *kd,
epoch_t epoch,
pg_info_t &info,
pg_info_t &last_written_info,
Expand Down Expand Up @@ -6885,6 +6886,10 @@ int prepare_info_keymap(
}
*_dout << dendl;
}
} else if (info.last_update <= last_written_info.last_update) {
// clean up any potentially stale fastinfo key resulting from last_update
// not moving forwards (e.g., a backwards jump during peering)
kd->insert(string(fastinfo_key));
}

last_written_info = info;
Expand Down
1 change: 1 addition & 0 deletions src/osd/osd_types.h
Expand Up @@ -6229,6 +6229,7 @@ static const __u8 pg_compat_struct_v = 10;
int prepare_info_keymap(
CephContext* cct,
map<string,bufferlist> *km,
set<string> *kd,
epoch_t epoch,
pg_info_t &info,
pg_info_t &last_written_info,
Expand Down

0 comments on commit 1de6111

Please sign in to comment.