bdev/ftl: treat null UUID as no UUID
Check if the UUID in the configuration is null (all zeroes) and treat it as if no UUID has been supplied. Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com> Change-Id: Ic91c77591528a8aaa4cf5c0241e6bde51b3757f1 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448628 Reviewed-by: Wojciech Malikowski <wojciech.malikowski@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
9674a7b6cb
commit
02b0230296
@ -236,7 +236,7 @@ Example config:
|
||||
|
||||
```
|
||||
[Ftl]
|
||||
TransportID "trtype:PCIe traddr:00:0a.0" nvme0 "0-3"
|
||||
TransportID "trtype:PCIe traddr:00:0a.0" nvme0 "0-3" 00000000-0000-0000-0000-000000000000
|
||||
TransportID "trtype:PCIe traddr:00:0a.0" nvme1 "4-5" e9825835-b03c-49d7-bc3e-5827cbde8a88
|
||||
```
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "spdk/string.h"
|
||||
#include "spdk/likely.h"
|
||||
#include "spdk/util.h"
|
||||
#include "spdk/string.h"
|
||||
#include "spdk/ftl.h"
|
||||
#include "spdk_internal/log.h"
|
||||
|
||||
@ -508,8 +509,6 @@ bdev_ftl_read_bdev_config(struct spdk_conf_section *sp,
|
||||
continue;
|
||||
}
|
||||
|
||||
opts->mode = SPDK_FTL_MODE_CREATE;
|
||||
|
||||
val = spdk_conf_section_get_nmval(sp, "TransportID", i, 1);
|
||||
if (!val) {
|
||||
SPDK_ERRLOG("No name provided for TransportID: %s\n", trid);
|
||||
@ -533,7 +532,9 @@ bdev_ftl_read_bdev_config(struct spdk_conf_section *sp,
|
||||
|
||||
val = spdk_conf_section_get_nmval(sp, "TransportID", i, 3);
|
||||
if (!val) {
|
||||
continue;
|
||||
SPDK_ERRLOG("No UUID provided for TransportID: %s\n", trid);
|
||||
rc = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
rc = spdk_uuid_parse(&opts->uuid, val);
|
||||
@ -543,7 +544,11 @@ bdev_ftl_read_bdev_config(struct spdk_conf_section *sp,
|
||||
break;
|
||||
}
|
||||
|
||||
opts->mode = 0;
|
||||
if (spdk_mem_all_zero(&opts->uuid, sizeof(opts->uuid))) {
|
||||
opts->mode = SPDK_FTL_MODE_CREATE;
|
||||
} else {
|
||||
opts->mode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!rc) {
|
||||
|
@ -142,13 +142,16 @@ spdk_rpc_construct_ftl_bdev(struct spdk_jsonrpc_request *request,
|
||||
}
|
||||
|
||||
if (req.uuid) {
|
||||
opts.mode = 0;
|
||||
if (spdk_uuid_parse(&opts.uuid, req.uuid) < 0) {
|
||||
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||
"Failed to parse uuid: %s",
|
||||
req.uuid);
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
if (!spdk_mem_all_zero(&opts.uuid, sizeof(opts.uuid))) {
|
||||
opts.mode &= ~SPDK_FTL_MODE_CREATE;
|
||||
}
|
||||
}
|
||||
|
||||
rc = bdev_ftl_init_bdev(&opts, _spdk_rpc_construct_ftl_bdev_cb, request);
|
||||
|
@ -19,6 +19,8 @@ function generate_config {
|
||||
echo " TransportID \"trtype:PCIe traddr:$1\" $2 $3 $4"
|
||||
}
|
||||
|
||||
uuid=00000000-0000-0000-0000-000000000000
|
||||
|
||||
while getopts ":a:n:l:m:u:" arg; do
|
||||
case "$arg" in
|
||||
a) addr=$OPTARG ;;
|
||||
|
Loading…
x
Reference in New Issue
Block a user