diff --git a/doc/jsonrpc.md b/doc/jsonrpc.md index ba9dbe4e6..d2f053974 100644 --- a/doc/jsonrpc.md +++ b/doc/jsonrpc.md @@ -1558,9 +1558,9 @@ name | Optional | string | Bdev name to use block_size | Required | number | Block size in bytes num_blocks | Required | number | Number of blocks uuid | Optional | string | UUID of new bdev -md_size | Optional | number | Metadata size in bytes -dif_type | Optional | number | Protection information type (0, 1, 2 or 3). Default: 0 - no protection. -dif_is_head_of_md | Optional | boolean | Protection information is in the first 8 bytes of MD. Default: in the last 8 bytes. +md_size | Optional | number | Metadata size for this bdev. Default=0. +dif_type | Optional | number | Protection information type. Parameter --md-size needs to be set along --dif-type. Default=0 - no protection. +dif_is_head_of_md | Optional | boolean | Protection information is in the first 8 bytes of metadata. Default=false. ### Result diff --git a/module/bdev/null/bdev_null_rpc.c b/module/bdev/null/bdev_null_rpc.c index f3a433e75..08bdb2897 100644 --- a/module/bdev/null/bdev_null_rpc.c +++ b/module/bdev/null/bdev_null_rpc.c @@ -120,6 +120,12 @@ rpc_bdev_null_create(struct spdk_jsonrpc_request *request, goto cleanup; } + if (req.dif_type != SPDK_DIF_DISABLE && !req.md_size) { + spdk_jsonrpc_send_error_response(request, -EINVAL, + "Interleaved metadata size should be set for DIF"); + goto cleanup; + } + opts.name = req.name; opts.uuid = uuid; opts.num_blocks = req.num_blocks; diff --git a/scripts/rpc.py b/scripts/rpc.py index 87957af29..944bcd948 100755 --- a/scripts/rpc.py +++ b/scripts/rpc.py @@ -323,6 +323,9 @@ if __name__ == "__main__": def bdev_null_create(args): num_blocks = (args.total_size * 1024 * 1024) // args.block_size + if args.dif_type and not args.md_size: + print("ERROR: --md-size must be > 0 when --dif-type is > 0") + exit(1) print_json(rpc.bdev.bdev_null_create(args.client, num_blocks=num_blocks, block_size=args.block_size, @@ -336,15 +339,16 @@ if __name__ == "__main__": help='Add a bdev with null backend') p.add_argument('name', help='Block device name') p.add_argument('-u', '--uuid', help='UUID of the bdev') - p.add_argument( - 'total_size', help='Size of null bdev in MB (int > 0)', type=int) - p.add_argument('block_size', help='Block size for this bdev', type=int) + p.add_argument('total_size', help='Size of null bdev in MB (int > 0). Includes only data blocks.', type=int) + p.add_argument('block_size', help='Block size for this bdev.' + 'Should be a sum of block size and metadata size if --md-size is used.', type=int) p.add_argument('-m', '--md-size', type=int, - help='Metadata size for this bdev. Default 0') - p.add_argument('-t', '--dif-type', type=int, choices=[0, 1, 2, 3], - help='Protection information type. Default: 0 - no protection') + help='Metadata size for this bdev. Default=0.') + p.add_argument('-t', '--dif-type', type=int, default=0, choices=[0, 1, 2, 3], + help='Protection information type. Parameter --md-size needs' + '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: in the last 8 bytes') + help='Protection information is in the first 8 bytes of metadata. Default=false.') p.set_defaults(func=bdev_null_create) def bdev_null_delete(args):