]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
client: When calling update_inode_file_size, provide correct size
authorChristopher Hoffman <choffman@redhat.com>
Fri, 23 Aug 2024 19:19:31 +0000 (19:19 +0000)
committerChristopher Hoffman <choffman@redhat.com>
Thu, 14 Aug 2025 20:08:09 +0000 (20:08 +0000)
Fixes: https://tracker.ceph.com/issues/67559
Signed-off-by: Christopher Hoffman <choffman@redhat.com>
src/client/Client.cc
src/messages/MClientCaps.h

index b132325fc70b44fa5c3396fb8ffc08360f2ee1aa..26002bdd06c2d08c5535ece6a07834cfbbad673f 100644 (file)
@@ -940,7 +940,7 @@ void Client::update_inode_file_size(Inode *in, int issued, uint64_t size,
   // (i.e. truncating from 8M to 4M) passed truncate_seq will be larger
   // than inode truncate_seq. This shows passed size is latest.
   if (truncate_seq > in->truncate_seq ||
-      (truncate_seq == in->truncate_seq && size > in->size)) {
+      (truncate_seq == in->truncate_seq && size > in->effective_size())) {
     ldout(cct, 10) << "size " << in->size << " -> " << size << dendl;
     if (in->is_fscrypt_enabled()) {
       in->set_effective_size(size);
@@ -5766,9 +5766,9 @@ void Client::handle_cap_trunc(MetaSession *session, Inode *in, const MConstRef<M
   mds_rank_t mds = session->mds_num;
   ceph_assert(in->caps.count(mds));
 
-  uint64_t size = m->get_size();
+  uint64_t size = m->effective_size();
   ldout(cct, 10) << __func__ << " on ino " << *in
-          << " size " << in->size << " -> " << m->get_size()
+          << " size " << in->size << " -> " << size
           << dendl;
 
   int issued;
@@ -6032,7 +6032,7 @@ void Client::handle_cap_grant(MetaSession *session, Inode *in, Cap *cap, const M
 
   if (new_caps & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR)) {
     in->layout = m->get_layout();
-    update_inode_file_size(in, issued, m->get_size(),
+    update_inode_file_size(in, issued, m->effective_size(),
                           m->get_truncate_seq(), m->get_truncate_size());
   }
 
index b001032225e2434f56ca1ae46ff6502c17fdf174..d4cedb601bed9c0fd2e6cf5eb7e663c6cf50c571 100644 (file)
@@ -62,6 +62,20 @@ private:
   std::vector<uint8_t> fscrypt_auth;
   std::vector<uint8_t> fscrypt_file;
 
+  bool is_fscrypt_enabled() const {
+    return !!fscrypt_auth.size();
+  }
+
+  uint64_t effective_size() const {
+    if(is_fscrypt_enabled()) {
+      if (fscrypt_file.size() >= sizeof(uint64_t)) {
+        return *(ceph_le64 *)fscrypt_file.data();
+      }
+    }
+
+    return size;
+  }
+
   int      get_caps() const { return head.caps; }
   int      get_wanted() const { return head.wanted; }
   int      get_dirty() const { return head.dirty; }