Commit c016e6ff authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

bdev/malloc: Make DIF PI format configurable at bdev creation



Make bdev's PI format configurable via the bdev_malloc_create RPC.
The PI format check is done by spdk_dif_ctx_init() as same as other
parameters.

Signed-off-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I28afca948916e36987d82e86f1a343203b83127d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24108


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent b1a1e099
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -598,6 +598,7 @@ bdev_malloc_write_json_config(struct spdk_bdev *bdev, struct spdk_json_write_ctx
	spdk_json_write_named_uint32(w, "md_size", bdev->md_len);
	spdk_json_write_named_uint32(w, "dif_type", bdev->dif_type);
	spdk_json_write_named_bool(w, "dif_is_head_of_md", bdev->dif_is_head_of_md);
	spdk_json_write_named_uint32(w, "dif_pi_format", bdev->dif_pi_format);

	spdk_json_write_object_end(w);

@@ -811,7 +812,7 @@ create_malloc_disk(struct spdk_bdev **bdev, const struct malloc_bdev_opts *opts)
	case SPDK_DIF_DISABLE:
		break;
	}
	mdisk->disk.dif_pi_format = SPDK_DIF_PI_FORMAT_16;
	mdisk->disk.dif_pi_format = opts->dif_pi_format;

	if (opts->dif_type != SPDK_DIF_DISABLE) {
		rc = malloc_disk_setup_pi(mdisk);
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ struct malloc_bdev_opts {
	bool md_interleave;
	enum spdk_dif_type dif_type;
	bool dif_is_head_of_md;
	enum spdk_dif_pi_format dif_pi_format;
};

int create_malloc_disk(struct spdk_bdev **bdev, const struct malloc_bdev_opts *opts);
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ static const struct spdk_json_object_decoder rpc_construct_malloc_decoders[] = {
	{"md_interleave", offsetof(struct malloc_bdev_opts, md_interleave), spdk_json_decode_bool, true},
	{"dif_type", offsetof(struct malloc_bdev_opts, dif_type), spdk_json_decode_int32, true},
	{"dif_is_head_of_md", offsetof(struct malloc_bdev_opts, dif_is_head_of_md), spdk_json_decode_bool, true},
	{"dif_pi_format", offsetof(struct malloc_bdev_opts, dif_pi_format), spdk_json_decode_uint32, true},
};

static void
+4 −1
Original line number Diff line number Diff line
@@ -249,7 +249,7 @@ def bdev_ocf_flush_status(client, name):


def bdev_malloc_create(client, num_blocks, block_size, physical_block_size=None, name=None, uuid=None, optimal_io_boundary=None,
                       md_size=None, md_interleave=None, dif_type=None, dif_is_head_of_md=None):
                       md_size=None, md_interleave=None, dif_type=None, dif_is_head_of_md=None, dif_pi_format=None):
    """Construct a malloc block device.
    Args:
        num_blocks: size of block device in blocks
@@ -262,6 +262,7 @@ def bdev_malloc_create(client, num_blocks, block_size, physical_block_size=None,
        md_interleave: metadata location, interleaved if set, and separated if omitted (optional)
        dif_type: protection information type (optional)
        dif_is_head_of_md: protection information is in the first 8 bytes of metadata (optional)
        dif_pi_format: protection information format (optional)
    Returns:
        Name of created block device.
    """
@@ -284,6 +285,8 @@ def bdev_malloc_create(client, num_blocks, block_size, physical_block_size=None,
        params['dif_type'] = dif_type
    if dif_is_head_of_md is not None:
        params['dif_is_head_of_md'] = dif_is_head_of_md
    if dif_pi_format is not None:
        params['dif_pi_format'] = dif_pi_format
    return client.call('bdev_malloc_create', params)


+5 −1
Original line number Diff line number Diff line
@@ -402,7 +402,8 @@ if __name__ == "__main__":
                                               md_size=args.md_size,
                                               md_interleave=args.md_interleave,
                                               dif_type=args.dif_type,
                                               dif_is_head_of_md=args.dif_is_head_of_md))
                                               dif_is_head_of_md=args.dif_is_head_of_md,
                                               dif_pi_format=args.dif_pi_format))
    p = subparsers.add_parser('bdev_malloc_create', help='Create a bdev with malloc backend')
    p.add_argument('-b', '--name', help="Name of the bdev")
    p.add_argument('-u', '--uuid', help="UUID of the bdev")
@@ -421,6 +422,9 @@ if __name__ == "__main__":
                        'to be set along --dif-type. Default=0 - no protection.')
    p.add_argument('-d', '--dif-is-head-of-md', action='store_true',
                   help='Protection information is in the first 8 bytes of metadata. Default=false.')
    p.add_argument('-f', '--dif-pi-format', type=int, choices=[0, 1, 2],
                   help='Protection infromation format. Parameter --dif-type needs to be set together.'
                        '0=16b Guard PI, 1=32b Guard PI, 2=64b Guard PI. Default=0.')
    p.set_defaults(func=bdev_malloc_create)

    def bdev_malloc_delete(args):