From 27d50fa1571e8fb8082f03da56e806ac4a7883ac Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 22 Feb 2017 17:14:58 -0600 Subject: [PATCH] osd/osd_types: drop ScrubMap::object::nlink; drop some decode compat cruft We moved to v7 encoding in ca81563d8d71052a2040eda74e7ac418f1616fc7, which was pre-jewel, so that's the oldest version we need to decode. Drop the nlink field, which has not been used in a long time. Signed-off-by: Sage Weil --- src/osd/PG.cc | 18 +----------------- src/osd/osd_types.cc | 43 +++++++++++++++---------------------------- src/osd/osd_types.h | 3 +-- 3 files changed, 17 insertions(+), 47 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index acc0884a8d0..a6fde97beb0 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -3959,10 +3959,9 @@ void PG::_scan_snaps(ScrubMap &smap) ScrubMap::object &o = i->second; if (hoid.snap < CEPH_MAXSNAP) { - // fake nlinks for old primaries + // check and if necessary fix snap_mapper bufferlist bl; if (o.attrs.find(OI_ATTR) == o.attrs.end()) { - o.nlinks = 0; continue; } bl.push_back(o.attrs[OI_ATTR]); @@ -3970,21 +3969,8 @@ void PG::_scan_snaps(ScrubMap &smap) try { oi.decode(bl); } catch(...) { - o.nlinks = 0; continue; } - if (oi.snaps.empty()) { - // Just head - o.nlinks = 1; - } else if (oi.snaps.size() == 1) { - // Just head + only snap - o.nlinks = 2; - } else { - // Just head + 1st and last snaps - o.nlinks = 3; - } - - // check and if necessary fix snap_mapper set oi_snaps(oi.snaps.begin(), oi.snaps.end()); set cur_snaps; int r = snap_mapper.get_snaps(hoid, &cur_snaps); @@ -4025,8 +4011,6 @@ void PG::_scan_snaps(ScrubMap &smap) << dendl; } } - } else { - o.nlinks = 1; } } } diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index b17670cb451..5db71951d7b 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -5571,13 +5571,13 @@ void ScrubMap::generate_test_instances(list& o) void ScrubMap::object::encode(bufferlist& bl) const { bool compat_read_error = read_error || ec_hash_mismatch || ec_size_mismatch; - ENCODE_START(8, 2, bl); + ENCODE_START(8, 7, bl); ::encode(size, bl); ::encode(negative, bl); ::encode(attrs, bl); ::encode(digest, bl); ::encode(digest_present, bl); - ::encode(nlinks, bl); + ::encode((uint32_t)0, bl); // obsolete nlinks ::encode(snapcolls, bl); ::encode(omap_digest, bl); ::encode(omap_digest_present, bl); @@ -5591,37 +5591,24 @@ void ScrubMap::object::encode(bufferlist& bl) const void ScrubMap::object::decode(bufferlist::iterator& bl) { - DECODE_START_LEGACY_COMPAT_LEN(8, 2, 2, bl); + DECODE_START(8, bl); ::decode(size, bl); bool tmp, compat_read_error = false; ::decode(tmp, bl); negative = tmp; ::decode(attrs, bl); - if (struct_v >= 3) { - ::decode(digest, bl); - ::decode(tmp, bl); - digest_present = tmp; - } - if (struct_v >= 4) { - ::decode(nlinks, bl); - ::decode(snapcolls, bl); - } else { - /* Indicates that encoder was not aware of this field since stat must - * return nlink >= 1 */ - nlinks = 0; - } - if (struct_v >= 5) { - ::decode(omap_digest, bl); - ::decode(tmp, bl); - omap_digest_present = tmp; - } - if (struct_v >= 6) { - ::decode(compat_read_error, bl); - } - if (struct_v >= 7) { - ::decode(tmp, bl); - stat_error = tmp; - } + ::decode(digest, bl); + ::decode(tmp, bl); + digest_present = tmp; + uint32_t nlinks; + ::decode(nlinks, bl); + ::decode(snapcolls, bl); + ::decode(omap_digest, bl); + ::decode(tmp, bl); + omap_digest_present = tmp; + ::decode(compat_read_error, bl); + ::decode(tmp, bl); + stat_error = tmp; if (struct_v >= 8) { ::decode(tmp, bl); read_error = tmp; diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 8d4209a4042..205ad8abfe6 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -4657,7 +4657,6 @@ struct ScrubMap { uint64_t size; __u32 omap_digest; ///< omap crc32c __u32 digest; ///< data crc32c - uint32_t nlinks; bool negative:1; bool digest_present:1; bool omap_digest_present:1; @@ -4668,7 +4667,7 @@ struct ScrubMap { object() : // Init invalid size so it won't match if we get a stat EIO error - size(-1), omap_digest(0), digest(0), nlinks(0), + size(-1), omap_digest(0), digest(0), negative(false), digest_present(false), omap_digest_present(false), read_error(false), stat_error(false), ec_hash_mismatch(false), ec_size_mismatch(false) {} -- 2.39.5