bdev/ftl: bdev_ftl_init_bdev: do not call cb if failed

According to the current implementation, the functions that called by
bdev_ftl_init_bdev() will not call callback if they return errno.
Besides, the caller of bdev_ftl_init_bdev() (e.g.
spdk_rpc_construct_ftl_bdev()) don't expect callback be called if callee
return errno.

Change-Id: I5f36d5332ac66db65bb2090e9625a73b1107306b
Signed-off-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-on: https://review.gerrithub.io/c/443068
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Wojciech Malikowski <wojciech.malikowski@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
wuzhouhui 2019-02-02 13:17:51 +08:00 committed by Jim Harris
parent a8fd4524d5
commit aea859eaab

View File

@ -823,7 +823,6 @@ bdev_ftl_init_bdev(struct ftl_bdev_init_opts *opts, ftl_bdev_init_fn cb, void *c
{
struct ftl_bdev_ctrlr *ftl_ctrlr;
struct spdk_nvme_ctrlr *ctrlr;
int rc = 0;
assert(opts != NULL);
assert(cb != NULL);
@ -843,24 +842,16 @@ bdev_ftl_init_bdev(struct ftl_bdev_init_opts *opts, ftl_bdev_init_fn cb, void *c
ctrlr = spdk_nvme_connect(&opts->trid, NULL, 0);
if (!ctrlr) {
rc = -ENODEV;
goto error;
return -ENODEV;
}
if (!spdk_nvme_ctrlr_is_ocssd_supported(ctrlr)) {
spdk_nvme_detach(ctrlr);
rc = -EPERM;
goto error;
return -EPERM;
}
rc = bdev_ftl_create(ctrlr, &opts->trid, opts->name, &opts->range,
opts->mode, &opts->uuid, cb, cb_arg);
return rc;
error:
cb(NULL, cb_arg, rc);
return rc;
return bdev_ftl_create(ctrlr, &opts->trid, opts->name, &opts->range,
opts->mode, &opts->uuid, cb, cb_arg);
}
void