Skip to content

Commit 9a63bf3

Browse files
committed
test
test
1 parent 4e231c6 commit 9a63bf3

File tree

15 files changed

+730
-48
lines changed

15 files changed

+730
-48
lines changed

src/bio/bio_config.c

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ check_name_from_bdev_subsys(struct json_config_ctx *ctx)
489489

490490
D_ASSERT(ctx->config_it != NULL);
491491

492+
// todo: /mnt/daos/2/daos_nvme.conf 这个文件是什么时候创建的
492493
rc = spdk_json_decode_object(ctx->config_it, config_entry_decoders,
493494
SPDK_COUNTOF(config_entry_decoders), &cfg);
494495
if (rc < 0) {
@@ -511,9 +512,11 @@ check_name_from_bdev_subsys(struct json_config_ctx *ctx)
511512
if (name == NULL)
512513
D_GOTO(free_method, rc = -DER_NOMEM);
513514

515+
// 遍历json 文件中 conf.params 元素
514516
key = spdk_json_object_first(cfg.params);
515517
while (key != NULL) {
516518
value = json_value(key);
519+
// 找到所有的 bdev_nvme_attach_controller,即nvme 列表
517520
if (spdk_json_strequal(key, "name")) {
518521
// 获取name 的值,类似:Nvme_server03_0_1_0
519522
value = json_value(key);
@@ -522,7 +525,7 @@ check_name_from_bdev_subsys(struct json_config_ctx *ctx)
522525
D_GOTO(free_name, rc = -DER_INVAL);
523526
}
524527

525-
// 追加到name
528+
// 追加到name. 例如:"Nvme_server03_0_1_0"
526529
memcpy(name, value->start, value->len);
527530
name[value->len] = '\0';
528531

@@ -547,6 +550,7 @@ check_name_from_bdev_subsys(struct json_config_ctx *ctx)
547550
},
548551
549552
*/
553+
// 解析name 转化成 role
550554
rc = bdev_name2roles(name);
551555
if (rc < 0) {
552556
D_ERROR("bdev_name contains invalid roles: %s\n", name);
@@ -555,6 +559,7 @@ check_name_from_bdev_subsys(struct json_config_ctx *ctx)
555559
// 统计role 二进制信息,并返回
556560
roles |= rc;
557561
}
562+
// 循环下一个param
558563
key = spdk_json_next(key);
559564
}
560565

