The fix:
diff --git a/src/client/Client.cc b/src/client/Client.cc
index 3b45ed8453f..6876573ba6e 100644
--- a/src/client/Client.cc
+++ b/src/client/Client.cc
@@ -1088,7 +1088,13 @@ Inode * Client::add_update_inode(InodeStat *st, utime_t from,
if (new_version ||
(new_issued & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR))) {
in->layout = st->layout;
- update_inode_file_size(in, issued, st->size, st->truncate_seq, st->truncate_size);
+ int size = st->size;
+ if (in->is_fscrypt_enabled()) {
+ if (st->fscrypt_file.size() >= sizeof(uint64_t)) {
+ size = *(ceph_le64 *)st->fscrypt_file.data();
+ }
+ }
+ update_inode_file_size(in, issued, size, st->truncate_seq, st->truncate_size);
}
if (in->is_dir()) {
diff --git a/src/mds/Server.cc b/src/mds/Server.cc
index aae51735d91..66a3b36568c 100644
--- a/src/mds/Server.cc
+++ b/src/mds/Server.cc
@@ -5521,6 +5521,8 @@ void Server::do_open_truncate(const MDRequestRef& mdr, int cmode)
uint64_t old_size = std::max<uint64_t>(pi.inode->size, mdr->client_request->head.args.open.old_size);
if (old_size > 0) {
+ if (pi.inode->fscrypt_file.size() >= sizeof(uint64_t))
+ *(ceph_le64 *)pi.inode->fscrypt_file.data() = 0;
pi.inode->truncate(old_size, 0);
le->metablob.add_truncate_start(in->ino()
Description:
add_update_inode() was not passing the effective_size when on fscrypt enabled dirs to update_inode_file_size. Also, during a truncate, effective_size was not reset to 0. MDS needed to be updated in this case as mds has newest version.