From 68eb7487599aef66506fcf1235f57a428be18d6c Mon Sep 17 00:00:00 2001 From: andypma Date: Fri, 15 Jan 2021 17:16:30 +0800 Subject: [PATCH] vhost/compat: add RTE_VHOST_USER_ASYNC_COPY flag when used IOVA_PA mode Recently, we discovered that under the SPDK + UIO mode, it is possible that vm may be wrong when doing io. such as: [root@VM_6_151_centos ~]# mkfs.xfs /dev/vdc meta-data=/dev/vdc isize=512 agcount=4, agsize=234421142 blks = sectsz=4096 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=937684566, imaxpct=5 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=457853, version=2 = sectsz=4096 sunit=1 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 bad magic number bad magic number Metadata corruption detected at xfs_sb block 0x0/0x1000 libxfs_writebufr: write verifer failed on xfs_sb bno 0x0/0x1000 the github issue link: https://github.com/spdk/spdk/issues/1738 After investigation, we found as below: The qemu set to VHOST_USER_SET_MEM_TABLE then call vhost_user_set_mem_table(dpdk version spdk-20.11)->mmap(without MAP_POPULATE) the mmap will only return the virtual address not map the virtual address to the physical address actually. after call vtophys_notify->vtophys_get_paddr_pagemap, we will get a wrong physical(the virtual address we not access) So this patch is to set MAP_POPULATE during we use SPDK + UIO. Signed-off-by: andypma Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5970 (master) (cherry picked from commit 7741de6b7d8de653a7ca8d104a5cf022072fee8e) Change-Id: Ib921b6d7381f46bb5894ed787cef52e02524197a Signed-off-by: Tomasz Zawadzki Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6182 Reviewed-by: Jim Harris Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins --- lib/vhost/rte_vhost_compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vhost/rte_vhost_compat.c b/lib/vhost/rte_vhost_compat.c index e1747cc12..85cce3dc9 100644 --- a/lib/vhost/rte_vhost_compat.c +++ b/lib/vhost/rte_vhost_compat.c @@ -331,7 +331,7 @@ vhost_register_unix_socket(const char *path, const char *ctrl_name, } } - if (rte_vhost_driver_register(path, 0) != 0) { + if (rte_vhost_driver_register(path, RTE_VHOST_USER_ASYNC_COPY) != 0) { SPDK_ERRLOG("Could not register controller %s with vhost library\n", ctrl_name); SPDK_ERRLOG("Check if domain socket %s already exists\n", path); return -EIO;