-
Notifications
You must be signed in to change notification settings - Fork 15
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
base: upstream_master
Are you sure you want to change the base?
Bdev ext api #36
Conversation
include/spdk/bdev.h
Outdated
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 |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) { \ |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
include/spdk/bdev.h
Outdated
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; |
There was a problem hiding this comment.
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.
include/spdk/bdev.h
Outdated
@@ -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, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 <[email protected]>
New functions accept extedable structure of IO options Change-Id: If6864df151a3c0ad722785cb26d1f5d4309cd733 Signed-off-by: Alexey Marchuk <[email protected]>
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 <[email protected]>
The new API is used if flags is not zero. Change-Id: I414b5d19bff54114d6708efed89ba19b5955f56a Signed-off-by: Alexey Marchuk <[email protected]>
9c31a76
to
130167c
Compare
* \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); |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 */ |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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;
|
*/ | ||
struct spdk_bdev_ext_io_opts { | ||
/** Combination of bits defined in \b enum spdk_bdev_ext_io_opts_flags */ | ||
uint64_t flags; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add void *cb_arg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1
No description provided.