bdev: Factor out md initialization with bounce buffer
Move part of function _bdev_io_set_buf which sets metadata pointer to another function _bdev_io_set_md_buf Next patches will make copying of bounce buffer async, metadata will be copied when data copy completes. This patch makes next change simpler Signed-off-by: Alexey Marchuk <alexeymar@mellanox.com> Change-Id: Iced45393f43f9c5a4818e4e9eadb3351583e0c00 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11518 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
0ae7f4d816
commit
52d1cb5003
@ -881,12 +881,36 @@ _bdev_io_set_bounce_md_buf(struct spdk_bdev_io *bdev_io, void *md_buf, size_t le
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_bdev_io_set_md_buf(struct spdk_bdev_io *bdev_io)
|
||||
{
|
||||
struct spdk_bdev *bdev = bdev_io->bdev;
|
||||
uint64_t md_len;
|
||||
void *buf;
|
||||
|
||||
if (spdk_bdev_is_md_separate(bdev)) {
|
||||
buf = (char *)bdev_io->u.bdev.iovs[0].iov_base + bdev_io->u.bdev.iovs[0].iov_len;
|
||||
md_len = bdev_io->u.bdev.num_blocks * bdev->md_len;
|
||||
|
||||
assert(((uintptr_t)buf & (spdk_bdev_get_buf_align(bdev) - 1)) == 0);
|
||||
|
||||
if (bdev_io->u.bdev.md_buf != NULL) {
|
||||
_bdev_io_set_bounce_md_buf(bdev_io, buf, md_len);
|
||||
return;
|
||||
} else {
|
||||
spdk_bdev_io_set_md_buf(bdev_io, buf, md_len);
|
||||
}
|
||||
}
|
||||
|
||||
bdev_io_get_buf_complete(bdev_io, true);
|
||||
}
|
||||
|
||||
static void
|
||||
_bdev_io_set_buf(struct spdk_bdev_io *bdev_io, void *buf, uint64_t len)
|
||||
{
|
||||
struct spdk_bdev *bdev = bdev_io->bdev;
|
||||
bool buf_allocated;
|
||||
uint64_t md_len, alignment;
|
||||
uint64_t alignment;
|
||||
void *aligned_buf;
|
||||
|
||||
bdev_io->internal.buf = buf;
|
||||
@ -906,19 +930,7 @@ _bdev_io_set_buf(struct spdk_bdev_io *bdev_io, void *buf, uint64_t len)
|
||||
spdk_bdev_io_set_buf(bdev_io, aligned_buf, len);
|
||||
}
|
||||
|
||||
if (spdk_bdev_is_md_separate(bdev)) {
|
||||
aligned_buf = (char *)aligned_buf + len;
|
||||
md_len = bdev_io->u.bdev.num_blocks * bdev->md_len;
|
||||
|
||||
assert(((uintptr_t)aligned_buf & (alignment - 1)) == 0);
|
||||
|
||||
if (bdev_io->u.bdev.md_buf != NULL) {
|
||||
_bdev_io_set_bounce_md_buf(bdev_io, aligned_buf, md_len);
|
||||
} else {
|
||||
spdk_bdev_io_set_md_buf(bdev_io, aligned_buf, md_len);
|
||||
}
|
||||
}
|
||||
bdev_io_get_buf_complete(bdev_io, true);
|
||||
_bdev_io_set_md_buf(bdev_io);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user