bdev/null: make md_size inclusive for dif_type

When using --dif-type option --md-size should be
required as well.
Update & improve bdev_null_create rpc.py help
messages as well.

Change-Id: I6588a97aef6c8792bab7a41ece17c0461bb36844
Signed-off-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3949
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Karol Latecki 2020-08-27 09:37:12 +02:00 committed by Tomasz Zawadzki
parent 7932bcd6b0
commit 7ff4e2af79
3 changed files with 20 additions and 10 deletions

View File

@ -1558,9 +1558,9 @@ name | Optional | string | Bdev name to use
block_size | Required | number | Block size in bytes block_size | Required | number | Block size in bytes
num_blocks | Required | number | Number of blocks num_blocks | Required | number | Number of blocks
uuid | Optional | string | UUID of new bdev uuid | Optional | string | UUID of new bdev
md_size | Optional | number | Metadata size in bytes md_size | Optional | number | Metadata size for this bdev. Default=0.
dif_type | Optional | number | Protection information type (0, 1, 2 or 3). Default: 0 - no protection. 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 MD. Default: in the last 8 bytes. dif_is_head_of_md | Optional | boolean | Protection information is in the first 8 bytes of metadata. Default=false.
### Result ### Result

View File

@ -120,6 +120,12 @@ rpc_bdev_null_create(struct spdk_jsonrpc_request *request,
goto cleanup; 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.name = req.name;
opts.uuid = uuid; opts.uuid = uuid;
opts.num_blocks = req.num_blocks; opts.num_blocks = req.num_blocks;

View File

@ -323,6 +323,9 @@ if __name__ == "__main__":
def bdev_null_create(args): def bdev_null_create(args):
num_blocks = (args.total_size * 1024 * 1024) // args.block_size 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, print_json(rpc.bdev.bdev_null_create(args.client,
num_blocks=num_blocks, num_blocks=num_blocks,
block_size=args.block_size, block_size=args.block_size,
@ -336,15 +339,16 @@ if __name__ == "__main__":
help='Add a bdev with null backend') help='Add a bdev with null backend')
p.add_argument('name', help='Block device name') p.add_argument('name', help='Block device name')
p.add_argument('-u', '--uuid', help='UUID of the bdev') p.add_argument('-u', '--uuid', help='UUID of the bdev')
p.add_argument( p.add_argument('total_size', help='Size of null bdev in MB (int > 0). Includes only data blocks.', type=int)
'total_size', help='Size of null bdev in MB (int > 0)', type=int) p.add_argument('block_size', help='Block size for this bdev.'
p.add_argument('block_size', help='Block size for this bdev', type=int) '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, p.add_argument('-m', '--md-size', type=int,
help='Metadata size for this bdev. Default 0') help='Metadata size for this bdev. Default=0.')
p.add_argument('-t', '--dif-type', type=int, choices=[0, 1, 2, 3], p.add_argument('-t', '--dif-type', type=int, default=0, choices=[0, 1, 2, 3],
help='Protection information type. Default: 0 - no protection') 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', 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) p.set_defaults(func=bdev_null_create)
def bdev_null_delete(args): def bdev_null_delete(args):