Commit dc93bd85 authored by Haoqian He's avatar Haoqian He Committed by Jim Harris
Browse files

vhost-scsi: add new rpc to enhance live recovery



After the vhost-scsi controller is started, qemu can reconnect
to spdk, but at this time the LUN may not be added to the scsi
target, struct spdk_scsi_dev_vhost_state's member dev has not
been set yet, which will lead to IO error subsequently.

So we add a vhost_create_scsi_controller RPC option to create
controller but doesn't start it, and add a new RPC to start
the controller separately.

Change-Id: I1f8a78528de3073293d1c5ce2c064123519bc320
Signed-off-by: default avatarHaoqian He <haoqian.he@smartx.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19590


Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
parent f99cce9c
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -6,6 +6,12 @@

Added `caw_iov` field to struct `spdk_scsi_task` to support SBC-3 compare_and_write IO.

Added parameter `delay` to `vhost_create_scsi_controller` RPC which allows user to defer starting
the vhost-scsi controller until adding the scsi target is completed.

Added `vhost_start_scsi_controller` RPC to start vhost-scsi controller, it could be used to support
live recovery feature of vhost-scsi target.

## v23.09

### accel
+39 −1
Original line number Diff line number Diff line
@@ -9209,6 +9209,7 @@ Name | Optional | Type | Description
----------------------- | -------- | ----------- | -----------
ctrlr                   | Required | string      | Controller name
cpumask                 | Optional | string      | @ref cpu_mask for this controller
delay                   | Optional | boolean     | If true, delay the controller startup.

#### Example

@@ -9218,7 +9219,8 @@ Example request:
{
  "params": {
    "cpumask": "0x2",
    "ctrlr": "VhostScsi0"
    "ctrlr": "VhostScsi0",
    "delay": true
  },
  "jsonrpc": "2.0",
  "method": "vhost_create_scsi_controller",
@@ -9236,6 +9238,42 @@ Example response:
}
~~~

### vhost_start_scsi_controller {#rpc_vhost_start_scsi_controller}

Start vhost SCSI controller, if controller is already started, do nothing.

#### Parameters

Name                    | Optional | Type        | Description
----------------------- | -------- | ----------- | -----------
ctrlr                   | Required | string      | Controller name

#### Example

Example request:

~~~json
{
  "params": {
    "ctrlr": "VhostScsi0",
  },
  "jsonrpc": "2.0",
  "method": "vhost_start_scsi_controller",
  "id": 1
}
~~~

Example response:

~~~json
response:
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": true
}
~~~

### vhost_scsi_controller_add_target {#rpc_vhost_scsi_controller_add_target}

In vhost target `ctrlr` create SCSI target with ID `scsi_target_num` and add `bdev_name` as LUN 0.
+16 −0
Original line number Diff line number Diff line
@@ -227,6 +227,22 @@ void spdk_vhost_get_coalescing(struct spdk_vhost_dev *vdev, uint32_t *delay_base
 */
int spdk_vhost_scsi_dev_construct(const char *name, const char *cpumask);

/**
 * Create an empty vhost SCSI device like \c spdk_vhost_scsi_dev_construct
 * but do not start the controller.
 *
 * This function is thread-safe.
 *
 * \param name name of the vhost device. The name will also be used
 * for socket name, which is exactly \c socket_base_dir/name
 * \param cpumask string containing cpumask in hex. The leading *0x*
 * is allowed but not required. The mask itself can be constructed as:
 * ((1 << cpu0) | (1 << cpu1) | ... | (1 << cpuN)).
 *
 * \return 0 on success, negative errno on error.
 */
int spdk_vhost_scsi_dev_construct_no_start(const char *name, const char *cpumask);

/**
 * Construct and attach new SCSI target to the vhost SCSI device
 * on given (unoccupied) slot.  The device will be created with a single
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 7
SO_MINOR := 0
SO_MINOR := 1

CFLAGS += -I.
CFLAGS += $(ENV_CFLAGS)
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
	spdk_vhost_set_coalescing;
	spdk_vhost_get_coalescing;
	spdk_vhost_scsi_dev_construct;
	spdk_vhost_scsi_dev_construct_no_start;
	spdk_vhost_scsi_dev_add_tgt;
	spdk_vhost_scsi_dev_get_tgt;
	spdk_vhost_scsi_dev_remove_tgt;
Loading