#if defined(__linux__) && defined(O_PATH)
if (fh->flags & O_PATH)
- return -CEPHFS_EBADF;
+ return -EBADF;
#endif
if(iovcnt < 0) {
- return -CEPHFS_EINVAL;
+ return -EINVAL;
}
- loff_t totallen = 0;
+ size_t totallen = 0;
for (int i = 0; i < iovcnt; i++) {
totallen += iov[i].iov_len;
}
std::scoped_lock cl(client_lock);
if (fh == NULL || !_ll_fh_exists(fh)) {
ldout(cct, 3) << "(fh)" << fh << " is invalid" << dendl;
- return -CEPHFS_EBADF;
+ return -EBADF;
}
- return _preadv_pwritev_locked(fh, iov, iovcnt, off, true, false);
+ return _preadv_pwritev_locked(fh, iov, iovcnt, off, true, true);
}
int64_t Client::ll_readv(struct Fh *fh, const struct iovec *iov, int iovcnt, int64_t off)
std::scoped_lock cl(client_lock);
if (fh == NULL || !_ll_fh_exists(fh)) {
ldout(cct, 3) << "(fh)" << fh << " is invalid" << dendl;
- return -CEPHFS_EBADF;
+ return -EBADF;
}
- return _preadv_pwritev_locked(fh, iov, iovcnt, off, false, false);
+ return _preadv_pwritev_locked(fh, iov, iovcnt, off, false, true);
}
int64_t Client::ll_preadv_pwritev(struct Fh *fh, const struct iovec *iov,
ASSERT_EQ(0, client->ll_unlink(root, filename, myperm));
rc = client->ll_writev(fh, iov_out, 2, 0);
- ASSERT_EQ(rc, -CEPHFS_EBADF);
+ ASSERT_EQ(rc, -EBADF);
rc = client->ll_readv(fh, iov_in, 2, 0);
- ASSERT_EQ(rc, -CEPHFS_EBADF);
+ ASSERT_EQ(rc, -EBADF);
}
+
+ TEST_F(TestClient, LlreadvLlwritevLargeBuffersSync) {
+ /* Test that sync I/O code paths handle large buffers (total len >= 4GiB)*/
+ int mypid = getpid();
+ char filename[256];
+
+ client->unmount();
+ TearDown();
+ SetUp();
+
+ sprintf(filename, "test_llreadvllwritevlargebufferssync%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));
+
+ struct statvfs stbuf;
+ int64_t rc;
+ const size_t BUFSIZE = (size_t)INT_MAX + 1;
+ rc = client->ll_statfs(root, &stbuf, myperm);
+ ASSERT_EQ(rc, 0);
+ int64_t fs_available_space = stbuf.f_bfree * stbuf.f_bsize;
+ ASSERT_GT(fs_available_space, BUFSIZE * 2);
+
+ auto out_buf_0 = std::make_unique<char[]>(BUFSIZE);
+ memset(out_buf_0.get(), 0xDD, BUFSIZE);
+ auto out_buf_1 = std::make_unique<char[]>(BUFSIZE);
+ memset(out_buf_1.get(), 0xFF, BUFSIZE);
+
+ struct iovec iov_out[2] = {
+ {out_buf_0.get(), BUFSIZE},
+ {out_buf_1.get(), BUFSIZE}
+ };
+
+ bufferlist bl;
+ auto in_buf_0 = std::make_unique<char[]>(BUFSIZE);
+ auto in_buf_1 = std::make_unique<char[]>(BUFSIZE);
+
+ struct iovec iov_in[2] = {
+ {in_buf_0.get(), BUFSIZE},
+ {in_buf_1.get(), BUFSIZE}
+ };
+
+ rc = client->ll_writev(fh, iov_out, 2, 0);
+ // total write length is clamped to INT_MAX in write paths
+ ASSERT_EQ(rc, INT_MAX);
+
+ rc = client->ll_readv(fh, iov_in, 2, 0);
+ // total write length is clamped to INT_MAX in write paths
+ ASSERT_EQ(rc, INT_MAX);
+
+ client->ll_release(fh);
+ ASSERT_EQ(0, client->ll_unlink(root, filename, myperm));
+ }