Commit 309682ca authored by Mateusz Kozlowski's avatar Mateusz Kozlowski Committed by Jim Harris
Browse files

module/bdev/ftl: New RPC to get FTL properties



This RPC call provides list of available properties for
the specified FTL device.

Change-Id: Ida63ae438101950502f7ba3b7ba1bc475f273648
Signed-off-by: default avatarMariusz Barczak <Mariusz.Barczak@solidigmtechnology.com>
Signed-off-by: default avatarMateusz Kozlowski <mateusz.kozlowski@solidigm.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19006


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
parent fa378811
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
@@ -482,6 +482,7 @@ Example response:
    "bdev_ftl_load",
    "bdev_ftl_unmap",
    "bdev_ftl_get_stats",
    "bdev_ftl_get_properties",
    "bdev_lvol_get_lvstores",
    "bdev_lvol_delete",
    "bdev_lvol_resize",
@@ -6065,6 +6066,52 @@ Example response:
}
~~~

### bdev_ftl_get_properties {#rpc_bdev_ftl_get_properties}

Get FTL properties

#### Parameters

Name                    | Optional | Type        | Description
----------------------- | -------- | ----------- | -----------
name                    | Required | string      | Bdev name

#### Response

The response contains FTL bdev properties. Some of them can be modified, other
reported as read only.

#### Example

Example request:

~~~json
{
  "params": {
    "name": "ftl0"
  },
  "jsonrpc": "2.0",
  "method": "bdev_ftl_get_properties",
  "id": 1
}
~~~

Example response:

~~~json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "name": "ftl0",
    "properties": {
      "flush_cache": "true",
      "fast_shutdown": "true"
    }
  }
}
~~~

### bdev_passthru_create {#rpc_bdev_passthru_create}

Create passthru bdev. This bdev type redirects all IO to it's base bdev. It has no other purpose than being an example
+14 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ extern "C" {

struct spdk_ftl_dev;
struct ftl_io;
struct spdk_jsonrpc_request;

/* Limit thresholds */
enum {
@@ -326,6 +327,19 @@ void spdk_ftl_dev_set_fast_shutdown(struct spdk_ftl_dev *dev, bool fast_shutdown
int spdk_ftl_get_stats(struct spdk_ftl_dev *dev, struct ftl_stats *stats, spdk_ftl_stats_fn cb_fn,
		       void *cb_arg);

/**
 * Gets properties of the specified device.
 *
 * \param dev FTL device
 * \param request JSON RPC request where the properties will be stored
 * \param cb_fn Callback function to invoke when the operation is completed
 * \param cb_arg Argument to pass to the callback function
 *
 * \return 0 if successfully submitted, negative errno otherwise.
 */
int spdk_ftl_get_properties(struct spdk_ftl_dev *dev, struct spdk_jsonrpc_request *request,
			    spdk_ftl_fn cb_fn, void *cb_arg);

#ifdef __cplusplus
}
#endif
+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

ifdef SPDK_FTL_RETRY_ON_ERROR
CFLAGS += -DSPDK_FTL_RETRY_ON_ERROR
+53 −0
Original line number Diff line number Diff line
@@ -322,3 +322,56 @@ ftl_mngt_deinit_unmap_map(struct spdk_ftl_dev *dev, struct ftl_mngt_process *mng

	ftl_mngt_next_step(mngt);
}

struct ftl_get_properties_ctx {
	struct spdk_ftl_dev *dev;
	struct spdk_jsonrpc_request *request;
	spdk_ftl_fn cb_fn;
	void *cb_arg;
	struct spdk_thread *cb_thread;
};

static void
ftl_get_properties_cb(void *arg)
{
	struct ftl_get_properties_ctx *ctx = arg;

	ctx->cb_fn(ctx->cb_arg, 0);
	free(ctx);
}

static void
ftl_get_properties_msg(void *arg)
{
	struct ftl_get_properties_ctx *ctx = arg;
	int rc;

	ftl_property_dump(ctx->dev, ctx->request);
	rc = spdk_thread_send_msg(ctx->cb_thread, ftl_get_properties_cb, ctx);
	ftl_bug(rc);
}

int
spdk_ftl_get_properties(struct spdk_ftl_dev *dev, struct spdk_jsonrpc_request *request,
			spdk_ftl_fn cb_fn, void *cb_arg)
{
	int rc;
	struct ftl_get_properties_ctx *ctx = calloc(1, sizeof(*ctx));

	if (ctx == NULL) {
		return -ENOMEM;
	}
	ctx->dev = dev;
	ctx->request = request;
	ctx->cb_fn = cb_fn;
	ctx->cb_arg = cb_arg;
	ctx->cb_thread = spdk_get_thread();

	rc = spdk_thread_send_msg(dev->core_thread, ftl_get_properties_msg, ctx);
	if (rc) {
		free(ctx);
		return rc;
	}

	return rc;
}
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
	spdk_ftl_unmap;
	spdk_ftl_dev_set_fast_shutdown;
	spdk_ftl_get_stats;
	spdk_ftl_get_properties;

	local: *;
};
Loading