]> git-server-git.apps.pok.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>
Fri, 13 Sep 2024 10:37:02 +0000 (10:37 +0000)
Make zapping precisely target block device labels.

Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/os/bluestore/bluestore_tool.cc

index 3cc7f71b31f10625203ff70714c735b4c89e6c35..0724aadff4296008c17f0589c0c3368b066cc74d 100644 (file)
@@ -8992,27 +8992,20 @@ void BlueStore::trim_free_space(const string& type, std::ostream& outss)
   }
 }
 
-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;
@@ -9034,7 +9027,6 @@ int BlueStore::zap_device(CephContext* cct, const string& dev, uint64_t gap_size
     }
   }
 
-fail_close:
   _bdev->close();
 
 fail:
index 53fe04eab9870af5cb5352f003d38eecbd60f83b..207ae2ec7a255590f60ab74504f7a0ae42558894 100644 (file)
@@ -3192,7 +3192,7 @@ public:
 
   int dump_bluefs_sizes(std::ostream& out);
   void trim_free_space(const std::string& type, std::ostream& outss);
-  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 160519583d456e51b1df280615e6bb4335ff73ba..c24bf2161aa6c5463ac28cdd0b5e0f12e28cc899 100644 (file)
@@ -290,7 +290,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()
@@ -317,7 +316,6 @@ int main(int argc, char **argv)
     ("resharding-ctrl", po::value<string>(&resharding_ctrl), "gives control over resharding procedure details")
     ("op", po::value<string>(&action_aux),
       "--command alias, ignored if the latter is present")
-    ("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()
@@ -1270,7 +1268,7 @@ int main(int argc, char **argv)
     bluestore.cold_close();
   } 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);