From: Christopher Hoffman Date: Tue, 17 Jun 2025 16:44:08 +0000 (+0000) Subject: client: Fix logic in fscrypt hole optimization X-Git-Tag: testing/wip-vshankar-testing-20260120.085915-debug^2~13^2~41 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f9fb36db8c28b9ff8b2660a46d33bbce441ef1f2;p=ceph-ci.git client: Fix logic in fscrypt hole optimization In fscrypt decryption code path, ensure if a data block is hit when there are holes present in adjacent blocks, that we exit hole traversal and continue on to decrypt the block. Fixes: https://tracker.ceph.com/issues/71602 Signed-off-by: Christopher Hoffman --- diff --git a/src/client/FSCrypt.cc b/src/client/FSCrypt.cc index d3f162c8af2..edb38898aff 100644 --- a/src/client/FSCrypt.cc +++ b/src/client/FSCrypt.cc @@ -898,11 +898,25 @@ int FSCryptFDataDenc::decrypt_bl(uint64_t off, uint64_t len, uint64_t pos, const while (pos < target_end) { bool has_hole = false; + /* + * Check to see if cur_block is part of a + * hole. We expect holes to ordered by offset. + * + * There is four states it can be in + * 1. If position is before hole offset, it cannot be part of a hole + * 2. If hole end is less than position, hole occurs completely before + * 3. If hole starts after target_end, hole occurs completely after + * 4. No conditionals are met, is a hole + */ + while (hiter != holes.end()) { uint64_t hofs = hiter->first; uint64_t hlen = hiter->second; uint64_t hend = hofs + hlen - 1; + if (pos < hofs) + break; + if (hend < pos) { ++hiter; continue;