From: Dhairya Parmar Date: Thu, 7 Dec 2023 17:47:20 +0000 (+0530) Subject: src/test: test zero bytes async i/o X-Git-Tag: v19.3.0~24^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ab8462443fc2831bc24df4822749bd289be6aacf;p=ceph.git src/test: test zero bytes async i/o Fixes: https://tracker.ceph.com/issues/63734 Signed-off-by: Dhairya Parmar --- diff --git a/src/test/client/nonblocking.cc b/src/test/client/nonblocking.cc index 1ea7c61bf89a..427bf0723ab7 100644 --- a/src/test/client/nonblocking.cc +++ b/src/test/client/nonblocking.cc @@ -457,3 +457,73 @@ TEST_F(TestClient, LlreadvLlwritevNegativeIOVCount) { client->ll_release(fh); ASSERT_EQ(0, client->ll_unlink(root, filename, myperm)); } + +TEST_F(TestClient, LlreadvLlwritevZeroBytes) { + /* Test async i/o with empty input/output buffers*/ + + int mypid = getpid(); + char filename[256]; + + client->unmount(); + TearDown(); + SetUp(); + + sprintf(filename, "test_llreadvllwritevzerobytesfile%u", mypid); + + Inode *root, *file; + root = client->get_root(); + ASSERT_NE(root, (Inode *)NULL); + + Fh *fh; + struct ceph_statx stx; + + ASSERT_EQ(0, client->ll_createx(root, filename, 0666, + O_RDWR | O_CREAT | O_TRUNC, + &file, &fh, &stx, 0, 0, myperm)); + + char out_empty_buf_0[0]; + char out_empty_buf_1[0]; + struct iovec iov_out[2] = { + {out_empty_buf_0, sizeof(out_empty_buf_0)}, + {out_empty_buf_1, sizeof(out_empty_buf_1)} + }; + + char in_empty_buf_0[sizeof(out_empty_buf_0)]; + char in_empty_buf_1[sizeof(out_empty_buf_1)]; + struct iovec iov_in[2] = { + {in_empty_buf_0, sizeof(in_empty_buf_0)}, + {in_empty_buf_1, sizeof(in_empty_buf_1)} + }; + + std::unique_ptr writefinish = nullptr; + std::unique_ptr readfinish = nullptr; + + writefinish.reset(new C_SaferCond("test-nonblocking-writefinish-zero-bytes")); + readfinish.reset(new C_SaferCond("test-nonblocking-readfinish-zero-bytes")); + + int64_t rc; + bufferlist bl; + + rc = client->ll_preadv_pwritev(fh, iov_out, 2, 0, true, writefinish.get(), + nullptr); + ASSERT_EQ(rc, 0); + ssize_t bytes_written = writefinish->wait(); + ASSERT_EQ(bytes_written, -CEPHFS_EINVAL); + + rc = client->ll_preadv_pwritev(fh, iov_in, 2, 0, false, readfinish.get(), + &bl); + ASSERT_EQ(rc, 0); + ssize_t bytes_read = readfinish->wait(); + ASSERT_EQ(bytes_read, 0); + + copy_bufferlist_to_iovec(iov_in, 2, &bl, bytes_read); + ASSERT_EQ(0, strncmp((const char*)iov_in[0].iov_base, + (const char*)iov_out[0].iov_base, + iov_out[0].iov_len)); + ASSERT_EQ(0, strncmp((const char*)iov_in[1].iov_base, + (const char*)iov_out[1].iov_base, + iov_out[1].iov_len)); + + client->ll_release(fh); + ASSERT_EQ(0, client->ll_unlink(root, filename, myperm)); +} \ No newline at end of file