From 598ba408a272a2ff6cbe2cbc0c97d3f6c481b6f7 Mon Sep 17 00:00:00 2001 From: lorneli Date: Sun, 28 Apr 2019 23:33:37 +0800 Subject: [PATCH] bdev: add test case for splitting iovs that exceeds child_iov Test multi vector command that needs to be split by strip and then needs to be split further due to the capacity of child iovs. Add a case that was not tested before. In this case, the length of the rest of iovec array with an I/O boundary is the multiple of block size. Expect the rest of iovec array to be submitted in the completion of previous iovec array. Change-Id: I5b95b1f1884a73b31709b2fd9187a8a9e9b2cd0b Signed-off-by: lorneli Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452414 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Ziye Yang Reviewed-by: Shuhei Matsumoto Reviewed-by: Darek Stojaczyk --- test/unit/lib/bdev/bdev.c/bdev_ut.c | 63 +++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/test/unit/lib/bdev/bdev.c/bdev_ut.c b/test/unit/lib/bdev/bdev.c/bdev_ut.c index 71db10756..961bb1ad0 100644 --- a/test/unit/lib/bdev/bdev.c/bdev_ut.c +++ b/test/unit/lib/bdev/bdev.c/bdev_ut.c @@ -1016,6 +1016,69 @@ bdev_io_split(void) CU_ASSERT(g_io_done == true); CU_ASSERT(g_bdev_ut_channel->outstanding_io_count == 0); + /* Test multi vector command that needs to be split by strip and then needs to be + * split further due to the capacity of child iovs. In this case, the length of + * the rest of iovec array with an I/O boundary is the multiple of block size. + */ + + /* Fill iovec array for exactly one boundary. The iovec cnt for this boundary + * is BDEV_IO_NUM_CHILD_IOV + 1, which exceeds the capacity of child iovs. + */ + for (i = 0; i < BDEV_IO_NUM_CHILD_IOV - 2; i++) { + iov[i].iov_base = (void *)((i + 1) * 0x10000); + iov[i].iov_len = 512; + } + for (i = BDEV_IO_NUM_CHILD_IOV - 2; i < BDEV_IO_NUM_CHILD_IOV; i++) { + iov[i].iov_base = (void *)((i + 1) * 0x10000); + iov[i].iov_len = 256; + } + iov[BDEV_IO_NUM_CHILD_IOV].iov_base = (void *)((BDEV_IO_NUM_CHILD_IOV + 1) * 0x10000); + iov[BDEV_IO_NUM_CHILD_IOV].iov_len = 512; + + /* Add an extra iovec to trigger split */ + iov[BDEV_IO_NUM_CHILD_IOV + 1].iov_base = (void *)((BDEV_IO_NUM_CHILD_IOV + 2) * 0x10000); + iov[BDEV_IO_NUM_CHILD_IOV + 1].iov_len = 512; + + bdev->optimal_io_boundary = BDEV_IO_NUM_CHILD_IOV; + g_io_done = false; + expected_io = ut_alloc_expected_io(SPDK_BDEV_IO_TYPE_READ, 0, + BDEV_IO_NUM_CHILD_IOV - 1, BDEV_IO_NUM_CHILD_IOV); + for (i = 0; i < BDEV_IO_NUM_CHILD_IOV - 2; i++) { + ut_expected_io_set_iov(expected_io, i, + (void *)((i + 1) * 0x10000), 512); + } + for (i = BDEV_IO_NUM_CHILD_IOV - 2; i < BDEV_IO_NUM_CHILD_IOV; i++) { + ut_expected_io_set_iov(expected_io, i, + (void *)((i + 1) * 0x10000), 256); + } + TAILQ_INSERT_TAIL(&g_bdev_ut_channel->expected_io, expected_io, link); + + expected_io = ut_alloc_expected_io(SPDK_BDEV_IO_TYPE_READ, BDEV_IO_NUM_CHILD_IOV - 1, + 1, 1); + ut_expected_io_set_iov(expected_io, 0, + (void *)((BDEV_IO_NUM_CHILD_IOV + 1) * 0x10000), 512); + TAILQ_INSERT_TAIL(&g_bdev_ut_channel->expected_io, expected_io, link); + + expected_io = ut_alloc_expected_io(SPDK_BDEV_IO_TYPE_READ, BDEV_IO_NUM_CHILD_IOV, + 1, 1); + ut_expected_io_set_iov(expected_io, 0, + (void *)((BDEV_IO_NUM_CHILD_IOV + 2) * 0x10000), 512); + TAILQ_INSERT_TAIL(&g_bdev_ut_channel->expected_io, expected_io, link); + + rc = spdk_bdev_readv_blocks(desc, io_ch, iov, BDEV_IO_NUM_CHILD_IOV + 2, 0, + BDEV_IO_NUM_CHILD_IOV + 1, io_done, NULL); + CU_ASSERT(rc == 0); + CU_ASSERT(g_io_done == false); + + CU_ASSERT(g_bdev_ut_channel->outstanding_io_count == 1); + stub_complete_io(1); + CU_ASSERT(g_io_done == false); + + CU_ASSERT(g_bdev_ut_channel->outstanding_io_count == 2); + stub_complete_io(2); + CU_ASSERT(g_io_done == true); + CU_ASSERT(g_bdev_ut_channel->outstanding_io_count == 0); + /* Test multi vector command that needs to be split by strip and then needs to be * split further due to the capacity of child iovs, but fails to split. The cause * of failure of split is that the length of an iovec is not multiple of block size.