From: Xiubo Li Date: Fri, 26 Nov 2021 02:20:12 +0000 (+0800) Subject: client: trust the fscrypt_file as the inode size and truncate caches X-Git-Tag: v18.0.0~1381^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5119882c65fb8c960436d891c95d48b9fa52dea3;p=ceph.git client: trust the fscrypt_file as the inode size and truncate caches Signed-off-by: Xiubo Li --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 779370d9cbc3..38881a8fb899 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -802,7 +802,7 @@ void Client::update_inode_file_size(Inode *in, int issued, uint64_t size, // truncate cached file data if (prior_size > size) { - _invalidate_inode_cache(in, truncate_size, prior_size - truncate_size); + _invalidate_inode_cache(in, size, prior_size - size); } } @@ -5214,15 +5214,20 @@ void Client::handle_cap_trunc(MetaSession *session, Inode *in, const MConstRefmds_num; ceph_assert(in->caps.count(mds)); + uint64_t size = m->get_size(); + if (in->is_fscrypt_enabled()) { + size = std::stoll(std::string(std::rbegin(m->fscrypt_file), + std::rend(m->fscrypt_file))); + } ldout(cct, 10) << __func__ << " on ino " << *in << " size " << in->size << " -> " << m->get_size() << dendl; - + int issued; in->caps_issued(&issued); issued |= in->caps_dirty(); - update_inode_file_size(in, issued, m->get_size(), - m->get_truncate_seq(), m->get_truncate_size()); + update_inode_file_size(in, issued, size, m->get_truncate_seq(), + m->get_truncate_size()); } void Client::handle_cap_flush_ack(MetaSession *session, Inode *in, Cap *cap, const MConstRef& m) diff --git a/src/client/Inode.h b/src/client/Inode.h index 72b8c0a2fb90..f5db5d7a905e 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -165,6 +165,9 @@ struct Inode : RefCountedObject { std::vector fscrypt_auth; std::vector fscrypt_file; + bool is_fscrypt_enabled() { + return !!fscrypt_auth.size(); + } bool is_root() const { return ino == CEPH_INO_ROOT; } bool is_symlink() const { return (mode & S_IFMT) == S_IFLNK; }