]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
client: Calculate len before prepare_data_read
authorChristopher Hoffman <choffman@redhat.com>
Tue, 4 Feb 2025 18:31:28 +0000 (18:31 +0000)
committerChristopher Hoffman <choffman@redhat.com>
Thu, 14 Aug 2025 20:09:47 +0000 (20:09 +0000)
Fixes: https://tracker.ceph.com/issues/69797
Signed-off-by: Christopher Hoffman <choffman@redhat.com>
src/client/Client.cc

index 0f88cded8d40013517c62b948c47b68aeb0cdad6..b72c6b3c6216f2d813e5e26937921d48a489b18b 100644 (file)
@@ -11717,6 +11717,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,
@@ -11727,7 +11732,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,
@@ -11757,10 +11761,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()