]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os: add fsck deep/shallow option
authorSage Weil <sage@redhat.com>
Fri, 28 Oct 2016 11:34:22 +0000 (06:34 -0500)
committerSage Weil <sage@redhat.com>
Tue, 1 Nov 2016 16:20:50 +0000 (12:20 -0400)
deep==false checks just metadata, and deep==true will (eventually) check
all data (and checksums) too.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/config_opts.h
src/os/ObjectStore.h
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/os/kstore/KStore.cc
src/os/kstore/KStore.h
src/test/objectstore/store_test.cc
src/tools/ceph_objectstore_tool.cc

index 4b1fa42d3cb633e83a00c9f21abf9e57021d3b8f..2cf5080d91444d5bf3ea2ccb2fb6a55fb42f23bf 100644 (file)
@@ -1009,8 +1009,11 @@ OPTION(bluestore_bitmapallocator_blocks_per_zone, OPT_INT, 1024) // must be powe
 OPTION(bluestore_bitmapallocator_span_size, OPT_INT, 1024) // must be power of 2 aligned, e.g., 512, 1024, 2048...
 OPTION(bluestore_rocksdb_options, OPT_STR, "compression=kNoCompression,max_write_buffer_number=4,min_write_buffer_number_to_merge=1,recycle_log_file_num=4,write_buffer_size=268435456")
 OPTION(bluestore_fsck_on_mount, OPT_BOOL, false)
+OPTION(bluestore_fsck_on_mount_deep, OPT_BOOL, true)
 OPTION(bluestore_fsck_on_umount, OPT_BOOL, false)
+OPTION(bluestore_fsck_on_umount_deep, OPT_BOOL, true)
 OPTION(bluestore_fsck_on_mkfs, OPT_BOOL, true)
+OPTION(bluestore_fsck_on_mkfs_deep, OPT_BOOL, false)
 OPTION(bluestore_sync_submit_transaction, OPT_BOOL, true) // submit kv txn in queueing thread (not kv_sync_thread)
 OPTION(bluestore_sync_wal_apply, OPT_BOOL, true)     // perform initial wal work synchronously (possibly in combination with aio so we only *queue* ios)
 OPTION(bluestore_wal_threads, OPT_INT, 4)
@@ -1041,6 +1044,7 @@ OPTION(kstore_max_bytes, OPT_U64, 64*1024*1024)
 OPTION(kstore_backend, OPT_STR, "rocksdb")
 OPTION(kstore_rocksdb_options, OPT_STR, "compression=kNoCompression")
 OPTION(kstore_fsck_on_mount, OPT_BOOL, false)
+OPTION(kstore_fsck_on_mount_deep, OPT_BOOL, true)
 OPTION(kstore_nid_prealloc, OPT_U64, 1024)
 OPTION(kstore_sync_transaction, OPT_BOOL, false)
 OPTION(kstore_sync_submit_transaction, OPT_BOOL, false)
index c04e63eb625a80d875bfc2dcb58dd16cef61bf50..67d0a73894f0d89f29efe9f5d51c0e5f88b266ad 100644 (file)
@@ -1879,7 +1879,7 @@ public:
   virtual bool test_mount_in_use() = 0;
   virtual int mount() = 0;
   virtual int umount() = 0;
