Skip to content

Commit 1a80319

Browse files
committed
tools/ceph-bluestore-tool: remove param zap_size
Make zapping precisely target block device labels. Signed-off-by: Adam Kupczyk <[email protected]>
1 parent 1b431a3 commit 1a80319

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

src/os/bluestore/BlueStore.cc

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8992,27 +8992,20 @@ void BlueStore::trim_free_space(const string& type, std::ostream& outss)
89928992
}
89938993
}
89948994

8995-
int BlueStore::zap_device(CephContext* cct, const string& dev, uint64_t gap_size)
8995+
int BlueStore::zap_device(CephContext* cct, const string& dev)
89968996
{
8997-
string path; // dummy var for dout
8998-
dout(5)<< __func__ << " " << dev << dendl;
8999-
auto * _bdev =
9000-
BlockDevice::create(cct, dev, nullptr, nullptr, nullptr, nullptr);
8997+
string path = dev; // dummy var for dout
8998+
uint64_t brush_size;
8999+
dout(5) << __func__ << " " << dev << dendl;
9000+
unique_ptr<BlockDevice>
9001+
_bdev(BlockDevice::create(cct, dev, nullptr, nullptr, nullptr, nullptr));
90019002
int r = _bdev->open(dev);
90029003
if (r < 0)
90039004
goto fail;
9004-
if (!gap_size) {
9005-
gap_size = _bdev->get_block_size();
9006-
}
9007-
if (p2align(gap_size, _bdev->get_block_size()) != gap_size) {
9008-
derr << __func__
9009-
<< " zapping size has to be aligned with device block size: 0x"
9010-
<< std::hex << gap_size << " vs. 0x" << _bdev->get_block_size()
9011-
<< std::dec << dendl;
9012-
return -EINVAL;
9013-
}
9005+
brush_size = std::max(_bdev->get_block_size(), BDEV_LABEL_BLOCK_SIZE);
9006+
90149007
for (auto off : bdev_label_positions) {
9015-
uint64_t end = std::min(off + gap_size, _bdev->get_size());
9008+
uint64_t end = std::min(off + brush_size, _bdev->get_size());
90169009
if (end > off) {
90179010
uint64_t l = end - off;
90189011
bufferlist bl;
@@ -9034,7 +9027,6 @@ int BlueStore::zap_device(CephContext* cct, const string& dev, uint64_t gap_size
90349027
}
90359028
}
90369029

9037-
fail_close:
90389030
_bdev->close();
90399031

90409032
fail:

src/os/bluestore/BlueStore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3192,7 +3192,7 @@ class BlueStore : public ObjectStore,
31923192

31933193
int dump_bluefs_sizes(std::ostream& out);
31943194
void trim_free_space(const std::string& type, std::ostream& outss);
3195-
static int zap_device(CephContext* cct, const std::string& dev, uint64_t gap_size);
3195+
static int zap_device(CephContext* cct, const std::string& dev);
31963196

31973197
public:
31983198
int statfs(struct store_statfs_t *buf,

src/os/bluestore/bluestore_tool.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ int main(int argc, char **argv)
290290
string new_sharding = empty_sharding;
291291
string resharding_ctrl;
292292
int log_level = 30;
293-
uint64_t zap_size = 0;
294293
bool fsck_deep = false;
295294
po::options_description po_options("Options");
296295
po_options.add_options()
@@ -317,7 +316,6 @@ int main(int argc, char **argv)
317316
("resharding-ctrl", po::value<string>(&resharding_ctrl), "gives control over resharding procedure details")
318317
("op", po::value<string>(&action_aux),
319318
"--command alias, ignored if the latter is present")
320-
("zap-size", po::value<uint64_t>(&zap_size), "size of a block written when zapping device")
321319
;
322320
po::options_description po_positional("Positional options");
323321
po_positional.add_options()
@@ -1270,7 +1268,7 @@ int main(int argc, char **argv)
12701268
bluestore.cold_close();
12711269
} else if (action == "zap-device") {
12721270
for(auto& dev : devs) {
1273-
int r = BlueStore::zap_device(cct.get(), dev, zap_size);
1271+
int r = BlueStore::zap_device(cct.get(), dev);
12741272
if (r < 0) {
12751273
cerr << "error from zap: " << cpp_strerror(r) << std::endl;
12761274
exit(EXIT_FAILURE);

0 commit comments

Comments
 (0)