From: Yite Gu Date: Wed, 31 Jul 2024 07:16:07 +0000 (+0800) Subject: os/bluestore: passing device type name parameter to kernel device X-Git-Tag: testing/wip-vshankar-testing-20250523.134245-squid-debug~35^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=54af1f6d48ecdf52a8b1d4a86def8a1afedfb3cd;p=ceph-ci.git os/bluestore: passing device type name parameter to kernel device Signed-off-by: Yite Gu (cherry picked from commit 90835d66b0cbf71b24bca58f6934c4e14d482121) --- diff --git a/src/blk/BlockDevice.cc b/src/blk/BlockDevice.cc index 7510fb89c8b..8c06256d254 100644 --- a/src/blk/BlockDevice.cc +++ b/src/blk/BlockDevice.cc @@ -140,13 +140,13 @@ BlockDevice::device_type_from_name(const std::string& blk_dev_name) BlockDevice* BlockDevice::create_with_type(block_device_t device_type, CephContext* cct, const std::string& path, aio_callback_t cb, - void *cbpriv, aio_callback_t d_cb, void *d_cbpriv) + void *cbpriv, aio_callback_t d_cb, void *d_cbpriv, const char* dev_name) { switch (device_type) { #if defined(HAVE_LIBAIO) || defined(HAVE_POSIXAIO) case block_device_t::aio: - return new KernelDevice(cct, cb, cbpriv, d_cb, d_cbpriv); + return new KernelDevice(cct, cb, cbpriv, d_cb, d_cbpriv, dev_name); #endif #if defined(HAVE_SPDK) case block_device_t::spdk: @@ -164,7 +164,7 @@ BlockDevice* BlockDevice::create_with_type(block_device_t device_type, BlockDevice *BlockDevice::create( CephContext* cct, const string& path, aio_callback_t cb, - void *cbpriv, aio_callback_t d_cb, void *d_cbpriv) + void *cbpriv, aio_callback_t d_cb, void *d_cbpriv, const char* dev_name) { const string blk_dev_name = cct->_conf.get_val("bdev_type"); block_device_t device_type = block_device_t::unknown; @@ -173,7 +173,7 @@ BlockDevice *BlockDevice::create( } else { device_type = device_type_from_name(blk_dev_name); } - return create_with_type(device_type, cct, path, cb, cbpriv, d_cb, d_cbpriv); + return create_with_type(device_type, cct, path, cb, cbpriv, d_cb, d_cbpriv, dev_name); } bool BlockDevice::is_valid_io(uint64_t off, uint64_t len) const { diff --git a/src/blk/BlockDevice.h b/src/blk/BlockDevice.h index e9768b35f13..d203166b82b 100644 --- a/src/blk/BlockDevice.h +++ b/src/blk/BlockDevice.h @@ -175,7 +175,8 @@ private: static block_device_t device_type_from_name(const std::string& blk_dev_name); static BlockDevice *create_with_type(block_device_t device_type, CephContext* cct, const std::string& path, aio_callback_t cb, - void *cbpriv, aio_callback_t d_cb, void *d_cbpriv); + void *cbpriv, aio_callback_t d_cb, void *d_cbpriv, const char* dev_name); + protected: uint64_t size = 0; uint64_t block_size = 0; @@ -206,7 +207,8 @@ public: virtual ~BlockDevice() = default; static BlockDevice *create( - CephContext* cct, const std::string& path, aio_callback_t cb, void *cbpriv, aio_callback_t d_cb, void *d_cbpriv); + CephContext* cct, const std::string& path, aio_callback_t cb, void *cbpriv, aio_callback_t d_cb, + void *d_cbpriv, const char* dev_name = ""); virtual bool supported_bdev_label() { return true; } virtual bool is_rotational() { return rotational; } diff --git a/src/blk/kernel/KernelDevice.cc b/src/blk/kernel/KernelDevice.cc index 13b1cf19615..77eb6898251 100644 --- a/src/blk/kernel/KernelDevice.cc +++ b/src/blk/kernel/KernelDevice.cc @@ -59,7 +59,7 @@ using ceph::make_timespan; using ceph::mono_clock; using ceph::operator <<; -KernelDevice::KernelDevice(CephContext* cct, aio_callback_t cb, void *cbpriv, aio_callback_t d_cb, void *d_cbpriv) +KernelDevice::KernelDevice(CephContext* cct, aio_callback_t cb, void *cbpriv, aio_callback_t d_cb, void *d_cbpriv, const char* dev_name) : BlockDevice(cct, cb, cbpriv), aio(false), dio(false), discard_callback(d_cb), diff --git a/src/blk/kernel/KernelDevice.h b/src/blk/kernel/KernelDevice.h index d5ac958e351..fac869f6584 100644 --- a/src/blk/kernel/KernelDevice.h +++ b/src/blk/kernel/KernelDevice.h @@ -119,7 +119,8 @@ private: ceph::unique_leakable_ptr create_custom_aligned(size_t len, IOContext* ioc) const; public: - KernelDevice(CephContext* cct, aio_callback_t cb, void *cbpriv, aio_callback_t d_cb, void *d_cbpriv); + KernelDevice(CephContext* cct, aio_callback_t cb, void *cbpriv, aio_callback_t d_cb, + void *d_cbpriv, const char* dev_name = ""); ~KernelDevice(); void aio_submit(IOContext *ioc) override; diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index c232524c000..2f4d20b2c20 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -483,17 +483,21 @@ int BlueFS::add_block_device(unsigned id, const string& path, bool trim, bluefs_shared_alloc_context_t* _shared_alloc) { uint64_t reserved; + string dev_name; switch(id) { case BDEV_WAL: case BDEV_NEWWAL: reserved = BDEV_LABEL_BLOCK_SIZE; + dev_name = "wal"; break; case BDEV_DB: case BDEV_NEWDB: reserved = SUPER_RESERVED; + dev_name = "db"; break; case BDEV_SLOW: reserved = 0; + dev_name = "slow"; break; default: ceph_assert(false); @@ -503,7 +507,7 @@ int BlueFS::add_block_device(unsigned id, const string& path, bool trim, ceph_assert(id < bdev.size()); ceph_assert(bdev[id] == NULL); BlockDevice *b = BlockDevice::create(cct, path, NULL, NULL, - discard_cb[id], static_cast(this)); + discard_cb[id], static_cast(this), dev_name.c_str()); block_reserved[id] = reserved; if (_shared_alloc) { b->set_no_exclusive_lock(); diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index b7353348dae..c3888146376 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -740,7 +740,7 @@ public: } int add_block_device(unsigned bdev, const std::string& path, bool trim, - bluefs_shared_alloc_context_t* _shared_alloc = nullptr); + bluefs_shared_alloc_context_t* _shared_alloc = nullptr); bool bdev_support_label(unsigned id); uint64_t get_block_device_size(unsigned bdev) const; BlockDevice* get_block_device(unsigned bdev) const; diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index db935ade9fc..8a0279db889 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -6991,7 +6991,7 @@ int BlueStore::_open_bdev(bool create) { ceph_assert(bdev == NULL); string p = path + "/block"; - bdev = BlockDevice::create(cct, p, aio_cb, static_cast(this), discard_cb, static_cast(this)); + bdev = BlockDevice::create(cct, p, aio_cb, static_cast(this), discard_cb, static_cast(this), "bluestore"); int r = bdev->open(p); if (r < 0) goto fail;