]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/ceph-bluestore-tool: remove param zap_size
authorAdam Kupczyk <akupczyk@ibm.com>
Thu, 12 Sep 2024 10:45:05 +0000 (10:45 +0000)
committerAdam Kupczyk <akupczyk@ibm.com>
Wed, 25 Sep 2024 06:16:49 +0000 (06:16 +0000)
Make zapping precisely target block device labels.

Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
(cherry picked from commit 1a80319bbff39f25a09d1fc6f8cd975ed1e3748b)

 Conflicts:
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/os/bluestore/bluestore_tool.cc
Trivial conficts with 'trim' feature.

src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/os/bluestore/bluestore_tool.cc

index 3b1e97c2b823ed0eb81c2acc1de9a32e45476a12..c883f6fb7dba84e2fb157b7e7aeaeed0e1800d4f 100644 (file)
@@ -8895,27 +8895,20 @@ int BlueStore::dump_bluefs_sizes(ostream& out)
   return r;
 }
 
-int BlueStore::zap_device(CephContext* cct, const string& dev, uint64_t gap_size)
+int BlueStore::zap_device(CephContext* cct, const string& dev)
 {
-  string path; // dummy var for dout
-  dout(5)<<  __func__ << " " << dev << dendl;
-  auto * _bdev =
-    BlockDevice::create(cct, dev, nullptr, nullptr, nullptr, nullptr);
+  string path = dev; // dummy var for dout
+  uint64_t brush_size;
+  dout(5) << __func__ << " " << dev << dendl;
+  unique_ptr<BlockDevice>
+    _bdev(BlockDevice::create(cct, dev, nullptr, nullptr, nullptr, nullptr));
   int r = _bdev->open(dev);
   if (r < 0)
     goto fail;
-  if (!gap_size) {
-    gap_size = _bdev->get_block_size();
-  }
-  if (p2align(gap_size, _bdev->get_block_size()) != gap_size) {
-    derr << __func__
-         << " zapping size has to be aligned with device block size: 0x" 
-         << std::hex << gap_size << " vs. 0x" << _bdev->get_block_size()
-         << std::dec << dendl;
-    return -EINVAL;
-  }
+  brush_size = std::max(_bdev->get_block_size(), BDEV_LABEL_BLOCK_SIZE);
+
   for (auto off : bdev_label_positions) {
-    uint64_t end = std::min(off + gap_size, _bdev->get_size());
+    uint64_t end = std::min(off + brush_size, _bdev->get_size());
     if (end > off) {
       uint64_t l = end - off;
       bufferlist bl;
@@ -8937,7 +8930,6 @@ int BlueStore::zap_device(CephContext* cct, const string& dev, uint64_t gap_size
     }
   }
 
-fail_close:
   _bdev->close();
 
 fail:
index 224620a620c30be41f617469351ce8e1cee15595..07690d54b0f7c1695e6e73ab60ec308e069994d9 100644 (file)
@@ -3084,7 +3084,7 @@ public:
   std::string get_device_path(unsigned id);
 
   int dump_bluefs_sizes(std::ostream& out);
-  static int zap_device(CephContext* cct, const std::string& dev, uint64_t gap_size);
+  static int zap_device(CephContext* cct, const std::string& dev);
 
 public:
   int statfs(struct store_statfs_t *buf,
index 25b2e9774552ee3ee8a7c40287b66d9dd112e8de..44129db6785b2ee07889ec52c4ac87687efb3eea 100644 (file)
@@ -289,7 +289,6 @@ int main(int argc, char **argv)
   string new_sharding = empty_sharding;
   string resharding_ctrl;
   int log_level = 30;
-  uint64_t zap_size = 0;
   bool fsck_deep = false;
   po::options_description po_options("Options");
   po_options.add_options()
@@ -311,7 +310,6 @@ int main(int argc, char **argv)
     ("yes-i-really-really-mean-it", "additional confirmation for dangerous commands")
     ("sharding", po::value<string>(&new_sharding), "new sharding to apply")
     ("resharding-ctrl", po::value<string>(&resharding_ctrl), "gives control over resharding procedure details")
-    ("zap-size", po::value<uint64_t>(&zap_size), "size of a block written when zapping device")
     ;
   po::options_description po_positional("Positional options");
   po_positional.add_options()
@@ -1206,7 +1204,7 @@ int main(int argc, char **argv)
     cout << sharding << std::endl;
   } else if (action == "zap-device") {
     for(auto& dev : devs) {
-      int r = BlueStore::zap_device(cct.get(), dev, zap_size);
+      int r = BlueStore::zap_device(cct.get(), dev);
       if (r < 0) {
         cerr << "error from zap: " << cpp_strerror(r) << std::endl;
         exit(EXIT_FAILURE);