Skip to content

Commit

Permalink
OCF: Add create and force parameters to bdev_ocf_create
Browse files Browse the repository at this point in the history
This will allow to switch behavior of automatic metadata interpretation
into loading via config files only, more inline with other bdevs.

Signed-off-by: Kozlowski Mateusz <mateusz.kozlowski@intel.com>
Change-Id: Ifa7c8f5c96c2cfc6fd0ecefd473fc1d0b3e4ae03
  • Loading branch information
mmkayPL committed May 12, 2021
1 parent 2ac800a commit 247e4da
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions module/bdev/ocf/vbdev_ocf_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ struct rpc_bdev_ocf_create {
uint64_t cache_line_size; /* OCF cache line size */
char *cache_bdev_name; /* sub bdev */
char *core_bdev_name; /* sub bdev */
bool create; /* Create cache instance */
bool force; /* Force create cache instance */
};

static void
Expand All @@ -63,6 +65,8 @@ static const struct spdk_json_object_decoder rpc_bdev_ocf_create_decoders[] = {
{"cache_line_size", offsetof(struct rpc_bdev_ocf_create, cache_line_size), spdk_json_decode_uint64, true},
{"cache_bdev_name", offsetof(struct rpc_bdev_ocf_create, cache_bdev_name), spdk_json_decode_string},
{"core_bdev_name", offsetof(struct rpc_bdev_ocf_create, core_bdev_name), spdk_json_decode_string},
{"create", offsetof(struct rpc_bdev_ocf_create, create), spdk_json_decode_bool, true},
{"force", offsetof(struct rpc_bdev_ocf_create, force), spdk_json_decode_bool, true},
};

static void
Expand Down
8 changes: 6 additions & 2 deletions scripts/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ def bdev_ocf_create(args):
mode=args.mode,
cache_line_size=args.cache_line_size,
cache_bdev_name=args.cache_bdev_name,
core_bdev_name=args.core_bdev_name))
core_bdev_name=args.core_bdev_name,
create=args.create,
force=args.force))
p = subparsers.add_parser('bdev_ocf_create', aliases=['construct_ocf_bdev'],
help='Add an OCF block device')
p.add_argument('name', help='Name of resulting OCF bdev')
Expand All @@ -297,7 +299,9 @@ def bdev_ocf_create(args):
default=0,
)
p.add_argument('cache_bdev_name', help='Name of underlying cache bdev')
p.add_argument('core_bdev_name', help='Name of unerlying core bdev')
p.add_argument('core_bdev_name', help='Name of underlying core bdev')
p.add_argument('--create', help='Creates a new cache instance, fails if metadata already exists (optional)', action='store_true', default=False)
p.add_argument('--force', help='Force creates a new cache instance, even if metadata already exists (optional); requires --create pargument', action='store_true', default=False)
p.set_defaults(func=bdev_ocf_create)

def bdev_ocf_delete(args):
Expand Down
6 changes: 5 additions & 1 deletion scripts/rpc/bdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def bdev_crypto_delete(client, name):


@deprecated_alias('construct_ocf_bdev')
def bdev_ocf_create(client, name, mode, cache_line_size, cache_bdev_name, core_bdev_name):
def bdev_ocf_create(client, name, mode, cache_line_size, cache_bdev_name, core_bdev_name, create=False, force=False):
"""Add an OCF block device
Args:
Expand All @@ -145,6 +145,8 @@ def bdev_ocf_create(client, name, mode, cache_line_size, cache_bdev_name, core_b
cache_line_size: OCF cache line size. The unit is KiB: {4, 8, 16, 32, 64}
cache_bdev_name: name of underlying cache bdev
core_bdev_name: name of underlying core bdev
create: Creates a new cache instance, no metadata may exist
force: Force creates a new cache instance, even if metadata already exists
Returns:
Name of created block device
Expand All @@ -155,6 +157,8 @@ def bdev_ocf_create(client, name, mode, cache_line_size, cache_bdev_name, core_b
'cache_line_size': cache_line_size,
'cache_bdev_name': cache_bdev_name,
'core_bdev_name': core_bdev_name,
'create': create,
'force': force,
}

return client.call('bdev_ocf_create', params)
Expand Down

0 comments on commit 247e4da

Please sign in to comment.