Skip to content

Commit 90835d6

Browse files
committed
os/bluestore: passing device type name parameter to kernel device
Signed-off-by: Yite Gu <[email protected]>
1 parent 08d2bd2 commit 90835d6

File tree

7 files changed

+18
-11
lines changed

7 files changed

+18
-11
lines changed

src/blk/BlockDevice.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ BlockDevice::device_type_from_name(const std::string& blk_dev_name)
140140

141141
BlockDevice* BlockDevice::create_with_type(block_device_t device_type,
142142
CephContext* cct, const std::string& path, aio_callback_t cb,
143-
void *cbpriv, aio_callback_t d_cb, void *d_cbpriv)
143+
void *cbpriv, aio_callback_t d_cb, void *d_cbpriv, const char* dev_name)
144144
{
145145

146146
switch (device_type) {
147147
#if defined(HAVE_LIBAIO) || defined(HAVE_POSIXAIO)
148148
case block_device_t::aio:
149-
return new KernelDevice(cct, cb, cbpriv, d_cb, d_cbpriv);
149+
return new KernelDevice(cct, cb, cbpriv, d_cb, d_cbpriv, dev_name);
150150
#endif
151151
#if defined(HAVE_SPDK)
152152
case block_device_t::spdk:
@@ -164,7 +164,7 @@ BlockDevice* BlockDevice::create_with_type(block_device_t device_type,
164164

165165
BlockDevice *BlockDevice::create(
166166
CephContext* cct, const string& path, aio_callback_t cb,
167-
void *cbpriv, aio_callback_t d_cb, void *d_cbpriv)
167+
void *cbpriv, aio_callback_t d_cb, void *d_cbpriv, const char* dev_name)
168168
{
169169
const string blk_dev_name = cct->_conf.get_val<string>("bdev_type");
170170
block_device_t device_type = block_device_t::unknown;
@@ -173,7 +173,7 @@ BlockDevice *BlockDevice::create(
173173
} else {
174174
device_type = device_type_from_name(blk_dev_name);
175175
}
176-
return create_with_type(device_type, cct, path, cb, cbpriv, d_cb, d_cbpriv);
176+
return create_with_type(device_type, cct, path, cb, cbpriv, d_cb, d_cbpriv, dev_name);
177177
}
178178

179179
bool BlockDevice::is_valid_io(uint64_t off, uint64_t len) const {

src/blk/BlockDevice.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ class BlockDevice {
175175
static block_device_t device_type_from_name(const std::string& blk_dev_name);
176176
static BlockDevice *create_with_type(block_device_t device_type,
177177
CephContext* cct, const std::string& path, aio_callback_t cb,
178-
void *cbpriv, aio_callback_t d_cb, void *d_cbpriv);
178+
void *cbpriv, aio_callback_t d_cb, void *d_cbpriv, const char* dev_name);
179+
179180
protected:
180181
uint64_t size = 0;
181182
uint64_t block_size = 0;
@@ -206,7 +207,8 @@ class BlockDevice {
206207
virtual ~BlockDevice() = default;
207208

208209
static BlockDevice *create(
209-
CephContext* cct, const std::string& path, aio_callback_t cb, void *cbpriv, aio_callback_t d_cb, void *d_cbpriv);
210+
CephContext* cct, const std::string& path, aio_callback_t cb, void *cbpriv, aio_callback_t d_cb,
211+
void *d_cbpriv, const char* dev_name = "");
210212
virtual bool supported_bdev_label() { return true; }
211213
virtual bool is_rotational() { return rotational; }
212214

src/blk/kernel/KernelDevice.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ using ceph::make_timespan;
5959
using ceph::mono_clock;
6060
using ceph::operator <<;
6161

62-
KernelDevice::KernelDevice(CephContext* cct, aio_callback_t cb, void *cbpriv, aio_callback_t d_cb, void *d_cbpriv)
62+
KernelDevice::KernelDevice(CephContext* cct, aio_callback_t cb, void *cbpriv, aio_callback_t d_cb, void *d_cbpriv, const char* dev_name)
6363
: BlockDevice(cct, cb, cbpriv),
6464
aio(false), dio(false),
6565
discard_callback(d_cb),

src/blk/kernel/KernelDevice.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ class KernelDevice : public BlockDevice,
119119
ceph::unique_leakable_ptr<buffer::raw> create_custom_aligned(size_t len, IOContext* ioc) const;
120120

121121
public:
122-
KernelDevice(CephContext* cct, aio_callback_t cb, void *cbpriv, aio_callback_t d_cb, void *d_cbpriv);
122+
KernelDevice(CephContext* cct, aio_callback_t cb, void *cbpriv, aio_callback_t d_cb,
123+
void *d_cbpriv, const char* dev_name = "");
123124
~KernelDevice();
124125

125126
void aio_submit(IOContext *ioc) override;

src/os/bluestore/BlueFS.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,17 +483,21 @@ int BlueFS::add_block_device(unsigned id, const string& path, bool trim,
483483
bluefs_shared_alloc_context_t* _shared_alloc)
484484
{
485485
uint64_t reserved;
486+
string dev_name;
486487
switch(id) {
487488
case BDEV_WAL:
488489
case BDEV_NEWWAL:
489490
reserved = BDEV_LABEL_BLOCK_SIZE;
491+
dev_name = "wal";
490492
break;
491493
case BDEV_DB:
492494
case BDEV_NEWDB:
493495
reserved = SUPER_RESERVED;
496+
dev_name = "db";
494497
break;
495498
case BDEV_SLOW:
496499
reserved = 0;
500+
dev_name = "slow";
497501
break;
498502
default:
499503
ceph_assert(false);
@@ -503,7 +507,7 @@ int BlueFS::add_block_device(unsigned id, const string& path, bool trim,
503507
ceph_assert(id < bdev.size());
504508
ceph_assert(bdev[id] == NULL);
505509
BlockDevice *b = BlockDevice::create(cct, path, NULL, NULL,
506-
discard_cb[id], static_cast<void*>(this));
510+
discard_cb[id], static_cast<void*>(this), dev_name.c_str());
507511
block_reserved[id] = reserved;
508512
if (_shared_alloc) {
509513
b->set_no_exclusive_lock();

src/os/bluestore/BlueFS.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ class BlueFS {
737737
}
738738

739739
int add_block_device(unsigned bdev, const std::string& path, bool trim,
740-
bluefs_shared_alloc_context_t* _shared_alloc = nullptr);
740+
bluefs_shared_alloc_context_t* _shared_alloc = nullptr);
741741
bool bdev_support_label(unsigned id);
742742
uint64_t get_block_device_size(unsigned bdev) const;
743743
BlockDevice* get_block_device(unsigned bdev) const;

src/os/bluestore/BlueStore.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6953,7 +6953,7 @@ int BlueStore::_open_bdev(bool create)
69536953
{
69546954
ceph_assert(bdev == NULL);
69556955
string p = path + "/block";
6956-
bdev = BlockDevice::create(cct, p, aio_cb, static_cast<void*>(this), discard_cb, static_cast<void*>(this));
6956+
bdev = BlockDevice::create(cct, p, aio_cb, static_cast<void*>(this), discard_cb, static_cast<void*>(this), "bluestore");
69576957
int r = bdev->open(p);
69586958
if (r < 0)
69596959
goto fail;

0 commit comments

Comments
 (0)