Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bdev ext api #36

Open
wants to merge 4 commits into
base: upstream_master
Choose a base branch
from
Open

Bdev ext api #36

wants to merge 4 commits into from

Conversation

AlekseyMarchuk
Copy link

No description provided.

struct spdk_bdev_io_memory_key_ctx {
void *ctx;
enum spdk_bdev_io_memory_key_ctx_type ctx_type;
/** Memory key to be filled by the user of \b spdk_bdev_readv_with_md_ext of \b spdk_bdev_writev_with_md_ext

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2nd "of" -> "or"

lib/bdev/bdev.c Outdated
return -EINVAL;
}

bdev_copy_ext_io_opts(opts, &opts_local, opts->opts_size);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have two copies of opts: here and in bdev_readv_blocks_with_md. Can we optimize somehow and keep just one?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will rework to pass user's struct and check if it is NULL or not

lib/bdev/bdev.c Outdated
} \

SET_FIELD(get_mkey_cb);
SET_FIELD(get_mkey_cb_arg);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just memcpy?

lib/bdev/bdev.c Outdated
dst->opts_size = opts_size;

#define SET_FIELD(field) \
if (offsetof(struct spdk_bdev_ext_io_opts, field) + sizeof(src->field) <= opts_size) { \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be that src and dst have different size?

lib/bdev/bdev.c Outdated

static void
bdev_copy_ext_io_opts(const struct spdk_bdev_ext_io_opts *src, struct spdk_bdev_ext_io_opts *dst,
size_t opts_size)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need opts_size argument? We have one in src.

lib/bdev/bdev.c Outdated
}

memset(&caps_local, 0, sizeof(caps_local));
caps_local.size = caps->size;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If user was built with newer version, caps->size can be larger than caps_local structure size

enum spdk_bdev_io_memory_key_ctx_type ctx_type;
/** Memory key to be filled by the user of \b spdk_bdev_readv_with_md_ext of \b spdk_bdev_writev_with_md_ext
* when bdev module calls \b spdk_bdev_io_get_mkey */
uint32_t mkey;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need more description here. It is not very clear that ctx and ctx_typre are input parameters and mkey is out parameter.

@@ -1733,6 +1733,28 @@ void spdk_bdev_histogram_get(struct spdk_bdev *bdev, struct spdk_histogram_data
size_t spdk_bdev_get_media_events(struct spdk_bdev_desc *bdev_desc,
struct spdk_bdev_media_event *events, size_t max_events);

enum spdk_bdev_capability_type {
/** Bdev module doesn't read or modify data buffer passed in IO request */
SPDK_BDEV_CAP_DATA_PASSTHRU = 1u << 0u,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description is not correct here. We use it to determine whether bdev supports IOs with mkey extended opt.
And the name should be changed.
Now I don't see any relation between this bdev capability and extended IO opts introduced in the next commits

spdk_nvme_cmd_cb cb_fn, void *cb_arg, uint32_t io_flags,
spdk_nvme_req_reset_sgl_cb reset_sgl_fn,
spdk_nvme_req_next_sge_cb next_sge_fn, void *metadata,
uint16_t apptag_mask, uint16_t apptag,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move apptag_mask, apptag and io_flags to ext_opts structure

The new API spdk_bdev_get_caps returns capabilities
specific for bdev module.

Change-Id: Ic9f42eff59bdc4c8c6e73deb76b3eecfc04f80a8
Signed-off-by: Alexey Marchuk <alexeymar@mellanox.com>
New functions accept extedable structure of IO options

Change-Id: If6864df151a3c0ad722785cb26d1f5d4309cd733
Signed-off-by: Alexey Marchuk <alexeymar@mellanox.com>
These functions accept extendable structure with IO request options.
The options structure contains a callback to get a memory key per
Io request. This callback is used in RDMA transport.

Change-Id: I65bfba279904e77539348520c3dfac7aadbe80d9
Signed-off-by: Alexey Marchuk <alexeymar@mellanox.com>
The new API is used if flags is not zero.

Change-Id: I414b5d19bff54114d6708efed89ba19b5955f56a
Signed-off-by: Alexey Marchuk <alexeymar@mellanox.com>
* \param caps Capabilities of Block device to be filled by this function
* \return 0 on success, negated errno on failure.
*/
int spdk_bdev_get_caps(struct spdk_bdev *bdev, struct spdk_bdev_capability *caps);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to
spdk_bdev_get_ext_caps

/** Bdev supports indirect memory access using Memory Key.
* That means that the user of ext bdev API can fill spdk_bdev_ext_io_opts_mem_type
* structure and set SPDK_BDEV_EXT_IO_OPTS_MEM_TYPE flag in spdk_bdev_ext_io_opts structure */
SPDK_BDEV_CAP_EXT_MEMORY_TYPE_MKEY = 1u << 0u,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/** Bdev supports indirect memory access using Memory Key.

  • That means that the user of ext bdev API can fill spdk_bdev_ext_io_opts_mem_type
  • structure and set SPDK_BDEV_EXT_IO_OPTS_MEM_TYPE flag in spdk_bdev_ext_io_opts structure
  • That also means that bdev can work with regular memory buffers */

@@ -222,6 +222,9 @@ struct spdk_bdev_fn_table {

/** Get bdev module context. */
void *(*get_module_ctx)(void *ctx);

/** Get block device capabilities */
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extended capabilities

struct vbdev_delay *delay_node = (struct vbdev_delay *)ctx;

if (delay_node->base_bdev->fn_table->get_caps) {
delay_node->base_bdev->fn_table->get_caps(delay_node->base_bdev, caps);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uint64_t local_flags = 0;

if (caps->flags & SPDK_BDEV_CAP_EXT_MEMORY_TYPE_MKEY) {
/* Delay bdev doesn't modify data so it can work with indirect memory if it is supported by underlying bdev */
local_flags |= SPDK_BDEV_CAP_EXT_MEMORY_TYPE_MKEY
}
caps->flags = local_flags;

compress/crypto:
uint64_t local_flags = 0;

@AlekseyMarchuk
Copy link
Author

  1. bdev in spdk can work with mkey - bdev_nvme over RDMA
    return caps with MKEY bit

  2. bdev can work with mkey but this bdev is not part of spdk (e.g. alibaba pangu)
    aware of SNAP - set MKEY bit
    otherise - do not set bit

  3. vbdev in spdk modifies data (vbdev_compress)
    default - get_caps cb is not implemented
    we can update all vbdevs and set correct bits

  4. vbdev out of spdk that touches data
    default - get_caps cb is not implemented

  5. vbdev raid0 - doesn't modify data

  6. lvol management (proprietary)

  7. proprietary vbdev that doesn't modify data but it is desgined for snap (aware of cross gvmi)

*/
struct spdk_bdev_ext_io_opts {
/** Combination of bits defined in \b enum spdk_bdev_ext_io_opts_flags */
uint64_t flags;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flags -> comp_mask

* Callback used to get a Memory Key per IO request
*
* pd is input parameter and should point to a memory domain
* mkey is an output value
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comments for other arguments

* pd is input parameter and should point to a memory domain
* mkey is an output value
*/
typedef int (*spdk_bdev_io_get_mkey)(void *cb_arg, void *address, size_t length, void *pd,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use forward declaration of ibv_pd structure

* mkey is an output value
*/
typedef int (*spdk_bdev_io_get_mkey)(void *cb_arg, void *address, size_t length, void *pd,
uint32_t *mkey);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return 2 keys - local and remote?
Ask if we need 2 keys

enum spdk_nvme_ns_cmd_ext_io_opts_mem_types type;
union {
struct {
spdk_nvme_ns_cmd_io_get_mkey get_mkey_cb;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add void *cb_arg

Copy link
Author

@AlekseyMarchuk AlekseyMarchuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants