From: Christopher Hoffman Date: Wed, 28 May 2025 17:23:12 +0000 (+0000) Subject: client: Skip fscrypt_last_block if in non-fscrypt mode X-Git-Tag: testing/wip-vshankar-testing-20260120.085915-debug^2~13^2~45 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b35b341c16d5ac297a30b42a18e0aa96c2b5c678;p=ceph-ci.git client: Skip fscrypt_last_block if in non-fscrypt mode Skip reading and sending fscrypt_last_block if client_fscrypt_as is false during do_setattr. Without the key, fscrypt truncate is not possible on fscrypt block boundary. Signed-off-by: Christopher Hoffman --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 9984fae62d2..d67020f57aa 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -8529,7 +8529,8 @@ int Client::_do_setattr(Inode *in, struct ceph_statx *stx, int mask, //and truncate size is non-zero. if (in->is_fscrypt_enabled() && stx_size < in->effective_size() && stx_size % FSCRYPT_BLOCK_SIZE != 0 && - (mask & CEPH_SETATTR_FSCRYPT_FILE) && stx_size != 0){ + (mask & CEPH_SETATTR_FSCRYPT_FILE) && stx_size != 0 && + cct->_conf.get_val("client_fscrypt_as")) { // steps: // 1. read last block @@ -15278,7 +15279,7 @@ size_t Client::_vxattrcb_fscrypt_file(Inode *in, char *val, size_t size) int Client::_vxattrcb_fscrypt_file_set(Inode *in, const void *val, size_t size, const UserPerm& perms) { - struct ceph_statx stx = { 0 }; + struct ceph_statx stx; std::vector aux; aux.resize(sizeof(uint64_t)); @@ -15286,6 +15287,7 @@ int Client::_vxattrcb_fscrypt_file_set(Inode *in, const void *val, size_t size, memcpy(&the_size, val, size); *(ceph_le64 *)aux.data() = the_size; + stx.stx_size = the_size; // TODO: rework _do_setattr to pass mask CEPH_SETATTR_FSCRYPT_FILE return _do_setattr(in, &stx, CEPH_SETATTR_SIZE, perms, nullptr, &aux);