rpc/blobfs: add cache size setting rpc
This RPC method can be used to set cache size of blobfs, in case a smaller or larger memory scale is requred by cache pool. Change-Id: I8046c7caeaa15c67825f86d14ae0b79395d51daf Signed-off-by: Xiaodong Liu <xiaodong.liu@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471870 Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
2f249ace0c
commit
138e6daec3
@ -16,6 +16,8 @@ sent.
|
||||
|
||||
Added boolean return value for function spdk_fs_set_cache_size to indicate its operation result.
|
||||
|
||||
Added `blobfs_set_cache_size` RPC method to set cache size for blobstore filesystem.
|
||||
|
||||
## v19.10:
|
||||
|
||||
### rpc
|
||||
|
@ -6174,6 +6174,47 @@ Example response:
|
||||
"id": 1,
|
||||
"result": "true"
|
||||
}
|
||||
~~
|
||||
|
||||
## blobfs_set_cache_size {#rpc_blobfs_set_cache_size}
|
||||
|
||||
Set cache pool size for blobfs filesystems. This RPC is only permitted when the cache pool is not already initialized.
|
||||
|
||||
The cache pool is initialized when the first blobfs filesystem is initialized or loaded. It is freed when the all initialized or loaded filesystems are unloaded.
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Optional | Type | Description
|
||||
----------------------- | -------- | ----------- | -----------
|
||||
size_in_mb | Required | number | Cache size in megabytes
|
||||
|
||||
### Response
|
||||
|
||||
True if cache size is set successfully; False if failed to set.
|
||||
|
||||
### Example
|
||||
|
||||
Example request:
|
||||
|
||||
~~~
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"method": "blobfs_set_cache_size",
|
||||
"params": {
|
||||
"size_in_mb": 512,
|
||||
}
|
||||
}
|
||||
~~~
|
||||
|
||||
Example response:
|
||||
|
||||
~~~
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": true
|
||||
}
|
||||
~~~
|
||||
|
||||
# Miscellaneous RPC commands
|
||||
|
@ -50,6 +50,49 @@
|
||||
|
||||
#define MIN_CLUSTER_SZ (1024 * 1024)
|
||||
|
||||
struct rpc_blobfs_set_cache_size {
|
||||
uint64_t size_in_mb;
|
||||
};
|
||||
|
||||
static const struct spdk_json_object_decoder rpc_blobfs_set_cache_size_decoders[] = {
|
||||
{"size_in_mb", offsetof(struct rpc_blobfs_set_cache_size, size_in_mb), spdk_json_decode_uint64},
|
||||
};
|
||||
|
||||
static void
|
||||
spdk_rpc_blobfs_set_cache_size(struct spdk_jsonrpc_request *request,
|
||||
const struct spdk_json_val *params)
|
||||
{
|
||||
struct rpc_blobfs_set_cache_size req;
|
||||
struct spdk_json_write_ctx *w;
|
||||
int rc;
|
||||
|
||||
if (spdk_json_decode_object(params, rpc_blobfs_set_cache_size_decoders,
|
||||
SPDK_COUNTOF(rpc_blobfs_set_cache_size_decoders),
|
||||
&req)) {
|
||||
SPDK_ERRLOG("spdk_json_decode_object failed\n");
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||
"spdk_json_decode_object failed");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.size_in_mb == 0) {
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||
"spdk_json_decode_object failed");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
rc = spdk_fs_set_cache_size(req.size_in_mb);
|
||||
|
||||
w = spdk_jsonrpc_begin_result(request);
|
||||
spdk_json_write_bool(w, rc == 0);
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
}
|
||||
|
||||
SPDK_RPC_REGISTER("blobfs_set_cache_size", spdk_rpc_blobfs_set_cache_size,
|
||||
SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
|
||||
|
||||
struct rpc_blobfs_detect {
|
||||
char *bdev_name;
|
||||
|
||||
|
@ -2225,6 +2225,14 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
|
||||
p.add_argument('mountpoint', help='Mountpoint path in host to mount blobfs. Example: /mnt/.')
|
||||
p.set_defaults(func=blobfs_mount)
|
||||
|
||||
def blobfs_set_cache_size(args):
|
||||
print(rpc.blobfs.blobfs_set_cache_size(args.client,
|
||||
size_in_mb=args.size_in_mb))
|
||||
|
||||
p = subparsers.add_parser('blobfs_set_cache_size', help='Set cache size for blobfs')
|
||||
p.add_argument('size_in_mb', help='Cache size for blobfs in megabytes.', type=int)
|
||||
p.set_defaults(func=blobfs_set_cache_size)
|
||||
|
||||
def check_called_name(name):
|
||||
if name in deprecated_aliases:
|
||||
print("{} is deprecated, use {} instead.".format(name, deprecated_aliases[name]), file=sys.stderr)
|
||||
|
@ -40,3 +40,18 @@ def blobfs_mount(client, bdev_name, mountpoint):
|
||||
'mountpoint': mountpoint
|
||||
}
|
||||
return client.call('blobfs_mount', params)
|
||||
|
||||
|
||||
def blobfs_set_cache_size(client, size_in_mb):
|
||||
"""Set cache size for the blobstore filesystem.
|
||||
|
||||
Args:
|
||||
size_in_mb: Cache size in megabytes
|
||||
|
||||
Returns:
|
||||
True if cache size is set successfully; False if failed to set.
|
||||
"""
|
||||
params = {
|
||||
'size_in_mb': size_in_mb
|
||||
}
|
||||
return client.call('blobfs_set_cache_size', params)
|
||||
|
Loading…
Reference in New Issue
Block a user