Commit fe0d81ba authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

bdev/nvme: attach_controller RPC returns callback rc as error code



Previously, if the bdev_nvme_attach_controller RPC fails after
bdev_nvme_create() is called, SPDK_JSONRPC_ERROR_INVALID_PARAMS was
returned as error code.

However, this was not good because error code was not consistent for
error due to path duplication. If path was duplicated with the
current active path, -EALREADY was returned. However, if path was
duplicated with any secondary path, SPDK_JSONRPC_ERROR_INVALID_PARAMS
was returned.

To fix this incosistency, we take two steps.

As the first step, in this patch, we change to return callback rc
instead of SPDK_JSONRPC_ERROR_INVALID_PARAMS as error code if the RPC
fails after bdev_nvme_create() is called.

This will be reasonable because if the bdev_nvme_attach_controller
RPC fails before bdev_nvme_create() is called, OS error code has been
used for all cases but decode error.

As the second step, the next patch will change the callback rc for one
case to fix a github issue.

Signed-off-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I49816009d420e9ef23cc683385d78e616a87d4a6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23217


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Mellanox Build Bot
parent 95df4e0d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -384,7 +384,7 @@ rpc_bdev_nvme_attach_controller_done(void *cb_ctx, size_t bdev_count, int rc)
	struct spdk_jsonrpc_request *request = ctx->request;

	if (rc < 0) {
		spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
		spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
		free_rpc_bdev_nvme_attach_controller_ctx(ctx);
		return;
	}