Skip to content

Commit 91591a6

Browse files
authored
Merge pull request ceph#60363 from aclamk/wip-aclamk-fix-bluefs-bdev-expand
os/bluestore: Create additional bdev labels when expanding block device.
2 parents 90e1ab8 + f8b1495 commit 91591a6

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

qa/standalone/osd/osd-bluefs-volume-ops.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function TEST_bluestore() {
7272

7373
truncate $dir/0/block -s 4294967296 # 4GB
7474
ceph-bluestore-tool --path $dir/0 bluefs-bdev-expand || return 1
75-
truncate $dir/1/block -s 4311744512 # 4GB + 16MB
75+
truncate $dir/1/block -s 11811160064 # 11GB to get bdev label at 10737418240
7676
ceph-bluestore-tool --path $dir/1 bluefs-bdev-expand || return 1
7777
truncate $dir/2/block -s 4295099392 # 4GB + 129KB
7878
ceph-bluestore-tool --path $dir/2 bluefs-bdev-expand || return 1

src/os/bluestore/BlueStore.cc

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6930,8 +6930,19 @@ int BlueStore::_check_main_bdev_label()
69306930
return -EIO;
69316931
}
69326932
if (bluestore_bdev_label_require_all && r != 0) {
6933-
derr << __func__ << " not all labels read properly" << dendl;
6934-
return -EIO;
6933+
// We are about to complain that some labels failed.
6934+
// But in case if we expanded block device some labels will not be good.
6935+
uint64_t lsize = std::max(BDEV_LABEL_BLOCK_SIZE, min_alloc_size);
6936+
uint32_t valid_locations = 0;
6937+
for (uint64_t loc : bdev_label_positions) {
6938+
if (loc + lsize <= bdev_label.size) {
6939+
++valid_locations;
6940+
}
6941+
}
6942+
if (valid_locations != bdev_label_valid_locations.size()) {
6943+
derr << __func__ << " not all labels read properly" << dendl;
6944+
return -EIO;
6945+
}
69356946
}
69366947
return 0;
69376948
}
@@ -8967,11 +8978,25 @@ int BlueStore::expand_devices(ostream& out)
89678978
_close_db_and_around();
89688979

89698980
// mount in read/write to sync expansion changes
8981+
if (bdev_label_multi) {
8982+
// We need not do fsck, because we can be broken - size is increased,
8983+
// but we might not have labels set.
8984+
cct->_conf.set_val_or_die("bluestore_fsck_on_mount", "false");
8985+
}
89708986
r = _mount();
89718987
ceph_assert(r == 0);
89728988
if (fm && fm->is_null_manager()) {
89738989
// we grow the allocation range, must reflect it in the allocation file
89748990
alloc->init_add_free(size0, size - size0);
8991+
if (bdev_label_multi) {
8992+
uint64_t lsize = std::max(BDEV_LABEL_BLOCK_SIZE, min_alloc_size);
8993+
for (uint64_t loc : bdev_label_positions) {
8994+
if ((loc >= size0) && (loc + lsize <= size)) {
8995+
bdev_label_valid_locations.push_back(loc);
8996+
}
8997+
}
8998+
_write_bdev_label(cct, bdev, path + "/block", bdev_label, bdev_label_valid_locations);
8999+
}
89759000
need_to_destage_allocation_file = true;
89769001
}
89779002
umount();

0 commit comments

Comments
 (0)