Commit 5e1e850b authored by Alexey Marchuk's avatar Alexey Marchuk Committed by Tomasz Zawadzki
Browse files

bdev/malloc: Add optimal IO boundary



Allow to specify optimal IO boundary for
malloc bdev, it can be used to test split
of IO requests on generic bdev layer

Signed-off-by: default avatarAlexey Marchuk <alexeymar@mellanox.com>
Change-Id: Ic3529dc00cf852ea5cf40d0553d846a698fff6c7
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10068


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent 933d5642
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -2496,6 +2496,7 @@ name | Optional | string | Bdev name to use
block_size              | Required | number      | Block size in bytes -must be multiple of 512
num_blocks              | Required | number      | Number of blocks
uuid                    | Optional | string      | UUID of new bdev
optimal_io_boundary     | Optional | number      | Split on optimal IO boundary, in number of blocks, default 0

#### Result

@@ -2511,7 +2512,8 @@ Example request:
    "block_size": 4096,
    "num_blocks": 16384,
    "name": "Malloc0",
    "uuid": "2b6601ba-eada-44fb-9a83-a20eb9eb9e90"
    "uuid": "2b6601ba-eada-44fb-9a83-a20eb9eb9e90",
    "optimal_io_boundary": 16
  },
  "jsonrpc": "2.0",
  "method": "bdev_malloc_create",
+7 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
 *
 *   Copyright (c) Intel Corporation.
 *   All rights reserved.
 *   Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 *
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following conditions
@@ -361,6 +362,7 @@ bdev_malloc_write_json_config(struct spdk_bdev *bdev, struct spdk_json_write_ctx
	spdk_json_write_named_uint32(w, "block_size", bdev->blocklen);
	spdk_uuid_fmt_lower(uuid_str, sizeof(uuid_str), &bdev->uuid);
	spdk_json_write_named_string(w, "uuid", uuid_str);
	spdk_json_write_named_uint32(w, "optimal_io_boundary", bdev->optimal_io_boundary);

	spdk_json_write_object_end(w);

@@ -377,7 +379,7 @@ static const struct spdk_bdev_fn_table malloc_fn_table = {

int
create_malloc_disk(struct spdk_bdev **bdev, const char *name, const struct spdk_uuid *uuid,
		   uint64_t num_blocks, uint32_t block_size)
		   uint64_t num_blocks, uint32_t block_size, uint32_t optimal_io_boundary)
{
	struct malloc_disk	*mdisk;
	int rc;
@@ -428,6 +430,10 @@ create_malloc_disk(struct spdk_bdev **bdev, const char *name, const struct spdk_
	mdisk->disk.write_cache = 1;
	mdisk->disk.blocklen = block_size;
	mdisk->disk.blockcnt = num_blocks;
	if (optimal_io_boundary) {
		mdisk->disk.optimal_io_boundary = optimal_io_boundary;
		mdisk->disk.split_on_optimal_io_boundary = true;
	}
	if (uuid) {
		mdisk->disk.uuid = *uuid;
	} else {
+2 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
 *
 *   Copyright (c) Intel Corporation.
 *   All rights reserved.
 *   Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 *
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following conditions
@@ -41,7 +42,7 @@
typedef void (*spdk_delete_malloc_complete)(void *cb_arg, int bdeverrno);

int create_malloc_disk(struct spdk_bdev **bdev, const char *name, const struct spdk_uuid *uuid,
		       uint64_t num_blocks, uint32_t block_size);
		       uint64_t num_blocks, uint32_t block_size, uint32_t optimal_io_boundary);

void delete_malloc_disk(struct spdk_bdev *bdev, spdk_delete_malloc_complete cb_fn, void *cb_arg);

+5 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
 *
 *   Copyright (c) Intel Corporation.
 *   All rights reserved.
 *   Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 *
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following conditions
@@ -43,6 +44,7 @@ struct rpc_construct_malloc {
	char *uuid;
	uint64_t num_blocks;
	uint32_t block_size;
	uint32_t optimal_io_boundary;
};

static void
@@ -57,6 +59,7 @@ static const struct spdk_json_object_decoder rpc_construct_malloc_decoders[] = {
	{"uuid", offsetof(struct rpc_construct_malloc, uuid), spdk_json_decode_string, true},
	{"num_blocks", offsetof(struct rpc_construct_malloc, num_blocks), spdk_json_decode_uint64},
	{"block_size", offsetof(struct rpc_construct_malloc, block_size), spdk_json_decode_uint32},
	{"optimal_io_boundary", offsetof(struct rpc_construct_malloc, optimal_io_boundary), spdk_json_decode_uint32, true},
};

static void
@@ -94,7 +97,8 @@ rpc_bdev_malloc_create(struct spdk_jsonrpc_request *request,
		uuid = &decoded_uuid;
	}

	rc = create_malloc_disk(&bdev, req.name, uuid, req.num_blocks, req.block_size);
	rc = create_malloc_disk(&bdev, req.name, uuid, req.num_blocks, req.block_size,
				req.optimal_io_boundary);
	if (rc) {
		spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
		goto cleanup;
+4 −1
Original line number Diff line number Diff line
@@ -341,7 +341,8 @@ if __name__ == "__main__":
                                               num_blocks=int(num_blocks),
                                               block_size=args.block_size,
                                               name=args.name,
                                               uuid=args.uuid))
                                               uuid=args.uuid,
                                               optimal_io_boundary=args.optimal_io_boundary))
    p = subparsers.add_parser('bdev_malloc_create', aliases=['construct_malloc_bdev'],
                              help='Create a bdev with malloc backend')
    p.add_argument('-b', '--name', help="Name of the bdev")
@@ -349,6 +350,8 @@ if __name__ == "__main__":
    p.add_argument(
        'total_size', help='Size of malloc bdev in MB (float > 0)', type=float)
    p.add_argument('block_size', help='Block size for this bdev', type=int)
    p.add_argument('-o', '--optimal-io-boundary', help="""Split on optimal IO boundary, in number of
    blocks, default 0 (disabled)""", type=int)
    p.set_defaults(func=bdev_malloc_create)

    def bdev_malloc_delete(args):
Loading