From: Christopher Hoffman Date: Tue, 4 Feb 2025 18:31:28 +0000 (+0000) Subject: client: Calculate len before prepare_data_read X-Git-Tag: v21.0.0~231^2~10^2~83 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=16d544f42d6b146c1386be2c663583333873b489;p=ceph.git client: Calculate len before prepare_data_read Fixes: https://tracker.ceph.com/issues/69797 Signed-off-by: Christopher Hoffman --- diff --git a/src/client/Client.cc b/src/client/Client.cc index ee3277da04c..412c75c3cac 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -11781,6 +11781,11 @@ int Client::_read_async(Fh *f, uint64_t off, uint64_t len, bufferlist *bl, uint64_t read_start; uint64_t read_len; + auto effective_size = in->effective_size(); + if (off + len > effective_size) { + len = effective_size - off; + } + FSCryptFDataDencRef fscrypt_denc; fscrypt->prepare_data_read(in->fscrypt_ctx, &in->fscrypt_key_validator, @@ -11791,7 +11796,6 @@ int Client::_read_async(Fh *f, uint64_t off, uint64_t len, bufferlist *bl, // get Fc cap ref before commencing read get_cap_ref(in, CEPH_CAP_FILE_CACHE); - auto effective_size = in->effective_size(); if (onfinish != nullptr) { io_finish.reset(new C_Read_Async_Finisher(this, onfinish, f, in, bl, f->pos, off, len, @@ -11821,10 +11825,6 @@ int Client::_read_async(Fh *f, uint64_t off, uint64_t len, bufferlist *bl, return 0; } - if (off + len > effective_size) { - len = effective_size - off; - } - auto target_len = std::min(len, effective_size - off); ldout(cct, 10) << " min_bytes=" << f->readahead.get_min_readahead_size()