lib/ublk: use page aligned data buffer
Kernel `ublk_drv` driver will do memcpy to this data buffer in unit of page size, for a simple 4KiB I/O, it may call memcpy twice if the data buffer isn't page aligned. Moreover, SPDK may also has double buffers with this case, so here, we use page aligned data buffer at initialization. Change-Id: Ica86a9702283327a2bb491e38990b8c00bc77f57 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17283 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
26037aa3b0
commit
e641e8f3f6
@ -65,6 +65,7 @@ __attribute__((unused)) = {
|
|||||||
|
|
||||||
struct ublk_io {
|
struct ublk_io {
|
||||||
void *payload;
|
void *payload;
|
||||||
|
void *mpool_entry;
|
||||||
uint32_t payload_size;
|
uint32_t payload_size;
|
||||||
uint32_t cmd_op;
|
uint32_t cmd_op;
|
||||||
int32_t result;
|
int32_t result;
|
||||||
@ -1262,8 +1263,7 @@ ublk_ios_fini(struct spdk_ublk_dev *ublk)
|
|||||||
|
|
||||||
for (i = 0; i < q->q_depth; i++) {
|
for (i = 0; i < q->q_depth; i++) {
|
||||||
if (q->ios[i].payload) {
|
if (q->ios[i].payload) {
|
||||||
spdk_mempool_put(ublk->io_buf_pool, q->ios[i].payload);
|
spdk_mempool_put(ublk->io_buf_pool, q->ios[i].mpool_entry);
|
||||||
q->ios[i].payload = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(q->ios);
|
free(q->ios);
|
||||||
@ -1286,8 +1286,8 @@ ublk_ios_init(struct spdk_ublk_dev *ublk)
|
|||||||
/* Create a mempool to allocate buf for each io */
|
/* Create a mempool to allocate buf for each io */
|
||||||
ublk->io_buf_pool = spdk_mempool_create(mempool_name,
|
ublk->io_buf_pool = spdk_mempool_create(mempool_name,
|
||||||
ublk->num_queues * ublk->queue_depth,
|
ublk->num_queues * ublk->queue_depth,
|
||||||
UBLK_IO_MAX_BYTES,
|
UBLK_IO_MAX_BYTES + 4096,
|
||||||
0,
|
SPDK_MEMPOOL_DEFAULT_CACHE_SIZE,
|
||||||
SPDK_ENV_SOCKET_ID_ANY);
|
SPDK_ENV_SOCKET_ID_ANY);
|
||||||
if (ublk->io_buf_pool == NULL) {
|
if (ublk->io_buf_pool == NULL) {
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
@ -1311,7 +1311,9 @@ ublk_ios_init(struct spdk_ublk_dev *ublk)
|
|||||||
}
|
}
|
||||||
for (j = 0; j < q->q_depth; j++) {
|
for (j = 0; j < q->q_depth; j++) {
|
||||||
q->ios[j].q = q;
|
q->ios[j].q = q;
|
||||||
q->ios[j].payload = spdk_mempool_get(ublk->io_buf_pool);
|
q->ios[j].mpool_entry = spdk_mempool_get(ublk->io_buf_pool);
|
||||||
|
q->ios[j].payload = (void *)(uintptr_t)SPDK_ALIGN_CEIL((uint64_t)(uintptr_t)q->ios[j].mpool_entry,
|
||||||
|
4096ULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user