blobfs: Add conf parse for blobfs.

This patch make the cache buffer shift of blobfs configurable. We
can configure the cache buffer shift according workload, it will
help to improve the performance.

Change-Id: Ied1c2e5d6fd9eaa7aa0759c03c654fcf2e77aa23
Signed-off-by: Cunyin Chang <cunyin.chang@intel.com>
Reviewed-on: https://review.gerrithub.io/383381
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ziye Yang <optimistyzy@gmail.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Cunyin Chang 2017-10-23 13:45:26 +08:00 committed by Ben Walker
parent cc57c4a9bc
commit 97f3104bc7
5 changed files with 58 additions and 4 deletions

View File

@ -34,6 +34,7 @@
#include "spdk/stdinc.h"
#include "spdk/blobfs.h"
#include "spdk/conf.h"
#include "blobfs_internal.h"
#include "spdk/queue.h"
@ -401,6 +402,23 @@ init_cb(void *ctx, struct spdk_blob_store *bs, int bserrno)
free_fs_request(req);
}
static void
fs_conf_parse(void)
{
struct spdk_conf_section *sp;
sp = spdk_conf_find_section(NULL, "Blobfs");
if (sp == NULL) {
g_fs_cache_buffer_shift = CACHE_BUFFER_SHIFT_DEFAULT;
return;
}
g_fs_cache_buffer_shift = spdk_conf_section_get_intval(sp, "CacheBufferShift");
if (g_fs_cache_buffer_shift <= 0) {
g_fs_cache_buffer_shift = CACHE_BUFFER_SHIFT_DEFAULT;
}
}
static struct spdk_filesystem *
fs_alloc(struct spdk_bs_dev *dev, fs_send_request_fn send_request_fn)
{
@ -449,6 +467,8 @@ spdk_fs_init(struct spdk_bs_dev *dev, fs_send_request_fn send_request_fn,
return;
}
fs_conf_parse();
req = alloc_fs_request(fs->md_target.md_fs_channel);
if (req == NULL) {
spdk_put_io_channel(fs->md_target.md_io_channel);
@ -657,6 +677,8 @@ spdk_fs_load(struct spdk_bs_dev *dev, fs_send_request_fn send_request_fn,
return;
}
fs_conf_parse();
req = alloc_fs_request(fs->md_target.md_fs_channel);
if (req == NULL) {
spdk_put_io_channel(fs->md_target.md_io_channel);

View File

@ -41,6 +41,8 @@
#include "spdk/env.h"
#include "spdk_internal/log.h"
uint32_t g_fs_cache_buffer_shift = CACHE_BUFFER_SHIFT_DEFAULT;
struct cache_buffer *
spdk_tree_find_buffer(struct cache_tree *tree, uint64_t offset)
{

View File

@ -43,14 +43,16 @@ struct cache_buffer {
bool in_progress;
};
#define CACHE_BUFFER_SHIFT (18)
#define CACHE_BUFFER_SIZE (1U << CACHE_BUFFER_SHIFT)
extern uint32_t g_fs_cache_buffer_shift;
#define CACHE_BUFFER_SHIFT_DEFAULT 18
#define CACHE_BUFFER_SIZE (1U << g_fs_cache_buffer_shift)
#define NEXT_CACHE_BUFFER_OFFSET(offset) \
(((offset + CACHE_BUFFER_SIZE) >> CACHE_BUFFER_SHIFT) << CACHE_BUFFER_SHIFT)
(((offset + CACHE_BUFFER_SIZE) >> g_fs_cache_buffer_shift) << g_fs_cache_buffer_shift)
#define CACHE_TREE_SHIFT 6
#define CACHE_TREE_WIDTH (1U << CACHE_TREE_SHIFT)
#define CACHE_TREE_LEVEL_SHIFT(level) (CACHE_BUFFER_SHIFT + (level) * CACHE_TREE_SHIFT)
#define CACHE_TREE_LEVEL_SHIFT(level) (g_fs_cache_buffer_shift + (level) * CACHE_TREE_SHIFT)
#define CACHE_TREE_LEVEL_SIZE(level) (1ULL << CACHE_TREE_LEVEL_SHIFT(level))
#define CACHE_TREE_LEVEL_MASK(level) (CACHE_TREE_LEVEL_SIZE(level) - 1)
#define CACHE_TREE_INDEX(level, offset) ((offset >> CACHE_TREE_LEVEL_SHIFT(level)) & (CACHE_TREE_WIDTH - 1))

View File

@ -47,6 +47,20 @@ struct spdk_filesystem *g_fs;
struct spdk_file *g_file;
int g_fserrno;
/* Return NULL to test hardcoded defaults. */
struct spdk_conf_section *
spdk_conf_find_section(struct spdk_conf *cp, const char *name)
{
return NULL;
}
/* Return -1 to test hardcoded defaults. */
int
spdk_conf_section_get_intval(struct spdk_conf_section *sp, const char *key)
{
return -1;
}
static void
_fs_send_msg(spdk_thread_fn fn, void *ctx, void *thread_ctx)
{

View File

@ -49,6 +49,20 @@ struct spdk_filesystem *g_fs;
struct spdk_file *g_file;
int g_fserrno;
/* Return NULL to test hardcoded defaults. */
struct spdk_conf_section *
spdk_conf_find_section(struct spdk_conf *cp, const char *name)
{
return NULL;
}
/* Return -1 to test hardcoded defaults. */
int
spdk_conf_section_get_intval(struct spdk_conf_section *sp, const char *key)
{
return -1;
}
static void
_fs_send_msg(spdk_thread_fn fn, void *ctx, void *thread_ctx)
{