Skip to contentSkip to conversation

Some questions about SPDK bdev module

SPDK liushengchao02 at meituan.com 1 participant 10 messages Feb 10, 2022 – Feb 11, 2022

lore
Share & tools
lore

liushengchao02 at meituan.com

#0 lore raw

I have read the source code of SPDK and implemented my own bdev module by referencing official bdev modules like null, malloc and aio. But I still have some questions and hope someone can explain.

1.When a bdev is deleted, the 'destruct' function pointer of spdk_bdev_fn_table is called and the block device is closed. I find that ongoing spdk_bdev_io is not explicitly completed by calling spdk_bdev_io_complete(). Are these spdk_bdev_io cleaned automatically by SPDK framework?

2.How to write the json config that corresponds to the rpc call of 'log_set_flag'? I have tried many ways but still can not work and I have to implement my own version of rpc call in my own bdev module to enable json config.

Thanks!

#1 lore raw

For 1st question, the bdev close/destruct is usually in the aysnc mode if there are ongoing IOs. The SPDK bdev framework will handle that from my understanding.

For 2nd question, take nvme bdev as example, there is a config_json function pointer for the json related configuration.

And for the specific log related, you could take a look at SPDK_LOG_REGISTER_COMPONENT macro first.

static struct spdk_bdev_module nvme_if = {
.name = "nvme",
.async_fini = true,
.module_init = bdev_nvme_library_init,
.module_fini = bdev_nvme_library_fini,
.config_json = bdev_nvme_config_json,
.get_ctx_size = bdev_nvme_get_ctx_size,

};
SPDK_BDEV_MODULE_REGISTER(nvme, &nvme_if)

-----Original Message-----
From: liushengchao02(a)meituan.com <liushengchao02(a)meituan.com>
Sent: Thursday, February 10, 2022 11:18
To: spdk(a)lists.01.org
Subject: [SPDK] Some questions about SPDK bdev module

I have read the source code of SPDK and implemented my own bdev module by referencing official bdev modules like null, malloc and aio. But I still have some questions and hope someone can explain.

1.When a bdev is deleted, the 'destruct' function pointer of spdk_bdev_fn_table is called and the block device is closed. I find that ongoing spdk_bdev_io is not explicitly completed by calling spdk_bdev_io_complete(). Are these spdk_bdev_io cleaned automatically by SPDK framework?

2.How to write the json config that corresponds to the rpc call of 'log_set_flag'? I have tried many ways but still can not work and I have to implement my own version of rpc call in my own bdev module to enable json config.

Thanks!
_______________________________________________
SPDK mailing list -- spdk(a)lists.01.org
To unsubscribe send an email to spdk-leave(a)lists.01.org

#2 lore raw

Thank you for the reply.

For the 1st question, is it certain that the SPDK framework will handle remaining uncompleted spdk_bdev_io?

For the 2nd question, what I want is an example of 'json config file' that would do the same thing as calling 'rpc.py log_set_flag nvme' when I start the SPDK app with '-c' option and specify the json config file.

Thanks!

#3 lore raw

https://github.com/spdk/spdk/blob/master/examples/bdev/fio_plugin/bdev.json is one example of JSON file which is to call the bdev_malloc_create() RPC method.

Basically it is to convert the RPC command to json format. You may refer this to change the log_set_flag RPC method to JSON content.

-----Original Message-----
From: liushengchao02(a)meituan.com <liushengchao02(a)meituan.com>
Sent: Thursday, February 10, 2022 12:50
To: spdk(a)lists.01.org
Subject: [SPDK] Re: Some questions about SPDK bdev module

Thank you for the reply.

For the 1st question, is it certain that the SPDK framework will handle remaining uncompleted spdk_bdev_io?

For the 2nd question, what I want is an example of 'json config file' that would do the same thing as calling 'rpc.py log_set_flag nvme' when I start the SPDK app with '-c' option and specify the json config file.

Thanks!
_______________________________________________
SPDK mailing list -- spdk(a)lists.01.org
To unsubscribe send an email to spdk-leave(a)lists.01.org

#4 lore raw

