Commit 7c233ade authored by Wojciech Malikowski's avatar Wojciech Malikowski Committed by Ben Walker
Browse files

bdev_ftl: Added FTL bdev module



This patch adds FTL bdev. RPC scripts have been updated to allow for
creation and removal of FTL bdevs.

Change-Id: I82a5c5033b65bbeb67c238cae969a68cff767dcc
Signed-off-by: default avatarJakub Radtke <jakub.radtke@intel.com>
Signed-off-by: default avatarWojciech Malikowski <wojciech.malikowski@intel.com>
Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Signed-off-by: default avatarMateusz Kozlowski <mateusz.kozlowski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/431329


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 363e48d9
Loading
Loading
Loading
Loading
+91 −0
Original line number Diff line number Diff line
@@ -294,6 +294,8 @@ Example response:
    "construct_null_bdev",
    "delete_malloc_bdev",
    "construct_malloc_bdev",
    "delete_ftl_bdev",
    "construct_ftl_bdev",
    "get_lvol_stores",
    "destroy_lvol_bdev",
    "resize_lvol_bdev",
@@ -1501,6 +1503,95 @@ Example response:
}
~~~

## construct_ftl_bdev {#rpc_construct_ftl_bdev}

Create FTL bdev.

This RPC is subject to change.

### Parameters

Name                    | Optional | Type        | Description
----------------------- | -------- | ----------- | -----------
name                    | Required | string      | Bdev name
trtype                  | Required | string      | Transport type
traddr                  | Required | string      | NVMe target address
punits                  | Required | string      | Parallel unit range in the form of start-end e.g 4-8
uuid                    | Optional | string      | UUID of restored bdev (not applicable when creating new instance)

### Result

Name of newly created bdev.

### Example

Example request:

~~~
{
  "params": {
    "name": "nvme0"
    "trtype" "pcie"
    "traddr": "0000:00:04.0"
    "punits": "0-3"
    "uuid": "4a7481ce-786f-41a0-9b86-8f7465c8f4d3"
  },
  "jsonrpc": "2.0",
  "method": "construct_ftl_bdev",
  "id": 1
}
~~~

Example response:

~~~
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
      "name" : "nvme0"
      "uuid" : "4a7481ce-786f-41a0-9b86-8f7465c8f4d3"
  }
}
~~~

## delete_ftl_bdev {#rpc_delete_ftl_bdev}

Delete FTL bdev.

This RPC is subject to change.

### Parameters

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

### Example

Example request:

~~~
{
  "params": {
    "name": "nvme0"
  },
  "jsonrpc": "2.0",
  "method": "delete_ftl_bdev",
  "id": 1
}
~~~

Example response:

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


## create_pmem_pool {#rpc_create_pmem_pool}

+1 −0
Original line number Diff line number Diff line
@@ -56,5 +56,6 @@ DIRS-$(CONFIG_PMDK) += pmem
endif

DIRS-$(CONFIG_RBD) += rbd
DIRS-$(CONFIG_FTL) += ftl

include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk

lib/bdev/ftl/Makefile

0 → 100644
+40 −0
Original line number Diff line number Diff line
#
#  BSD LICENSE
#
#  Copyright (c) Intel Corporation.
#  All rights reserved.
#
#  Redistribution and use in source and binary forms, with or without
#  modification, are permitted provided that the following conditions
#  are met:
#
#    * Redistributions of source code must retain the above copyright
#      notice, this list of conditions and the following disclaimer.
#    * Redistributions in binary form must reproduce the above copyright
#      notice, this list of conditions and the following disclaimer in
#      the documentation and/or other materials provided with the
#      distribution.
#    * Neither the name of Intel Corporation nor the names of its
#      contributors may be used to endorse or promote products derived
#      from this software without specific prior written permission.
#
#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

C_SRCS = bdev_ftl.c bdev_ftl_rpc.c
LIBNAME = bdev_ftl

include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
+928 −0

File added.

Preview size limit exceeded, changes collapsed.

+74 −0
Original line number Diff line number Diff line
/*-
 *   BSD LICENSE
 *
 *   Copyright (c) Intel Corporation.
 *   All rights reserved.
 *
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following conditions
 *   are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in
 *       the documentation and/or other materials provided with the
 *       distribution.
 *     * Neither the name of Intel Corporation nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef SPDK_BDEV_FTL_H
#define SPDK_BDEV_FTL_H

#include <spdk/stdinc.h>
#include <spdk/nvme.h>
#include <spdk/bdev_module.h>
#include <spdk/ftl.h>

#define FTL_MAX_CONTROLLERS	64
#define FTL_MAX_BDEVS		(FTL_MAX_CONTROLLERS * 128)
#define FTL_RANGE_MAX_LENGTH	32

struct spdk_bdev;
struct spdk_uuid;

struct ftl_bdev_info {
	const char		*name;
	struct spdk_uuid	uuid;
};

struct ftl_bdev_init_opts {
	/* NVMe controller's transport ID */
	struct spdk_nvme_transport_id		trid;
	/* Parallel unit range */
	struct spdk_ftl_punit_range		range;
	/* Bdev's name */
	const char				*name;
	/* Bdev's mode */
	uint32_t				mode;
	/* UUID if device is restored from SSD */
	struct spdk_uuid			uuid;
};

typedef void (*ftl_bdev_init_fn)(const struct ftl_bdev_info *, void *, int);

int	bdev_ftl_parse_punits(struct spdk_ftl_punit_range *range, const char *range_string);
int	bdev_ftl_init_bdev(struct ftl_bdev_init_opts *opts, ftl_bdev_init_fn cb,
			   void *cb_arg);
void	bdev_ftl_delete_bdev(const char *name, spdk_bdev_unregister_cb cb_fn, void *cb_arg);

#endif /* SPDK_BDEV_FTL_H */
Loading