]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: introduce 'fix_on_mount' mode for no per pool tolerance.
authorIgor Fedotov <ifedotov@suse.com>
Mon, 9 Sep 2019 13:08:40 +0000 (16:08 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Mon, 18 Nov 2019 09:14:25 +0000 (12:14 +0300)
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
(cherry picked from commit 52af6cda58409d4e90363d1bd741485683f54395)

 Conflicts:
src/os/bluestore/BlueStore.cc
        - trivial

src/common/legacy_config_opts.h
src/common/options.cc
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index d9ea52b2928745c7b2d1f4709457d2b109f6b037..7e9799567c6340c00ac7c5a4abac8cc9aff07f68 100644 (file)
@@ -1044,6 +1044,7 @@ OPTION(bluestore_max_deferred_txc, OPT_U64)
 OPTION(bluestore_rocksdb_options, OPT_STR)
 OPTION(bluestore_fsck_on_mount, OPT_BOOL)
 OPTION(bluestore_fsck_on_mount_deep, OPT_BOOL)
+OPTION(bluestore_fsck_quick_fix_on_mount, OPT_BOOL)
 OPTION(bluestore_fsck_on_umount, OPT_BOOL)
 OPTION(bluestore_fsck_on_umount_deep, OPT_BOOL)
 OPTION(bluestore_fsck_on_mkfs, OPT_BOOL)
index 1b63c5516b0e317403568028b3b935acd3197245..ce055b72b603467f286955e5709e47258f1d9bd1 100644 (file)
@@ -4734,6 +4734,10 @@ std::vector<Option> get_global_options() {
     .set_default(false)
     .set_description("Run deep fsck at mount when bluestore_fsck_on_mount is set to true"),
 
+    Option("bluestore_fsck_quick_fix_on_mount", Option::TYPE_BOOL, Option::LEVEL_DEV)
+      .set_default(true)
+      .set_description("Do quick-fix for the store at mount"),
+
     Option("bluestore_fsck_on_umount", Option::TYPE_BOOL, Option::LEVEL_DEV)
     .set_default(false)
     .set_description("Run fsck at umount"),
index 6dd8384a1c16841e9efce50281b985ad68c0569f..078faeea6775f332addca134b9b79634b6a69f16 100644 (file)
@@ -5671,9 +5671,10 @@ int BlueStore::_balance_bluefs_freespace()
   return ret;
 }
 
-int BlueStore::_open_collections(int64_t *errors)
+int BlueStore::_open_collections()
 {
   dout(10) << __func__ << dendl;
+  collections_had_errors = false;
   ceph_assert(coll_map.empty());
   KeyValueDB::Iterator it = db->get_iterator(PREFIX_COLL);
   for (it->upper_bound(string());
@@ -5702,13 +5703,31 @@ int BlueStore::_open_collections(int64_t *errors)
 
     } else {
       derr << __func__ << " unrecognized collection " << it->key() << dendl;
-      if (errors)
-       (*errors)++;
+      collections_had_errors = true;
     }
   }
   return 0;
 }
 
+void BlueStore::_fsck_collections(int64_t* errors)
+{
+  if (collections_had_errors) {
+    dout(10) << __func__ << dendl;
+    KeyValueDB::Iterator it = db->get_iterator(PREFIX_COLL);
+    for (it->upper_bound(string());
+      it->valid();
+      it->next()) {
+      coll_t cid;
+      if (!cid.parse(it->key())) {
+        derr << __func__ << " unrecognized collection " << it->key() << dendl;
+        if (errors) {
+          (*errors)++;
+        }
+      }
+    }
+  }
+}
+
 void BlueStore::_open_statfs()
 {
   osd_pools.clear();
@@ -6546,6 +6565,18 @@ int BlueStore::_mount(bool kv_only, bool open_db)
 
   mempool_thread.init();
 
+  if (!per_pool_stat_collection &&
+    cct->_conf->bluestore_fsck_quick_fix_on_mount == true) {
+    dout(1) << __func__ << " quick-fix on mount" << dendl;
+    _fsck_on_open(FSCK_SHALLOW, true);
+
+    //reread statfs
+    //FIXME minor: replace with actual open/close?
+    _open_statfs();
+
+    _check_legacy_statfs_alert();
+  }
+
   mounted = true;
   return 0;
 
@@ -6750,7 +6781,7 @@ void BlueStore::_fsck_check_pool_statfs(
            s = "fsck error: ";
          }
          derr << s << "legacy statfs record found, suggest to "
-                 "run store repair to get consistent statistic reports"
+                 "run store repair/quick_fix to get consistent statistic reports"
               << dendl;
        }
        continue;
