]> 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>
Wed, 5 Nov 2025 13:59:34 +0000 (13:59 +0000)
Fixes: https://tracker.ceph.com/issues/69797
Signed-off-by: Christopher Hoffman <choffman@redhat.com>
src/client/Client.cc

index ee3277da04cee4c653d74ec20ade970ef9bf9f47..412c75c3cacb7d9d6942f6939a2e4ce62eb51939 100644 (file)
@@ -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()