bdev: rename blockdev instances to bdev
This includes file names, functions, #defines, etc. There are still a few uses of "blockdev" outside of include/ and lib/ - these can be handled later. This preps for a future patch to consolidate vbdev modules and bdev modules into just bdev modules. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I70e575709ae1b0a116b08515fd38ae793de05377 Reviewed-on: https://review.gerrithub.io/369325 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
4fc7e66614
commit
dd06e98d4a
@ -60,7 +60,7 @@ struct spdk_bdev_fn_table;
|
||||
struct spdk_io_channel;
|
||||
struct spdk_json_write_ctx;
|
||||
|
||||
/** Blockdev status */
|
||||
/** bdev status */
|
||||
enum spdk_bdev_status {
|
||||
SPDK_BDEV_STATUS_INVALID,
|
||||
SPDK_BDEV_STATUS_READY,
|
||||
@ -79,7 +79,7 @@ struct spdk_bdev;
|
||||
*/
|
||||
struct spdk_bdev_desc;
|
||||
|
||||
/** Blockdev I/O type */
|
||||
/** bdev I/O type */
|
||||
enum spdk_bdev_io_type {
|
||||
SPDK_BDEV_IO_TYPE_READ = 1,
|
||||
SPDK_BDEV_IO_TYPE_WRITE,
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
/**
|
||||
* \file
|
||||
* SCSI to blockdev translation layer
|
||||
* SCSI to bdev translation layer
|
||||
*/
|
||||
|
||||
#ifndef SPDK_SCSI_H
|
||||
@ -134,7 +134,7 @@ struct spdk_scsi_task {
|
||||
uint8_t sense_data[32];
|
||||
size_t sense_data_len;
|
||||
|
||||
void *blockdev_io;
|
||||
void *bdev_io;
|
||||
|
||||
TAILQ_ENTRY(spdk_scsi_task) scsi_link;
|
||||
|
||||
|
@ -158,7 +158,7 @@ struct spdk_bdev_fn_table {
|
||||
int (*dump_config_json)(void *ctx, struct spdk_json_write_ctx *w);
|
||||
};
|
||||
|
||||
/** Blockdev I/O completion status */
|
||||
/** bdev I/O completion status */
|
||||
enum spdk_bdev_io_status {
|
||||
SPDK_BDEV_IO_STATUS_SCSI_ERROR = -3,
|
||||
SPDK_BDEV_IO_STATUS_NVME_ERROR = -2,
|
||||
@ -275,7 +275,7 @@ struct spdk_bdev_io {
|
||||
/** Total size of data to be transferred. */
|
||||
size_t len;
|
||||
|
||||
/** Starting offset (in bytes) of the blockdev for this I/O. */
|
||||
/** Starting offset (in bytes) of the bdev for this I/O. */
|
||||
uint64_t offset;
|
||||
} read;
|
||||
struct {
|
||||
@ -291,7 +291,7 @@ struct spdk_bdev_io {
|
||||
/** Total size of data to be transferred. */
|
||||
size_t len;
|
||||
|
||||
/** Starting offset (in bytes) of the blockdev for this I/O. */
|
||||
/** Starting offset (in bytes) of the bdev for this I/O. */
|
||||
uint64_t offset;
|
||||
} write;
|
||||
struct {
|
||||
@ -366,7 +366,7 @@ struct spdk_bdev_io {
|
||||
TAILQ_ENTRY(spdk_bdev_io) module_link;
|
||||
|
||||
/**
|
||||
* Per I/O context for use by the blockdev module.
|
||||
* Per I/O context for use by the bdev module.
|
||||
*
|
||||
* Note that vbdev modules may not use this field if modifying a bdev_io and resubmitting
|
||||
* to the next lower bdev.
|
||||
|
@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
CFLAGS += -I$(SPDK_ROOT_DIR)/lib/bdev/
|
||||
C_SRCS = blockdev_aio.c blockdev_aio_rpc.c
|
||||
C_SRCS = bdev_aio.c bdev_aio_rpc.c
|
||||
LIBNAME = bdev_aio
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
|
||||
|
@ -31,7 +31,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "blockdev_aio.h"
|
||||
#include "bdev_aio.h"
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
|
||||
@ -43,19 +43,19 @@
|
||||
|
||||
#include "spdk_internal/log.h"
|
||||
|
||||
static void blockdev_aio_initialize(void);
|
||||
static void bdev_aio_initialize(void);
|
||||
static void aio_free_disk(struct file_disk *fdisk);
|
||||
|
||||
static int
|
||||
blockdev_aio_get_ctx_size(void)
|
||||
bdev_aio_get_ctx_size(void)
|
||||
{
|
||||
return sizeof(struct blockdev_aio_task);
|
||||
return sizeof(struct bdev_aio_task);
|
||||
}
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(aio, blockdev_aio_initialize, NULL, NULL, blockdev_aio_get_ctx_size)
|
||||
SPDK_BDEV_MODULE_REGISTER(aio, bdev_aio_initialize, NULL, NULL, bdev_aio_get_ctx_size)
|
||||
|
||||
static int
|
||||
blockdev_aio_open(struct file_disk *disk)
|
||||
bdev_aio_open(struct file_disk *disk)
|
||||
{
|
||||
int fd;
|
||||
|
||||
@ -72,7 +72,7 @@ blockdev_aio_open(struct file_disk *disk)
|
||||
}
|
||||
|
||||
static int
|
||||
blockdev_aio_close(struct file_disk *disk)
|
||||
bdev_aio_close(struct file_disk *disk)
|
||||
{
|
||||
int rc;
|
||||
|
||||
@ -92,12 +92,12 @@ blockdev_aio_close(struct file_disk *disk)
|
||||
}
|
||||
|
||||
static int64_t
|
||||
blockdev_aio_readv(struct file_disk *fdisk, struct spdk_io_channel *ch,
|
||||
struct blockdev_aio_task *aio_task,
|
||||
struct iovec *iov, int iovcnt, uint64_t nbytes, uint64_t offset)
|
||||
bdev_aio_readv(struct file_disk *fdisk, struct spdk_io_channel *ch,
|
||||
struct bdev_aio_task *aio_task,
|
||||
struct iovec *iov, int iovcnt, uint64_t nbytes, uint64_t offset)
|
||||
{
|
||||
struct iocb *iocb = &aio_task->iocb;
|
||||
struct blockdev_aio_io_channel *aio_ch = spdk_io_channel_get_ctx(ch);
|
||||
struct bdev_aio_io_channel *aio_ch = spdk_io_channel_get_ctx(ch);
|
||||
int rc;
|
||||
|
||||
io_prep_preadv(iocb, fdisk->fd, iov, iovcnt, offset);
|
||||
@ -118,12 +118,12 @@ blockdev_aio_readv(struct file_disk *fdisk, struct spdk_io_channel *ch,
|
||||
}
|
||||
|
||||
static int64_t
|
||||
blockdev_aio_writev(struct file_disk *fdisk, struct spdk_io_channel *ch,
|
||||
struct blockdev_aio_task *aio_task,
|
||||
struct iovec *iov, int iovcnt, size_t len, uint64_t offset)
|
||||
bdev_aio_writev(struct file_disk *fdisk, struct spdk_io_channel *ch,
|
||||
struct bdev_aio_task *aio_task,
|
||||
struct iovec *iov, int iovcnt, size_t len, uint64_t offset)
|
||||
{
|
||||
struct iocb *iocb = &aio_task->iocb;
|
||||
struct blockdev_aio_io_channel *aio_ch = spdk_io_channel_get_ctx(ch);
|
||||
struct bdev_aio_io_channel *aio_ch = spdk_io_channel_get_ctx(ch);
|
||||
int rc;
|
||||
|
||||
io_prep_pwritev(iocb, fdisk->fd, iov, iovcnt, offset);
|
||||
@ -144,8 +144,8 @@ blockdev_aio_writev(struct file_disk *fdisk, struct spdk_io_channel *ch,
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_aio_flush(struct file_disk *fdisk, struct blockdev_aio_task *aio_task,
|
||||
uint64_t offset, uint64_t nbytes)
|
||||
bdev_aio_flush(struct file_disk *fdisk, struct bdev_aio_task *aio_task,
|
||||
uint64_t offset, uint64_t nbytes)
|
||||
{
|
||||
int rc = fsync(fdisk->fd);
|
||||
|
||||
@ -154,21 +154,21 @@ blockdev_aio_flush(struct file_disk *fdisk, struct blockdev_aio_task *aio_task,
|
||||
}
|
||||
|
||||
static int
|
||||
blockdev_aio_destruct(void *ctx)
|
||||
bdev_aio_destruct(void *ctx)
|
||||
{
|
||||
struct file_disk *fdisk = ctx;
|
||||
int rc = 0;
|
||||
|
||||
rc = blockdev_aio_close(fdisk);
|
||||
rc = bdev_aio_close(fdisk);
|
||||
if (rc < 0) {
|
||||
SPDK_ERRLOG("blockdev_aio_close() failed\n");
|
||||
SPDK_ERRLOG("bdev_aio_close() failed\n");
|
||||
}
|
||||
aio_free_disk(fdisk);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
blockdev_aio_initialize_io_channel(struct blockdev_aio_io_channel *ch)
|
||||
bdev_aio_initialize_io_channel(struct bdev_aio_io_channel *ch)
|
||||
{
|
||||
ch->queue_depth = 128;
|
||||
|
||||
@ -187,12 +187,12 @@ blockdev_aio_initialize_io_channel(struct blockdev_aio_io_channel *ch)
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_aio_poll(void *arg)
|
||||
bdev_aio_poll(void *arg)
|
||||
{
|
||||
struct blockdev_aio_io_channel *ch = arg;
|
||||
struct bdev_aio_io_channel *ch = arg;
|
||||
int nr, i;
|
||||
enum spdk_bdev_io_status status;
|
||||
struct blockdev_aio_task *aio_task;
|
||||
struct bdev_aio_task *aio_task;
|
||||
struct timespec timeout;
|
||||
|
||||
timeout.tv_sec = 0;
|
||||
@ -219,63 +219,63 @@ blockdev_aio_poll(void *arg)
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_aio_reset(struct file_disk *fdisk, struct blockdev_aio_task *aio_task)
|
||||
bdev_aio_reset(struct file_disk *fdisk, struct bdev_aio_task *aio_task)
|
||||
{
|
||||
spdk_bdev_io_complete(spdk_bdev_io_from_ctx(aio_task), SPDK_BDEV_IO_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
static void blockdev_aio_get_buf_cb(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
static void bdev_aio_get_buf_cb(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
{
|
||||
blockdev_aio_readv((struct file_disk *)bdev_io->bdev->ctxt,
|
||||
ch,
|
||||
(struct blockdev_aio_task *)bdev_io->driver_ctx,
|
||||
bdev_io->u.read.iovs,
|
||||
bdev_io->u.read.iovcnt,
|
||||
bdev_io->u.read.len,
|
||||
bdev_io->u.read.offset);
|
||||
bdev_aio_readv((struct file_disk *)bdev_io->bdev->ctxt,
|
||||
ch,
|
||||
(struct bdev_aio_task *)bdev_io->driver_ctx,
|
||||
bdev_io->u.read.iovs,
|
||||
bdev_io->u.read.iovcnt,
|
||||
bdev_io->u.read.len,
|
||||
bdev_io->u.read.offset);
|
||||
}
|
||||
|
||||
static int _blockdev_aio_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
static int _bdev_aio_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
{
|
||||
switch (bdev_io->type) {
|
||||
case SPDK_BDEV_IO_TYPE_READ:
|
||||
spdk_bdev_io_get_buf(bdev_io, blockdev_aio_get_buf_cb);
|
||||
spdk_bdev_io_get_buf(bdev_io, bdev_aio_get_buf_cb);
|
||||
return 0;
|
||||
|
||||
case SPDK_BDEV_IO_TYPE_WRITE:
|
||||
blockdev_aio_writev((struct file_disk *)bdev_io->bdev->ctxt,
|
||||
ch,
|
||||
(struct blockdev_aio_task *)bdev_io->driver_ctx,
|
||||
bdev_io->u.write.iovs,
|
||||
bdev_io->u.write.iovcnt,
|
||||
bdev_io->u.write.len,
|
||||
bdev_io->u.write.offset);
|
||||
bdev_aio_writev((struct file_disk *)bdev_io->bdev->ctxt,
|
||||
ch,
|
||||
(struct bdev_aio_task *)bdev_io->driver_ctx,
|
||||
bdev_io->u.write.iovs,
|
||||
bdev_io->u.write.iovcnt,
|
||||
bdev_io->u.write.len,
|
||||
bdev_io->u.write.offset);
|
||||
return 0;
|
||||
case SPDK_BDEV_IO_TYPE_FLUSH:
|
||||
blockdev_aio_flush((struct file_disk *)bdev_io->bdev->ctxt,
|
||||
(struct blockdev_aio_task *)bdev_io->driver_ctx,
|
||||
bdev_io->u.flush.offset,
|
||||
bdev_io->u.flush.length);
|
||||
bdev_aio_flush((struct file_disk *)bdev_io->bdev->ctxt,
|
||||
(struct bdev_aio_task *)bdev_io->driver_ctx,
|
||||
bdev_io->u.flush.offset,
|
||||
bdev_io->u.flush.length);
|
||||
return 0;
|
||||
|
||||
case SPDK_BDEV_IO_TYPE_RESET:
|
||||
blockdev_aio_reset((struct file_disk *)bdev_io->bdev->ctxt,
|
||||
(struct blockdev_aio_task *)bdev_io->driver_ctx);
|
||||
bdev_aio_reset((struct file_disk *)bdev_io->bdev->ctxt,
|
||||
(struct bdev_aio_task *)bdev_io->driver_ctx);
|
||||
return 0;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void blockdev_aio_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
static void bdev_aio_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
{
|
||||
if (_blockdev_aio_submit_request(ch, bdev_io) < 0) {
|
||||
if (_bdev_aio_submit_request(ch, bdev_io) < 0) {
|
||||
spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
blockdev_aio_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
|
||||
bdev_aio_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
|
||||
{
|
||||
switch (io_type) {
|
||||
case SPDK_BDEV_IO_TYPE_READ:
|
||||
@ -290,23 +290,23 @@ blockdev_aio_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
|
||||
}
|
||||
|
||||
static int
|
||||
blockdev_aio_create_cb(void *io_device, void *ctx_buf)
|
||||
bdev_aio_create_cb(void *io_device, void *ctx_buf)
|
||||
{
|
||||
struct blockdev_aio_io_channel *ch = ctx_buf;
|
||||
struct bdev_aio_io_channel *ch = ctx_buf;
|
||||
|
||||
if (blockdev_aio_initialize_io_channel(ch) != 0) {
|
||||
if (bdev_aio_initialize_io_channel(ch) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
spdk_bdev_poller_start(&ch->poller, blockdev_aio_poll, ch,
|
||||
spdk_bdev_poller_start(&ch->poller, bdev_aio_poll, ch,
|
||||
spdk_env_get_current_core(), 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_aio_destroy_cb(void *io_device, void *ctx_buf)
|
||||
bdev_aio_destroy_cb(void *io_device, void *ctx_buf)
|
||||
{
|
||||
struct blockdev_aio_io_channel *io_channel = ctx_buf;
|
||||
struct bdev_aio_io_channel *io_channel = ctx_buf;
|
||||
|
||||
io_destroy(io_channel->io_ctx);
|
||||
free(io_channel->events);
|
||||
@ -314,7 +314,7 @@ blockdev_aio_destroy_cb(void *io_device, void *ctx_buf)
|
||||
}
|
||||
|
||||
static struct spdk_io_channel *
|
||||
blockdev_aio_get_io_channel(void *ctx)
|
||||
bdev_aio_get_io_channel(void *ctx)
|
||||
{
|
||||
struct file_disk *fdisk = ctx;
|
||||
|
||||
@ -322,10 +322,10 @@ blockdev_aio_get_io_channel(void *ctx)
|
||||
}
|
||||
|
||||
static const struct spdk_bdev_fn_table aio_fn_table = {
|
||||
.destruct = blockdev_aio_destruct,
|
||||
.submit_request = blockdev_aio_submit_request,
|
||||
.io_type_supported = blockdev_aio_io_type_supported,
|
||||
.get_io_channel = blockdev_aio_get_io_channel,
|
||||
.destruct = bdev_aio_destruct,
|
||||
.submit_request = bdev_aio_submit_request,
|
||||
.io_type_supported = bdev_aio_io_type_supported,
|
||||
.get_io_channel = bdev_aio_get_io_channel,
|
||||
};
|
||||
|
||||
static void aio_free_disk(struct file_disk *fdisk)
|
||||
@ -348,7 +348,7 @@ create_aio_disk(const char *name, const char *fname)
|
||||
}
|
||||
|
||||
fdisk->file = fname;
|
||||
if (blockdev_aio_open(fdisk)) {
|
||||
if (bdev_aio_open(fdisk)) {
|
||||
SPDK_ERRLOG("Unable to open file %s. fd: %d errno: %d\n", fname, fdisk->fd, errno);
|
||||
goto error_return;
|
||||
}
|
||||
@ -371,19 +371,19 @@ create_aio_disk(const char *name, const char *fname)
|
||||
|
||||
fdisk->disk.fn_table = &aio_fn_table;
|
||||
|
||||
spdk_io_device_register(&fdisk->fd, blockdev_aio_create_cb, blockdev_aio_destroy_cb,
|
||||
sizeof(struct blockdev_aio_io_channel));
|
||||
spdk_io_device_register(&fdisk->fd, bdev_aio_create_cb, bdev_aio_destroy_cb,
|
||||
sizeof(struct bdev_aio_io_channel));
|
||||
spdk_bdev_register(&fdisk->disk);
|
||||
return &fdisk->disk;
|
||||
|
||||
error_return:
|
||||
blockdev_aio_close(fdisk);
|
||||
bdev_aio_close(fdisk);
|
||||
aio_free_disk(fdisk);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_aio_initialize(void)
|
||||
bdev_aio_initialize(void)
|
||||
{
|
||||
size_t i;
|
||||
struct spdk_conf_section *sp;
|
@ -31,8 +31,8 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SPDK_BLOCKDEV_AIO_H
|
||||
#define SPDK_BLOCKDEV_AIO_H
|
||||
#ifndef SPDK_BDEV_AIO_H
|
||||
#define SPDK_BDEV_AIO_H
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
|
||||
@ -43,13 +43,13 @@
|
||||
|
||||
#include "spdk_internal/bdev.h"
|
||||
|
||||
struct blockdev_aio_task {
|
||||
struct bdev_aio_task {
|
||||
struct iocb iocb;
|
||||
uint64_t len;
|
||||
TAILQ_ENTRY(blockdev_aio_task) link;
|
||||
TAILQ_ENTRY(bdev_aio_task) link;
|
||||
};
|
||||
|
||||
struct blockdev_aio_io_channel {
|
||||
struct bdev_aio_io_channel {
|
||||
io_context_t io_ctx;
|
||||
long queue_depth;
|
||||
struct io_event *events;
|
||||
@ -66,9 +66,9 @@ struct file_disk {
|
||||
* For storing I/O that were completed synchronously, and will be
|
||||
* completed during next check_io call.
|
||||
*/
|
||||
TAILQ_HEAD(, blockdev_aio_task) sync_completion_list;
|
||||
TAILQ_HEAD(, bdev_aio_task) sync_completion_list;
|
||||
};
|
||||
|
||||
struct spdk_bdev *create_aio_disk(const char *name, const char *fname);
|
||||
|
||||
#endif // SPDK_BLOCKDEV_AIO_H
|
||||
#endif // SPDK_BDEV_AIO_H
|
@ -31,7 +31,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "blockdev_aio.h"
|
||||
#include "bdev_aio.h"
|
||||
#include "spdk/rpc.h"
|
||||
#include "spdk/util.h"
|
||||
|
@ -475,7 +475,7 @@ spdk_bdev_initialize(spdk_bdev_init_cb cb_fn, void *cb_arg,
|
||||
g_bdev_mgr.start_poller_fn = start_poller_fn;
|
||||
g_bdev_mgr.stop_poller_fn = stop_poller_fn;
|
||||
|
||||
g_bdev_mgr.bdev_io_pool = spdk_mempool_create("blockdev_io",
|
||||
g_bdev_mgr.bdev_io_pool = spdk_mempool_create("bdev_io",
|
||||
SPDK_BDEV_IO_POOL_SIZE,
|
||||
sizeof(struct spdk_bdev_io) +
|
||||
spdk_bdev_module_get_max_ctx_size(),
|
||||
@ -805,7 +805,7 @@ spdk_bdev_io_valid(struct spdk_bdev *bdev, uint64_t offset, uint64_t nbytes)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Return failure if offset + nbytes exceeds the size of the blockdev */
|
||||
/* Return failure if offset + nbytes exceeds the size of the bdev */
|
||||
if (offset + nbytes > bdev->blockcnt * bdev->blocklen) {
|
||||
return -1;
|
||||
}
|
||||
@ -903,7 +903,7 @@ spdk_bdev_write(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
|
||||
|
||||
bdev_io = spdk_bdev_get_io();
|
||||
if (!bdev_io) {
|
||||
SPDK_ERRLOG("blockdev_io memory allocation failed duing write\n");
|
||||
SPDK_ERRLOG("bdev_io memory allocation failed duing write\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
@ -1238,7 +1238,7 @@ spdk_bdev_io_complete(struct spdk_bdev_io *bdev_io, enum spdk_bdev_io_status sta
|
||||
if (bdev_io->type == SPDK_BDEV_IO_TYPE_RESET) {
|
||||
/* Successful reset */
|
||||
if (status == SPDK_BDEV_IO_STATUS_SUCCESS) {
|
||||
/* Increase the blockdev generation */
|
||||
/* Increase the bdev generation */
|
||||
bdev_io->bdev->gencnt++;
|
||||
}
|
||||
bdev_io->bdev->reset_in_progress = false;
|
||||
|
@ -316,7 +316,7 @@ vbdev_error_examine(struct spdk_bdev *bdev)
|
||||
|
||||
base_bdev_name = spdk_conf_section_get_nmval(sp, "BdevError", i, 0);
|
||||
if (!base_bdev_name) {
|
||||
SPDK_ERRLOG("ErrorInjection configuration missing blockdev name\n");
|
||||
SPDK_ERRLOG("ErrorInjection configuration missing bdev name\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,8 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SPDK_BLOCKDEV_ERROR_H
|
||||
#define SPDK_BLOCKDEV_ERROR_H
|
||||
#ifndef SPDK_VBDEV_ERROR_H
|
||||
#define SPDK_VBDEV_ERROR_H
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
#include "spdk/bdev.h"
|
||||
@ -46,4 +46,4 @@ int spdk_vbdev_error_create(struct spdk_bdev *base_bdev);
|
||||
int spdk_vbdev_inject_error(char *name, uint32_t io_type, uint32_t error_type,
|
||||
uint32_t error_num);
|
||||
|
||||
#endif // SPDK_BLOCKDEV_ERROR_H
|
||||
#endif // SPDK_VBDEV_ERROR_H
|
||||
|
@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
CFLAGS += $(ENV_CFLAGS) -I$(SPDK_ROOT_DIR)/lib/bdev/
|
||||
C_SRCS = blockdev_malloc.c blockdev_malloc_rpc.c
|
||||
C_SRCS = bdev_malloc.c bdev_malloc_rpc.c
|
||||
LIBNAME = bdev_malloc
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
|
||||
#include "blockdev_malloc.h"
|
||||
#include "bdev_malloc.h"
|
||||
#include "spdk/bdev.h"
|
||||
#include "spdk/conf.h"
|
||||
#include "spdk/endian.h"
|
||||
@ -89,21 +89,21 @@ static struct malloc_disk *g_malloc_disk_head = NULL;
|
||||
|
||||
int malloc_disk_count = 0;
|
||||
|
||||
static void blockdev_malloc_initialize(void);
|
||||
static void blockdev_malloc_finish(void);
|
||||
static void blockdev_malloc_get_spdk_running_config(FILE *fp);
|
||||
static void bdev_malloc_initialize(void);
|
||||
static void bdev_malloc_finish(void);
|
||||
static void bdev_malloc_get_spdk_running_config(FILE *fp);
|
||||
|
||||
static int
|
||||
blockdev_malloc_get_ctx_size(void)
|
||||
bdev_malloc_get_ctx_size(void)
|
||||
{
|
||||
return sizeof(struct malloc_task) + spdk_copy_task_size();
|
||||
}
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(malloc, blockdev_malloc_initialize, blockdev_malloc_finish,
|
||||
blockdev_malloc_get_spdk_running_config, blockdev_malloc_get_ctx_size)
|
||||
SPDK_BDEV_MODULE_REGISTER(malloc, bdev_malloc_initialize, bdev_malloc_finish,
|
||||
bdev_malloc_get_spdk_running_config, bdev_malloc_get_ctx_size)
|
||||
|
||||
static void
|
||||
blockdev_malloc_delete_from_list(struct malloc_disk *malloc_disk)
|
||||
bdev_malloc_delete_from_list(struct malloc_disk *malloc_disk)
|
||||
{
|
||||
struct malloc_disk *prev = NULL;
|
||||
struct malloc_disk *node = g_malloc_disk_head;
|
||||
@ -138,16 +138,16 @@ malloc_disk_free(struct malloc_disk *malloc_disk)
|
||||
}
|
||||
|
||||
static int
|
||||
blockdev_malloc_destruct(void *ctx)
|
||||
bdev_malloc_destruct(void *ctx)
|
||||
{
|
||||
struct malloc_disk *malloc_disk = ctx;
|
||||
blockdev_malloc_delete_from_list(malloc_disk);
|
||||
bdev_malloc_delete_from_list(malloc_disk);
|
||||
malloc_disk_free(malloc_disk);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
blockdev_malloc_check_iov_len(struct iovec *iovs, int iovcnt, size_t nbytes)
|
||||
bdev_malloc_check_iov_len(struct iovec *iovs, int iovcnt, size_t nbytes)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -162,15 +162,15 @@ blockdev_malloc_check_iov_len(struct iovec *iovs, int iovcnt, size_t nbytes)
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_malloc_readv(struct malloc_disk *mdisk, struct spdk_io_channel *ch,
|
||||
struct malloc_task *task,
|
||||
struct iovec *iov, int iovcnt, size_t len, uint64_t offset)
|
||||
bdev_malloc_readv(struct malloc_disk *mdisk, struct spdk_io_channel *ch,
|
||||
struct malloc_task *task,
|
||||
struct iovec *iov, int iovcnt, size_t len, uint64_t offset)
|
||||
{
|
||||
int64_t res = 0;
|
||||
void *src = mdisk->malloc_buf + offset;
|
||||
int i;
|
||||
|
||||
if (blockdev_malloc_check_iov_len(iov, iovcnt, len)) {
|
||||
if (bdev_malloc_check_iov_len(iov, iovcnt, len)) {
|
||||
spdk_bdev_io_complete(spdk_bdev_io_from_ctx(task),
|
||||
SPDK_BDEV_IO_STATUS_FAILED);
|
||||
return;
|
||||
@ -197,15 +197,15 @@ blockdev_malloc_readv(struct malloc_disk *mdisk, struct spdk_io_channel *ch,
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_malloc_writev(struct malloc_disk *mdisk, struct spdk_io_channel *ch,
|
||||
struct malloc_task *task,
|
||||
struct iovec *iov, int iovcnt, size_t len, uint64_t offset)
|
||||
bdev_malloc_writev(struct malloc_disk *mdisk, struct spdk_io_channel *ch,
|
||||
struct malloc_task *task,
|
||||
struct iovec *iov, int iovcnt, size_t len, uint64_t offset)
|
||||
{
|
||||
int64_t res = 0;
|
||||
void *dst = mdisk->malloc_buf + offset;
|
||||
int i;
|
||||
|
||||
if (blockdev_malloc_check_iov_len(iov, iovcnt, len)) {
|
||||
if (bdev_malloc_check_iov_len(iov, iovcnt, len)) {
|
||||
spdk_bdev_io_complete(spdk_bdev_io_from_ctx(task),
|
||||
SPDK_BDEV_IO_STATUS_FAILED);
|
||||
return;
|
||||
@ -232,11 +232,11 @@ blockdev_malloc_writev(struct malloc_disk *mdisk, struct spdk_io_channel *ch,
|
||||
}
|
||||
|
||||
static int
|
||||
blockdev_malloc_unmap(struct malloc_disk *mdisk,
|
||||
struct spdk_io_channel *ch,
|
||||
struct malloc_task *task,
|
||||
struct spdk_scsi_unmap_bdesc *unmap_d,
|
||||
uint16_t bdesc_count)
|
||||
bdev_malloc_unmap(struct malloc_disk *mdisk,
|
||||
struct spdk_io_channel *ch,
|
||||
struct malloc_task *task,
|
||||
struct spdk_scsi_unmap_bdesc *unmap_d,
|
||||
uint16_t bdesc_count)
|
||||
{
|
||||
uint64_t lba, offset, byte_count;
|
||||
uint32_t block_count;
|
||||
@ -266,8 +266,8 @@ blockdev_malloc_unmap(struct malloc_disk *mdisk,
|
||||
}
|
||||
|
||||
static int64_t
|
||||
blockdev_malloc_flush(struct malloc_disk *mdisk, struct malloc_task *task,
|
||||
uint64_t offset, uint64_t nbytes)
|
||||
bdev_malloc_flush(struct malloc_disk *mdisk, struct malloc_task *task,
|
||||
uint64_t offset, uint64_t nbytes)
|
||||
{
|
||||
spdk_bdev_io_complete(spdk_bdev_io_from_ctx(task), SPDK_BDEV_IO_STATUS_SUCCESS);
|
||||
|
||||
@ -275,14 +275,14 @@ blockdev_malloc_flush(struct malloc_disk *mdisk, struct malloc_task *task,
|
||||
}
|
||||
|
||||
static int
|
||||
blockdev_malloc_reset(struct malloc_disk *mdisk, struct malloc_task *task)
|
||||
bdev_malloc_reset(struct malloc_disk *mdisk, struct malloc_task *task)
|
||||
{
|
||||
spdk_bdev_io_complete(spdk_bdev_io_from_ctx(task), SPDK_BDEV_IO_STATUS_SUCCESS);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _blockdev_malloc_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
static int _bdev_malloc_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
{
|
||||
switch (bdev_io->type) {
|
||||
case SPDK_BDEV_IO_TYPE_READ:
|
||||
@ -297,56 +297,56 @@ static int _blockdev_malloc_submit_request(struct spdk_io_channel *ch, struct sp
|
||||
return 0;
|
||||
}
|
||||
|
||||
blockdev_malloc_readv((struct malloc_disk *)bdev_io->bdev->ctxt,
|
||||
ch,
|
||||
(struct malloc_task *)bdev_io->driver_ctx,
|
||||
bdev_io->u.read.iovs,
|
||||
bdev_io->u.read.iovcnt,
|
||||
bdev_io->u.read.len,
|
||||
bdev_io->u.read.offset);
|
||||
bdev_malloc_readv((struct malloc_disk *)bdev_io->bdev->ctxt,
|
||||
ch,
|
||||
(struct malloc_task *)bdev_io->driver_ctx,
|
||||
bdev_io->u.read.iovs,
|
||||
bdev_io->u.read.iovcnt,
|
||||
bdev_io->u.read.len,
|
||||
bdev_io->u.read.offset);
|
||||
return 0;
|
||||
|
||||
case SPDK_BDEV_IO_TYPE_WRITE:
|
||||
blockdev_malloc_writev((struct malloc_disk *)bdev_io->bdev->ctxt,
|
||||
ch,
|
||||
(struct malloc_task *)bdev_io->driver_ctx,
|
||||
bdev_io->u.write.iovs,
|
||||
bdev_io->u.write.iovcnt,
|
||||
bdev_io->u.write.len,
|
||||
bdev_io->u.write.offset);
|
||||
bdev_malloc_writev((struct malloc_disk *)bdev_io->bdev->ctxt,
|
||||
ch,
|
||||
(struct malloc_task *)bdev_io->driver_ctx,
|
||||
bdev_io->u.write.iovs,
|
||||
bdev_io->u.write.iovcnt,
|
||||
bdev_io->u.write.len,
|
||||
bdev_io->u.write.offset);
|
||||
return 0;
|
||||
|
||||
case SPDK_BDEV_IO_TYPE_RESET:
|
||||
return blockdev_malloc_reset((struct malloc_disk *)bdev_io->bdev->ctxt,
|
||||
(struct malloc_task *)bdev_io->driver_ctx);
|
||||
return bdev_malloc_reset((struct malloc_disk *)bdev_io->bdev->ctxt,
|
||||
(struct malloc_task *)bdev_io->driver_ctx);
|
||||
|
||||
case SPDK_BDEV_IO_TYPE_FLUSH:
|
||||
return blockdev_malloc_flush((struct malloc_disk *)bdev_io->bdev->ctxt,
|
||||
(struct malloc_task *)bdev_io->driver_ctx,
|
||||
bdev_io->u.flush.offset,
|
||||
bdev_io->u.flush.length);
|
||||
return bdev_malloc_flush((struct malloc_disk *)bdev_io->bdev->ctxt,
|
||||
(struct malloc_task *)bdev_io->driver_ctx,
|
||||
bdev_io->u.flush.offset,
|
||||
bdev_io->u.flush.length);
|
||||
|
||||
case SPDK_BDEV_IO_TYPE_UNMAP:
|
||||
return blockdev_malloc_unmap((struct malloc_disk *)bdev_io->bdev->ctxt,
|
||||
ch,
|
||||
(struct malloc_task *)bdev_io->driver_ctx,
|
||||
bdev_io->u.unmap.unmap_bdesc,
|
||||
bdev_io->u.unmap.bdesc_count);
|
||||
return bdev_malloc_unmap((struct malloc_disk *)bdev_io->bdev->ctxt,
|
||||
ch,
|
||||
(struct malloc_task *)bdev_io->driver_ctx,
|
||||
bdev_io->u.unmap.unmap_bdesc,
|
||||
bdev_io->u.unmap.bdesc_count);
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void blockdev_malloc_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
static void bdev_malloc_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
{
|
||||
if (_blockdev_malloc_submit_request(ch, bdev_io) < 0) {
|
||||
if (_bdev_malloc_submit_request(ch, bdev_io) < 0) {
|
||||
spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
blockdev_malloc_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
|
||||
bdev_malloc_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
|
||||
{
|
||||
switch (io_type) {
|
||||
case SPDK_BDEV_IO_TYPE_READ:
|
||||
@ -362,16 +362,16 @@ blockdev_malloc_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
|
||||
}
|
||||
|
||||
static struct spdk_io_channel *
|
||||
blockdev_malloc_get_io_channel(void *ctx)
|
||||
bdev_malloc_get_io_channel(void *ctx)
|
||||
{
|
||||
return spdk_copy_engine_get_io_channel();
|
||||
}
|
||||
|
||||
static const struct spdk_bdev_fn_table malloc_fn_table = {
|
||||
.destruct = blockdev_malloc_destruct,
|
||||
.submit_request = blockdev_malloc_submit_request,
|
||||
.io_type_supported = blockdev_malloc_io_type_supported,
|
||||
.get_io_channel = blockdev_malloc_get_io_channel,
|
||||
.destruct = bdev_malloc_destruct,
|
||||
.submit_request = bdev_malloc_submit_request,
|
||||
.io_type_supported = bdev_malloc_io_type_supported,
|
||||
.get_io_channel = bdev_malloc_get_io_channel,
|
||||
};
|
||||
|
||||
struct spdk_bdev *create_malloc_disk(uint64_t num_blocks, uint32_t block_size)
|
||||
@ -439,7 +439,7 @@ static void free_malloc_disk(struct malloc_disk *mdisk)
|
||||
spdk_dma_free(mdisk);
|
||||
}
|
||||
|
||||
static void blockdev_malloc_initialize(void)
|
||||
static void bdev_malloc_initialize(void)
|
||||
{
|
||||
struct spdk_conf_section *sp = spdk_conf_find_section(NULL, "Malloc");
|
||||
int NumberOfLuns, LunSizeInMB, BlockSize, i, rc = 0;
|
||||
@ -474,7 +474,7 @@ end:
|
||||
spdk_bdev_module_init_next(rc);
|
||||
}
|
||||
|
||||
static void blockdev_malloc_finish(void)
|
||||
static void bdev_malloc_finish(void)
|
||||
{
|
||||
struct malloc_disk *mdisk;
|
||||
|
||||
@ -486,7 +486,7 @@ static void blockdev_malloc_finish(void)
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_malloc_get_spdk_running_config(FILE *fp)
|
||||
bdev_malloc_get_spdk_running_config(FILE *fp)
|
||||
{
|
||||
int num_malloc_luns = 0;
|
||||
uint64_t malloc_lun_size = 0;
|
@ -31,8 +31,8 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SPDK_BLOCKDEV_MALLOC_H
|
||||
#define SPDK_BLOCKDEV_MALLOC_H
|
||||
#ifndef SPDK_BDEV_MALLOC_H
|
||||
#define SPDK_BDEV_MALLOC_H
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
|
||||
@ -40,4 +40,4 @@
|
||||
|
||||
struct spdk_bdev *create_malloc_disk(uint64_t num_blocks, uint32_t block_size);
|
||||
|
||||
#endif /* SPDK_BLOCKDEV_MALLOC_H */
|
||||
#endif /* SPDK_BDEV_MALLOC_H */
|
@ -31,7 +31,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "blockdev_malloc.h"
|
||||
#include "bdev_malloc.h"
|
||||
#include "spdk/rpc.h"
|
||||
#include "spdk/util.h"
|
||||
|
@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
CFLAGS += $(ENV_CFLAGS) -I$(SPDK_ROOT_DIR)/lib/bdev/
|
||||
C_SRCS = blockdev_null.c blockdev_null_rpc.c
|
||||
C_SRCS = bdev_null.c bdev_null_rpc.c
|
||||
LIBNAME = bdev_null
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include "spdk_internal/bdev.h"
|
||||
#include "spdk_internal/log.h"
|
||||
|
||||
#include "blockdev_null.h"
|
||||
#include "bdev_null.h"
|
||||
|
||||
SPDK_DECLARE_BDEV_MODULE(null);
|
||||
|
||||
@ -54,13 +54,13 @@ static TAILQ_HEAD(, null_bdev) g_null_bdev_head;
|
||||
static void *g_null_read_buf;
|
||||
|
||||
static int
|
||||
blockdev_null_get_ctx_size(void)
|
||||
bdev_null_get_ctx_size(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
blockdev_null_destruct(void *ctx)
|
||||
bdev_null_destruct(void *ctx)
|
||||
{
|
||||
struct null_bdev *bdev = ctx;
|
||||
|
||||
@ -72,7 +72,7 @@ blockdev_null_destruct(void *ctx)
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_null_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
bdev_null_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
{
|
||||
switch (bdev_io->type) {
|
||||
case SPDK_BDEV_IO_TYPE_READ:
|
||||
@ -96,7 +96,7 @@ blockdev_null_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bd
|
||||
}
|
||||
|
||||
static bool
|
||||
blockdev_null_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
|
||||
bdev_null_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
|
||||
{
|
||||
switch (io_type) {
|
||||
case SPDK_BDEV_IO_TYPE_READ:
|
||||
@ -111,16 +111,16 @@ blockdev_null_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
|
||||
}
|
||||
|
||||
static struct spdk_io_channel *
|
||||
blockdev_null_get_io_channel(void *ctx)
|
||||
bdev_null_get_io_channel(void *ctx)
|
||||
{
|
||||
return spdk_get_io_channel(&g_null_bdev_head);
|
||||
}
|
||||
|
||||
static const struct spdk_bdev_fn_table null_fn_table = {
|
||||
.destruct = blockdev_null_destruct,
|
||||
.submit_request = blockdev_null_submit_request,
|
||||
.io_type_supported = blockdev_null_io_type_supported,
|
||||
.get_io_channel = blockdev_null_get_io_channel,
|
||||
.destruct = bdev_null_destruct,
|
||||
.submit_request = bdev_null_submit_request,
|
||||
.io_type_supported = bdev_null_io_type_supported,
|
||||
.get_io_channel = bdev_null_get_io_channel,
|
||||
};
|
||||
|
||||
struct spdk_bdev *
|
||||
@ -179,7 +179,7 @@ null_bdev_destroy_cb(void *io_device, void *ctx_buf)
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_null_initialize(void)
|
||||
bdev_null_initialize(void)
|
||||
{
|
||||
struct spdk_conf_section *sp = spdk_conf_find_section(NULL, "Null");
|
||||
uint64_t size_in_mb, num_blocks;
|
||||
@ -261,7 +261,7 @@ end:
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_null_finish(void)
|
||||
bdev_null_finish(void)
|
||||
{
|
||||
struct null_bdev *bdev, *tmp;
|
||||
|
||||
@ -272,7 +272,7 @@ blockdev_null_finish(void)
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_null_get_spdk_running_config(FILE *fp)
|
||||
bdev_null_get_spdk_running_config(FILE *fp)
|
||||
{
|
||||
struct null_bdev *bdev;
|
||||
uint64_t null_bdev_size;
|
||||
@ -287,7 +287,7 @@ blockdev_null_get_spdk_running_config(FILE *fp)
|
||||
}
|
||||
}
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(null, blockdev_null_initialize, blockdev_null_finish,
|
||||
blockdev_null_get_spdk_running_config, blockdev_null_get_ctx_size)
|
||||
SPDK_BDEV_MODULE_REGISTER(null, bdev_null_initialize, bdev_null_finish,
|
||||
bdev_null_get_spdk_running_config, bdev_null_get_ctx_size)
|
||||
|
||||
SPDK_LOG_REGISTER_TRACE_FLAG("bdev_null", SPDK_TRACE_BDEV_NULL)
|
@ -31,8 +31,8 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SPDK_BLOCKDEV_NULL_H
|
||||
#define SPDK_BLOCKDEV_NULL_H
|
||||
#ifndef SPDK_BDEV_NULL_H
|
||||
#define SPDK_BDEV_NULL_H
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
|
||||
@ -40,4 +40,4 @@ struct spdk_bdev;
|
||||
|
||||
struct spdk_bdev *create_null_bdev(const char *name, uint64_t num_blocks, uint32_t block_size);
|
||||
|
||||
#endif /* SPDK_BLOCKDEV_NULL_H */
|
||||
#endif /* SPDK_BDEV_NULL_H */
|
@ -37,7 +37,7 @@
|
||||
#include "spdk_internal/bdev.h"
|
||||
#include "spdk_internal/log.h"
|
||||
|
||||
#include "blockdev_null.h"
|
||||
#include "bdev_null.h"
|
||||
|
||||
struct rpc_construct_null {
|
||||
char *name;
|
@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
CFLAGS += $(ENV_CFLAGS) -I$(SPDK_ROOT_DIR)/lib/bdev/
|
||||
C_SRCS = blockdev_nvme.c blockdev_nvme_rpc.c
|
||||
C_SRCS = bdev_nvme.c bdev_nvme_rpc.c
|
||||
LIBNAME = bdev_nvme
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
|
||||
#include "blockdev_nvme.h"
|
||||
#include "bdev_nvme.h"
|
||||
|
||||
#include "spdk/conf.h"
|
||||
#include "spdk/endian.h"
|
||||
@ -783,7 +783,7 @@ remove_cb(void *cb_ctx, struct spdk_nvme_ctrlr *ctrlr)
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_nvme_hotplug(void *arg)
|
||||
bdev_nvme_hotplug(void *arg)
|
||||
{
|
||||
if (spdk_nvme_probe(NULL, NULL, hotplug_probe_cb, attach_cb, remove_cb) != 0) {
|
||||
SPDK_ERRLOG("spdk_nvme_probe() failed\n");
|
||||
@ -984,7 +984,7 @@ bdev_nvme_library_init(void)
|
||||
}
|
||||
|
||||
if (g_nvme_hotplug_enabled) {
|
||||
spdk_bdev_poller_start(&g_hotplug_poller, blockdev_nvme_hotplug, NULL,
|
||||
spdk_bdev_poller_start(&g_hotplug_poller, bdev_nvme_hotplug, NULL,
|
||||
g_nvme_hotplug_poll_core,
|
||||
g_nvme_hotplug_poll_timeout_us);
|
||||
}
|
@ -31,8 +31,8 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SPDK_BLOCKDEV_NVME_H
|
||||
#define SPDK_BLOCKDEV_NVME_H
|
||||
#ifndef SPDK_BDEV_NVME_H
|
||||
#define SPDK_BDEV_NVME_H
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
|
||||
@ -44,4 +44,4 @@ int spdk_bdev_nvme_create(struct spdk_nvme_transport_id *trid,
|
||||
const char *base_name,
|
||||
const char **names, size_t *count);
|
||||
|
||||
#endif // SPDK_BLOCKDEV_NVME_H
|
||||
#endif // SPDK_BDEV_NVME_H
|
@ -33,7 +33,7 @@
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
|
||||
#include "blockdev_nvme.h"
|
||||
#include "bdev_nvme.h"
|
||||
|
||||
#include "spdk/string.h"
|
||||
#include "spdk/rpc.h"
|
||||
@ -71,7 +71,7 @@ static const struct spdk_json_object_decoder rpc_construct_nvme_decoders[] = {
|
||||
{"subnqn", offsetof(struct rpc_construct_nvme, subnqn), spdk_json_decode_string, true},
|
||||
};
|
||||
|
||||
#define NVME_MAX_BLOCKDEVS_PER_RPC 32
|
||||
#define NVME_MAX_BDEVS_PER_RPC 32
|
||||
|
||||
static void
|
||||
spdk_rpc_construct_nvme_bdev(struct spdk_jsonrpc_request *request,
|
||||
@ -80,7 +80,7 @@ spdk_rpc_construct_nvme_bdev(struct spdk_jsonrpc_request *request,
|
||||
struct rpc_construct_nvme req = {};
|
||||
struct spdk_json_write_ctx *w;
|
||||
struct spdk_nvme_transport_id trid = {};
|
||||
const char *names[NVME_MAX_BLOCKDEVS_PER_RPC];
|
||||
const char *names[NVME_MAX_BDEVS_PER_RPC];
|
||||
size_t count;
|
||||
size_t i;
|
||||
int rc;
|
||||
@ -121,7 +121,7 @@ spdk_rpc_construct_nvme_bdev(struct spdk_jsonrpc_request *request,
|
||||
snprintf(trid.subnqn, sizeof(trid.subnqn), "%s", req.subnqn);
|
||||
}
|
||||
|
||||
count = NVME_MAX_BLOCKDEVS_PER_RPC;
|
||||
count = NVME_MAX_BDEVS_PER_RPC;
|
||||
if (spdk_bdev_nvme_create(&trid, req.name, names, &count)) {
|
||||
goto invalid;
|
||||
}
|
@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
||||
|
||||
CFLAGS += -I$(SPDK_ROOT_DIR)/lib/bdev/
|
||||
C_SRCS = blockdev_rbd.c blockdev_rbd_rpc.c
|
||||
C_SRCS = bdev_rbd.c bdev_rbd_rpc.c
|
||||
LIBNAME = bdev_rbd
|
||||
|
||||
include $(SPDK_ROOT_DIR)/mk/spdk.lib.mk
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
|
||||
#include "blockdev_rbd.h"
|
||||
#include "bdev_rbd.h"
|
||||
|
||||
#include <rbd/librbd.h>
|
||||
#include <rados/librados.h>
|
||||
@ -48,34 +48,34 @@
|
||||
|
||||
#include "spdk_internal/bdev.h"
|
||||
|
||||
static TAILQ_HEAD(, blockdev_rbd) g_rbds = TAILQ_HEAD_INITIALIZER(g_rbds);
|
||||
static int blockdev_rbd_count = 0;
|
||||
static TAILQ_HEAD(, bdev_rbd) g_rbds = TAILQ_HEAD_INITIALIZER(g_rbds);
|
||||
static int bdev_rbd_count = 0;
|
||||
|
||||
struct blockdev_rbd_io {
|
||||
struct bdev_rbd_io {
|
||||
rbd_completion_t completion;
|
||||
};
|
||||
|
||||
struct blockdev_rbd {
|
||||
struct bdev_rbd {
|
||||
struct spdk_bdev disk;
|
||||
char *rbd_name;
|
||||
char *pool_name;
|
||||
rbd_image_info_t info;
|
||||
TAILQ_ENTRY(blockdev_rbd) tailq;
|
||||
TAILQ_ENTRY(bdev_rbd) tailq;
|
||||
};
|
||||
|
||||
struct blockdev_rbd_io_channel {
|
||||
struct bdev_rbd_io_channel {
|
||||
rados_ioctx_t io_ctx;
|
||||
rados_t cluster;
|
||||
struct pollfd pfd;
|
||||
rbd_image_t image;
|
||||
rbd_completion_t *comps;
|
||||
uint32_t queue_depth;
|
||||
struct blockdev_rbd *disk;
|
||||
struct bdev_rbd *disk;
|
||||
struct spdk_bdev_poller *poller;
|
||||
};
|
||||
|
||||
static void
|
||||
blockdev_rbd_free(struct blockdev_rbd *rbd)
|
||||
bdev_rbd_free(struct bdev_rbd *rbd)
|
||||
{
|
||||
if (!rbd) {
|
||||
return;
|
||||
@ -88,8 +88,8 @@ blockdev_rbd_free(struct blockdev_rbd *rbd)
|
||||
}
|
||||
|
||||
static int
|
||||
blockdev_rados_context_init(const char *rbd_pool_name, rados_t *cluster,
|
||||
rados_ioctx_t *io_ctx)
|
||||
bdev_rados_context_init(const char *rbd_pool_name, rados_t *cluster,
|
||||
rados_ioctx_t *io_ctx)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -124,14 +124,14 @@ blockdev_rados_context_init(const char *rbd_pool_name, rados_t *cluster,
|
||||
}
|
||||
|
||||
static int
|
||||
blockdev_rbd_init(const char *rbd_pool_name, const char *rbd_name, rbd_image_info_t *info)
|
||||
bdev_rbd_init(const char *rbd_pool_name, const char *rbd_name, rbd_image_info_t *info)
|
||||
{
|
||||
int ret;
|
||||
rados_t cluster = NULL;
|
||||
rados_ioctx_t io_ctx = NULL;
|
||||
rbd_image_t image = NULL;
|
||||
|
||||
ret = blockdev_rados_context_init(rbd_pool_name, &cluster, &io_ctx);
|
||||
ret = bdev_rados_context_init(rbd_pool_name, &cluster, &io_ctx);
|
||||
if (ret < 0) {
|
||||
SPDK_ERRLOG("Failed to create rados context for rbd_pool=%s\n",
|
||||
rbd_name);
|
||||
@ -158,26 +158,26 @@ err:
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_rbd_exit(rbd_image_t image)
|
||||
bdev_rbd_exit(rbd_image_t image)
|
||||
{
|
||||
rbd_flush(image);
|
||||
rbd_close(image);
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_rbd_finish_aiocb(rbd_completion_t cb, void *arg)
|
||||
bdev_rbd_finish_aiocb(rbd_completion_t cb, void *arg)
|
||||
{
|
||||
/* Doing nothing here */
|
||||
}
|
||||
|
||||
static int
|
||||
blockdev_rbd_start_aio(rbd_image_t image, struct blockdev_rbd_io *cmd,
|
||||
void *buf, uint64_t offset, size_t len)
|
||||
bdev_rbd_start_aio(rbd_image_t image, struct bdev_rbd_io *cmd,
|
||||
void *buf, uint64_t offset, size_t len)
|
||||
{
|
||||
int ret;
|
||||
struct spdk_bdev_io *bdev_io = spdk_bdev_io_from_ctx(cmd);
|
||||
|
||||
ret = rbd_aio_create_completion((void *)cmd, blockdev_rbd_finish_aiocb,
|
||||
ret = rbd_aio_create_completion((void *)cmd, bdev_rbd_finish_aiocb,
|
||||
&cmd->completion);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
@ -201,112 +201,112 @@ blockdev_rbd_start_aio(rbd_image_t image, struct blockdev_rbd_io *cmd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void blockdev_rbd_library_init(void);
|
||||
static void blockdev_rbd_library_fini(void);
|
||||
static void bdev_rbd_library_init(void);
|
||||
static void bdev_rbd_library_fini(void);
|
||||
|
||||
static int
|
||||
blockdev_rbd_get_ctx_size(void)
|
||||
bdev_rbd_get_ctx_size(void)
|
||||
{
|
||||
return sizeof(struct blockdev_rbd_io);
|
||||
return sizeof(struct bdev_rbd_io);
|
||||
}
|
||||
|
||||
SPDK_BDEV_MODULE_REGISTER(rbd, blockdev_rbd_library_init, blockdev_rbd_library_fini, NULL,
|
||||
blockdev_rbd_get_ctx_size)
|
||||
SPDK_BDEV_MODULE_REGISTER(rbd, bdev_rbd_library_init, bdev_rbd_library_fini, NULL,
|
||||
bdev_rbd_get_ctx_size)
|
||||
|
||||
static int64_t
|
||||
blockdev_rbd_readv(struct blockdev_rbd *disk, struct spdk_io_channel *ch,
|
||||
struct blockdev_rbd_io *cmd, struct iovec *iov,
|
||||
int iovcnt, size_t len, uint64_t offset)
|
||||
bdev_rbd_readv(struct bdev_rbd *disk, struct spdk_io_channel *ch,
|
||||
struct bdev_rbd_io *cmd, struct iovec *iov,
|
||||
int iovcnt, size_t len, uint64_t offset)
|
||||
{
|
||||
struct blockdev_rbd_io_channel *rbdio_ch = spdk_io_channel_get_ctx(ch);
|
||||
struct bdev_rbd_io_channel *rbdio_ch = spdk_io_channel_get_ctx(ch);
|
||||
|
||||
if (iovcnt != 1 || iov->iov_len != len)
|
||||
return -1;
|
||||
|
||||
return blockdev_rbd_start_aio(rbdio_ch->image, cmd, iov->iov_base, offset, len);
|
||||
return bdev_rbd_start_aio(rbdio_ch->image, cmd, iov->iov_base, offset, len);
|
||||
}
|
||||
|
||||
static int64_t
|
||||
blockdev_rbd_writev(struct blockdev_rbd *disk, struct spdk_io_channel *ch,
|
||||
struct blockdev_rbd_io *cmd, struct iovec *iov,
|
||||
int iovcnt, size_t len, uint64_t offset)
|
||||
bdev_rbd_writev(struct bdev_rbd *disk, struct spdk_io_channel *ch,
|
||||
struct bdev_rbd_io *cmd, struct iovec *iov,
|
||||
int iovcnt, size_t len, uint64_t offset)
|
||||
{
|
||||
struct blockdev_rbd_io_channel *rbdio_ch = spdk_io_channel_get_ctx(ch);
|
||||
struct bdev_rbd_io_channel *rbdio_ch = spdk_io_channel_get_ctx(ch);
|
||||
|
||||
if ((iovcnt != 1) || (iov->iov_len != len))
|
||||
return -1;
|
||||
|
||||
return blockdev_rbd_start_aio(rbdio_ch->image, cmd, (void *)iov->iov_base, offset, len);
|
||||
return bdev_rbd_start_aio(rbdio_ch->image, cmd, (void *)iov->iov_base, offset, len);
|
||||
}
|
||||
|
||||
static int64_t
|
||||
blockdev_rbd_flush(struct blockdev_rbd *disk, struct spdk_io_channel *ch,
|
||||
struct blockdev_rbd_io *cmd, uint64_t offset, uint64_t nbytes)
|
||||
bdev_rbd_flush(struct bdev_rbd *disk, struct spdk_io_channel *ch,
|
||||
struct bdev_rbd_io *cmd, uint64_t offset, uint64_t nbytes)
|
||||
{
|
||||
struct blockdev_rbd_io_channel *rbdio_ch = spdk_io_channel_get_ctx(ch);
|
||||
struct bdev_rbd_io_channel *rbdio_ch = spdk_io_channel_get_ctx(ch);
|
||||
|
||||
return blockdev_rbd_start_aio(rbdio_ch->image, cmd, NULL, offset, nbytes);
|
||||
return bdev_rbd_start_aio(rbdio_ch->image, cmd, NULL, offset, nbytes);
|
||||
}
|
||||
|
||||
static int
|
||||
blockdev_rbd_destruct(void *ctx)
|
||||
bdev_rbd_destruct(void *ctx)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void blockdev_rbd_get_buf_cb(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
static void bdev_rbd_get_buf_cb(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = blockdev_rbd_readv(bdev_io->bdev->ctxt,
|
||||
ch,
|
||||
(struct blockdev_rbd_io *)bdev_io->driver_ctx,
|
||||
bdev_io->u.read.iovs,
|
||||
bdev_io->u.read.iovcnt,
|
||||
bdev_io->u.read.len,
|
||||
bdev_io->u.read.offset);
|
||||
ret = bdev_rbd_readv(bdev_io->bdev->ctxt,
|
||||
ch,
|
||||
(struct bdev_rbd_io *)bdev_io->driver_ctx,
|
||||
bdev_io->u.read.iovs,
|
||||
bdev_io->u.read.iovcnt,
|
||||
bdev_io->u.read.len,
|
||||
bdev_io->u.read.offset);
|
||||
|
||||
if (ret != 0) {
|
||||
spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
static int _blockdev_rbd_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
static int _bdev_rbd_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
{
|
||||
switch (bdev_io->type) {
|
||||
case SPDK_BDEV_IO_TYPE_READ:
|
||||
spdk_bdev_io_get_buf(bdev_io, blockdev_rbd_get_buf_cb);
|
||||
spdk_bdev_io_get_buf(bdev_io, bdev_rbd_get_buf_cb);
|
||||
return 0;
|
||||
|
||||
case SPDK_BDEV_IO_TYPE_WRITE:
|
||||
return blockdev_rbd_writev((struct blockdev_rbd *)bdev_io->bdev->ctxt,
|
||||
ch,
|
||||
(struct blockdev_rbd_io *)bdev_io->driver_ctx,
|
||||
bdev_io->u.write.iovs,
|
||||
bdev_io->u.write.iovcnt,
|
||||
bdev_io->u.write.len,
|
||||
bdev_io->u.write.offset);
|
||||
return bdev_rbd_writev((struct bdev_rbd *)bdev_io->bdev->ctxt,
|
||||
ch,
|
||||
(struct bdev_rbd_io *)bdev_io->driver_ctx,
|
||||
bdev_io->u.write.iovs,
|
||||
bdev_io->u.write.iovcnt,
|
||||
bdev_io->u.write.len,
|
||||
bdev_io->u.write.offset);
|
||||
case SPDK_BDEV_IO_TYPE_FLUSH:
|
||||
return blockdev_rbd_flush((struct blockdev_rbd *)bdev_io->bdev->ctxt,
|
||||
ch,
|
||||
(struct blockdev_rbd_io *)bdev_io->driver_ctx,
|
||||
bdev_io->u.flush.offset,
|
||||
bdev_io->u.flush.length);
|
||||
return bdev_rbd_flush((struct bdev_rbd *)bdev_io->bdev->ctxt,
|
||||
ch,
|
||||
(struct bdev_rbd_io *)bdev_io->driver_ctx,
|
||||
bdev_io->u.flush.offset,
|
||||
bdev_io->u.flush.length);
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void blockdev_rbd_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
static void bdev_rbd_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
|
||||
{
|
||||
if (_blockdev_rbd_submit_request(ch, bdev_io) < 0) {
|
||||
if (_bdev_rbd_submit_request(ch, bdev_io) < 0) {
|
||||
spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
blockdev_rbd_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
|
||||
bdev_rbd_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
|
||||
{
|
||||
switch (io_type) {
|
||||
case SPDK_BDEV_IO_TYPE_READ:
|
||||
@ -320,10 +320,10 @@ blockdev_rbd_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_rbd_io_poll(void *arg)
|
||||
bdev_rbd_io_poll(void *arg)
|
||||
{
|
||||
struct blockdev_rbd_io_channel *ch = arg;
|
||||
struct blockdev_rbd_io *req;
|
||||
struct bdev_rbd_io_channel *ch = arg;
|
||||
struct bdev_rbd_io *req;
|
||||
struct spdk_bdev_io *bdev_io;
|
||||
int i, io_status, status, rc;
|
||||
|
||||
@ -336,7 +336,7 @@ blockdev_rbd_io_poll(void *arg)
|
||||
|
||||
rc = rbd_poll_io_events(ch->image, ch->comps, ch->queue_depth);
|
||||
for (i = 0; i < rc; i++) {
|
||||
req = (struct blockdev_rbd_io *)rbd_aio_get_arg(ch->comps[i]);
|
||||
req = (struct bdev_rbd_io *)rbd_aio_get_arg(ch->comps[i]);
|
||||
bdev_io = spdk_bdev_io_from_ctx(req);
|
||||
io_status = rbd_aio_get_return_value(ch->comps[i]);
|
||||
if (bdev_io->type == SPDK_BDEV_IO_TYPE_READ) {
|
||||
@ -359,14 +359,14 @@ blockdev_rbd_io_poll(void *arg)
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_rbd_free_channel(struct blockdev_rbd_io_channel *ch)
|
||||
bdev_rbd_free_channel(struct bdev_rbd_io_channel *ch)
|
||||
{
|
||||
if (!ch) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ch->image) {
|
||||
blockdev_rbd_exit(ch->image);
|
||||
bdev_rbd_exit(ch->image);
|
||||
}
|
||||
|
||||
if (ch->io_ctx) {
|
||||
@ -387,9 +387,9 @@ blockdev_rbd_free_channel(struct blockdev_rbd_io_channel *ch)
|
||||
}
|
||||
|
||||
static void *
|
||||
blockdev_rbd_handle(void *arg)
|
||||
bdev_rbd_handle(void *arg)
|
||||
{
|
||||
struct blockdev_rbd_io_channel *ch = arg;
|
||||
struct bdev_rbd_io_channel *ch = arg;
|
||||
void *ret = arg;
|
||||
|
||||
if (rbd_open(ch->io_ctx, ch->disk->rbd_name, &ch->image, NULL) < 0) {
|
||||
@ -401,24 +401,24 @@ blockdev_rbd_handle(void *arg)
|
||||
}
|
||||
|
||||
static int
|
||||
blockdev_rbd_create_cb(void *io_device, void *ctx_buf)
|
||||
bdev_rbd_create_cb(void *io_device, void *ctx_buf)
|
||||
{
|
||||
struct blockdev_rbd_io_channel *ch = ctx_buf;
|
||||
struct bdev_rbd_io_channel *ch = ctx_buf;
|
||||
int ret;
|
||||
|
||||
ch->disk = (struct blockdev_rbd *)((uintptr_t)io_device - offsetof(struct blockdev_rbd, info));
|
||||
ch->disk = (struct bdev_rbd *)((uintptr_t)io_device - offsetof(struct bdev_rbd, info));
|
||||
ch->image = NULL;
|
||||
ch->io_ctx = NULL;
|
||||
ch->pfd.fd = -1;
|
||||
|
||||
ret = blockdev_rados_context_init(ch->disk->pool_name, &ch->cluster, &ch->io_ctx);
|
||||
ret = bdev_rados_context_init(ch->disk->pool_name, &ch->cluster, &ch->io_ctx);
|
||||
if (ret < 0) {
|
||||
SPDK_ERRLOG("Failed to create rados context for rbd_pool=%s\n",
|
||||
ch->disk->pool_name);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (spdk_call_unaffinitized(blockdev_rbd_handle, ch) == NULL) {
|
||||
if (spdk_call_unaffinitized(bdev_rbd_handle, ch) == NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -442,95 +442,95 @@ blockdev_rbd_create_cb(void *io_device, void *ctx_buf)
|
||||
goto err;
|
||||
}
|
||||
|
||||
spdk_bdev_poller_start(&ch->poller, blockdev_rbd_io_poll, ch,
|
||||
spdk_bdev_poller_start(&ch->poller, bdev_rbd_io_poll, ch,
|
||||
spdk_env_get_current_core(), 0);
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
blockdev_rbd_free_channel(ch);
|
||||
bdev_rbd_free_channel(ch);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_rbd_destroy_cb(void *io_device, void *ctx_buf)
|
||||
bdev_rbd_destroy_cb(void *io_device, void *ctx_buf)
|
||||
{
|
||||
struct blockdev_rbd_io_channel *io_channel = ctx_buf;
|
||||
struct bdev_rbd_io_channel *io_channel = ctx_buf;
|
||||
|
||||
blockdev_rbd_free_channel(io_channel);
|
||||
bdev_rbd_free_channel(io_channel);
|
||||
|
||||
spdk_bdev_poller_stop(&io_channel->poller);
|
||||
}
|
||||
|
||||
static struct spdk_io_channel *
|
||||
blockdev_rbd_get_io_channel(void *ctx)
|
||||
bdev_rbd_get_io_channel(void *ctx)
|
||||
{
|
||||
struct blockdev_rbd *rbd_bdev = ctx;
|
||||
struct bdev_rbd *rbd_bdev = ctx;
|
||||
|
||||
return spdk_get_io_channel(&rbd_bdev->info);
|
||||
}
|
||||
|
||||
static const struct spdk_bdev_fn_table rbd_fn_table = {
|
||||
.destruct = blockdev_rbd_destruct,
|
||||
.submit_request = blockdev_rbd_submit_request,
|
||||
.io_type_supported = blockdev_rbd_io_type_supported,
|
||||
.get_io_channel = blockdev_rbd_get_io_channel,
|
||||
.destruct = bdev_rbd_destruct,
|
||||
.submit_request = bdev_rbd_submit_request,
|
||||
.io_type_supported = bdev_rbd_io_type_supported,
|
||||
.get_io_channel = bdev_rbd_get_io_channel,
|
||||
};
|
||||
|
||||
static void
|
||||
blockdev_rbd_library_fini(void)
|
||||
bdev_rbd_library_fini(void)
|
||||
{
|
||||
struct blockdev_rbd *rbd;
|
||||
struct bdev_rbd *rbd;
|
||||
|
||||
while (!TAILQ_EMPTY(&g_rbds)) {
|
||||
rbd = TAILQ_FIRST(&g_rbds);
|
||||
TAILQ_REMOVE(&g_rbds, rbd, tailq);
|
||||
blockdev_rbd_free(rbd);
|
||||
bdev_rbd_free(rbd);
|
||||
}
|
||||
}
|
||||
|
||||
struct spdk_bdev *
|
||||
spdk_bdev_rbd_create(const char *pool_name, const char *rbd_name, uint32_t block_size)
|
||||
{
|
||||
struct blockdev_rbd *rbd;
|
||||
struct bdev_rbd *rbd;
|
||||
int ret;
|
||||
|
||||
if ((pool_name == NULL) || (rbd_name == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rbd = calloc(1, sizeof(struct blockdev_rbd));
|
||||
rbd = calloc(1, sizeof(struct bdev_rbd));
|
||||
if (rbd == NULL) {
|
||||
SPDK_ERRLOG("Failed to allocate blockdev_rbd struct\n");
|
||||
SPDK_ERRLOG("Failed to allocate bdev_rbd struct\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rbd->rbd_name = strdup(rbd_name);
|
||||
if (!rbd->rbd_name) {
|
||||
blockdev_rbd_free(rbd);
|
||||
bdev_rbd_free(rbd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rbd->pool_name = strdup(pool_name);
|
||||
if (!rbd->pool_name) {
|
||||
blockdev_rbd_free(rbd);
|
||||
bdev_rbd_free(rbd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = blockdev_rbd_init(rbd->pool_name, rbd_name, &rbd->info);
|
||||
ret = bdev_rbd_init(rbd->pool_name, rbd_name, &rbd->info);
|
||||
if (ret < 0) {
|
||||
blockdev_rbd_free(rbd);
|
||||
bdev_rbd_free(rbd);
|
||||
SPDK_ERRLOG("Failed to init rbd device\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rbd->disk.name = spdk_sprintf_alloc("Ceph%d", blockdev_rbd_count);
|
||||
rbd->disk.name = spdk_sprintf_alloc("Ceph%d", bdev_rbd_count);
|
||||
if (!rbd->disk.name) {
|
||||
blockdev_rbd_free(rbd);
|
||||
bdev_rbd_free(rbd);
|
||||
return NULL;
|
||||
}
|
||||
rbd->disk.product_name = "Ceph Rbd Disk";
|
||||
blockdev_rbd_count++;
|
||||
bdev_rbd_count++;
|
||||
|
||||
rbd->disk.write_cache = 0;
|
||||
rbd->disk.blocklen = block_size;
|
||||
@ -542,15 +542,15 @@ spdk_bdev_rbd_create(const char *pool_name, const char *rbd_name, uint32_t block
|
||||
SPDK_NOTICELOG("Add %s rbd disk to lun\n", rbd->disk.name);
|
||||
TAILQ_INSERT_TAIL(&g_rbds, rbd, tailq);
|
||||
|
||||
spdk_io_device_register(&rbd->info, blockdev_rbd_create_cb,
|
||||
blockdev_rbd_destroy_cb,
|
||||
sizeof(struct blockdev_rbd_io_channel));
|
||||
spdk_io_device_register(&rbd->info, bdev_rbd_create_cb,
|
||||
bdev_rbd_destroy_cb,
|
||||
sizeof(struct bdev_rbd_io_channel));
|
||||
spdk_bdev_register(&rbd->disk);
|
||||
return &rbd->disk;
|
||||
}
|
||||
|
||||
static void
|
||||
blockdev_rbd_library_init(void)
|
||||
bdev_rbd_library_init(void)
|
||||
{
|
||||
int i, rc = 0;
|
||||
const char *val;
|
@ -31,8 +31,8 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SPDK_BLOCKDEV_RBD_H
|
||||
#define SPDK_BLOCKDEV_RBD_H
|
||||
#ifndef SPDK_BDEV_RBD_H
|
||||
#define SPDK_BDEV_RBD_H
|
||||
|
||||
#include "spdk/stdinc.h"
|
||||
|
||||
@ -41,4 +41,4 @@
|
||||
struct spdk_bdev *spdk_bdev_rbd_create(const char *pool_name, const char *rbd_name,
|
||||
uint32_t block_size);
|
||||
|
||||
#endif // SPDK_BLOCKDEV_RBD_H
|
||||
#endif // SPDK_BDEV_RBD_H
|
@ -31,7 +31,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "blockdev_rbd.h"
|
||||
#include "bdev_rbd.h"
|
||||
#include "spdk/rpc.h"
|
||||
#include "spdk/util.h"
|
||||
|
@ -369,7 +369,7 @@ vbdev_split_examine(struct spdk_bdev *bdev)
|
||||
|
||||
base_bdev_name = spdk_conf_section_get_nmval(sp, "Split", i, 0);
|
||||
if (!base_bdev_name) {
|
||||
SPDK_ERRLOG("Split configuration missing blockdev name\n");
|
||||
SPDK_ERRLOG("Split configuration missing bdev name\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -249,9 +249,9 @@ spdk_scsi_lun_hot_remove(void *remove_ctx)
|
||||
* \brief Constructs a new spdk_scsi_lun object based on the provided parameters.
|
||||
*
|
||||
* \param name Name for the SCSI LUN.
|
||||
* \param blockdev Blockdev associated with this LUN
|
||||
* \param bdev bdev associated with this LUN
|
||||
*
|
||||
* \return NULL if blockdev == NULL
|
||||
* \return NULL if bdev == NULL
|
||||
* \return pointer to the new spdk_scsi_lun object otherwise
|
||||
*/
|
||||
_spdk_scsi_lun *
|
||||
@ -262,7 +262,7 @@ spdk_scsi_lun_construct(const char *name, struct spdk_bdev *bdev,
|
||||
int rc;
|
||||
|
||||
if (bdev == NULL) {
|
||||
SPDK_ERRLOG("blockdev must be non-NULL\n");
|
||||
SPDK_ERRLOG("bdev must be non-NULL\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1249,7 +1249,7 @@ spdk_bdev_scsi_task_complete_cmd(struct spdk_bdev_io *bdev_io, bool success,
|
||||
struct spdk_scsi_task *task = cb_arg;
|
||||
int sc, sk, asc, ascq;
|
||||
|
||||
task->blockdev_io = bdev_io;
|
||||
task->bdev_io = bdev_io;
|
||||
|
||||
spdk_bdev_io_get_scsi_status(bdev_io, &sc, &sk, &asc, &ascq);
|
||||
spdk_scsi_task_set_status(task, sc, sk, asc, ascq);
|
||||
@ -1262,7 +1262,7 @@ spdk_bdev_scsi_task_complete_mgmt(struct spdk_bdev_io *bdev_io, bool success,
|
||||
{
|
||||
struct spdk_scsi_task *task = cb_arg;
|
||||
|
||||
task->blockdev_io = bdev_io;
|
||||
task->bdev_io = bdev_io;
|
||||
|
||||
if (success) {
|
||||
task->response = SPDK_SCSI_TASK_MGMT_RESP_SUCCESS;
|
||||
|
@ -78,13 +78,13 @@ struct spdk_scsi_lun {
|
||||
/** Pointer to the SCSI device containing this LUN. */
|
||||
struct spdk_scsi_dev *dev;
|
||||
|
||||
/** The blockdev associated with this LUN. */
|
||||
/** The bdev associated with this LUN. */
|
||||
struct spdk_bdev *bdev;
|
||||
|
||||
/** Descriptor for opened block device. */
|
||||
struct spdk_bdev_desc *bdev_desc;
|
||||
|
||||
/** I/O channel for the blockdev associated with this LUN. */
|
||||
/** I/O channel for the bdev associated with this LUN. */
|
||||
struct spdk_io_channel *io_channel;
|
||||
|
||||
/** Thread ID for the thread that allocated the I/O channel for this
|
||||
|
@ -47,7 +47,7 @@ spdk_scsi_task_put(struct spdk_scsi_task *task)
|
||||
task->ref--;
|
||||
|
||||
if (task->ref == 0) {
|
||||
struct spdk_bdev_io *bdev_io = task->blockdev_io;
|
||||
struct spdk_bdev_io *bdev_io = task->bdev_io;
|
||||
|
||||
if (task->parent) {
|
||||
spdk_scsi_task_put(task->parent);
|
||||
|
Loading…
Reference in New Issue
Block a user