MCPcopy Create free account
hub / github.com/ceph/ceph / _read

Method _read

src/client/Client.cc:11557–11770  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11555}
11556
11557int64_t Client::_read(Fh *f, int64_t offset, uint64_t size, bufferlist *bl,
11558 Context *onfinish, bool read_for_write)
11559{
11560 ceph_assert(ceph_mutex_is_locked_by_me(client_lock));
11561
11562 ldout(cct, 10) << __func__ << " " << f->inode.get() << " " << offset << "~"
11563 << size << dendl;
11564
11565 if ((f->mode & CEPH_FILE_MODE_RD) == 0 && !read_for_write)
11566 return -EBADF;
11567
11568 // zero bytes read is not supported by osd
11569 if (size == 0) {
11570 if (onfinish) {
11571 onfinish->complete(0);
11572 }
11573 return 0;
11574 }
11575
11576 int want, have = 0;
11577 bool movepos = false;
11578 std::unique_ptr<Context> iofinish = nullptr;
11579 std::unique_ptr<C_Read_Finisher> crf = nullptr;
11580 int64_t rc = 0;
11581 const auto& conf = cct->_conf;
11582 Inode *in = f->inode.get();
11583 utime_t lat;
11584 utime_t start = mono_clock_now();
11585 CRF_iofinish *crf_iofinish = nullptr;
11586
11587 //bool lazy = f->mode == CEPH_FILE_MODE_LAZY;
11588
11589 if (offset < 0) {
11590 lock_fh_pos(f);
11591 offset = f->pos;
11592 movepos = true;
11593 }
11594 loff_t start_pos = offset;
11595
11596 if (in->inline_version == 0) {
11597 auto r = _getattr(in, CEPH_STAT_CAP_INLINE_DATA, f->actor_perms, true);
11598 if (r < 0) {
11599 rc = r;
11600 goto done;
11601 }
11602 ceph_assert(in->inline_version > 0);
11603 }
11604
11605retry:
11606 if (f->mode & CEPH_FILE_MODE_LAZY)
11607 want = CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO;
11608 else
11609 want = CEPH_CAP_FILE_CACHE;
11610 {
11611 auto r = get_caps(f, CEPH_CAP_FILE_RD, want, &have, -1);
11612 if (r < 0) {
11613 rc = r;
11614 goto done;

Callers 1

readMethod · 0.45

Calls 11

mono_clock_nowFunction · 0.85
add_metricMethod · 0.80
getMethod · 0.45
completeMethod · 0.45
lengthMethod · 0.45
effective_sizeMethod · 0.45
substr_ofMethod · 0.45
append_zeroMethod · 0.45
resetMethod · 0.45
releaseMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected