lib/blobfs: remove spdk prefix from private APIs
This should help reduce confusion within libraries about which APIs are public and which are private. Signed-off-by: Seth Howell <seth.howell@intel.com> Change-Id: I7755081b016f269d4761d8cc2ce4bac2835c077d Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1703 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
parent
6569a0ea06
commit
bc0180f67f
@ -109,7 +109,7 @@ SPDK_TRACE_REGISTER_FN(blobfs_trace, "blobfs", TRACE_GROUP_BLOBFS)
|
||||
}
|
||||
|
||||
void
|
||||
spdk_cache_buffer_free(struct cache_buffer *cache_buffer)
|
||||
cache_buffer_free(struct cache_buffer *cache_buffer)
|
||||
{
|
||||
spdk_mempool_put(g_cache_pool, cache_buffer->buf);
|
||||
free(cache_buffer);
|
||||
@ -251,8 +251,8 @@ struct spdk_fs_cb_args {
|
||||
};
|
||||
|
||||
static void cache_free_buffers(struct spdk_file *file);
|
||||
static void spdk_fs_io_device_unregister(struct spdk_filesystem *fs);
|
||||
static void spdk_fs_free_io_channels(struct spdk_filesystem *fs);
|
||||
static void fs_io_device_unregister(struct spdk_filesystem *fs);
|
||||
static void fs_free_io_channels(struct spdk_filesystem *fs);
|
||||
|
||||
void
|
||||
spdk_fs_opts_init(struct spdk_blobfs_opts *opts)
|
||||
@ -443,8 +443,8 @@ free_fs_request(struct spdk_fs_request *req)
|
||||
}
|
||||
|
||||
static int
|
||||
_spdk_fs_channel_create(struct spdk_filesystem *fs, struct spdk_fs_channel *channel,
|
||||
uint32_t max_ops)
|
||||
fs_channel_create(struct spdk_filesystem *fs, struct spdk_fs_channel *channel,
|
||||
uint32_t max_ops)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
@ -467,40 +467,40 @@ _spdk_fs_channel_create(struct spdk_filesystem *fs, struct spdk_fs_channel *chan
|
||||
}
|
||||
|
||||
static int
|
||||
_spdk_fs_md_channel_create(void *io_device, void *ctx_buf)
|
||||
fs_md_channel_create(void *io_device, void *ctx_buf)
|
||||
{
|
||||
struct spdk_filesystem *fs;
|
||||
struct spdk_fs_channel *channel = ctx_buf;
|
||||
|
||||
fs = SPDK_CONTAINEROF(io_device, struct spdk_filesystem, md_target);
|
||||
|
||||
return _spdk_fs_channel_create(fs, channel, fs->md_target.max_ops);
|
||||
return fs_channel_create(fs, channel, fs->md_target.max_ops);
|
||||
}
|
||||
|
||||
static int
|
||||
_spdk_fs_sync_channel_create(void *io_device, void *ctx_buf)
|
||||
fs_sync_channel_create(void *io_device, void *ctx_buf)
|
||||
{
|
||||
struct spdk_filesystem *fs;
|
||||
struct spdk_fs_channel *channel = ctx_buf;
|
||||
|
||||
fs = SPDK_CONTAINEROF(io_device, struct spdk_filesystem, sync_target);
|
||||
|
||||
return _spdk_fs_channel_create(fs, channel, fs->sync_target.max_ops);
|
||||
return fs_channel_create(fs, channel, fs->sync_target.max_ops);
|
||||
}
|
||||
|
||||
static int
|
||||
_spdk_fs_io_channel_create(void *io_device, void *ctx_buf)
|
||||
fs_io_channel_create(void *io_device, void *ctx_buf)
|
||||
{
|
||||
struct spdk_filesystem *fs;
|
||||
struct spdk_fs_channel *channel = ctx_buf;
|
||||
|
||||
fs = SPDK_CONTAINEROF(io_device, struct spdk_filesystem, io_target);
|
||||
|
||||
return _spdk_fs_channel_create(fs, channel, fs->io_target.max_ops);
|
||||
return fs_channel_create(fs, channel, fs->io_target.max_ops);
|
||||
}
|
||||
|
||||
static void
|
||||
_spdk_fs_channel_destroy(void *io_device, void *ctx_buf)
|
||||
fs_channel_destroy(void *io_device, void *ctx_buf)
|
||||
{
|
||||
struct spdk_fs_channel *channel = ctx_buf;
|
||||
|
||||
@ -584,19 +584,19 @@ fs_alloc(struct spdk_bs_dev *dev, fs_send_request_fn send_request_fn)
|
||||
TAILQ_INIT(&fs->files);
|
||||
|
||||
fs->md_target.max_ops = 512;
|
||||
spdk_io_device_register(&fs->md_target, _spdk_fs_md_channel_create, _spdk_fs_channel_destroy,
|
||||
spdk_io_device_register(&fs->md_target, fs_md_channel_create, fs_channel_destroy,
|
||||
sizeof(struct spdk_fs_channel), "blobfs_md");
|
||||
fs->md_target.md_io_channel = spdk_get_io_channel(&fs->md_target);
|
||||
fs->md_target.md_fs_channel = spdk_io_channel_get_ctx(fs->md_target.md_io_channel);
|
||||
|
||||
fs->sync_target.max_ops = 512;
|
||||
spdk_io_device_register(&fs->sync_target, _spdk_fs_sync_channel_create, _spdk_fs_channel_destroy,
|
||||
spdk_io_device_register(&fs->sync_target, fs_sync_channel_create, fs_channel_destroy,
|
||||
sizeof(struct spdk_fs_channel), "blobfs_sync");
|
||||
fs->sync_target.sync_io_channel = spdk_get_io_channel(&fs->sync_target);
|
||||
fs->sync_target.sync_fs_channel = spdk_io_channel_get_ctx(fs->sync_target.sync_io_channel);
|
||||
|
||||
fs->io_target.max_ops = 512;
|
||||
spdk_io_device_register(&fs->io_target, _spdk_fs_io_channel_create, _spdk_fs_channel_destroy,
|
||||
spdk_io_device_register(&fs->io_target, fs_io_channel_create, fs_channel_destroy,
|
||||
sizeof(struct spdk_fs_channel), "blobfs_io");
|
||||
|
||||
return fs;
|
||||
@ -631,8 +631,8 @@ spdk_fs_init(struct spdk_bs_dev *dev, struct spdk_blobfs_opts *opt,
|
||||
|
||||
req = alloc_fs_request(fs->md_target.md_fs_channel);
|
||||
if (req == NULL) {
|
||||
spdk_fs_free_io_channels(fs);
|
||||
spdk_fs_io_device_unregister(fs);
|
||||
fs_free_io_channels(fs);
|
||||
fs_io_device_unregister(fs);
|
||||
cb_fn(cb_arg, NULL, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
@ -809,8 +809,8 @@ load_cb(void *ctx, struct spdk_blob_store *bs, int bserrno)
|
||||
if (bserrno != 0) {
|
||||
args->fn.fs_op_with_handle(args->arg, NULL, bserrno);
|
||||
free_fs_request(req);
|
||||
spdk_fs_free_io_channels(fs);
|
||||
spdk_fs_io_device_unregister(fs);
|
||||
fs_free_io_channels(fs);
|
||||
fs_io_device_unregister(fs);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -824,8 +824,8 @@ load_cb(void *ctx, struct spdk_blob_store *bs, int bserrno)
|
||||
SPDK_LOGDUMP(SPDK_LOG_BLOBFS, "bstype", &bstype, sizeof(bstype));
|
||||
args->fn.fs_op_with_handle(args->arg, NULL, -EINVAL);
|
||||
free_fs_request(req);
|
||||
spdk_fs_free_io_channels(fs);
|
||||
spdk_fs_io_device_unregister(fs);
|
||||
fs_free_io_channels(fs);
|
||||
fs_io_device_unregister(fs);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -834,7 +834,7 @@ load_cb(void *ctx, struct spdk_blob_store *bs, int bserrno)
|
||||
}
|
||||
|
||||
static void
|
||||
spdk_fs_io_device_unregister(struct spdk_filesystem *fs)
|
||||
fs_io_device_unregister(struct spdk_filesystem *fs)
|
||||
{
|
||||
assert(fs != NULL);
|
||||
spdk_io_device_unregister(&fs->md_target, NULL);
|
||||
@ -844,7 +844,7 @@ spdk_fs_io_device_unregister(struct spdk_filesystem *fs)
|
||||
}
|
||||
|
||||
static void
|
||||
spdk_fs_free_io_channels(struct spdk_filesystem *fs)
|
||||
fs_free_io_channels(struct spdk_filesystem *fs)
|
||||
{
|
||||
assert(fs != NULL);
|
||||
spdk_fs_free_io_channel(fs->md_target.md_io_channel);
|
||||
@ -870,8 +870,8 @@ spdk_fs_load(struct spdk_bs_dev *dev, fs_send_request_fn send_request_fn,
|
||||
|
||||
req = alloc_fs_request(fs->md_target.md_fs_channel);
|
||||
if (req == NULL) {
|
||||
spdk_fs_free_io_channels(fs);
|
||||
spdk_fs_io_device_unregister(fs);
|
||||
fs_free_io_channels(fs);
|
||||
fs_io_device_unregister(fs);
|
||||
cb_fn(cb_arg, NULL, -ENOMEM);
|
||||
return;
|
||||
}
|
||||
@ -908,7 +908,7 @@ unload_cb(void *ctx, int bserrno)
|
||||
args->fn.fs_op(args->arg, bserrno);
|
||||
free(req);
|
||||
|
||||
spdk_fs_io_device_unregister(fs);
|
||||
fs_io_device_unregister(fs);
|
||||
}
|
||||
|
||||
void
|
||||
@ -932,7 +932,7 @@ spdk_fs_unload(struct spdk_filesystem *fs, spdk_fs_op_complete cb_fn, void *cb_a
|
||||
args->arg = cb_arg;
|
||||
args->fs = fs;
|
||||
|
||||
spdk_fs_free_io_channels(fs);
|
||||
fs_free_io_channels(fs);
|
||||
spdk_bs_unload(fs->bs, unload_cb, req);
|
||||
}
|
||||
|
||||
@ -1358,7 +1358,7 @@ fs_rename_blob_open_cb(void *ctx, struct spdk_blob *blob, int bserrno)
|
||||
}
|
||||
|
||||
static void
|
||||
__spdk_fs_md_rename_file(struct spdk_fs_request *req)
|
||||
_fs_md_rename_file(struct spdk_fs_request *req)
|
||||
{
|
||||
struct spdk_fs_cb_args *args = &req->args;
|
||||
struct spdk_file *f;
|
||||
@ -1380,7 +1380,7 @@ __spdk_fs_md_rename_file(struct spdk_fs_request *req)
|
||||
static void
|
||||
fs_rename_delete_done(void *arg, int fserrno)
|
||||
{
|
||||
__spdk_fs_md_rename_file(arg);
|
||||
_fs_md_rename_file(arg);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1415,7 +1415,7 @@ spdk_fs_rename_file_async(struct spdk_filesystem *fs,
|
||||
|
||||
f = fs_find_file(fs, new_name);
|
||||
if (f == NULL) {
|
||||
__spdk_fs_md_rename_file(req);
|
||||
_fs_md_rename_file(req);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2007,7 +2007,7 @@ spdk_fs_alloc_thread_ctx(struct spdk_filesystem *fs)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_spdk_fs_channel_create(fs, &ctx->ch, 512);
|
||||
fs_channel_create(fs, &ctx->ch, 512);
|
||||
|
||||
ctx->ch.send_request = fs->send_request;
|
||||
ctx->ch.sync = 1;
|
||||
@ -2032,7 +2032,7 @@ spdk_fs_free_thread_ctx(struct spdk_fs_thread_ctx *ctx)
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
_spdk_fs_channel_destroy(NULL, &ctx->ch);
|
||||
fs_channel_destroy(NULL, &ctx->ch);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
@ -2082,7 +2082,7 @@ reclaim_cache_buffers(struct spdk_file *file)
|
||||
pthread_spin_unlock(&file->lock);
|
||||
return -1;
|
||||
}
|
||||
spdk_tree_free_buffers(file->tree);
|
||||
tree_free_buffers(file->tree);
|
||||
|
||||
TAILQ_REMOVE(&g_caches, file, cache_tailq);
|
||||
/* If not freed, put it in the end of the queue */
|
||||
@ -2181,7 +2181,7 @@ cache_insert_buffer(struct spdk_file *file, uint64_t offset)
|
||||
if (file->tree->present_mask == 0) {
|
||||
TAILQ_INSERT_TAIL(&g_caches, file, cache_tailq);
|
||||
}
|
||||
file->tree = spdk_tree_insert_buffer(file->tree, buf);
|
||||
file->tree = tree_insert_buffer(file->tree, buf);
|
||||
pthread_spin_unlock(&g_caches_lock);
|
||||
|
||||
return buf;
|
||||
@ -2282,7 +2282,7 @@ __file_flush_done(void *ctx, int bserrno)
|
||||
}
|
||||
if (next->bytes_flushed == next->buf_size) {
|
||||
BLOBFS_TRACE(file, "write buffer fully flushed 0x%jx\n", file->length_flushed);
|
||||
next = spdk_tree_find_buffer(file->tree, file->length_flushed);
|
||||
next = tree_find_buffer(file->tree, file->length_flushed);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2310,7 +2310,7 @@ __file_flush(void *ctx)
|
||||
uint32_t lba_size;
|
||||
|
||||
pthread_spin_lock(&file->lock);
|
||||
next = spdk_tree_find_buffer(file->tree, file->length_flushed);
|
||||
next = tree_find_buffer(file->tree, file->length_flushed);
|
||||
if (next == NULL || next->in_progress ||
|
||||
((next->bytes_filled < next->buf_size) && TAILQ_EMPTY(&file->sync_requests))) {
|
||||
/*
|
||||
@ -2610,7 +2610,7 @@ check_readahead(struct spdk_file *file, uint64_t offset,
|
||||
struct spdk_fs_cb_args *args;
|
||||
|
||||
offset = __next_cache_buffer_offset(offset);
|
||||
if (spdk_tree_find_buffer(file->tree, offset) != NULL || file->length <= offset) {
|
||||
if (tree_find_buffer(file->tree, offset) != NULL || file->length <= offset) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2684,7 +2684,7 @@ spdk_file_read(struct spdk_file *file, struct spdk_fs_thread_ctx *ctx,
|
||||
length = final_offset - offset;
|
||||
}
|
||||
|
||||
buf = spdk_tree_find_filled_buffer(file->tree, offset);
|
||||
buf = tree_find_filled_buffer(file->tree, offset);
|
||||
if (buf == NULL) {
|
||||
pthread_spin_unlock(&file->lock);
|
||||
rc = __send_rw_from_file(file, payload, offset, length, true, channel);
|
||||
@ -2701,7 +2701,7 @@ spdk_file_read(struct spdk_file *file, struct spdk_fs_thread_ctx *ctx,
|
||||
memcpy(payload, &buf->buf[offset - buf->offset], read_len);
|
||||
if ((offset + read_len) % CACHE_BUFFER_SIZE == 0) {
|
||||
pthread_spin_lock(&g_caches_lock);
|
||||
spdk_tree_remove_buffer(file->tree, buf);
|
||||
tree_remove_buffer(file->tree, buf);
|
||||
if (file->tree->present_mask == 0) {
|
||||
TAILQ_REMOVE(&g_caches, file, cache_tailq);
|
||||
}
|
||||
@ -2948,7 +2948,7 @@ cache_free_buffers(struct spdk_file *file)
|
||||
pthread_spin_unlock(&file->lock);
|
||||
return;
|
||||
}
|
||||
spdk_tree_free_buffers(file->tree);
|
||||
tree_free_buffers(file->tree);
|
||||
|
||||
TAILQ_REMOVE(&g_caches, file, cache_tailq);
|
||||
assert(file->tree->present_mask == 0);
|
||||
|
@ -44,7 +44,7 @@
|
||||
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)
|
||||
tree_find_buffer(struct cache_tree *tree, uint64_t offset)
|
||||
{
|
||||
uint64_t index;
|
||||
|
||||
@ -65,11 +65,11 @@ spdk_tree_find_buffer(struct cache_tree *tree, uint64_t offset)
|
||||
}
|
||||
|
||||
struct cache_buffer *
|
||||
spdk_tree_find_filled_buffer(struct cache_tree *tree, uint64_t offset)
|
||||
tree_find_filled_buffer(struct cache_tree *tree, uint64_t offset)
|
||||
{
|
||||
struct cache_buffer *buf;
|
||||
|
||||
buf = spdk_tree_find_buffer(tree, offset);
|
||||
buf = tree_find_buffer(tree, offset);
|
||||
if (buf != NULL && buf->bytes_filled > 0) {
|
||||
return buf;
|
||||
} else {
|
||||
@ -78,7 +78,7 @@ spdk_tree_find_filled_buffer(struct cache_tree *tree, uint64_t offset)
|
||||
}
|
||||
|
||||
struct cache_tree *
|
||||
spdk_tree_insert_buffer(struct cache_tree *root, struct cache_buffer *buffer)
|
||||
tree_insert_buffer(struct cache_tree *root, struct cache_buffer *buffer)
|
||||
{
|
||||
struct cache_tree *tree;
|
||||
uint64_t index, offset;
|
||||
@ -118,7 +118,7 @@ spdk_tree_insert_buffer(struct cache_tree *root, struct cache_buffer *buffer)
|
||||
}
|
||||
|
||||
void
|
||||
spdk_tree_remove_buffer(struct cache_tree *tree, struct cache_buffer *buffer)
|
||||
tree_remove_buffer(struct cache_tree *tree, struct cache_buffer *buffer)
|
||||
{
|
||||
struct cache_tree *child;
|
||||
uint64_t index;
|
||||
@ -130,13 +130,13 @@ spdk_tree_remove_buffer(struct cache_tree *tree, struct cache_buffer *buffer)
|
||||
assert(buffer == tree->u.buffer[index]);
|
||||
tree->present_mask &= ~(1ULL << index);
|
||||
tree->u.buffer[index] = NULL;
|
||||
spdk_cache_buffer_free(buffer);
|
||||
cache_buffer_free(buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
child = tree->u.tree[index];
|
||||
assert(child != NULL);
|
||||
spdk_tree_remove_buffer(child, buffer);
|
||||
tree_remove_buffer(child, buffer);
|
||||
if (child->present_mask == 0) {
|
||||
tree->present_mask &= ~(1ULL << index);
|
||||
tree->u.tree[index] = NULL;
|
||||
@ -145,7 +145,7 @@ spdk_tree_remove_buffer(struct cache_tree *tree, struct cache_buffer *buffer)
|
||||
}
|
||||
|
||||
void
|
||||
spdk_tree_free_buffers(struct cache_tree *tree)
|
||||
tree_free_buffers(struct cache_tree *tree)
|
||||
{
|
||||
struct cache_buffer *buffer;
|
||||
struct cache_tree *child;
|
||||
@ -160,7 +160,7 @@ spdk_tree_free_buffers(struct cache_tree *tree)
|
||||
buffer = tree->u.buffer[i];
|
||||
if (buffer != NULL && buffer->in_progress == false &&
|
||||
buffer->bytes_filled == buffer->bytes_flushed) {
|
||||
spdk_cache_buffer_free(buffer);
|
||||
cache_buffer_free(buffer);
|
||||
tree->u.buffer[i] = NULL;
|
||||
tree->present_mask &= ~(1ULL << i);
|
||||
}
|
||||
@ -169,7 +169,7 @@ spdk_tree_free_buffers(struct cache_tree *tree)
|
||||
for (i = 0; i < CACHE_TREE_WIDTH; i++) {
|
||||
child = tree->u.tree[i];
|
||||
if (child != NULL) {
|
||||
spdk_tree_free_buffers(child);
|
||||
tree_free_buffers(child);
|
||||
if (child->present_mask == 0) {
|
||||
free(child);
|
||||
tree->u.tree[i] = NULL;
|
||||
|
@ -66,12 +66,12 @@ struct cache_tree {
|
||||
} u;
|
||||
};
|
||||
|
||||
void spdk_cache_buffer_free(struct cache_buffer *cache_buffer);
|
||||
void cache_buffer_free(struct cache_buffer *cache_buffer);
|
||||
|
||||
struct cache_tree *spdk_tree_insert_buffer(struct cache_tree *root, struct cache_buffer *buffer);
|
||||
void spdk_tree_free_buffers(struct cache_tree *tree);
|
||||
struct cache_buffer *spdk_tree_find_buffer(struct cache_tree *tree, uint64_t offset);
|
||||
struct cache_buffer *spdk_tree_find_filled_buffer(struct cache_tree *tree, uint64_t offset);
|
||||
void spdk_tree_remove_buffer(struct cache_tree *tree, struct cache_buffer *buffer);
|
||||
struct cache_tree *tree_insert_buffer(struct cache_tree *root, struct cache_buffer *buffer);
|
||||
void tree_free_buffers(struct cache_tree *tree);
|
||||
struct cache_buffer *tree_find_buffer(struct cache_tree *tree, uint64_t offset);
|
||||
struct cache_buffer *tree_find_filled_buffer(struct cache_tree *tree, uint64_t offset);
|
||||
void tree_remove_buffer(struct cache_tree *tree, struct cache_buffer *buffer);
|
||||
|
||||
#endif /* SPDK_TREE_H_ */
|
||||
|
@ -576,38 +576,38 @@ tree_find_buffer_ut(void)
|
||||
level1_0->u.tree[12] = level0_0_12;
|
||||
level1_0->present_mask |= (1ULL << 12);
|
||||
|
||||
buffer = spdk_tree_find_buffer(NULL, 0);
|
||||
buffer = tree_find_buffer(NULL, 0);
|
||||
CU_ASSERT(buffer == NULL);
|
||||
|
||||
buffer = spdk_tree_find_buffer(level0_0_0, 0);
|
||||
buffer = tree_find_buffer(level0_0_0, 0);
|
||||
CU_ASSERT(buffer == NULL);
|
||||
|
||||
buffer = spdk_tree_find_buffer(level0_0_0, CACHE_TREE_LEVEL_SIZE(0) + 1);
|
||||
buffer = tree_find_buffer(level0_0_0, CACHE_TREE_LEVEL_SIZE(0) + 1);
|
||||
CU_ASSERT(buffer == NULL);
|
||||
|
||||
buffer = spdk_tree_find_buffer(level0_0_0, leaf_0_0_4->offset);
|
||||
buffer = tree_find_buffer(level0_0_0, leaf_0_0_4->offset);
|
||||
CU_ASSERT(buffer == leaf_0_0_4);
|
||||
|
||||
buffer = spdk_tree_find_buffer(level1_0, leaf_0_0_4->offset);
|
||||
buffer = tree_find_buffer(level1_0, leaf_0_0_4->offset);
|
||||
CU_ASSERT(buffer == leaf_0_0_4);
|
||||
|
||||
buffer = spdk_tree_find_buffer(level1_0, leaf_0_12_8->offset);
|
||||
buffer = tree_find_buffer(level1_0, leaf_0_12_8->offset);
|
||||
CU_ASSERT(buffer == leaf_0_12_8);
|
||||
|
||||
buffer = spdk_tree_find_buffer(level1_0, leaf_0_12_8->offset + CACHE_BUFFER_SIZE - 1);
|
||||
buffer = tree_find_buffer(level1_0, leaf_0_12_8->offset + CACHE_BUFFER_SIZE - 1);
|
||||
CU_ASSERT(buffer == leaf_0_12_8);
|
||||
|
||||
buffer = spdk_tree_find_buffer(level1_0, leaf_0_12_8->offset - 1);
|
||||
buffer = tree_find_buffer(level1_0, leaf_0_12_8->offset - 1);
|
||||
CU_ASSERT(buffer == NULL);
|
||||
|
||||
leaf_9_23_15->offset = CACHE_TREE_LEVEL_SIZE(2) * 9 +
|
||||
CACHE_TREE_LEVEL_SIZE(1) * 23 +
|
||||
CACHE_BUFFER_SIZE * 15;
|
||||
root = spdk_tree_insert_buffer(level1_0, leaf_9_23_15);
|
||||
root = tree_insert_buffer(level1_0, leaf_9_23_15);
|
||||
CU_ASSERT(root != level1_0);
|
||||
buffer = spdk_tree_find_buffer(root, leaf_9_23_15->offset);
|
||||
buffer = tree_find_buffer(root, leaf_9_23_15->offset);
|
||||
CU_ASSERT(buffer == leaf_9_23_15);
|
||||
spdk_tree_free_buffers(root);
|
||||
tree_free_buffers(root);
|
||||
free(root);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "blobfs/tree.c"
|
||||
|
||||
void
|
||||
spdk_cache_buffer_free(struct cache_buffer *cache_buffer)
|
||||
cache_buffer_free(struct cache_buffer *cache_buffer)
|
||||
{
|
||||
free(cache_buffer);
|
||||
}
|
||||
@ -59,74 +59,74 @@ blobfs_tree_op_test(void)
|
||||
|
||||
/* insert buffer[0] */
|
||||
buffer[0]->offset = 0;
|
||||
tree = spdk_tree_insert_buffer(tree, buffer[0]);
|
||||
tree = tree_insert_buffer(tree, buffer[0]);
|
||||
SPDK_CU_ASSERT_FATAL(tree != NULL);
|
||||
CU_ASSERT(tree->level == 0);
|
||||
tmp_buffer = spdk_tree_find_buffer(tree, buffer[0]->offset);
|
||||
tmp_buffer = tree_find_buffer(tree, buffer[0]->offset);
|
||||
CU_ASSERT(tmp_buffer == buffer[0]);
|
||||
|
||||
/* insert buffer[1] */
|
||||
buffer[1]->offset = CACHE_BUFFER_SIZE;
|
||||
/* set the bytes_filled equal = bytes_filled with same non zero value, e.g., 32 */
|
||||
buffer[1]->bytes_filled = buffer[1]->bytes_flushed = 32;
|
||||
tree = spdk_tree_insert_buffer(tree, buffer[1]);
|
||||
tree = tree_insert_buffer(tree, buffer[1]);
|
||||
SPDK_CU_ASSERT_FATAL(tree != NULL);
|
||||
CU_ASSERT(tree->level == 0);
|
||||
tmp_buffer = spdk_tree_find_filled_buffer(tree, buffer[1]->offset);
|
||||
tmp_buffer = tree_find_filled_buffer(tree, buffer[1]->offset);
|
||||
CU_ASSERT(tmp_buffer == buffer[1]);
|
||||
|
||||
/* insert buffer[2] */
|
||||
buffer[2]->offset = (CACHE_TREE_WIDTH - 1) * CACHE_BUFFER_SIZE;
|
||||
tree = spdk_tree_insert_buffer(tree, buffer[2]);
|
||||
tree = tree_insert_buffer(tree, buffer[2]);
|
||||
SPDK_CU_ASSERT_FATAL(tree != NULL);
|
||||
CU_ASSERT(tree->level == 0);
|
||||
tmp_buffer = spdk_tree_find_buffer(tree, buffer[2]->offset);
|
||||
tmp_buffer = tree_find_buffer(tree, buffer[2]->offset);
|
||||
CU_ASSERT(tmp_buffer == buffer[2]);
|
||||
tmp_buffer = spdk_tree_find_filled_buffer(tree, buffer[2]->offset);
|
||||
tmp_buffer = tree_find_filled_buffer(tree, buffer[2]->offset);
|
||||
CU_ASSERT(tmp_buffer == NULL);
|
||||
|
||||
/* insert buffer[3], set an offset which can not be fit level 0 */
|
||||
buffer[3]->offset = CACHE_TREE_LEVEL_SIZE(1);
|
||||
tree = spdk_tree_insert_buffer(tree, buffer[3]);
|
||||
tree = tree_insert_buffer(tree, buffer[3]);
|
||||
SPDK_CU_ASSERT_FATAL(tree != NULL);
|
||||
CU_ASSERT(tree->level == 1);
|
||||
tmp_buffer = spdk_tree_find_buffer(tree, buffer[3]->offset);
|
||||
tmp_buffer = tree_find_buffer(tree, buffer[3]->offset);
|
||||
CU_ASSERT(tmp_buffer == buffer[3]);
|
||||
|
||||
/* insert buffer[4], set an offset which can not be fit level 1 */
|
||||
buffer[4]->offset = CACHE_TREE_LEVEL_SIZE(2);
|
||||
tree = spdk_tree_insert_buffer(tree, buffer[4]);
|
||||
tree = tree_insert_buffer(tree, buffer[4]);
|
||||
SPDK_CU_ASSERT_FATAL(tree != NULL);
|
||||
CU_ASSERT(tree->level == 2);
|
||||
tmp_buffer = spdk_tree_find_buffer(tree, buffer[4]->offset);
|
||||
tmp_buffer = tree_find_buffer(tree, buffer[4]->offset);
|
||||
CU_ASSERT(tmp_buffer == buffer[4]);
|
||||
|
||||
/* delete buffer[0] */
|
||||
spdk_tree_remove_buffer(tree, buffer[0]);
|
||||
tree_remove_buffer(tree, buffer[0]);
|
||||
/* check whether buffer[0] is still existed or not */
|
||||
tmp_buffer = spdk_tree_find_buffer(tree, 0);
|
||||
tmp_buffer = tree_find_buffer(tree, 0);
|
||||
CU_ASSERT(tmp_buffer == NULL);
|
||||
|
||||
/* delete buffer[3] */
|
||||
spdk_tree_remove_buffer(tree, buffer[3]);
|
||||
tree_remove_buffer(tree, buffer[3]);
|
||||
/* check whether buffer[3] is still existed or not */
|
||||
tmp_buffer = spdk_tree_find_buffer(tree, CACHE_TREE_LEVEL_SIZE(1));
|
||||
tmp_buffer = tree_find_buffer(tree, CACHE_TREE_LEVEL_SIZE(1));
|
||||
CU_ASSERT(tmp_buffer == NULL);
|
||||
|
||||
/* free all buffers in the tree */
|
||||
spdk_tree_free_buffers(tree);
|
||||
tree_free_buffers(tree);
|
||||
|
||||
/* check whether buffer[1] is still existed or not */
|
||||
tmp_buffer = spdk_tree_find_buffer(tree, CACHE_BUFFER_SIZE);
|
||||
tmp_buffer = tree_find_buffer(tree, CACHE_BUFFER_SIZE);
|
||||
CU_ASSERT(tmp_buffer == NULL);
|
||||
/* check whether buffer[2] is still existed or not */
|
||||
tmp_buffer = spdk_tree_find_buffer(tree, (CACHE_TREE_WIDTH - 1) * CACHE_BUFFER_SIZE);
|
||||
tmp_buffer = tree_find_buffer(tree, (CACHE_TREE_WIDTH - 1) * CACHE_BUFFER_SIZE);
|
||||
CU_ASSERT(tmp_buffer == NULL);
|
||||
/* check whether buffer[4] is still existed or not */
|
||||
tmp_buffer = spdk_tree_find_buffer(tree, CACHE_TREE_LEVEL_SIZE(2));
|
||||
tmp_buffer = tree_find_buffer(tree, CACHE_TREE_LEVEL_SIZE(2));
|
||||
CU_ASSERT(tmp_buffer == NULL);
|
||||
|
||||
/* According to spdk_tree_free_buffers, root will not be freed */
|
||||
/* According to tree_free_buffers, root will not be freed */
|
||||
free(tree);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user