From 1fe6cb0f0243eac384803d1a6e4a67c51090e94c Mon Sep 17 00:00:00 2001 From: David Zafman Date: Tue, 8 Aug 2017 07:22:33 -0700 Subject: [PATCH] osd: Avoid confusion over legacy snaps when head_exists corrupt Signed-off-by: David Zafman --- qa/standalone/scrub/osd-scrub-snaps.sh | 3 +-- src/osd/PG.cc | 3 +++ src/osd/PrimaryLogPG.cc | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/qa/standalone/scrub/osd-scrub-snaps.sh b/qa/standalone/scrub/osd-scrub-snaps.sh index 2c647845709..8fa348ec6b7 100755 --- a/qa/standalone/scrub/osd-scrub-snaps.sh +++ b/qa/standalone/scrub/osd-scrub-snaps.sh @@ -450,9 +450,8 @@ EOF err_strings[19]="log_channel[(]cluster[)] log [[]ERR[]] : scrub [0-9]*[.]0 .*:::obj9:1 is missing in clone_size" err_strings[20]="log_channel[(]cluster[)] log [[]ERR[]] : scrub [0-9]*[.]0 .*:::obj11:1 is an unexpected clone" err_strings[21]="log_channel[(]cluster[)] log [[]ERR[]] : scrub [0-9]*[.]0 .*:::obj14:1 size 1032 != clone_size 1033" - err_strings[22]="log_channel[(]cluster[)] log [[]ERR[]] : [0-9]*[.]0 scrub 23 errors" + err_strings[22]="log_channel[(]cluster[)] log [[]ERR[]] : [0-9]*[.]0 scrub 22 errors" err_strings[23]="log_channel[(]cluster[)] log [[]ERR[]] : scrub [0-9]*[.]0 .*:::obj15:head can't decode 'snapset' attr buffer" - err_strings[24]="log_channel[(]cluster[)] log [[]ERR[]] : scrub [0-9]*[.]0 .*:::obj12:1 has no oi or legacy_snaps; cannot convert 1=[[]1[]]:[[]1[]].stray_clone_snaps=[{]1=[[]1[]][}]" for i in `seq 0 ${#err_strings[@]}` do diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 56866b6e383..c5ff1f22319 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -3992,6 +3992,9 @@ void PG::_scan_snaps(ScrubMap &smap) continue; } head = hoid.get_head(); + // Make sure head_exists is correct for is_legacy() check + if (hoid.is_head()) + snapset.head_exists = true; continue; } if (hoid.snap < CEPH_MAXSNAP) { diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index dbacb3c63c0..6e50990addd 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -13893,12 +13893,16 @@ void PrimaryLogPG::scrub_snapshot_metadata( << " snapset.head_exists=false, but head exists"; ++scrubber.shallow_errors; head_error.set_head_mismatch(); + // Fix head_exists locally so is_legacy() returns correctly + snapset->head_exists = true; } if (soid.is_snapdir() && snapset->head_exists) { osd->clog->error() << mode << " " << info.pgid << " " << soid << " snapset.head_exists=true, but snapdir exists"; ++scrubber.shallow_errors; head_error.set_head_mismatch(); + // For symmetry fix this too, but probably doesn't matter + snapset->head_exists = false; } if (get_osdmap()->require_osd_release >= CEPH_RELEASE_LUMINOUS) {