-  virtual int fsck() {
+  virtual int fsck(bool deep) {
     return -EOPNOTSUPP;
   }
 
index ca54224049e3b217b5d825ceab6bc069f5f24aab..53f3047b02af905ac83831fc289c220cb11fe8f4 100644 (file)
@@ -3748,7 +3748,7 @@ int BlueStore::mkfs()
     if (r == 0) {
       dout(1) << __func__ << " already created" << dendl;
       if (g_conf->bluestore_fsck_on_mkfs) {
-        r = fsck();
+        r = fsck(g_conf->bluestore_fsck_on_mkfs_deep);
         if (r < 0) {
           derr << __func__ << " fsck found fatal error: " << cpp_strerror(r)
                << dendl;
@@ -3912,7 +3912,7 @@ int BlueStore::mkfs()
 
   if (r == 0 &&
       g_conf->bluestore_fsck_on_mkfs) {
-    int rc = fsck();
+    int rc = fsck(g_conf->bluestore_fsck_on_mkfs_deep);
     if (rc < 0)
       return rc;
     if (rc > 0) {
@@ -3954,7 +3954,7 @@ int BlueStore::mount()
   }
 
   if (g_conf->bluestore_fsck_on_mount) {
-    int rc = fsck();
+    int rc = fsck(g_conf->bluestore_fsck_on_mount_deep);
     if (rc < 0)
       return rc;
     if (rc > 0) {
@@ -4085,7 +4085,7 @@ int BlueStore::umount()
   _close_path();
 
   if (g_conf->bluestore_fsck_on_umount) {
-    int rc = fsck();
+    int rc = fsck(g_conf->bluestore_fsck_on_umount_deep);
     if (rc < 0)
       return rc;
     if (rc > 0) {
@@ -4115,7 +4115,8 @@ int BlueStore::_fsck_check_extents(
   const vector<bluestore_pextent_t>& extents,
   bool compressed,
   boost::dynamic_bitset<> &used_blocks,
-  store_statfs_t& expected_statfs)
+  store_statfs_t& expected_statfs,
+  bool deep)
 {
   dout(30) << __func__ << " oid " << oid << " extents " << extents << dendl;
   int errors = 0;
@@ -4149,9 +4150,9 @@ int BlueStore::_fsck_check_extents(
   return errors;
 }
 
-int BlueStore::fsck()
+int BlueStore::fsck(bool deep)
 {
-  dout(1) << __func__ << " start" << dendl;
+  dout(1) << __func__ << (deep ? " (deep)" : " (shallow)") << " start" << dendl;
   int errors = 0;
   set<uint64_t> used_nids;
   set<uint64_t> used_omap_head;
@@ -4421,7 +4422,8 @@ int BlueStore::fsck()
          errors += _fsck_check_extents(oid, blob.extents,
                                        blob.is_compressed(),
                                        used_blocks,
-                                       expected_statfs);
+                                       expected_statfs,
+                                       deep);
         }
       }
       // omap
@@ -4472,9 +4474,9 @@ int BlueStore::fsck()
          extents.emplace_back(bluestore_pextent_t(r.first, r.second.length));
        }
        errors += _fsck_check_extents(p->second.oids.front(),
-                           extents,
-                           p->second.compressed,
-                           used_blocks, expected_statfs);
+                                     extents,
+                                     p->second.compressed,
+                                     used_blocks, expected_statfs, deep);
        sb_info.erase(p);
       }
     }
index 12ad2d007a75848ef33bbc243ddaaec94edd29b2..97542c0f6ee16df0195cc479c497776d5a4ff678 100644 (file)
@@ -1581,7 +1581,8 @@ private:
     const vector<bluestore_pextent_t>& extents,
     bool compressed,
     boost::dynamic_bitset<> &used_blocks,
-    store_statfs_t& expected_statfs);
+    store_statfs_t& expected_statfs,
+    bool deep);
 
   void _buffer_cache_write(
     TransContext *txc,
@@ -1625,7 +1626,7 @@ public:
   int umount() override;
   void _sync();
 
-  int fsck() override;
+  int fsck(bool deep) override;
 
   void set_cache_shards(unsigned num) override;
 
index c74f04d08aa506645f108ec1b727753b3047a3de..ed10be43fc16b80d1ed53d32515d68113860b5a8 100755 (executable)
@@ -973,7 +973,7 @@ int KStore::mount()
   dout(1) << __func__ << " path " << path << dendl;
 
   if (g_conf->kstore_fsck_on_mount) {
-    int rc = fsck();
+    int rc = fsck(g_conf->kstore_fsck_on_mount_deep);
     if (rc < 0)
       return rc;
   }
@@ -1044,7 +1044,7 @@ int KStore::umount()
   return 0;
 }
 
-int KStore::fsck()
+int KStore::fsck(bool deep)
 {
   dout(1) << __func__ << dendl;
   int errors = 0;
index eeccf9727530b8649ca1ebf158121a00e8af5e3e..8bb76178347198a91b2268a18dd03bacd90fecbd 100644 (file)
@@ -416,7 +416,7 @@ public:
   int umount();
   void _sync();
 
-  int fsck();
+  int fsck(bool deep) override;
 
 
   int validate_hobject_key(const hobject_t &obj) const override {
index a293f0476f6d4bbffaf82d3760d7f1c9b3a812db..d615355fc3defd1175fa89f3a8c8d0e8930eec72 100644 (file)
@@ -4066,13 +4066,13 @@ public:
     return status;
   }
 
-  void fsck() {
+  void fsck(bool deep) {
     Mutex::Locker locker(lock);
     EnterExit ee("fsck");
     while (in_flight)
       cond.Wait(lock);
     store->umount();
-    store->fsck();
+    store->fsck(deep);
     store->mount();
   }
 
@@ -4250,7 +4250,9 @@ void doSyntheticTest(boost::scoped_ptr<ObjectStore>& store,
     boost::uniform_int<> true_false(0, 999);
     int val = true_false(rng);
     if (val > 998) {
-      test_obj.fsck();
+      test_obj.fsck(true);
+    } else if (val > 997) {
+      test_obj.fsck(false);
     } else if (val > 970) {
       test_obj.scan();
     } else if (val > 950) {
index 93ee890815722b4f3884c5c39008e182171fe539..c25b5218c41e0e2b9bcb83d32cafdc0255556a86 100644 (file)
@@ -2595,7 +2595,20 @@ int main(int argc, char **argv)
   }
 
   if (op == "fsck") {
-    int r = fs->fsck();
+    int r = fs->fsck(false);
+    if (r < 0) {
+      cerr << "fsck failed: " << cpp_strerror(r) << std::endl;
+      myexit(1);
+    }
+    if (r > 0) {
+      cerr << "fsck found " << r << " errors" << std::endl;
+      myexit(1);
+    }
+    cout << "fsck found no errors" << std::endl;
+    exit(0);
+  }
+  if (op == "fsck-deep") {
+    int r = fs->fsck(true);
     if (r < 0) {
       cerr << "fsck failed: " << cpp_strerror(r) << std::endl;
       myexit(1);