Commit ba8f1a9e authored by Alexey Marchuk's avatar Alexey Marchuk Committed by Tomasz Zawadzki
Browse files

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: default avatarAlexey Marchuk <alexeymar@mellanox.com>
Change-Id: Id94542196eff999827bf00591fd43804256fccb4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11369


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
parent 5fd9561f
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -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);

+47 −0
Original line number Diff line number Diff line
@@ -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,
};
+1 −1
Original line number Diff line number Diff line
@@ -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
+20 −0
Original line number Diff line number Diff line
@@ -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;
+4 −0
Original line number Diff line number Diff line
@@ -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)
Loading