Commit 7741de6b authored by andypma's avatar andypma Committed by Tomasz Zawadzki
Browse files

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: default avatarandypma <andypma@tencent.com>
Reviewed-by: default avatarZhigang Lu <tonnylu@tencent.com>
Reviewed-by: default avatarXun Ni <richardni@tencent.com>
Reviewed-by: default avatarYuZhoujian <windyu@tencent.com>
Reviewed-by: default avatarLuWeiKang <luweikang@tencent.com>
Change-Id: Ib921b6d7381f46bb5894ed787cef52e02524197a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5970


Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarZiye Yang <ziye.yang@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 3b673b84
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;