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

Method _read_async

src/client/Client.cc:11834–11966  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11832}
11833
11834int Client::_read_async(Fh *f, uint64_t off, uint64_t len, bufferlist *bl,
11835 Context *onfinish)
11836{
11837 ceph_assert(ceph_mutex_is_locked_by_me(client_lock));
11838
11839 const auto& conf = cct->_conf;
11840 Inode *in = f->inode.get();
11841 std::unique_ptr<Context> io_finish = nullptr;
11842 C_SaferCond *io_finish_cond = nullptr;
11843
11844 ldout(cct, 10) << __func__ << " " << *in << " " << off << "~" << len << dendl;
11845
11846 uint64_t read_start;
11847 uint64_t read_len;
11848
11849 auto effective_size = in->effective_size();
11850 if (off + len > effective_size) {
11851 len = effective_size - off;
11852 }
11853
11854#if defined(__linux__)
11855 FSCryptFDataDencRef fscrypt_denc;
11856 fscrypt->prepare_data_read(in->fscrypt_ctx,
11857 &in->fscrypt_key_validator,
11858 off, len, in->size,
11859 &read_start, &read_len,
11860 &fscrypt_denc);
11861#else
11862 read_start = off;
11863 read_len = len;
11864#endif
11865
11866 // get Fc cap ref before commencing read
11867 get_cap_ref(in, CEPH_CAP_FILE_CACHE);
11868
11869 if (onfinish != nullptr) {
11870 io_finish.reset(new C_Read_Async_Finisher(this, onfinish, f, in, bl,
11871 f->pos, off, len,
11872#if defined(__linux__)
11873 fscrypt_denc,
11874#endif
11875 read_start, read_len));
11876 }
11877
11878 // trim read based on file size?
11879 if ((off >= effective_size) || (len == 0)) {
11880 // read is requested at the EOF or the read len is zero, therefore release
11881 // Fc cap first before proceeding further
11882 put_cap_ref(in, CEPH_CAP_FILE_CACHE);
11883
11884 // If not async, immediate return of 0 bytes
11885 if (onfinish == nullptr) {
11886 return 0;
11887 }
11888
11889 // Release C_Read_Async_Finisher from managed pointer, we need to complete
11890 // immediately. The C_Read_Async_Finisher is safely handled and won't be
11891 // abandoned.

Callers

nothing calls this directly

Calls 15

mono_clock_nowFunction · 0.85
prepare_data_readMethod · 0.80
file_read_exMethod · 0.80
decrypt_blMethod · 0.80
add_metricMethod · 0.80
getMethod · 0.45
effective_sizeMethod · 0.45
resetMethod · 0.45
releaseMethod · 0.45
completeMethod · 0.45

Tested by

no test coverage detected