@@ -7589,42 +7620,14 @@ Detection stage (in processing order):
 int BlueStore::_fsck(BlueStore::FSCKDepth depth, bool repair)
 {
   dout(1) << __func__
-         << " <<<START>>>"
-         << (repair ? " repair" : " check")
-         << (depth == FSCK_DEEP ? " (deep)" :
-                depth == FSCK_SHALLOW ? " (shallow)" : " (regular)")
-          << " start" << dendl;
-  int64_t errors = 0;
-  int64_t warnings = 0; // just a placeholder to be inline with master
-  unsigned repaired = 0;
-
-  uint64_t_btree_t used_omap_head;
-  uint64_t_btree_t used_pgmeta_omap_head;
-  uint64_t_btree_t used_sbids;
-
-  mempool_dynamic_bitset used_blocks;
-  KeyValueDB::Iterator it;
-  store_statfs_t expected_store_statfs, actual_statfs;
-  per_pool_statfs expected_pool_statfs;
+    << (repair ? " repair" : " check")
+    << (depth == FSCK_DEEP ? " (deep)" :
+      depth == FSCK_SHALLOW ? " (shallow)" : " (regular)")
+    << dendl;
 
-  sb_info_map_t sb_info;
-
-  uint64_t num_objects = 0;
-  uint64_t num_extents = 0;
-  uint64_t num_blobs = 0;
-  uint64_t num_spanning_blobs = 0;
-  uint64_t num_shared_blobs = 0;
-  uint64_t num_sharded_objects = 0;
-  BlueStoreRepairer repairer;
   // in deep mode we need R/W write access to be able to replay deferred ops
   bool read_only = !(repair || depth == FSCK_DEEP);
 
-  utime_t start = ceph_clock_now();
-  const auto& no_pps_mode = cct->_conf->bluestore_no_per_pool_stats_tolerance;
-  bool need_per_pool_stats = no_pps_mode == "until_fsck" ||
-    (no_pps_mode == "until_repair" && repair);
-  bool enforce_no_per_pool_stats = no_pps_mode == "enforce";
-
   int r = _open_path();
   if (r < 0)
     return r;
@@ -7655,7 +7658,7 @@ int BlueStore::_fsck(BlueStore::FSCKDepth depth, bool repair)
     }
   }
 
-  r = _open_collections(&errors);
+  r = _open_collections();
   if (r < 0)
     goto out_db;
 
@@ -7671,6 +7674,62 @@ int BlueStore::_fsck(BlueStore::FSCKDepth depth, bool repair)
   if (r < 0)
     goto out_scan;
 
