From 2f249ace0c4834ef5351caf86b22079989cd488f Mon Sep 17 00:00:00 2001 From: Xiaodong Liu Date: Mon, 21 Oct 2019 23:15:20 +0800 Subject: [PATCH] blobfs: add result for set_cache_size Since g_fs_cache_size only takes effect when creating g_cache_pool, so spdk_fs_set_cache_size is only permitted when cache pool is already freed or hasn't been initialized. Add a return value to indicate the result of spdk_fs_set_cache_size. Change-Id: I3828b136976d6f03f0751b2f20f68cd47c36ec04 Signed-off-by: Xiaodong Liu Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471869 Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- CHANGELOG.md | 4 ++++ include/spdk/blobfs.h | 4 +++- lib/blobfs/blobfs.c | 11 ++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a753e7c6..3e34db7dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ optimization for aarch64. `spdk_thread_send_msg` now returns int indicating if the message was successfully sent. +### blobfs + +Added boolean return value for function spdk_fs_set_cache_size to indicate its operation result. + ## v19.10: ### rpc diff --git a/include/spdk/blobfs.h b/include/spdk/blobfs.h index 47cd67886..2a4342ded 100644 --- a/include/spdk/blobfs.h +++ b/include/spdk/blobfs.h @@ -364,8 +364,10 @@ int64_t spdk_file_read(struct spdk_file *file, struct spdk_fs_thread_ctx *ctx, * Set cache size for the blobstore filesystem. * * \param size_in_mb Cache size in megabytes. + * + * \return 0 on success, negative errno on failure. */ -void spdk_fs_set_cache_size(uint64_t size_in_mb); +int spdk_fs_set_cache_size(uint64_t size_in_mb); /** * Obtain the cache size. diff --git a/lib/blobfs/blobfs.c b/lib/blobfs/blobfs.c index f9dcc3aeb..c28843dc3 100644 --- a/lib/blobfs/blobfs.c +++ b/lib/blobfs/blobfs.c @@ -1971,10 +1971,19 @@ spdk_fs_free_thread_ctx(struct spdk_fs_thread_ctx *ctx) free(ctx); } -void +int spdk_fs_set_cache_size(uint64_t size_in_mb) { + /* setting g_fs_cache_size is only permitted if cache pool + * is already freed or hasn't been initialized + */ + if (g_cache_pool != NULL) { + return -EPERM; + } + g_fs_cache_size = size_in_mb * 1024 * 1024; + + return 0; } uint64_t