Skip to content

Commit d45818b

Browse files
committed
Merge PR ceph#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 <[email protected]> Reviewed-by: Milind Changire <[email protected]> Reviewed-by: Frank S. Filz <[email protected]>
2 parents 23443d3 + f78549d commit d45818b

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

.githubmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,4 @@ baergj Joshua Baergen <[email protected]>
176176
zmc Zack Cerza <[email protected]>
177177
robbat2 Robin H. Johnson <[email protected]>
178178
leonid-s-usov Leonid Usov <[email protected]>
179+
ffilz Frank S. Filz <[email protected]>

src/client/Client.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11269,7 +11269,7 @@ int64_t Client::_preadv_pwritev_locked(Fh *fh, const struct iovec *iov,
1126911269
}
1127011270

1127111271
client_lock.unlock();
11272-
copy_bufferlist_to_iovec(iov, iovcnt, &bl, r);
11272+
copy_bufferlist_to_iovec(iov, iovcnt, blp ? blp : &bl, r);
1127311273
client_lock.lock();
1127411274
return r;
1127511275
}

src/test/client/nonblocking.cc

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,62 @@ TEST_F(TestClient, LlreadvLlwritev) {
149149
ASSERT_EQ(0, client->ll_unlink(root, filename, myperm));
150150
}
151151

152+
TEST_F(TestClient, LlreadvLlwritevNullContext) {
153+
/* Test that if Client::ll_preadv_pwritev is called with nullptr context
154+
then it performs a sync call. */
155+
156+
int mypid = getpid();
157+
char filename[256];
158+
159+
client->unmount();
160+
TearDown();
161+
SetUp();
162+
163+
sprintf(filename, "test_llreadvllwritevnullcontextfile%u", mypid);
164+
165+
Inode *root, *file;
166+
root = client->get_root();
167+
ASSERT_NE(root, (Inode *)NULL);
168+
169+
Fh *fh;
170+
struct ceph_statx stx;
171+
172+
ASSERT_EQ(0, client->ll_createx(root, filename, 0666,
173+
O_RDWR | O_CREAT | O_TRUNC,
174+
&file, &fh, &stx, 0, 0, myperm));
175+
176+
char out0[] = "hello ";
177+
char out1[] = "world\n";
178+
struct iovec iov_out[2] = {
179+
{out0, sizeof(out0)},
180+
{out1, sizeof(out1)}
181+
};
182+
183+
char in0[sizeof(out0)];
184+
char in1[sizeof(out1)];
185+
struct iovec iov_in[2] = {
186+
{in0, sizeof(in0)},
187+
{in1, sizeof(in1)}
188+
};
189+
190+
ssize_t bytes_to_write = iov_out[0].iov_len + iov_out[1].iov_len;
191+
192+
int64_t rc;
193+
bufferlist bl;
194+
rc = client->ll_preadv_pwritev(fh, iov_out, 2, 0, true, nullptr, nullptr);
195+
ASSERT_EQ(rc, bytes_to_write);
196+
197+
rc = client->ll_preadv_pwritev(fh, iov_in, 2, 0, false, nullptr, &bl);
198+
ASSERT_EQ(rc, bytes_to_write);
199+
200+
copy_bufferlist_to_iovec(iov_in, 2, &bl, rc);
201+
ASSERT_EQ(0, strncmp((const char*)iov_in[0].iov_base,
202+
(const char*)iov_out[0].iov_base,
203+
iov_out[0].iov_len));
204+
ASSERT_EQ(0, strncmp((const char*)iov_in[1].iov_base,
205+
(const char*)iov_out[1].iov_base,
206+
iov_out[1].iov_len));
207+
208+
client->ll_release(fh);
209+
ASSERT_EQ(0, client->ll_unlink(root, filename, myperm));
210+
}

0 commit comments

Comments
 (0)