mirror of
https://github.com/ceph/ceph
synced 2024-12-24 20:33:27 +00:00
Merge PR #54808 into main
* refs/pull/54808/head: client: fix copying bufferlist to iovec structures in Client::_read src/test: test sync call providing nullptr as ctx to async api Reviewed-by: Venky Shankar <vshankar@redhat.com> Reviewed-by: Milind Changire <mchangir@redhat.com> Reviewed-by: Frank S. Filz <ffilzlnx@mindspring.com>
This commit is contained in:
commit
d45818bce9
@ -176,3 +176,4 @@ baergj Joshua Baergen <jbaergen@digitalocean.com>
|
||||
zmc Zack Cerza <zack@redhat.com>
|
||||
robbat2 Robin H. Johnson <robbat2@orbis-terrarum.net>
|
||||
leonid-s-usov Leonid Usov <leonid.usov@ibm.com>
|
||||
ffilz Frank S. Filz <ffilzlnx@mindspring.com>
|
||||
|
@ -11269,7 +11269,7 @@ int64_t Client::_preadv_pwritev_locked(Fh *fh, const struct iovec *iov,
|
||||
}
|
||||
|
||||
client_lock.unlock();
|
||||
copy_bufferlist_to_iovec(iov, iovcnt, &bl, r);
|
||||
copy_bufferlist_to_iovec(iov, iovcnt, blp ? blp : &bl, r);
|
||||
client_lock.lock();
|
||||
return r;
|
||||
}
|
||||
|
@ -149,3 +149,62 @@ TEST_F(TestClient, LlreadvLlwritev) {
|
||||
ASSERT_EQ(0, client->ll_unlink(root, filename, myperm));
|
||||
}
|
||||
|
||||
TEST_F(TestClient, LlreadvLlwritevNullContext) {
|
||||
/* Test that if Client::ll_preadv_pwritev is called with nullptr context
|
||||
then it performs a sync call. */
|
||||
|
||||
int mypid = getpid();
|
||||
char filename[256];
|
||||
|
||||
client->unmount();
|
||||
TearDown();
|
||||
SetUp();
|
||||
|
||||
sprintf(filename, "test_llreadvllwritevnullcontextfile%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 out0[] = "hello ";
|
||||
char out1[] = "world\n";
|
||||
struct iovec iov_out[2] = {
|
||||
{out0, sizeof(out0)},
|
||||
{out1, sizeof(out1)}
|
||||
};
|
||||
|
||||
char in0[sizeof(out0)];
|
||||
char in1[sizeof(out1)];
|
||||
struct iovec iov_in[2] = {
|
||||
{in0, sizeof(in0)},
|
||||
{in1, sizeof(in1)}
|
||||
};
|
||||
|
||||
ssize_t bytes_to_write = iov_out[0].iov_len + iov_out[1].iov_len;
|
||||
|
||||
int64_t rc;
|
||||
bufferlist bl;
|
||||
rc = client->ll_preadv_pwritev(fh, iov_out, 2, 0, true, nullptr, nullptr);
|
||||
ASSERT_EQ(rc, bytes_to_write);
|
||||
|
||||
rc = client->ll_preadv_pwritev(fh, iov_in, 2, 0, false, nullptr, &bl);
|
||||
ASSERT_EQ(rc, bytes_to_write);
|
||||
|
||||
copy_bufferlist_to_iovec(iov_in, 2, &bl, rc);
|
||||
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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user