blob: Add readv/writev ext ops to spdk_bs_dev

Introduce spdk_blob_ext_io_opts structure which
is used in the new *_ext functions.
Zeroes dev is updated with implementation of
readv_ext which uses  memory domains memzero
or regular memset().

Signed-off-by: Alexey Marchuk <alexeymar@mellanox.com>
Change-Id: Id94542196eff999827bf00591fd43804256fccb4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11369
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
This commit is contained in:
Alexey Marchuk 2022-01-31 11:53:15 +03:00 committed by Tomasz Zawadzki
parent 5fd9561f54
commit ba8f1a9e5d
8 changed files with 129 additions and 1 deletions

View File

@ -149,6 +149,21 @@ struct spdk_bs_dev_cb_args {
void *cb_arg;
};
/**
* Structure with optional IO request parameters
* The content of this structure must be valid until the IO request is completed
*/
struct spdk_blob_ext_io_opts {
/** Size of this structure in bytes */
size_t size;
/** Memory domain which describes payload in this IO request. */
struct spdk_memory_domain *memory_domain;
/** Context to be passed to memory domain operations */
void *memory_domain_ctx;
/** Optional user context */
void *user_ctx;
};
struct spdk_bs_dev {
/* Create a new channel which is a software construct that is used
* to submit I/O. */
@ -181,6 +196,18 @@ struct spdk_bs_dev {
uint64_t lba, uint32_t lba_count,
struct spdk_bs_dev_cb_args *cb_args);
void (*readv_ext)(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt,
uint64_t lba, uint32_t lba_count,
struct spdk_bs_dev_cb_args *cb_args,
struct spdk_blob_ext_io_opts *ext_io_opts);
void (*writev_ext)(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt,
uint64_t lba, uint32_t lba_count,
struct spdk_bs_dev_cb_args *cb_args,
struct spdk_blob_ext_io_opts *ext_io_opts);
void (*flush)(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
struct spdk_bs_dev_cb_args *cb_args);

View File

@ -3,6 +3,7 @@
*
* Copyright (c) Intel Corporation.
* All rights reserved.
* Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -33,6 +34,7 @@
#include "spdk/stdinc.h"
#include "spdk/blob.h"
#include "spdk/dma.h"
#include "blobstore.h"
@ -83,6 +85,49 @@ zeroes_writev(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
assert(false);
}
static void
_read_memory_domain_memzero_done(void *ctx, int rc)
{
struct spdk_bs_dev_cb_args *cb_args = (struct spdk_bs_dev_cb_args *)ctx;
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, rc);
}
static void
zeroes_readv_ext(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt,
uint64_t lba, uint32_t lba_count, struct spdk_bs_dev_cb_args *cb_args,
struct spdk_blob_ext_io_opts *ext_io_opts)
{
int i, rc;
if (ext_io_opts->memory_domain) {
rc = spdk_memory_domain_memzero(ext_io_opts->memory_domain, ext_io_opts->memory_domain_ctx, iov,
iovcnt, _read_memory_domain_memzero_done, cb_args);
if (rc) {
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, rc);
}
return;
}
for (i = 0; i < iovcnt; i++) {
memset(iov[i].iov_base, 0, iov[i].iov_len);
}
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, 0);
}
static void
zeroes_writev_ext(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt,
uint64_t lba, uint32_t lba_count,
struct spdk_bs_dev_cb_args *cb_args,
struct spdk_blob_ext_io_opts *ext_io_opts)
{
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, -EPERM);
assert(false);
}
static void
zeroes_write_zeroes(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
uint64_t lba, uint64_t lba_count,
@ -111,6 +156,8 @@ static struct spdk_bs_dev g_zeroes_bs_dev = {
.write = zeroes_write,
.readv = zeroes_readv,
.writev = zeroes_writev,
.readv_ext = zeroes_readv_ext,
.writev_ext = zeroes_writev_ext,
.write_zeroes = zeroes_write_zeroes,
.unmap = zeroes_unmap,
};

View File

@ -71,7 +71,7 @@ ifeq ($(CONFIG_VFIO_USER),y)
DEPDIRS-nvme += vfio_user
endif
DEPDIRS-blob := log util thread
DEPDIRS-blob := log util thread dma
DEPDIRS-accel := log util thread json
DEPDIRS-jsonrpc := log util json
DEPDIRS-virtio := log util json thread

View File

@ -193,6 +193,24 @@ bdev_blob_writev(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
}
}
static void
bdev_blob_readv_ext(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt,
uint64_t lba, uint32_t lba_count, struct spdk_bs_dev_cb_args *cb_args,
struct spdk_blob_ext_io_opts *io_opts)
{
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, -ENOTSUP);
}
static void
bdev_blob_writev_ext(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt,
uint64_t lba, uint32_t lba_count, struct spdk_bs_dev_cb_args *cb_args,
struct spdk_blob_ext_io_opts *io_opts)
{
cb_args->cb_fn(cb_args->channel, cb_args->cb_arg, -ENOTSUP);
}
static void
bdev_blob_write_zeroes(struct spdk_bs_dev *dev, struct spdk_io_channel *channel, uint64_t lba,
uint64_t lba_count, struct spdk_bs_dev_cb_args *cb_args)
@ -345,6 +363,8 @@ blob_bdev_init(struct blob_bdev *b, struct spdk_bdev_desc *desc)
b->bs_dev.write = bdev_blob_write;
b->bs_dev.readv = bdev_blob_readv;
b->bs_dev.writev = bdev_blob_writev;
b->bs_dev.readv_ext = bdev_blob_readv_ext;
b->bs_dev.writev_ext = bdev_blob_writev_ext;
b->bs_dev.write_zeroes = bdev_blob_write_zeroes;
b->bs_dev.unmap = bdev_blob_unmap;
b->bs_dev.get_base_bdev = bdev_blob_get_base_bdev;

