Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/os/bluestore/BlueFS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ void BlueFS::_shutdown_logger()
{
cct->get_perfcounters_collection()->remove(logger);
delete logger;
logger = nullptr;
}

void BlueFS::_update_logger_stats()
Expand All @@ -434,11 +435,26 @@ void BlueFS::_update_logger_stats()
}

int BlueFS::add_block_device(unsigned id, const string& path, bool trim,
uint64_t reserved,
bluefs_shared_alloc_context_t* _shared_alloc)
{
uint64_t reserved;
switch(id) {
case BDEV_WAL:
case BDEV_NEWWAL:
reserved = BDEV_LABEL_BLOCK_SIZE;
break;
case BDEV_DB:
case BDEV_NEWDB:
reserved = DB_SUPER_RESERVED;
break;
case BDEV_SLOW:
reserved = 0;
break;
default:
ceph_assert(false);
}
dout(10) << __func__ << " bdev " << id << " path " << path << " "
<< reserved << dendl;
<< " reserved " << reserved << dendl;
ceph_assert(id < bdev.size());
ceph_assert(bdev[id] == NULL);
BlockDevice *b = BlockDevice::create(cct, path, NULL, NULL,
Expand Down Expand Up @@ -698,6 +714,7 @@ void BlueFS::_init_alloc()
<< ", allocator name " << name
<< ", allocator type " << cct->_conf->bluefs_allocator
<< ", capacity 0x" << bdev[id]->get_size()
<< ", reserved 0x" << block_reserved[id]
<< ", block size 0x" << alloc_size[id]
<< std::dec << dendl;
alloc[id] = Allocator::create(cct, cct->_conf->bluefs_allocator,
Expand Down
1 change: 0 additions & 1 deletion src/os/bluestore/BlueFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,6 @@ class BlueFS {
}

int add_block_device(unsigned bdev, const std::string& path, bool trim,
uint64_t reserved,
bluefs_shared_alloc_context_t* _shared_alloc = nullptr);
bool bdev_support_label(unsigned id);
uint64_t get_block_device_size(unsigned bdev) const;
Expand Down
46 changes: 16 additions & 30 deletions src/os/bluestore/BlueStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,6 @@ const string PREFIX_ZONED_CL_INFO = "G"; // (per-zone cleaner metadata)

const string BLUESTORE_GLOBAL_STATFS_KEY = "bluestore_statfs";

// write a label in the first block. always use this size. note that
// bluefs makes a matching assumption about the location of its
// superblock (always the second block of the device).
#define BDEV_LABEL_BLOCK_SIZE 4096

// reserve: label (4k) + bluefs super (4k), which means we start at 8k.
#define SUPER_RESERVED 8192

#define OBJECT_MAX_SIZE 0xffffffff // 32 bits


Expand Down Expand Up @@ -5461,7 +5453,8 @@ int BlueStore::_read_bdev_label(CephContext* cct, const string &path,
decode(expected_crc, p);
}
catch (ceph::buffer::error& e) {
derr << __func__ << " unable to decode label at offset " << p.get_off()
derr << __func__ << " unable to decode label " << path.c_str()
<< " at offset " << p.get_off()
<< ": " << e.what()
<< dendl;
return -ENOENT;
Expand Down Expand Up @@ -6181,8 +6174,7 @@ int BlueStore::_minimal_open_bluefs(bool create)
if (::stat(bfn.c_str(), &st) == 0) {
r = bluefs->add_block_device(
BlueFS::BDEV_DB, bfn,
create && cct->_conf->bdev_enable_discard,
SUPER_RESERVED);
create && cct->_conf->bdev_enable_discard);
if (r < 0) {
derr << __func__ << " add block device(" << bfn << ") returned: "
<< cpp_strerror(r) << dendl;
Expand Down Expand Up @@ -6219,7 +6211,6 @@ int BlueStore::_minimal_open_bluefs(bool create)
bfn = path + "/block";
// never trim here
r = bluefs->add_block_device(bluefs_layout.shared_bdev, bfn, false,
0, // no need to provide valid 'reserved' for shared dev
&shared_alloc);
if (r < 0) {
derr << __func__ << " add block device(" << bfn << ") returned: "
Expand All @@ -6230,8 +6221,7 @@ int BlueStore::_minimal_open_bluefs(bool create)
bfn = path + "/block.wal";
if (::stat(bfn.c_str(), &st) == 0) {
r = bluefs->add_block_device(BlueFS::BDEV_WAL, bfn,
create && cct->_conf->bdev_enable_discard,
BDEV_LABEL_BLOCK_SIZE);
create && cct->_conf->bdev_enable_discard);
if (r < 0) {
derr << __func__ << " add block device(" << bfn << ") returned: "
<< cpp_strerror(r) << dendl;
Expand Down Expand Up @@ -7353,8 +7343,7 @@ int BlueStore::add_new_bluefs_device(int id, const string& dev_path)
ceph_assert(r == 0);

r = bluefs->add_block_device(BlueFS::BDEV_NEWWAL, p,
cct->_conf->bdev_enable_discard,
BDEV_LABEL_BLOCK_SIZE);
cct->_conf->bdev_enable_discard);
ceph_assert(r == 0);

if (bluefs->bdev_support_label(BlueFS::BDEV_NEWWAL)) {
Expand All @@ -7375,8 +7364,7 @@ int BlueStore::add_new_bluefs_device(int id, const string& dev_path)
ceph_assert(r == 0);

r = bluefs->add_block_device(BlueFS::BDEV_NEWDB, p,
cct->_conf->bdev_enable_discard,
SUPER_RESERVED);
cct->_conf->bdev_enable_discard);
ceph_assert(r == 0);

if (bluefs->bdev_support_label(BlueFS::BDEV_NEWDB)) {
Expand Down Expand Up @@ -7505,8 +7493,7 @@ int BlueStore::migrate_to_new_bluefs_device(const set<int>& devs_source,
bluefs_layout.dedicated_wal = true;

r = bluefs->add_block_device(BlueFS::BDEV_NEWWAL, dev_path,
cct->_conf->bdev_enable_discard,
BDEV_LABEL_BLOCK_SIZE);
cct->_conf->bdev_enable_discard);
ceph_assert(r == 0);

if (bluefs->bdev_support_label(BlueFS::BDEV_NEWWAL)) {
Expand All @@ -7524,8 +7511,7 @@ int BlueStore::migrate_to_new_bluefs_device(const set<int>& devs_source,
bluefs_layout.dedicated_db = true;

r = bluefs->add_block_device(BlueFS::BDEV_NEWDB, dev_path,
cct->_conf->bdev_enable_discard,
SUPER_RESERVED);
cct->_conf->bdev_enable_discard);
ceph_assert(r == 0);

if (bluefs->bdev_support_label(BlueFS::BDEV_NEWDB)) {
Expand Down Expand Up @@ -9273,7 +9259,7 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair)
bluefs_used_blocks = used_blocks;

apply_for_bitset_range(
0, std::max<uint64_t>(min_alloc_size, SUPER_RESERVED), alloc_size, used_blocks,
0, std::max<uint64_t>(min_alloc_size, DB_SUPER_RESERVED), alloc_size, used_blocks,
[&](uint64_t pos, mempool_dynamic_bitset &bs) {
bs.set(pos);
}
Expand Down Expand Up @@ -9970,14 +9956,14 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair)
[&](uint64_t pos, mempool_dynamic_bitset &bs) {
ceph_assert(pos < bs.size());
if (bs.test(pos) && !bluefs_used_blocks.test(pos)) {
if (offset == SUPER_RESERVED &&
length == min_alloc_size - SUPER_RESERVED) {
if (offset == DB_SUPER_RESERVED &&
length == min_alloc_size - DB_SUPER_RESERVED) {
// this is due to the change just after luminous to min_alloc_size
// granularity allocations, and our baked in assumption at the top
// of _fsck that 0~round_up_to(SUPER_RESERVED,min_alloc_size) is used
// (vs luminous's round_up_to(SUPER_RESERVED,block_size)). harmless,
// of _fsck that 0~round_up_to(DB_SUPER_RESERVED,min_alloc_size) is used
// (vs luminous's round_up_to(DB_SUPER_RESERVED,block_size)). harmless,
// since we will never allocate this region below min_alloc_size.
dout(10) << __func__ << " ignoring free extent between SUPER_RESERVED"
dout(10) << __func__ << " ignoring free extent between DB_SUPER_RESERVED"
<< " and min_alloc_size, 0x" << std::hex << offset << "~"
<< length << std::dec << dendl;
} else {
Expand Down Expand Up @@ -12251,7 +12237,7 @@ ObjectMap::ObjectMapIterator BlueStore::get_omap_iterator(
uint64_t BlueStore::_get_ondisk_reserved() const {
ceph_assert(min_alloc_size);
return round_up_to(
std::max<uint64_t>(SUPER_RESERVED, min_alloc_size), min_alloc_size);
std::max<uint64_t>(DB_SUPER_RESERVED, min_alloc_size), min_alloc_size);
}

void BlueStore::_prepare_ondisk_format_super(KeyValueDB::Transaction& t)
Expand Down Expand Up @@ -19118,7 +19104,7 @@ int BlueStore::read_allocation_from_onodes(SimpleBitmap *sbmap, read_alloc_stats
int BlueStore::reconstruct_allocations(SimpleBitmap *sbmap, read_alloc_stats_t &stats)
{
// first set space used by superblock
auto super_length = std::max<uint64_t>(min_alloc_size, SUPER_RESERVED);
auto super_length = std::max<uint64_t>(min_alloc_size, DB_SUPER_RESERVED);
set_allocation_in_simple_bmap(sbmap, 0, super_length);
stats.extent_count++;

Expand Down
10 changes: 10 additions & 0 deletions src/os/bluestore/bluestore_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,14 @@ struct Int64ArrayMergeOperator : public KeyValueDB::MergeOperator {
}
};

// write a label in the first block. always use this size. note that
// bluefs makes a matching assumption about the location of its
// superblock (always the second block of the device).
#define BDEV_LABEL_BLOCK_SIZE 4096

// reserved for standalone DB volume:
// label (4k) + bluefs super (4k), which means we start at 8k.
#define DB_SUPER_RESERVED (BDEV_LABEL_BLOCK_SIZE + 4096)


#endif
Loading