Thank you for the reply.

I have tested many ways in a "json config file" but still can not work as executing 'rpc.py log_set_flag nvme' when starting the SPDK app with '-c' option and specify the json config file.

That's why I'm here asking for an example of "json config file".

Does anybody know the answers? Or currently SPDK does not support "log_set_flag" in a json config file?

Thanks

#5 lore raw

Hi,

The example that Gang provided looked pretty good, you just need to use that format and change the keys/values. Can you provide the exact json file that you’ve tried (mentioned below) that isn’t working?

Thx
Paul

From: liushengchao02(a)meituan.com <liushengchao02(a)meituan.com>
Date: Thursday, February 10, 2022 at 12:22 AM
To: spdk(a)lists.01.org <spdk(a)lists.01.org>
Subject: [SPDK] Re: Some questions about SPDK bdev module Thank you for the reply.

I have tested many ways in a "json config file" but still can not work as executing 'rpc.py log_set_flag nvme' when starting the SPDK app with '-c' option and specify the json config file.

That's why I'm here asking for an example of "json config file".

Does anybody know the answers? Or currently SPDK does not support "log_set_flag" in a json config file?

Thanks
_______________________________________________
SPDK mailing list -- spdk(a)lists.01.org
To unsubscribe send an email to spdk-leave(a)lists.01.org

#6 lore raw

Hi,

Please try the following:

{
"subsystems": [

    {
      "subsystem": "log",
      "config": [
        {
          "method": "log_set_flag",
          "params": { "flag": "nvme" }
        }
      ]
    }

]
}

This JSON file will work if you only want to set the nvme log flag. Or if you have an existing JSON file, you can just add the "subsystem" entry to the "subsystems" array in that file.

Regards,

Jim

On 2/10/22, 6:34 AM, "Luse, Paul E" <paul.e.luse(a)intel.com> wrote:

Hi,

The example that Gang provided looked pretty good, you just need to use that format and change the keys/values. Can you provide the exact json file that you’ve tried (mentioned below) that isn’t working?

Thx
Paul

From: liushengchao02(a)meituan.com <liushengchao02(a)meituan.com>
Date: Thursday, February 10, 2022 at 12:22 AM
To: spdk(a)lists.01.org <spdk(a)lists.01.org>
Subject: [SPDK] Re: Some questions about SPDK bdev module Thank you for the reply.

I have tested many ways in a "json config file" but still can not work as executing 'rpc.py log_set_flag nvme' when starting the SPDK app with '-c' option and specify the json config file.

That's why I'm here asking for an example of "json config file".

Does anybody know the answers? Or currently SPDK does not support "log_set_flag" in a json config file?

Thanks
_______________________________________________
SPDK mailing list -- spdk(a)lists.01.org
To unsubscribe send an email to spdk-leave(a)lists.01.org
_______________________________________________
SPDK mailing list -- spdk(a)lists.01.org
To unsubscribe send an email to spdk-leave(a)lists.01.org

#7 lore raw

Thanks Jim.

The json you provde works! I remember that I have tested similar formats. Maybe I've made some mistakes at that time.

My final question is whether SPDK framework would handle inflight spdk_bdev_io data when a bdev is deleted?

Or the 'destruct' of 'spdk_bdev_fn_table' would not be called until all inflight spdk_bdev_io data are completed? If so, is it OK that I change the 'module_link' of 'spdk_bdev_io' in my own bdev module?

Thanks!

#8 lore raw
In reply to Luse

Thanks, Paul. Jim has provided the correct json format and it worked!

I remember that I tested similar format. Maybe I made some mistakes at that time.

Thanks!

#9 lore raw

Great!

-from my iPhone

Quoted 10 lines · On Feb 11, 2022, at 5:31 AM, liushengchao02(a)meituan.com wrote:

Thanks, Paul. Jim has provided the correct json format and it worked!

I remember that I tested similar format. Maybe I made some mistakes at that time.

Thanks!
_______________________________________________
SPDK mailing list -- spdk(a)lists.01.org
To unsubscribe send an email to spdk-leave(a)lists.01.org