RDMA WRITE:ibv_wc.byte_len 与我尝试写入的内容不匹配

RDMA WRITE: ibv_wc.byte_len does not match what I try to write

我是 Infiniband/RDMA 新手,在 Mellanox Infiniband 硬件上玩 RDMA。我使用了源代码here。乍一看程序运行正常:服务器使用 RDMA_WRITE 操作向客户端内存写入一些字节。但是,后来我发现写入完成结构(ibv_wc)指示的传输字节数与我放入ibv_send_wr结构的数据量不匹配。这是 rdma_write() 中 ibv_send_wr 初始化的代码:

ctx->sge_list.addr = (uintptr_t)ctx->buf;
ctx->sge_list.length = ctx->size; //which is 65536
ctx->sge_list.lkey = ctx->mr->lkey;
ctx->wr.wr.rdma.remote_addr = data->remote_connection->vaddr;
ctx->wr.wr_id = RDMA_WRID;
ctx->wr.sg_list = &ctx->sge_list;
ctx->wr_num_sge = 1;
ctx->wr.opcode = IBV_WR_RDMA_WRITE;
ctx->wr.send_flags = IBV_SEND_SIGNALED;
ctx->wr.next = NULL;

然后我在写完成队列中得到一个写完成条目后读取ibv_wc.byte_len。它显示随机数:32537、32743、32533。我假设传输成功,因为 ibv_wc.status 等于 IBV_WC_SUCCESS。我是不是做错了什么?

根据 ibv_poll_cq() page at RDMAMojo 博客,byte_len 字段仅对一小部分操作有效,因此在您对发送队列执行 RDMA 写入操作的情况下,它未初始化。

byte_len: The number of bytes transferred. Relevant if the Receive Queue for incoming Send or RDMA Write with immediate operations. This value doesn't include the length of the immediate data, if such exists. Relevant in the Send Queue for RDMA Read and Atomic operations.