// (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);
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;
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());
}
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; }