+  r = _fsck_on_open(depth, repair);
+
+out_scan:
+  mempool_thread.shutdown();
+  _flush_cache();
+out_db:
+  _close_db_and_around();
+out_bdev:
+  _close_bdev();
+out_fsid:
+  _close_fsid();
+out_path:
+  _close_path();
+
+  return r;
+}
+
+int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair)
+{
+  dout(1) << __func__
+         << " <<<START>>>"
+         << (repair ? " repair" : " check")
+         << (depth == FSCK_DEEP ? " (deep)" :
+                depth == FSCK_SHALLOW ? " (shallow)" : " (regular)")
+          << " start" << dendl;
+  int64_t errors = 0;
+  int64_t warnings = 0;
+  unsigned repaired = 0;
+
+  uint64_t_btree_t used_omap_head;
+  uint64_t_btree_t used_per_pool_omap_head;
+  uint64_t_btree_t used_pgmeta_omap_head;
+  uint64_t_btree_t used_sbids;
+
+  mempool_dynamic_bitset used_blocks;
+  KeyValueDB::Iterator it;
+  store_statfs_t expected_store_statfs, actual_statfs;
+  per_pool_statfs expected_pool_statfs;
+
+  sb_info_map_t sb_info;
+
+  uint64_t num_objects = 0;
+  uint64_t num_extents = 0;
+  uint64_t num_blobs = 0;
+  uint64_t num_spanning_blobs = 0;
+  uint64_t num_shared_blobs = 0;
+  uint64_t num_sharded_objects = 0;
+  BlueStoreRepairer repairer;
+
+  utime_t start = ceph_clock_now();
+  const auto& no_pps_mode = cct->_conf->bluestore_no_per_pool_stats_tolerance;
+  bool need_per_pool_stats = no_pps_mode == "until_fsck" ||
+    ((no_pps_mode == "until_repair")  && repair);
+  bool enforce_no_per_pool_stats = no_pps_mode == "enforce";
+
+  _fsck_collections(&errors);
   used_blocks.resize(fm->get_alloc_units());
   apply(
     0, std::max<uint64_t>(min_alloc_size, SUPER_RESERVED), fm->get_alloc_size(), used_blocks,
@@ -7721,9 +7780,9 @@ int BlueStore::_fsck(BlueStore::FSCKDepth depth, bool repair)
         }
        );
     }
-    r = bluefs->fsck();
+    int r = bluefs->fsck();
     if (r < 0) {
-      goto out_scan;
+      return r;
     }
     if (r > 0)
       errors += r;
@@ -7741,6 +7800,7 @@ int BlueStore::_fsck(BlueStore::FSCKDepth depth, bool repair)
   need_per_pool_stats = per_pool_stat_collection || need_per_pool_stats;
 
   if (g_conf()->bluestore_debug_fsck_abort) {
+    dout(1) << __func__ << " debug abort" << dendl;
     goto out_scan;
   }
   // walk PREFIX_OBJ
@@ -8240,23 +8300,8 @@ int BlueStore::_fsck(BlueStore::FSCKDepth depth, bool repair)
     repaired = repairer.apply(db);
     dout(5) << __func__ << " repair applied" << dendl;
   }
- out_scan:
-  mempool_thread.shutdown();
-  _flush_cache();
- out_db:
-  it.reset();  // before db is closed
-  _close_db_and_around();
- out_bdev:
-  _close_bdev();
- out_fsid:
-  _close_fsid();
- out_path:
-  _close_path();
-
-  // fatal errors take precedence
-  if (r < 0)
-    return r;
 
+out_scan:
   dout(2) << __func__ << " " << num_objects << " objects, "
          << num_sharded_objects << " of them sharded.  "
          << dendl;
index 3ba2950197198dd19034377c88636c739ecfbb8f..6eaf6494db5a255b45db877d1354eeaecde5b384 100644 (file)
@@ -1931,6 +1931,7 @@ private:
 
   RWLock coll_lock = {"BlueStore::coll_lock"};  ///< rwlock to protect coll_map
   mempool::bluestore_cache_other::unordered_map<coll_t, CollectionRef> coll_map;
+  bool collections_had_errors = false;
   map<coll_t,CollectionRef> new_coll_map;
 
   vector<Cache*> cache_shards;
@@ -2245,7 +2246,8 @@ private:
   void _close_fm();
   int _open_alloc();
   void _close_alloc();
-  int _open_collections(int64_t *errors=0);
+  int _open_collections();
+  void _fsck_collections(int64_t* errors);
   void _close_collections();
 
   int _setup_block_symlink_or_file(string name, string path, uint64_t size,
@@ -2357,7 +2359,7 @@ private:
     BlueStoreRepairer* repairer);
 
   int _fsck(FSCKDepth depth, bool repair);
-
+  int _fsck_on_open(BlueStore::FSCKDepth depth, bool repair);
 
   void _buffer_cache_write(
     TransContext *txc,