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