From db9c17aebb14bd472677d5550aff46fd27c5320d Mon Sep 17 00:00:00 2001 From: Christopher Hoffman Date: Fri, 23 Aug 2024 19:19:31 +0000 Subject: [PATCH] client: When calling update_inode_file_size, provide correct size Fixes: https://tracker.ceph.com/issues/67559 Signed-off-by: Christopher Hoffman --- src/client/Client.cc | 8 ++++---- src/messages/MClientCaps.h | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index b132325fc70..26002bdd06c 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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 MConstRefmds_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()); } diff --git a/src/messages/MClientCaps.h b/src/messages/MClientCaps.h index b001032225e..d4cedb601be 100644 --- a/src/messages/MClientCaps.h +++ b/src/messages/MClientCaps.h @@ -62,6 +62,20 @@ private: std::vector fscrypt_auth; std::vector 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; } -- 2.39.5