bdev/rbd: Support config_param and config_file simultaneously for rbd_register_cluster
config_param and config_file are not conflict to specify rados configurations, support specify both of them is more reasonable. Therefore, After this patch, users can choose the one from the three ways: config_param, config_file + key_file or config_param + config_file + key_file. Signed-off-by: Tan Long <tanl12@chinatelecom.cn> Change-Id: Ide17af72c4965df1e6541f4f50d4fa5309865486 Signed-off-by: Tan Long <tanl12@chinatelecom.cn> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10679 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Reviewed-by: GangCao <gang.cao@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com> Reviewed-by: Dong Yi <dongx.yi@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
20c8a3b8db
commit
a79af5e7a5
@ -802,7 +802,8 @@ bdev_rbd_cluster_dump_entry(const char *cluster_name, struct spdk_json_write_ctx
|
|||||||
config_entry += 2;
|
config_entry += 2;
|
||||||
}
|
}
|
||||||
spdk_json_write_object_end(w);
|
spdk_json_write_object_end(w);
|
||||||
} else if (entry->config_file) {
|
}
|
||||||
|
if (entry->config_file) {
|
||||||
spdk_json_write_named_string(w, "config_file", entry->config_file);
|
spdk_json_write_named_string(w, "config_file", entry->config_file);
|
||||||
}
|
}
|
||||||
if (entry->key_file) {
|
if (entry->key_file) {
|
||||||
@ -912,7 +913,8 @@ dump_single_cluster_entry(struct bdev_rbd_cluster *entry, struct spdk_json_write
|
|||||||
config_entry += 2;
|
config_entry += 2;
|
||||||
}
|
}
|
||||||
spdk_json_write_object_end(w);
|
spdk_json_write_object_end(w);
|
||||||
} else if (entry->config_file) {
|
}
|
||||||
|
if (entry->config_file) {
|
||||||
spdk_json_write_named_string(w, "config_file", entry->config_file);
|
spdk_json_write_named_string(w, "config_file", entry->config_file);
|
||||||
}
|
}
|
||||||
if (entry->key_file) {
|
if (entry->key_file) {
|
||||||
@ -1010,14 +1012,16 @@ rbd_register_cluster(const char *name, const char *user_id, const char *const *c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The first priority is the config_param, then we use the config_file */
|
/* Support specify config_param or config_file separately, or both of them. */
|
||||||
if (config_param) {
|
if (config_param) {
|
||||||
entry->config_param = bdev_rbd_dup_config(config_param);
|
entry->config_param = bdev_rbd_dup_config(config_param);
|
||||||
if (entry->config_param == NULL) {
|
if (entry->config_param == NULL) {
|
||||||
SPDK_ERRLOG("Failed to save the config_param=%p on entry = %p\n", config_param, entry);
|
SPDK_ERRLOG("Failed to save the config_param=%p on entry = %p\n", config_param, entry);
|
||||||
goto err_handle;
|
goto err_handle;
|
||||||
}
|
}
|
||||||
} else if (config_file) {
|
}
|
||||||
|
|
||||||
|
if (config_file) {
|
||||||
entry->config_file = strdup(config_file);
|
entry->config_file = strdup(config_file);
|
||||||
if (entry->config_file == NULL) {
|
if (entry->config_file == NULL) {
|
||||||
SPDK_ERRLOG("Failed to save the config_file=%s on entry = %p\n", config_file, entry);
|
SPDK_ERRLOG("Failed to save the config_file=%s on entry = %p\n", config_file, entry);
|
||||||
@ -1039,6 +1043,14 @@ rbd_register_cluster(const char *name, const char *user_id, const char *const *c
|
|||||||
goto err_handle;
|
goto err_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Try default location when entry->config_file is NULL, but ignore failure when it is NULL */
|
||||||
|
rc = rados_conf_read_file(entry->cluster, entry->config_file);
|
||||||
|
if (entry->config_file && rc < 0) {
|
||||||
|
SPDK_ERRLOG("Failed to read conf file %s\n", entry->config_file);
|
||||||
|
rados_shutdown(entry->cluster);
|
||||||
|
goto err_handle;
|
||||||
|
}
|
||||||
|
|
||||||
if (config_param) {
|
if (config_param) {
|
||||||
const char *const *config_entry = config_param;
|
const char *const *config_entry = config_param;
|
||||||
while (*config_entry) {
|
while (*config_entry) {
|
||||||
@ -1050,13 +1062,6 @@ rbd_register_cluster(const char *name, const char *user_id, const char *const *c
|
|||||||
}
|
}
|
||||||
config_entry += 2;
|
config_entry += 2;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
rc = rados_conf_read_file(entry->cluster, entry->config_file);
|
|
||||||
if (rc < 0) {
|
|
||||||
SPDK_ERRLOG("Failed to read conf file\n");
|
|
||||||
rados_shutdown(entry->cluster);
|
|
||||||
goto err_handle;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key_file) {
|
if (key_file) {
|
||||||
|
Loading…
Reference in New Issue
Block a user