+5
−0
+7
−6
+24
−9
+23
−9
Loading
Fixes #3610. Consider a case when zero-copy with some threshold is enabled. For some large requests we can run into calling sendmsg multiple times. If the last chunk was sent without MSG_ZEROCOPY (the threshold was not met), but some previous chunks were sent with it, then we don't wait for the zero-copy completion from the kernel and complete the socket request prematurely. This can lead, for example, to data integrity issues when the upper layer reuses buffers soon enough. To fix it, we need to make zcopy flag active until the notification is received. It may happen several sendmsg calls later, so cache the index of the last zcopy chunk for a given req in new zcopy_idx field (note this new field breaks ABI). However, such solution creates a new bug, consider a case: 1. Upper layer calls spdk_sock_flush, we have some chunk of a request sent with zcopy. 2. We call flush again, in the meantime zcopy notification arrived, but we don't check it, because the request is not on the pending list. 3. We call sendmsg with the last chunk of the request, without zcopy. The req could be completed now, but we ignored the notification, so we can't, because pending_zcopy flag is still active. To fix it, clear the flag in check_zcopy for the first queued request (the only possible partial one) by checking with the last index (partial request should have last index). This way if next flush will send last chunk, it should be completed. Add two new unit tests for these cases. Signed-off-by:Maciej Szulik <maciej.szulik@intel.com> Change-Id: I6d8b96e8b9d49a860a48ddaebce4ee62437a20ba Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/25645 Reviewed-by:
Jacek Kalwas <jacek.kalwas@nutanix.com> Tested-by:
SPDK Automated Test System <spdkbot@gmail.com> Reviewed-by:
Aleksey Marchuk <alexeymar@nvidia.com> Reviewed-by:
Konrad Sztyber <ksztyber@nvidia.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>