Commit e5693d68 authored by Mateusz Kozlowski's avatar Mateusz Kozlowski Committed by Konrad Sztyber
Browse files

bdev/aio: Add UUID to the bdev_aio_create function



Adds an optional UUID to the RPC call. The parameter is persisted upon
save_config call. This allows for the bdev to have a consistent UUID and
means it can be used with RAID bdev.

Change-Id: If6e7ab1fb327a958bba5a6aa583ba5a4943105f8
Signed-off-by: default avatarMateusz Kozlowski <mateusz.kozlowski@solidigm.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24502


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent e321b863
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3884,6 +3884,7 @@ filename | Required | number | Path to device or file
block_size              | Optional | number      | Block size in bytes
readonly                | Optional | boolean     | set aio bdev as read-only
fallocate               | Optional | boolean     | Enable UNMAP and WRITE ZEROES support. Intended only for testing purposes due to synchronous syscall.
uuid                    | Optional | string      | UUID of new bdev

#### Result

+6 −1
Original line number Diff line number Diff line
@@ -765,6 +765,7 @@ static void
bdev_aio_write_json_config(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w)
{
	struct file_disk *fdisk = bdev->ctxt;
	const struct spdk_uuid *uuid = spdk_bdev_get_uuid(bdev);

	spdk_json_write_object_begin(w);

@@ -778,6 +779,9 @@ bdev_aio_write_json_config(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w
	spdk_json_write_named_string(w, "filename", fdisk->filename);
	spdk_json_write_named_bool(w, "readonly", fdisk->readonly);
	spdk_json_write_named_bool(w, "fallocate", fdisk->fallocate);
	if (!spdk_uuid_is_null(uuid)) {
		spdk_json_write_named_uuid(w, "uuid", uuid);
	}
	spdk_json_write_object_end(w);

	spdk_json_write_object_end(w);
@@ -877,7 +881,7 @@ bdev_aio_group_destroy_cb(void *io_device, void *ctx_buf)

int
create_aio_bdev(const char *name, const char *filename, uint32_t block_size, bool readonly,
		bool fallocate)
		bool fallocate, const struct spdk_uuid *uuid)
{
	struct file_disk *fdisk;
	uint32_t detected_block_size;
@@ -976,6 +980,7 @@ create_aio_bdev(const char *name, const char *filename, uint32_t block_size, boo

	fdisk->disk.blockcnt = disk_size / fdisk->disk.blocklen;
	fdisk->disk.ctxt = fdisk;
	spdk_uuid_copy(&fdisk->disk.uuid, uuid);

	fdisk->disk.fn_table = &aio_fn_table;

+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
typedef void (*delete_aio_bdev_complete)(void *cb_arg, int bdeverrno);

int create_aio_bdev(const char *name, const char *filename, uint32_t block_size, bool readonly,
		    bool falloc);
		    bool falloc, const struct spdk_uuid *uuid);

int bdev_aio_rescan(const char *name);
void bdev_aio_delete(const char *name, delete_aio_bdev_complete cb_fn, void *cb_arg);
+3 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ struct rpc_construct_aio {
	uint32_t block_size;
	bool readonly;
	bool fallocate;
	struct spdk_uuid uuid;
};

struct rpc_construct_aio_ctx {
@@ -36,6 +37,7 @@ static const struct spdk_json_object_decoder rpc_construct_aio_decoders[] = {
	{"block_size", offsetof(struct rpc_construct_aio, block_size), spdk_json_decode_uint32, true},
	{"readonly", offsetof(struct rpc_construct_aio, readonly), spdk_json_decode_bool, true},
	{"fallocate", offsetof(struct rpc_construct_aio, fallocate), spdk_json_decode_bool, true},
	{"uuid", offsetof(struct rpc_construct_aio, uuid), spdk_json_decode_uuid, true},
};

static void
@@ -76,7 +78,7 @@ rpc_bdev_aio_create(struct spdk_jsonrpc_request *request,

	ctx->request = request;
	rc = create_aio_bdev(ctx->req.name, ctx->req.filename, ctx->req.block_size,
			     ctx->req.readonly, ctx->req.fallocate);
			     ctx->req.readonly, ctx->req.fallocate, &ctx->req.uuid);
	if (rc) {
		spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
		free_rpc_construct_aio(ctx);
+4 −1
Original line number Diff line number Diff line
@@ -449,7 +449,7 @@ def bdev_raid_remove_base_bdev(client, name):
    return client.call('bdev_raid_remove_base_bdev', params)


def bdev_aio_create(client, filename, name, block_size=None, readonly=None, fallocate=None):
def bdev_aio_create(client, filename, name, block_size=None, readonly=None, fallocate=None, uuid=None):
    """Construct a Linux AIO block device.
    Args:
        filename: path to device or file (ex: /dev/sda)
@@ -457,6 +457,7 @@ def bdev_aio_create(client, filename, name, block_size=None, readonly=None, fall
        block_size: block size of device (optional; autodetected if omitted)
        readonly: set aio bdev as read-only
        fallocate: enable fallocate for UNMAP/WRITEZEROS support (note that fallocate syscall would block reactor)
        uuid: UUID of the bdev (optional)
    Returns:
        Name of created block device.
    """
@@ -469,6 +470,8 @@ def bdev_aio_create(client, filename, name, block_size=None, readonly=None, fall
        params['readonly'] = readonly
    if fallocate is not None:
        params['fallocate'] = fallocate
    if uuid is not None:
        params['uuid'] = uuid
    return client.call('bdev_aio_create', params)


Loading