@@ -603,6 +608,7 @@ add_bdevs_to_opts(struct json_config_ctx *ctx, struct spdk_json_val *bdev_ss, bo
603608
return rc;
604609

605610
while (ctx->config_it != NULL) {
611+
// 将pci 地址添加到opts 中
606612
rc = add_traddrs_from_bdev_subsys(ctx, vmd_enabled, opts);
607613
if (rc != 0)
608614
return rc;
@@ -687,7 +693,79 @@ bio_add_allowed_alloc(const char *nvme_conf, struct spdk_env_opts *opts, int *ro
687693
if (ctx == NULL)
688694
return -DER_NOMEM;
689695

696+
// 读取保存bdev pcie 地址的json 文件
690697
rc = read_config(nvme_conf, ctx);
698+
/*
699+
root@server01:~# cat /mnt/daos/2/daos_nvme.conf
700+
{
701+
"daos_data": {
702+
"config": []
703+
},
704+
"subsystems": [
705+
{
706+
"subsystem": "bdev",
707+
"config": [
708+
{
709+
"params": {
710+
"bdev_io_pool_size": 65536,
711+
"bdev_io_cache_size": 256
712+
},
713+
"method": "bdev_set_options"
714+
},
715+
{
716+
"params": {
717+
"retry_count": 4,
718+
"timeout_us": 0,
719+
"nvme_adminq_poll_period_us": 100000,
720+
"action_on_timeout": "none",
721+
"nvme_ioq_poll_period_us": 0
722+
},
723+
"method": "bdev_nvme_set_options"
724+
},
725+
{
726+
"params": {
727+
"enable": false,
728+
"period_us": 0
729+
},
730+
"method": "bdev_nvme_set_hotplug"
731+
},
732+
{
733+
"params": {
734+
"trtype": "PCIe",
735+
"name": "Nvme_server01_0_1_0",
736+
"traddr": "0000:e3:00.0"
737+
},
738+
"method": "bdev_nvme_attach_controller"
739+
},
740+
{
741+
"params": {
742+
"trtype": "PCIe",
743+
"name": "Nvme_server01_1_1_0",
744+
"traddr": "0000:e4:00.0"
745+
},
746+
"method": "bdev_nvme_attach_controller"
747+
},
748+
{
749+
"params": {
750+
"trtype": "PCIe",
751+
"name": "Nvme_server01_2_1_0",
752+
"traddr": "0000:e5:00.0"
753+
},
754+
"method": "bdev_nvme_attach_controller"
755+
},
756+
{
757+
"params": {
758+
"trtype": "PCIe",
759+
"name": "Nvme_server01_3_1_0",
760+
"traddr": "0000:e6:00.0"
761+
},
762+
"method": "bdev_nvme_attach_controller"
763+
}
764+
]
765+
}
766+
]
767+
}root@server01:~#
768+
*/
691769
if (rc != 0)
692770
D_GOTO(out, rc);
693771

@@ -716,14 +794,17 @@ bio_add_allowed_alloc(const char *nvme_conf, struct spdk_env_opts *opts, int *ro
716794
D_GOTO(out, rc = -DER_INVAL);
717795
}
718796

719-
// 找到subsystem 的bdev
797+
// 当前子系统如果是bdev
720798
if (spdk_json_strequal(ctx->subsystem_name, "bdev"))
799+
// todo: 如果有多个bdev 不就覆盖了?正常只会有一个子系统
721800
bdev_ss = ctx->subsystems_it;
722801

802+
// vmd 技术:将nvme 插拔pcie 总线事件重定向至存储感知的驱动程序
723803
if (spdk_json_strequal(ctx->subsystem_name, BIO_DEV_TYPE_VMD))
724804
vmd_ss = ctx->subsystems_it;
725805

726806
/* Move on to next subsystem */
807+
// 继续下一个循环,正常只循环一次
727808
ctx->subsystems_it = spdk_json_next(ctx->subsystems_it);
728809
};
729810

@@ -740,8 +821,10 @@ bio_add_allowed_alloc(const char *nvme_conf, struct spdk_env_opts *opts, int *ro
740821
rc = check_md_on_ssd_status(ctx, bdev_ss);
741822
if (rc < 0)
742823
goto out;
824+
// role 作为返回值
743825
*roles = rc;
744826

827+
// 将解析出来的pcie 地址,添加到 opts 中
745828
rc = add_bdevs_to_opts(ctx, bdev_ss, vmd_enabled, opts);
746829
out:
747830
free_json_config_ctx(ctx);

src/bio/bio_context.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ int bio_mc_create(struct bio_xs_context *xs_ctxt, uuid_t pool_id, uint64_t meta_
691691
D_ASSERT(!(flags & BIO_MC_FL_RDB));
692692
// 创建data 的blob。一个池只创建最多三个blob 吗?data/meta/wal
693693
// 每个bs 对应一个blob
694+
// xs ctxt 里面保存了bs 信息
694695
rc = bio_blob_create(pool_id, xs_ctxt, data_sz, SMD_DEV_TYPE_DATA, flags,
695696
&data_blobid);
696697
if (rc)

src/bio/bio_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ struct bio_xs_blobstore {
390390
// 每个xs 的nvme ctx
391391
struct bio_xs_context {
392392
int bxc_tgt_id;
393+
// todo: 这个thread 和abt 中的thread 有什么联系吗
393394
struct spdk_thread *bxc_thread;
394395
// 对应三种类型的设备:meta,wal 和data
395396
struct bio_xs_blobstore *bxc_xs_blobstores[SMD_DEV_TYPE_MAX];

0 commit comments

Comments
 (0)