View File

@ -85,6 +85,10 @@ static void ut_blob_close_and_delete(struct spdk_blob_store *bs, struct spdk_blo
static void suite_blob_setup(void);
static void suite_blob_cleanup(void);
DEFINE_STUB(spdk_memory_domain_memzero, int, (struct spdk_memory_domain *src_domain,
void *src_domain_ctx, struct iovec *iov, uint32_t iovcnt, void (*cpl_cb)(void *, int),
void *cpl_cb_arg), 0);
static void
_get_xattr_value(void *arg, const char *name,
const void **value, size_t *value_len)

View File

@ -251,6 +251,16 @@ dev_readv(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
spdk_thread_send_msg(spdk_get_thread(), dev_complete, cb_args);
}
static void
dev_readv_ext(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt,
uint64_t lba, uint32_t lba_count,
struct spdk_bs_dev_cb_args *cb_args,
struct spdk_blob_ext_io_opts *io_opts)
{
dev_readv(dev, channel, iov, iovcnt, lba, lba_count, cb_args);
}
static void
dev_writev(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt,
@ -290,6 +300,16 @@ dev_writev(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
spdk_thread_send_msg(spdk_get_thread(), dev_complete, cb_args);
}
static void
dev_writev_ext(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
struct iovec *iov, int iovcnt,
uint64_t lba, uint32_t lba_count,
struct spdk_bs_dev_cb_args *cb_args,
struct spdk_blob_ext_io_opts *io_opts)
{
dev_writev(dev, channel, iov, iovcnt, lba, lba_count, cb_args);
}
static void
dev_flush(struct spdk_bs_dev *dev, struct spdk_io_channel *channel,
struct spdk_bs_dev_cb_args *cb_args)
@ -387,6 +407,8 @@ init_dev(void)
dev->write = dev_write;
dev->readv = dev_readv;
dev->writev = dev_writev;
dev->readv_ext = dev_readv_ext;
dev->writev_ext = dev_writev_ext;
dev->flush = dev_flush;
dev->unmap = dev_unmap;
dev->write_zeroes = dev_write_zeroes;

View File

@ -48,6 +48,10 @@ struct spdk_filesystem *g_fs;
struct spdk_file *g_file;
int g_fserrno;
DEFINE_STUB(spdk_memory_domain_memzero, int, (struct spdk_memory_domain *src_domain,
void *src_domain_ctx, struct iovec *iov, uint32_t iovcnt, void (*cpl_cb)(void *, int),
void *cpl_cb_arg), 0);
static void
fs_op_complete(void *ctx, int fserrno)
{

View File

@ -56,6 +56,10 @@ struct ut_request {
volatile int done;
};
DEFINE_STUB(spdk_memory_domain_memzero, int, (struct spdk_memory_domain *src_domain,
void *src_domain_ctx, struct iovec *iov, uint32_t iovcnt, void (*cpl_cb)(void *, int),
void *cpl_cb_arg), 0);
static void
send_request(fs_request_fn fn, void *arg)
{