| 11347 | // blocking osd interface |
| 11348 | |
| 11349 | int Client::read(int fd, char *buf, loff_t size, loff_t offset) |
| 11350 | { |
| 11351 | RWRef_t mref_reader(mount_state, CLIENT_MOUNTING); |
| 11352 | if (!mref_reader.is_state_satisfied()) |
| 11353 | return -ENOTCONN; |
| 11354 | |
| 11355 | tout(cct) << "read" << std::endl; |
| 11356 | tout(cct) << fd << std::endl; |
| 11357 | tout(cct) << size << std::endl; |
| 11358 | tout(cct) << offset << std::endl; |
| 11359 | |
| 11360 | std::unique_lock lock(client_lock); |
| 11361 | Fh *f = get_filehandle(fd); |
| 11362 | if (!f) |
| 11363 | return -EBADF; |
| 11364 | #if defined(__linux__) && defined(O_PATH) |
| 11365 | if (f->flags & O_PATH) |
| 11366 | return -EBADF; |
| 11367 | #endif |
| 11368 | bufferlist bl; |
| 11369 | #if defined(__linux__) |
| 11370 | /* We can't return bytes written larger than INT_MAX, clamp size to |
| 11371 | * that or FSCRYPT_MAXIO_SIZE*/ |
| 11372 | Inode *in = f->inode.get(); |
| 11373 | if (in->is_fscrypt_enabled()) { |
| 11374 | size = std::min(size, (loff_t)FSCRYPT_MAXIO_SIZE); |
| 11375 | } else { |
| 11376 | size = std::min(size, (loff_t)INT_MAX); |
| 11377 | } |
| 11378 | #else |
| 11379 | size = std::min(size, (loff_t)INT_MAX); |
| 11380 | #endif |
| 11381 | int r = _read(f, offset, size, &bl); |
| 11382 | ldout(cct, 3) << "read(" << fd << ", " << (void*)buf << ", " << size << ", " << offset << ") = " << r << dendl; |
| 11383 | if (r >= 0) { |
| 11384 | lock.unlock(); |
| 11385 | bl.begin().copy(bl.length(), buf); |
| 11386 | r = bl.length(); |
| 11387 | } |
| 11388 | return r; |
| 11389 | } |
| 11390 | |
| 11391 | int Client::preadv(int fd, const struct iovec *iov, int iovcnt, loff_t offset) |
| 11392 | { |
no test coverage detected