OCF: rebase to ocf master 276d91fcd7
- locks moved from ocf to adapter code, - 'data object' renamed to 'volume', - context and volume API reorganized. Change-Id: Id4670ddfcb8eda9aefabc273497498c5bd3db1d5 Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/444092 Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Robert Bałdyga <r.baldyga@hackerion.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
f96b8293e6
commit
c274db3bf8
@ -322,53 +322,27 @@ vbdev_ocf_ctx_cleaner_stop(ocf_cleaner_t c)
|
|||||||
/* TODO [writeback]: implement with writeback mode support */
|
/* TODO [writeback]: implement with writeback mode support */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vbdev_ocf_dobj_updater_init(ocf_metadata_updater_t mu)
|
static int vbdev_ocf_volume_updater_init(ocf_metadata_updater_t mu)
|
||||||
{
|
{
|
||||||
/* TODO [metadata]: implement with persistent metadata support */
|
/* TODO [metadata]: implement with persistent metadata support */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static void vbdev_ocf_dobj_updater_stop(ocf_metadata_updater_t mu)
|
static void vbdev_ocf_volume_updater_stop(ocf_metadata_updater_t mu)
|
||||||
{
|
{
|
||||||
/* TODO [metadata]: implement with persistent metadata support */
|
/* TODO [metadata]: implement with persistent metadata support */
|
||||||
}
|
}
|
||||||
static void vbdev_ocf_dobj_updater_kick(ocf_metadata_updater_t mu)
|
static void vbdev_ocf_volume_updater_kick(ocf_metadata_updater_t mu)
|
||||||
{
|
{
|
||||||
/* TODO [metadata]: implement with persistent metadata support */
|
/* TODO [metadata]: implement with persistent metadata support */
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct ocf_ctx_ops vbdev_ocf_ctx_ops = {
|
|
||||||
.name = "OCF SPDK",
|
|
||||||
|
|
||||||
.data_alloc = vbdev_ocf_ctx_data_alloc,
|
|
||||||
.data_free = vbdev_ocf_ctx_data_free,
|
|
||||||
.data_mlock = vbdev_ocf_ctx_data_mlock,
|
|
||||||
.data_munlock = vbdev_ocf_ctx_data_munlock,
|
|
||||||
.data_rd = vbdev_ocf_ctx_data_rd,
|
|
||||||
.data_wr = vbdev_ocf_ctx_data_wr,
|
|
||||||
.data_zero = vbdev_ocf_ctx_data_zero,
|
|
||||||
.data_seek = vbdev_ocf_ctx_data_seek,
|
|
||||||
.data_cpy = vbdev_ocf_ctx_data_cpy,
|
|
||||||
.data_secure_erase = vbdev_ocf_ctx_data_secure_erase,
|
|
||||||
|
|
||||||
.queue_init = vbdev_ocf_ctx_queue_init,
|
|
||||||
.queue_kick = vbdev_ocf_ctx_queue_kick,
|
|
||||||
.queue_stop = vbdev_ocf_ctx_queue_stop,
|
|
||||||
|
|
||||||
.cleaner_init = vbdev_ocf_ctx_cleaner_init,
|
|
||||||
.cleaner_stop = vbdev_ocf_ctx_cleaner_stop,
|
|
||||||
|
|
||||||
.metadata_updater_init = vbdev_ocf_dobj_updater_init,
|
|
||||||
.metadata_updater_stop = vbdev_ocf_dobj_updater_stop,
|
|
||||||
.metadata_updater_kick = vbdev_ocf_dobj_updater_kick,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* This function is main way by which OCF communicates with user
|
/* This function is main way by which OCF communicates with user
|
||||||
* We don't want to use SPDK_LOG here because debugging information that is
|
* We don't want to use SPDK_LOG here because debugging information that is
|
||||||
* associated with every print message is not helpful in callback that only prints info
|
* associated with every print message is not helpful in callback that only prints info
|
||||||
* while the real source is somewhere in OCF code */
|
* while the real source is somewhere in OCF code */
|
||||||
static int
|
static int
|
||||||
vbdev_ocf_ctx_log_printf(const struct ocf_logger *logger,
|
vbdev_ocf_ctx_log_printf(ocf_logger_t logger, ocf_logger_lvl_t lvl,
|
||||||
ocf_logger_lvl_t lvl, const char *fmt, va_list args)
|
const char *fmt, va_list args)
|
||||||
{
|
{
|
||||||
FILE *lfile = stdout;
|
FILE *lfile = stdout;
|
||||||
|
|
||||||
@ -383,9 +357,46 @@ vbdev_ocf_ctx_log_printf(const struct ocf_logger *logger,
|
|||||||
return vfprintf(lfile, fmt, args);
|
return vfprintf(lfile, fmt, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct ocf_logger logger = {
|
static const struct ocf_ctx_config vbdev_ocf_ctx_cfg = {
|
||||||
.printf = vbdev_ocf_ctx_log_printf,
|
.name = "OCF SPDK",
|
||||||
.dump_stack = NULL,
|
|
||||||
|
.ops = {
|
||||||
|
.data = {
|
||||||
|
.alloc = vbdev_ocf_ctx_data_alloc,
|
||||||
|
.free = vbdev_ocf_ctx_data_free,
|
||||||
|
.mlock = vbdev_ocf_ctx_data_mlock,
|
||||||
|
.munlock = vbdev_ocf_ctx_data_munlock,
|
||||||
|
.read = vbdev_ocf_ctx_data_rd,
|
||||||
|
.write = vbdev_ocf_ctx_data_wr,
|
||||||
|
.zero = vbdev_ocf_ctx_data_zero,
|
||||||
|
.seek = vbdev_ocf_ctx_data_seek,
|
||||||
|
.copy = vbdev_ocf_ctx_data_cpy,
|
||||||
|
.secure_erase = vbdev_ocf_ctx_data_secure_erase,
|
||||||
|
},
|
||||||
|
|
||||||
|
.queue = {
|
||||||
|
.init = vbdev_ocf_ctx_queue_init,
|
||||||
|
.kick = vbdev_ocf_ctx_queue_kick,
|
||||||
|
.stop = vbdev_ocf_ctx_queue_stop,
|
||||||
|
},
|
||||||
|
|
||||||
|
.metadata_updater = {
|
||||||
|
.init = vbdev_ocf_volume_updater_init,
|
||||||
|
.stop = vbdev_ocf_volume_updater_stop,
|
||||||
|
.kick = vbdev_ocf_volume_updater_kick,
|
||||||
|
},
|
||||||
|
|
||||||
|
.cleaner = {
|
||||||
|
.init = vbdev_ocf_ctx_cleaner_init,
|
||||||
|
.stop = vbdev_ocf_ctx_cleaner_stop,
|
||||||
|
},
|
||||||
|
|
||||||
|
.logger = {
|
||||||
|
.printf = vbdev_ocf_ctx_log_printf,
|
||||||
|
.dump_stack = NULL,
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -393,13 +404,11 @@ vbdev_ocf_ctx_init(void)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = ocf_ctx_init(&vbdev_ocf_ctx, &vbdev_ocf_ctx_ops);
|
ret = ocf_ctx_init(&vbdev_ocf_ctx, &vbdev_ocf_ctx_cfg);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ocf_ctx_set_logger(vbdev_ocf_ctx, &logger);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ extern ocf_ctx_t vbdev_ocf_ctx;
|
|||||||
|
|
||||||
#define OCF_WRITE_FLUSH 11
|
#define OCF_WRITE_FLUSH 11
|
||||||
|
|
||||||
#define SPDK_OBJECT 0
|
#define SPDK_OBJECT 1
|
||||||
|
|
||||||
int vbdev_ocf_ctx_init(void);
|
int vbdev_ocf_ctx_init(void);
|
||||||
void vbdev_ocf_ctx_cleanup(void);
|
void vbdev_ocf_ctx_cleanup(void);
|
||||||
|
30
lib/bdev/ocf/env/ocf_env.h
vendored
30
lib/bdev/ocf/env/ocf_env.h
vendored
@ -459,6 +459,26 @@ static inline void env_atomic64_dec(env_atomic64 *a)
|
|||||||
atomic_dec(a);
|
atomic_dec(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int env_atomic64_add_return(int i, env_atomic *a)
|
||||||
|
{
|
||||||
|
return __sync_add_and_fetch(a, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int env_atomic64_sub_return(int i, env_atomic *a)
|
||||||
|
{
|
||||||
|
return __sync_sub_and_fetch(a, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int env_atomic64_inc_return(env_atomic *a)
|
||||||
|
{
|
||||||
|
return env_atomic64_add_return(1, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int env_atomic64_dec_return(env_atomic *a)
|
||||||
|
{
|
||||||
|
return env_atomic_sub_return(1, a);
|
||||||
|
}
|
||||||
|
|
||||||
static inline long env_atomic64_cmpxchg(env_atomic64 *a, long old, long new)
|
static inline long env_atomic64_cmpxchg(env_atomic64 *a, long old, long new)
|
||||||
{
|
{
|
||||||
return atomic_cmpxchg(a, old, new);
|
return atomic_cmpxchg(a, old, new);
|
||||||
@ -623,6 +643,16 @@ static inline uint64_t env_ticks_to_msecs(uint64_t j)
|
|||||||
return env_ticks_to_secs(j) * 1000;
|
return env_ticks_to_secs(j) * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline uint64_t env_ticks_to_nsecs(uint64_t j)
|
||||||
|
{
|
||||||
|
return env_ticks_to_secs(j) * 1000 * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint64_t env_ticks_to_usecs(uint64_t j)
|
||||||
|
{
|
||||||
|
return env_ticks_to_secs(j) * 1000 * 1000 * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
static inline uint64_t env_secs_to_ticks(uint64_t j)
|
static inline uint64_t env_secs_to_ticks(uint64_t j)
|
||||||
{
|
{
|
||||||
return j * spdk_get_ticks_hz();
|
return j * spdk_get_ticks_hz();
|
||||||
|
@ -35,29 +35,28 @@
|
|||||||
#include "stats.h"
|
#include "stats.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
vbdev_ocf_stats_get(int cache_id, int core_id, struct vbdev_ocf_stats *stats)
|
vbdev_ocf_stats_get(ocf_cache_t cache, ocf_core_id_t core_id, struct vbdev_ocf_stats *stats)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
struct ocf_stats_core core_stats;
|
|
||||||
ocf_cache_t cache;
|
|
||||||
ocf_core_t core;
|
ocf_core_t core;
|
||||||
|
|
||||||
status = ocf_mngt_cache_get(vbdev_ocf_ctx, cache_id, &cache);
|
if (cache == NULL) {
|
||||||
|
assert(false);
|
||||||
|
return -EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = ocf_mngt_cache_read_lock(cache);
|
||||||
if (status) {
|
if (status) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = ocf_core_get(cache, 0, &core);
|
status = ocf_core_get(cache, core_id, &core);
|
||||||
if (status) {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = ocf_core_get_stats(core, &core_stats);
|
|
||||||
if (status) {
|
if (status) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = ocf_stats_collect_core(core, &stats->usage, &stats->reqs, &stats->blocks, &stats->errors);
|
status = ocf_stats_collect_core(core, &stats->usage, &stats->reqs, &stats->blocks, &stats->errors);
|
||||||
|
ocf_mngt_cache_read_unlock(cache);
|
||||||
if (status) {
|
if (status) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -101,24 +100,24 @@ vbdev_ocf_stats_write_json(struct spdk_json_write_ctx *w, struct vbdev_ocf_stats
|
|||||||
spdk_json_write_object_end(w);
|
spdk_json_write_object_end(w);
|
||||||
|
|
||||||
spdk_json_write_named_object_begin(w, "blocks");
|
spdk_json_write_named_object_begin(w, "blocks");
|
||||||
WJSON_STAT(w, stats, blocks, core_obj_rd, "4KiB blocks");
|
WJSON_STAT(w, stats, blocks, core_volume_rd, "4KiB blocks");
|
||||||
WJSON_STAT(w, stats, blocks, core_obj_wr, "4KiB blocks");
|
WJSON_STAT(w, stats, blocks, core_volume_wr, "4KiB blocks");
|
||||||
WJSON_STAT(w, stats, blocks, core_obj_total, "4KiB blocks");
|
WJSON_STAT(w, stats, blocks, core_volume_total, "4KiB blocks");
|
||||||
WJSON_STAT(w, stats, blocks, cache_obj_rd, "4KiB blocks");
|
WJSON_STAT(w, stats, blocks, cache_volume_rd, "4KiB blocks");
|
||||||
WJSON_STAT(w, stats, blocks, cache_obj_wr, "4KiB blocks");
|
WJSON_STAT(w, stats, blocks, cache_volume_wr, "4KiB blocks");
|
||||||
WJSON_STAT(w, stats, blocks, cache_obj_total, "4KiB blocks");
|
WJSON_STAT(w, stats, blocks, cache_volume_total, "4KiB blocks");
|
||||||
WJSON_STAT(w, stats, blocks, volume_rd, "4KiB blocks");
|
WJSON_STAT(w, stats, blocks, volume_rd, "4KiB blocks");
|
||||||
WJSON_STAT(w, stats, blocks, volume_wr, "4KiB blocks");
|
WJSON_STAT(w, stats, blocks, volume_wr, "4KiB blocks");
|
||||||
WJSON_STAT(w, stats, blocks, volume_total, "4KiB blocks");
|
WJSON_STAT(w, stats, blocks, volume_total, "4KiB blocks");
|
||||||
spdk_json_write_object_end(w);
|
spdk_json_write_object_end(w);
|
||||||
|
|
||||||
spdk_json_write_named_object_begin(w, "errors");
|
spdk_json_write_named_object_begin(w, "errors");
|
||||||
WJSON_STAT(w, stats, errors, core_obj_rd, "Requests");
|
WJSON_STAT(w, stats, errors, core_volume_rd, "Requests");
|
||||||
WJSON_STAT(w, stats, errors, core_obj_wr, "Requests");
|
WJSON_STAT(w, stats, errors, core_volume_wr, "Requests");
|
||||||
WJSON_STAT(w, stats, errors, core_obj_total, "Requests");
|
WJSON_STAT(w, stats, errors, core_volume_total, "Requests");
|
||||||
WJSON_STAT(w, stats, errors, cache_obj_rd, "Requests");
|
WJSON_STAT(w, stats, errors, cache_volume_rd, "Requests");
|
||||||
WJSON_STAT(w, stats, errors, cache_obj_wr, "Requests");
|
WJSON_STAT(w, stats, errors, cache_volume_wr, "Requests");
|
||||||
WJSON_STAT(w, stats, errors, cache_obj_total, "Requests");
|
WJSON_STAT(w, stats, errors, cache_volume_total, "Requests");
|
||||||
WJSON_STAT(w, stats, errors, total, "Requests");
|
WJSON_STAT(w, stats, errors, total, "Requests");
|
||||||
spdk_json_write_object_end(w);
|
spdk_json_write_object_end(w);
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ struct vbdev_ocf_stats {
|
|||||||
struct ocf_stats_errors errors;
|
struct ocf_stats_errors errors;
|
||||||
};
|
};
|
||||||
|
|
||||||
int vbdev_ocf_stats_get(int cache_id, int core_id, struct vbdev_ocf_stats *stats);
|
int vbdev_ocf_stats_get(ocf_cache_t cache, ocf_core_id_t core_id, struct vbdev_ocf_stats *stats);
|
||||||
|
|
||||||
void vbdev_ocf_stats_write_json(struct spdk_json_write_ctx *w, struct vbdev_ocf_stats *stats);
|
void vbdev_ocf_stats_write_json(struct spdk_json_write_ctx *w, struct vbdev_ocf_stats *stats);
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
#include "ctx.h"
|
#include "ctx.h"
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "dobj.h"
|
#include "volume.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "vbdev_ocf.h"
|
#include "vbdev_ocf.h"
|
||||||
|
|
||||||
@ -92,11 +92,17 @@ stop_vbdev(struct vbdev_ocf *vbdev)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc = ocf_mngt_cache_lock(vbdev->ocf_cache);
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
/* This function blocks execution until all OCF requests are finished
|
/* This function blocks execution until all OCF requests are finished
|
||||||
* But we don't have to worry about possible deadlocks because in
|
* But we don't have to worry about possible deadlocks because in
|
||||||
* supported modes (WT and PT) all OCF requests are finished before
|
* supported modes (WT and PT) all OCF requests are finished before
|
||||||
* SPDK bdev io requests */
|
* SPDK bdev io requests */
|
||||||
rc = ocf_mngt_cache_stop(vbdev->ocf_cache);
|
rc = ocf_mngt_cache_stop(vbdev->ocf_cache);
|
||||||
|
ocf_mngt_cache_unlock(vbdev->ocf_cache);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
SPDK_ERRLOG("Could not stop cache for '%s'\n", vbdev->name);
|
SPDK_ERRLOG("Could not stop cache for '%s'\n", vbdev->name);
|
||||||
return rc;
|
return rc;
|
||||||
@ -109,6 +115,7 @@ stop_vbdev(struct vbdev_ocf *vbdev)
|
|||||||
static int
|
static int
|
||||||
remove_base(struct vbdev_ocf_base *base)
|
remove_base(struct vbdev_ocf_base *base)
|
||||||
{
|
{
|
||||||
|
ocf_core_t core;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
if (base == NULL) {
|
if (base == NULL) {
|
||||||
@ -122,10 +129,20 @@ remove_base(struct vbdev_ocf_base *base)
|
|||||||
if (base->is_cache) {
|
if (base->is_cache) {
|
||||||
rc = stop_vbdev(base->parent);
|
rc = stop_vbdev(base->parent);
|
||||||
} else {
|
} else {
|
||||||
rc = ocf_mngt_cache_remove_core(base->parent->ocf_cache, base->id, false);
|
rc = ocf_core_get(base->parent->ocf_cache, base->id, &core);
|
||||||
|
if (rc) {
|
||||||
|
goto close_spdk_dev;
|
||||||
|
}
|
||||||
|
rc = ocf_mngt_cache_lock(base->parent->ocf_cache);
|
||||||
|
if (rc) {
|
||||||
|
goto close_spdk_dev;
|
||||||
|
}
|
||||||
|
rc = ocf_mngt_cache_remove_core(core);
|
||||||
|
ocf_mngt_cache_unlock(base->parent->ocf_cache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close_spdk_dev:
|
||||||
/* Release SPDK-part */
|
/* Release SPDK-part */
|
||||||
spdk_bdev_module_release_bdev(base->bdev);
|
spdk_bdev_module_release_bdev(base->bdev);
|
||||||
spdk_bdev_close(base->desc);
|
spdk_bdev_close(base->desc);
|
||||||
@ -276,13 +293,16 @@ io_submit_to_ocf(struct spdk_bdev_io *bdev_io, struct ocf_io *io)
|
|||||||
dir = OCF_WRITE;
|
dir = OCF_WRITE;
|
||||||
}
|
}
|
||||||
ocf_io_configure(io, offset, len, dir, 0, 0);
|
ocf_io_configure(io, offset, len, dir, 0, 0);
|
||||||
return ocf_submit_io(io);
|
ocf_core_submit_io(io);
|
||||||
|
return 0;
|
||||||
case SPDK_BDEV_IO_TYPE_FLUSH:
|
case SPDK_BDEV_IO_TYPE_FLUSH:
|
||||||
ocf_io_configure(io, offset, len, OCF_WRITE, 0, OCF_WRITE_FLUSH);
|
ocf_io_configure(io, offset, len, OCF_WRITE, 0, OCF_WRITE_FLUSH);
|
||||||
return ocf_submit_flush(io);
|
ocf_core_submit_flush(io);
|
||||||
|
return 0;
|
||||||
case SPDK_BDEV_IO_TYPE_UNMAP:
|
case SPDK_BDEV_IO_TYPE_UNMAP:
|
||||||
ocf_io_configure(io, offset, len, 0, 0, 0);
|
ocf_io_configure(io, offset, len, 0, 0, 0);
|
||||||
return ocf_submit_discard(io);
|
ocf_core_submit_discard(io);
|
||||||
|
return 0;
|
||||||
case SPDK_BDEV_IO_TYPE_RESET:
|
case SPDK_BDEV_IO_TYPE_RESET:
|
||||||
case SPDK_BDEV_IO_TYPE_WRITE_ZEROES:
|
case SPDK_BDEV_IO_TYPE_WRITE_ZEROES:
|
||||||
default:
|
default:
|
||||||
@ -301,7 +321,7 @@ io_handle(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
|||||||
struct vbdev_ocf_qcxt *qctx = spdk_io_channel_get_ctx(ch);
|
struct vbdev_ocf_qcxt *qctx = spdk_io_channel_get_ctx(ch);
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
io = ocf_new_io(vbdev->ocf_core);
|
io = ocf_core_new_io(vbdev->ocf_core);
|
||||||
if (!io) {
|
if (!io) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -469,6 +489,7 @@ start_cache(struct vbdev_ocf *vbdev)
|
|||||||
vbdev->cache.id = ocf_cache_get_id(vbdev->ocf_cache);
|
vbdev->cache.id = ocf_cache_get_id(vbdev->ocf_cache);
|
||||||
|
|
||||||
rc = ocf_mngt_cache_attach(vbdev->ocf_cache, &vbdev->cfg.device);
|
rc = ocf_mngt_cache_attach(vbdev->ocf_cache, &vbdev->cfg.device);
|
||||||
|
ocf_mngt_cache_unlock(vbdev->ocf_cache);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
SPDK_ERRLOG("Failed to attach cache device\n");
|
SPDK_ERRLOG("Failed to attach cache device\n");
|
||||||
return rc;
|
return rc;
|
||||||
@ -483,7 +504,13 @@ add_core(struct vbdev_ocf *vbdev)
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
rc = ocf_mngt_cache_lock(vbdev->ocf_cache);
|
||||||
|
if (rc) {
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
rc = ocf_mngt_cache_add_core(vbdev->ocf_cache, &vbdev->ocf_core, &vbdev->cfg.core);
|
rc = ocf_mngt_cache_add_core(vbdev->ocf_cache, &vbdev->ocf_core, &vbdev->cfg.core);
|
||||||
|
ocf_mngt_cache_unlock(vbdev->ocf_cache);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
SPDK_ERRLOG("Failed to add core device to cache instance\n");
|
SPDK_ERRLOG("Failed to add core device to cache instance\n");
|
||||||
return rc;
|
return rc;
|
||||||
@ -656,7 +683,6 @@ init_vbdev_config(struct vbdev_ocf *vbdev)
|
|||||||
/* Id 0 means OCF decides the id */
|
/* Id 0 means OCF decides the id */
|
||||||
cfg->cache.id = 0;
|
cfg->cache.id = 0;
|
||||||
cfg->cache.name = vbdev->name;
|
cfg->cache.name = vbdev->name;
|
||||||
cfg->cache.name_size = strlen(vbdev->name) + 1;
|
|
||||||
|
|
||||||
/* TODO [metadata]: make configurable with persistent
|
/* TODO [metadata]: make configurable with persistent
|
||||||
* metadata support */
|
* metadata support */
|
||||||
@ -683,7 +709,10 @@ init_vbdev_config(struct vbdev_ocf *vbdev)
|
|||||||
cfg->device.perform_test = false;
|
cfg->device.perform_test = false;
|
||||||
cfg->device.discard_on_start = false;
|
cfg->device.discard_on_start = false;
|
||||||
|
|
||||||
cfg->core.data_obj_type = SPDK_OBJECT;
|
vbdev->cfg.cache.locked = true;
|
||||||
|
|
||||||
|
cfg->core.volume_type = SPDK_OBJECT;
|
||||||
|
cfg->device.volume_type = SPDK_OBJECT;
|
||||||
|
|
||||||
cfg->device.uuid.size = strlen(vbdev->cache.name) + 1;
|
cfg->device.uuid.size = strlen(vbdev->cache.name) + 1;
|
||||||
cfg->device.uuid.data = vbdev->cache.name;
|
cfg->device.uuid.data = vbdev->cache.name;
|
||||||
@ -702,7 +731,7 @@ init_vbdev(const char *vbdev_name,
|
|||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
if (spdk_bdev_get_by_name(vbdev_name) || vbdev_ocf_get_by_name(vbdev_name)) {
|
if (spdk_bdev_get_by_name(vbdev_name) || vbdev_ocf_get_by_name(vbdev_name)) {
|
||||||
SPDK_ERRLOG("Device with name '%s' already exists", vbdev_name);
|
SPDK_ERRLOG("Device with name '%s' already exists\n", vbdev_name);
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -748,7 +777,6 @@ init_vbdev(const char *vbdev_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
init_vbdev_config(vbdev);
|
init_vbdev_config(vbdev);
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&g_ocf_vbdev_head, vbdev, tailq);
|
TAILQ_INSERT_TAIL(&g_ocf_vbdev_head, vbdev, tailq);
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
@ -774,10 +802,10 @@ vbdev_ocf_init(void)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = vbdev_ocf_dobj_init();
|
status = vbdev_ocf_volume_init();
|
||||||
if (status) {
|
if (status) {
|
||||||
vbdev_ocf_ctx_cleanup();
|
vbdev_ocf_ctx_cleanup();
|
||||||
SPDK_ERRLOG("OCF dobj initialization failed with=%d\n", status);
|
SPDK_ERRLOG("OCF volume initialization failed with=%d\n", status);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -836,7 +864,7 @@ vbdev_ocf_module_fini(void)
|
|||||||
free_vbdev(vbdev);
|
free_vbdev(vbdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
vbdev_ocf_dobj_cleanup();
|
vbdev_ocf_volume_cleanup();
|
||||||
vbdev_ocf_ctx_cleanup();
|
vbdev_ocf_ctx_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ spdk_rpc_get_ocf_stats(struct spdk_jsonrpc_request *request, const struct spdk_j
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = vbdev_ocf_stats_get(vbdev->cache.id, vbdev->core.id, &stats);
|
status = vbdev_ocf_stats_get(vbdev->ocf_cache, 0, &stats);
|
||||||
if (status) {
|
if (status) {
|
||||||
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
|
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
|
||||||
"Could not get stats: %s",
|
"Could not get stats: %s",
|
||||||
|
@ -39,34 +39,35 @@
|
|||||||
#include "spdk_internal/log.h"
|
#include "spdk_internal/log.h"
|
||||||
|
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "dobj.h"
|
#include "volume.h"
|
||||||
#include "ctx.h"
|
#include "ctx.h"
|
||||||
#include "vbdev_ocf.h"
|
#include "vbdev_ocf.h"
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vbdev_ocf_dobj_open(ocf_data_obj_t obj)
|
vbdev_ocf_volume_open(ocf_volume_t volume)
|
||||||
{
|
{
|
||||||
struct vbdev_ocf_base *base = vbdev_ocf_get_base_by_name(ocf_data_obj_get_uuid(obj)->data);
|
struct vbdev_ocf_base **priv = ocf_volume_get_priv(volume);
|
||||||
|
struct vbdev_ocf_base *base = vbdev_ocf_get_base_by_name(ocf_volume_get_uuid(volume)->data);
|
||||||
|
|
||||||
if (base == NULL) {
|
if (base == NULL) {
|
||||||
assert(false);
|
assert(false);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ocf_data_obj_set_priv(obj, base);
|
*priv = base;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vbdev_ocf_dobj_close(ocf_data_obj_t obj)
|
vbdev_ocf_volume_close(ocf_volume_t volume)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t
|
static uint64_t
|
||||||
vbdev_ocf_dobj_get_length(ocf_data_obj_t obj)
|
vbdev_ocf_volume_get_length(ocf_volume_t volume)
|
||||||
{
|
{
|
||||||
struct vbdev_ocf_base *base = ocf_data_obj_get_priv(obj);
|
struct vbdev_ocf_base *base = *((struct vbdev_ocf_base **)ocf_volume_get_priv(volume));
|
||||||
uint64_t len;
|
uint64_t len;
|
||||||
|
|
||||||
len = base->bdev->blocklen * base->bdev->blockcnt;
|
len = base->bdev->blocklen * base->bdev->blockcnt;
|
||||||
@ -75,8 +76,8 @@ vbdev_ocf_dobj_get_length(ocf_data_obj_t obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vbdev_ocf_dobj_io_set_data(struct ocf_io *io, ctx_data_t *data,
|
vbdev_ocf_volume_io_set_data(struct ocf_io *io, ctx_data_t *data,
|
||||||
uint32_t offset)
|
uint32_t offset)
|
||||||
{
|
{
|
||||||
struct ocf_io_ctx *io_ctx = ocf_get_io_ctx(io);
|
struct ocf_io_ctx *io_ctx = ocf_get_io_ctx(io);
|
||||||
|
|
||||||
@ -91,13 +92,13 @@ vbdev_ocf_dobj_io_set_data(struct ocf_io *io, ctx_data_t *data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static ctx_data_t *
|
static ctx_data_t *
|
||||||
vbdev_ocf_dobj_io_get_data(struct ocf_io *io)
|
vbdev_ocf_volume_io_get_data(struct ocf_io *io)
|
||||||
{
|
{
|
||||||
return ocf_get_io_ctx(io)->data;
|
return ocf_get_io_ctx(io)->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vbdev_ocf_dobj_io_get(struct ocf_io *io)
|
vbdev_ocf_volume_io_get(struct ocf_io *io)
|
||||||
{
|
{
|
||||||
struct ocf_io_ctx *io_ctx = ocf_get_io_ctx(io);
|
struct ocf_io_ctx *io_ctx = ocf_get_io_ctx(io);
|
||||||
|
|
||||||
@ -105,43 +106,13 @@ vbdev_ocf_dobj_io_get(struct ocf_io *io)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vbdev_ocf_dobj_io_put(struct ocf_io *io)
|
vbdev_ocf_volume_io_put(struct ocf_io *io)
|
||||||
{
|
{
|
||||||
struct ocf_io_ctx *io_ctx = ocf_get_io_ctx(io);
|
struct ocf_io_ctx *io_ctx = ocf_get_io_ctx(io);
|
||||||
|
|
||||||
if (--io_ctx->ref) {
|
if (--io_ctx->ref) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ocf_data_obj_del_io(io);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct ocf_io_ops vbdev_ocf_dobj_io_ops = {
|
|
||||||
.set_data = vbdev_ocf_dobj_io_set_data,
|
|
||||||
.get_data = vbdev_ocf_dobj_io_get_data,
|
|
||||||
.get = vbdev_ocf_dobj_io_get,
|
|
||||||
.put = vbdev_ocf_dobj_io_put,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct ocf_io *
|
|
||||||
vbdev_ocf_dobj_new_io(ocf_data_obj_t obj)
|
|
||||||
{
|
|
||||||
struct ocf_io *io;
|
|
||||||
struct ocf_io_ctx *io_ctx;
|
|
||||||
|
|
||||||
io = ocf_data_obj_new_io(obj);
|
|
||||||
if (io == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
io->ops = &vbdev_ocf_dobj_io_ops;
|
|
||||||
|
|
||||||
io_ctx = ocf_get_io_ctx(io);
|
|
||||||
io_ctx->rq_cnt = 0;
|
|
||||||
io_ctx->ref = 1;
|
|
||||||
io_ctx->error = 0;
|
|
||||||
|
|
||||||
return io;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -187,7 +158,7 @@ initialize_cpy_vector(struct iovec *cpy_vec, int cpy_vec_len, struct iovec *orig
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vbdev_ocf_dobj_submit_io_cb(struct spdk_bdev_io *bdev_io, bool success, void *opaque)
|
vbdev_ocf_volume_submit_io_cb(struct spdk_bdev_io *bdev_io, bool success, void *opaque)
|
||||||
{
|
{
|
||||||
struct ocf_io *io;
|
struct ocf_io *io;
|
||||||
struct ocf_io_ctx *io_ctx;
|
struct ocf_io_ctx *io_ctx;
|
||||||
@ -216,7 +187,7 @@ vbdev_ocf_dobj_submit_io_cb(struct spdk_bdev_io *bdev_io, bool success, void *op
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (io_ctx->error) {
|
if (io_ctx->error) {
|
||||||
SPDK_DEBUGLOG(SPDK_TRACE_VBDEV_OCF_DOBJ,
|
SPDK_DEBUGLOG(SPDK_TRACE_VBDEV_OCF_VOLUME,
|
||||||
"base returned error on io submission: %d\n", io_ctx->error);
|
"base returned error on io submission: %d\n", io_ctx->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +195,7 @@ vbdev_ocf_dobj_submit_io_cb(struct spdk_bdev_io *bdev_io, bool success, void *op
|
|||||||
spdk_put_io_channel(io_ctx->ch);
|
spdk_put_io_channel(io_ctx->ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
vbdev_ocf_dobj_io_put(io);
|
vbdev_ocf_volume_io_put(io);
|
||||||
if (bdev_io) {
|
if (bdev_io) {
|
||||||
spdk_bdev_free_io(bdev_io);
|
spdk_bdev_free_io(bdev_io);
|
||||||
}
|
}
|
||||||
@ -248,8 +219,8 @@ prepare_submit(struct ocf_io *io)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
vbdev_ocf_dobj_io_get(io);
|
vbdev_ocf_volume_io_get(io);
|
||||||
base = ocf_data_obj_get_priv(io->obj);
|
base = *((struct vbdev_ocf_base **)ocf_volume_get_priv(io->volume));
|
||||||
|
|
||||||
if (io->io_queue == 0) {
|
if (io->io_queue == 0) {
|
||||||
/* In SPDK we never set queue id to 0
|
/* In SPDK we never set queue id to 0
|
||||||
@ -281,9 +252,9 @@ prepare_submit(struct ocf_io *io)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vbdev_ocf_dobj_submit_flush(struct ocf_io *io)
|
vbdev_ocf_volume_submit_flush(struct ocf_io *io)
|
||||||
{
|
{
|
||||||
struct vbdev_ocf_base *base = ocf_data_obj_get_priv(io->obj);
|
struct vbdev_ocf_base *base = *((struct vbdev_ocf_base **)ocf_volume_get_priv(io->volume));
|
||||||
struct ocf_io_ctx *io_ctx = ocf_get_io_ctx(io);
|
struct ocf_io_ctx *io_ctx = ocf_get_io_ctx(io);
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
@ -295,39 +266,39 @@ vbdev_ocf_dobj_submit_flush(struct ocf_io *io)
|
|||||||
status = prepare_submit(io);
|
status = prepare_submit(io);
|
||||||
if (status) {
|
if (status) {
|
||||||
SPDK_ERRLOG("Preparing io failed with status=%d\n", status);
|
SPDK_ERRLOG("Preparing io failed with status=%d\n", status);
|
||||||
vbdev_ocf_dobj_submit_io_cb(NULL, false, io);
|
vbdev_ocf_volume_submit_io_cb(NULL, false, io);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = spdk_bdev_flush(
|
status = spdk_bdev_flush(
|
||||||
base->desc, io_ctx->ch,
|
base->desc, io_ctx->ch,
|
||||||
io->addr, io->bytes,
|
io->addr, io->bytes,
|
||||||
vbdev_ocf_dobj_submit_io_cb, io);
|
vbdev_ocf_volume_submit_io_cb, io);
|
||||||
if (status) {
|
if (status) {
|
||||||
/* Since callback is not called, we need to do it manually to free io structures */
|
/* Since callback is not called, we need to do it manually to free io structures */
|
||||||
SPDK_ERRLOG("Submission failed with status=%d\n", status);
|
SPDK_ERRLOG("Submission failed with status=%d\n", status);
|
||||||
vbdev_ocf_dobj_submit_io_cb(NULL, false, io);
|
vbdev_ocf_volume_submit_io_cb(NULL, false, io);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vbdev_ocf_dobj_submit_io(struct ocf_io *io)
|
vbdev_ocf_volume_submit_io(struct ocf_io *io)
|
||||||
{
|
{
|
||||||
struct vbdev_ocf_base *base = ocf_data_obj_get_priv(io->obj);
|
struct vbdev_ocf_base *base = *((struct vbdev_ocf_base **)ocf_volume_get_priv(io->volume));
|
||||||
struct ocf_io_ctx *io_ctx = ocf_get_io_ctx(io);
|
struct ocf_io_ctx *io_ctx = ocf_get_io_ctx(io);
|
||||||
struct iovec *iovs;
|
struct iovec *iovs;
|
||||||
int iovcnt, status = 0, i, offset;
|
int iovcnt, status = 0, i, offset;
|
||||||
uint64_t addr, len;
|
uint64_t addr, len;
|
||||||
|
|
||||||
if (io->flags == OCF_WRITE_FLUSH) {
|
if (io->flags == OCF_WRITE_FLUSH) {
|
||||||
vbdev_ocf_dobj_submit_flush(io);
|
vbdev_ocf_volume_submit_flush(io);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = prepare_submit(io);
|
status = prepare_submit(io);
|
||||||
if (status) {
|
if (status) {
|
||||||
SPDK_ERRLOG("Preparing io failed with status=%d\n", status);
|
SPDK_ERRLOG("Preparing io failed with status=%d\n", status);
|
||||||
vbdev_ocf_dobj_submit_io_cb(NULL, false, io);
|
vbdev_ocf_volume_submit_io_cb(NULL, false, io);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,7 +312,7 @@ vbdev_ocf_dobj_submit_io(struct ocf_io *io)
|
|||||||
|
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
SPDK_ERRLOG("offset bigger than data size\n");
|
SPDK_ERRLOG("offset bigger than data size\n");
|
||||||
vbdev_ocf_dobj_submit_io_cb(NULL, false, io);
|
vbdev_ocf_volume_submit_io_cb(NULL, false, io);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,7 +322,7 @@ vbdev_ocf_dobj_submit_io(struct ocf_io *io)
|
|||||||
|
|
||||||
if (!iovs) {
|
if (!iovs) {
|
||||||
SPDK_ERRLOG("allocation failed\n");
|
SPDK_ERRLOG("allocation failed\n");
|
||||||
vbdev_ocf_dobj_submit_io_cb(NULL, false, io);
|
vbdev_ocf_volume_submit_io_cb(NULL, false, io);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,10 +335,10 @@ vbdev_ocf_dobj_submit_io(struct ocf_io *io)
|
|||||||
|
|
||||||
if (io->dir == OCF_READ) {
|
if (io->dir == OCF_READ) {
|
||||||
status = spdk_bdev_readv(base->desc, io_ctx->ch,
|
status = spdk_bdev_readv(base->desc, io_ctx->ch,
|
||||||
iovs, iovcnt, addr, len, vbdev_ocf_dobj_submit_io_cb, io);
|
iovs, iovcnt, addr, len, vbdev_ocf_volume_submit_io_cb, io);
|
||||||
} else if (io->dir == OCF_WRITE) {
|
} else if (io->dir == OCF_WRITE) {
|
||||||
status = spdk_bdev_writev(base->desc, io_ctx->ch,
|
status = spdk_bdev_writev(base->desc, io_ctx->ch,
|
||||||
iovs, iovcnt, addr, len, vbdev_ocf_dobj_submit_io_cb, io);
|
iovs, iovcnt, addr, len, vbdev_ocf_volume_submit_io_cb, io);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
@ -375,76 +346,80 @@ vbdev_ocf_dobj_submit_io(struct ocf_io *io)
|
|||||||
|
|
||||||
/* Since callback is not called, we need to do it manually to free io structures */
|
/* Since callback is not called, we need to do it manually to free io structures */
|
||||||
SPDK_ERRLOG("submission failed with status=%d\n", status);
|
SPDK_ERRLOG("submission failed with status=%d\n", status);
|
||||||
vbdev_ocf_dobj_submit_io_cb(NULL, false, io);
|
vbdev_ocf_volume_submit_io_cb(NULL, false, io);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vbdev_ocf_dobj_submit_discard(struct ocf_io *io)
|
vbdev_ocf_volume_submit_discard(struct ocf_io *io)
|
||||||
{
|
{
|
||||||
struct vbdev_ocf_base *base = ocf_data_obj_get_priv(io->obj);
|
struct vbdev_ocf_base *base = *((struct vbdev_ocf_base **)ocf_volume_get_priv(io->volume));
|
||||||
struct ocf_io_ctx *io_ctx = ocf_get_io_ctx(io);
|
struct ocf_io_ctx *io_ctx = ocf_get_io_ctx(io);
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
status = prepare_submit(io);
|
status = prepare_submit(io);
|
||||||
if (status) {
|
if (status) {
|
||||||
SPDK_ERRLOG("Preparing io failed with status=%d\n", status);
|
SPDK_ERRLOG("Preparing io failed with status=%d\n", status);
|
||||||
vbdev_ocf_dobj_submit_io_cb(NULL, false, io);
|
vbdev_ocf_volume_submit_io_cb(NULL, false, io);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = spdk_bdev_unmap(
|
status = spdk_bdev_unmap(
|
||||||
base->desc, io_ctx->ch,
|
base->desc, io_ctx->ch,
|
||||||
io->addr, io->bytes,
|
io->addr, io->bytes,
|
||||||
vbdev_ocf_dobj_submit_io_cb, io);
|
vbdev_ocf_volume_submit_io_cb, io);
|
||||||
if (status) {
|
if (status) {
|
||||||
/* Since callback is not called, we need to do it manually to free io structures */
|
/* Since callback is not called, we need to do it manually to free io structures */
|
||||||
SPDK_ERRLOG("Submission failed with status=%d\n", status);
|
SPDK_ERRLOG("Submission failed with status=%d\n", status);
|
||||||
vbdev_ocf_dobj_submit_io_cb(NULL, false, io);
|
vbdev_ocf_volume_submit_io_cb(NULL, false, io);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vbdev_ocf_dobj_submit_metadata(struct ocf_io *io)
|
vbdev_ocf_volume_submit_metadata(struct ocf_io *io)
|
||||||
{
|
{
|
||||||
/* Implement with persistent metadata support */
|
/* Implement with persistent metadata support */
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int
|
static unsigned int
|
||||||
vbdev_ocf_dobj_get_max_io_size(ocf_data_obj_t obj)
|
vbdev_ocf_volume_get_max_io_size(ocf_volume_t volume)
|
||||||
{
|
{
|
||||||
return 256;
|
return 131072;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct ocf_data_obj_properties vbdev_ocf_dobj_props = {
|
static struct ocf_volume_properties vbdev_volume_props = {
|
||||||
.name = "SPDK block device",
|
.name = "SPDK block device",
|
||||||
.io_context_size = sizeof(struct ocf_io_ctx),
|
.io_priv_size = sizeof(struct ocf_io_ctx),
|
||||||
|
.volume_priv_size = sizeof(struct vbdev_ocf_base *),
|
||||||
.caps = {
|
.caps = {
|
||||||
.atomic_writes = 0 /* to enable need to have ops->submit_metadata */
|
.atomic_writes = 0 /* to enable need to have ops->submit_metadata */
|
||||||
},
|
},
|
||||||
.ops = {
|
.ops = {
|
||||||
.new_io = vbdev_ocf_dobj_new_io,
|
.open = vbdev_ocf_volume_open,
|
||||||
.open = vbdev_ocf_dobj_open,
|
.close = vbdev_ocf_volume_close,
|
||||||
.close = vbdev_ocf_dobj_close,
|
.get_length = vbdev_ocf_volume_get_length,
|
||||||
.get_length = vbdev_ocf_dobj_get_length,
|
.submit_io = vbdev_ocf_volume_submit_io,
|
||||||
.submit_io = vbdev_ocf_dobj_submit_io,
|
.submit_discard = vbdev_ocf_volume_submit_discard,
|
||||||
.submit_discard = vbdev_ocf_dobj_submit_discard,
|
.submit_flush = vbdev_ocf_volume_submit_flush,
|
||||||
.submit_flush = vbdev_ocf_dobj_submit_flush,
|
.get_max_io_size = vbdev_ocf_volume_get_max_io_size,
|
||||||
.get_max_io_size = vbdev_ocf_dobj_get_max_io_size,
|
.submit_metadata = vbdev_ocf_volume_submit_metadata,
|
||||||
.submit_metadata = vbdev_ocf_dobj_submit_metadata,
|
},
|
||||||
}
|
.io_ops = {
|
||||||
|
.set_data = vbdev_ocf_volume_io_set_data,
|
||||||
|
.get_data = vbdev_ocf_volume_io_get_data,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
vbdev_ocf_dobj_init(void)
|
vbdev_ocf_volume_init(void)
|
||||||
{
|
{
|
||||||
return ocf_ctx_register_data_obj_type(vbdev_ocf_ctx, SPDK_OBJECT, &vbdev_ocf_dobj_props);
|
return ocf_ctx_register_volume_type(vbdev_ocf_ctx, SPDK_OBJECT, &vbdev_volume_props);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
vbdev_ocf_dobj_cleanup(void)
|
vbdev_ocf_volume_cleanup(void)
|
||||||
{
|
{
|
||||||
ocf_ctx_unregister_data_obj_type(vbdev_ocf_ctx, SPDK_OBJECT);
|
ocf_ctx_unregister_volume_type(vbdev_ocf_ctx, SPDK_OBJECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
SPDK_LOG_REGISTER_COMPONENT("vbdev_ocf_dobj", SPDK_TRACE_VBDEV_OCF_DOBJ)
|
SPDK_LOG_REGISTER_COMPONENT("vbdev_ocf_volume", SPDK_TRACE_VBDEV_OCF_VOLUME)
|
@ -51,12 +51,12 @@ struct ocf_io_ctx {
|
|||||||
int error;
|
int error;
|
||||||
};
|
};
|
||||||
|
|
||||||
int vbdev_ocf_dobj_init(void);
|
int vbdev_ocf_volume_init(void);
|
||||||
void vbdev_ocf_dobj_cleanup(void);
|
void vbdev_ocf_volume_cleanup(void);
|
||||||
|
|
||||||
static inline struct ocf_io_ctx *ocf_get_io_ctx(struct ocf_io *io)
|
static inline struct ocf_io_ctx *ocf_get_io_ctx(struct ocf_io *io)
|
||||||
{
|
{
|
||||||
return ocf_data_obj_get_data_from_io(io);
|
return ocf_io_get_priv(io);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
2
ocf
2
ocf
@ -1 +1 @@
|
|||||||
Subproject commit 2074495935888683a94b3915f70630ecb2a25e0d
|
Subproject commit 276d91fcd7ca693fe093eb08d801b3c46df50cbf
|
Loading…
Reference in New Issue
Block a user