From: Christopher Hoffman Date: Fri, 23 Aug 2024 19:19:31 +0000 (+0000) Subject: client: When calling update_inode_file_size, provide correct size X-Git-Tag: testing/wip-pdonnell-testing-20251117.182723-debug~69^2~106 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b640e05bbccae7ef244a585cd518cadaa26e0dd3;p=ceph-ci.git client: When calling update_inode_file_size, provide correct size Fixes: https://tracker.ceph.com/issues/67559 Signed-off-by: Christopher Hoffman --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 2337d910957..0bb0ebb9ef4 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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 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; @@ -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()); } diff --git a/src/messages/MClientCaps.h b/src/messages/MClientCaps.h index 5bf71f35ff2..aa4c36274c1 100644 --- a/src/messages/MClientCaps.h +++ b/src/messages/MClientCaps.h @@ -64,6 +64,20 @@ private: std::vector 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; }