From f16629980d4caeeefe1c81d5c0b313d97b69b2d5 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Tue, 21 Jan 2020 00:00:49 +0300 Subject: [PATCH] os/bluestore: limit error/warning lines shown during fsck. Some 'expected' fsck falures (e.g. legacy omap records from previous releases in Octopus) might produce tons of corresponding error/warning log lines. This is a simple and rough workaround which limits number of printed lines by a predefined value of 100. Curretly applied to omap-related errors only. Known flaw is that limit is applied on per-task basis hence multi-threaded quick-fix will prooduce up to 100 * lines instead of 100 which is a bit confusing. Signed-off-by: Igor Fedotov --- src/os/bluestore/BlueStore.cc | 53 ++++++++++++++++++++++++----------- src/os/bluestore/BlueStore.h | 3 ++ 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index a9c72ba8f8c..0b3865e86d4 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -7080,6 +7080,19 @@ int BlueStore::cold_close() return 0; } +// derr wrapper to limit enormous output and avoid log flooding. +// Of limited use where such output is expected for now +#define fsck_derr(err_cnt, threshold) \ + if (err_cnt <= threshold) { \ + bool need_skip_print = err_cnt == threshold; \ + derr + +#define fsck_dendl \ + dendl; \ + if (need_skip_print) \ + derr << "more error lines skipped..." << dendl; \ + } + int _fsck_sum_extents( const PExtentVector& extents, bool compressed, @@ -7702,27 +7715,32 @@ void BlueStore::_fsck_check_object_omap(FSCKDepth depth, ceph_assert(o->onode.has_omap()); if (!o->onode.is_perpool_omap() && !o->onode.is_pgmeta_omap()) { if (per_pool_omap) { - derr << "fsck error: " << o->oid - << " has omap that is not per-pool or pgmeta" << dendl; + fsck_derr(errors, MAX_FSCK_ERROR_LINES) + << "fsck error: " << o->oid + << " has omap that is not per-pool or pgmeta" + << fsck_dendl; ++errors; } else { const char* w; + int64_t num; if (cct->_conf->bluestore_fsck_error_on_no_per_pool_omap) { ++errors; + num = errors; w = "error"; } else { ++warnings; + num = warnings; w = "warning"; } - //FIXME - dout(10) << "fsck " << w << ": " << o->oid - << " has omap that is not per-pool or pgmeta" << dendl; + fsck_derr(num, MAX_FSCK_ERROR_LINES) + << "fsck " << w << ": " << o->oid + << " has omap that is not per-pool or pgmeta" + << fsck_dendl; } } if (repairer && - o->onode.has_omap() && !o->onode.is_perpool_omap() && - !o->oid.is_pgmeta()) { + !o->onode.is_pgmeta_omap()) { dout(10) << "fsck converting " << o->oid << " omap to per-pool" << dendl; bufferlist h; map kv; @@ -8606,7 +8624,7 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair) errors, warnings, repair ? &repairer : nullptr); if (depth != FSCK_SHALLOW) { - dout(1) << __func__ << " checking for stray omap data " << used_omap_head.size() << dendl; + dout(1) << __func__ << " checking for stray omap data " << dendl; it = db->get_iterator(PREFIX_OMAP); if (it) { uint64_t last_omap_head = 0; @@ -8615,8 +8633,9 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair) _key_decode_u64(it->key().c_str(), &omap_head); if (used_omap_head.count(omap_head) == 0 && omap_head != last_omap_head) { - dout(10) << "fsck error: found stray omap data on omap_head " - << omap_head << dendl; + fsck_derr(errors, MAX_FSCK_ERROR_LINES) + << "fsck error: found stray omap data on omap_head " + << omap_head << " " << last_omap_head << " " << used_omap_head.count(omap_head)<< fsck_dendl; ++errors; last_omap_head = omap_head; } @@ -8630,9 +8649,10 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair) _key_decode_u64(it->key().c_str(), &omap_head); if (used_omap_head.count(omap_head) == 0 && omap_head != last_omap_head) { - dout(10) << "fsck error: found stray (pgmeta) omap data on omap_head " - << omap_head << dendl; - last_omap_head = omap_head; + fsck_derr(errors, MAX_FSCK_ERROR_LINES) + << "fsck error: found stray (pgmeta) omap data on omap_head " + << omap_head << " " << last_omap_head << " " << used_omap_head.count(omap_head) << fsck_dendl; + last_omap_head = omap_head; ++errors; } } @@ -8649,9 +8669,10 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair) c = _key_decode_u64(c, &omap_head); if (used_omap_head.count(omap_head) == 0 && omap_head != last_omap_head) { - dout(10) << "fsck error: found stray (per-pool) omap data on omap_head " - << omap_head << dendl; - ++errors; + fsck_derr(errors, MAX_FSCK_ERROR_LINES) + << "fsck error: found stray (per-pool) omap data on omap_head " + << omap_head << " " << last_omap_head << " " << used_omap_head.count(omap_head) << fsck_dendl; + ++errors; last_omap_head = omap_head; } } diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 6cba03d32e6..63f1acaa2f5 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -2372,6 +2372,9 @@ public: FSCK_DEEP, FSCK_SHALLOW }; + enum { + MAX_FSCK_ERROR_LINES = 100, + }; private: int _fsck_check_extents( -- 2.39.5