Commit 59d6f047 authored by Ziye Yang's avatar Ziye Yang Committed by Daniel Verkamp
Browse files

nbd: fix bdev alignment issue



When using AIO as the real device of /dev/nbd, we
fail the test due to the alignment issue

Change-Id: I608dfdad1e0cac0beaf438c7a1f115c2d1a9f943
Signed-off-by: default avatarZiye Yang <optimistyzy@gmail.com>
Reviewed-on: https://review.gerrithub.io/370233


Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent b98569fd
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -46,6 +46,14 @@
static char *g_bdev_name;
static char *g_nbd_name = "/dev/nbd0";

/*
 * Used to determine how the I/O buffers should be aligned.
 *  This alignment will be bumped up for blockdevs that
 *  require alignment based on block length - for example,
 *  AIO blockdevs.
 */
static size_t g_min_alignment = 64;

#include "../common.c"

struct nbd_io {
@@ -213,7 +221,7 @@ process_request(struct nbd_disk *nbd)

	io->payload_size = from_be32(&io->req.len);
	spdk_dma_free(io->payload);
	io->payload = spdk_dma_malloc(io->payload_size, 64, NULL);
	io->payload = spdk_dma_malloc(io->payload_size, g_min_alignment, NULL);
	if (io->payload == NULL) {
		SPDK_ERRLOG("could not allocate io->payload of size %d\n", io->payload_size);
		spdk_app_stop(-1);
@@ -365,6 +373,7 @@ nbd_start(void *arg1, void *arg2)
	}

	g_nbd_disk.bdev = bdev;
	g_min_alignment = spdk_max(g_min_alignment, spdk_bdev_get_buf_align(bdev));
	g_nbd_disk.ch = spdk_bdev_get_io_channel(g_nbd_disk.bdev_desc);

	rc = socketpair(AF_UNIX, SOCK_STREAM, 0, sp);