]> git.apps.os.sepia.ceph.com Git - ceph.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>
Wed, 5 Nov 2025 13:59:34 +0000 (13:59 +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 2337d9109575da7a677cdf7d123fe402707cbbce..0bb0ebb9ef4de2910e1865266fceeeee93edba5a 100644 (file)
@@ -960,7 +960,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);
@@ -5802,9 +5802,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;
@@ -6068,7 +6068,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 5bf71f35ff257e771da0d80f97397e7c3a2c0fe8..aa4c36274c16cdba1b8fe009fec1e05fa31c2ea0 100644 (file)
@@ -64,6 +64,20 @@ private:
   std::vector<uint8_t> fscrypt_file;
   uint64_t subvolume_id = 0;
 
+  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; }