Backport/squid 19.2.4 cobaltcore storage/rgw kms cache#4
Merged
irq0 merged 28 commits intoJun 10, 2026
Merged
Conversation
if async_wait() can race with complete() across threads, the yield_waiter's handler_state needs to be protected by a mutex. add an async_wait() overload for unique_lock that behaves like condition_variable::wait(): the lock is released immediately before suspending, and reacquired immediately before calling its completion handler Signed-off-by: Casey Bodley <cbodley@redhat.com> (cherry picked from commit 604fad5)
also adds an empty() function so it's easier to specify its precondition Signed-off-by: Casey Bodley <cbodley@redhat.com> (cherry picked from commit 165f2ec)
modeled after std::call_once() to guarantee that racing callers wait for the initial caller to finish. the main differences here are * support for coroutine callers to suspend instead of blocking while waiting for the initial caller, and * the wrapped function must return a value, which is cached and returned to all callers Signed-off-by: Casey Bodley <cbodley@redhat.com> (cherry picked from commit 3cd3c11)
A cache data structure for values that need to be retrieved form outside systems (e.g Key Management Systems). Features: - Thread safe, optimized for concurrent lookups and cache hits - Entry TTL expiration - Cache replacement strategy tuned to "web" workloads (SIEVE) - Performance Counters on hit, miss, expire, size, capacity, clears Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit 9618827)
Add Google benchmark [0] based micro benchmarks for Cache/LRU implementations in the Ceph code base. [0] https://github.com/google/benchmark Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit 8354a97)
Benchmark: - Linux Kernel Key Retention Service (kernel keystore) [0] - memfd_secret(2) - plain memory Tests: - Random reads - (keystore) Write, Read, Remove [0] https://docs.kernel.org/security/keys/core.html Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit a4b8d7d)
Add RAII wrapper around the Linux Key Retention Service add_key(2), keyctl_read(3), keyctl_invalidate(3) Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit 0307119)
To allow RGW threads to share possession over process keyring keys the keyring must be created before a child thread adds keys. Since we only use the process keyring for KMS cache secrets, only initialize the keyring if it is enabled on startup. Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit 0000467)
Add caching section to the RGW Encryption docs. Add cache settings to the RGW configuration reference. Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit a88f029)
Goal: Support multiple backends and faking / mocking for testing. Add abstract classes Keyring (factory) and KeyringSecret. Add "Unsupported" implementation for non-Linux platforms. Add a get_best factory function that currently returns the LinuxKeyring impl on Linux or Unsupported elsewhere. Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit 35f2bb4)
Add SSE Key Management System secrets cache to RGW. It is common to have secrets shared by many if not all objects in a bucket. Without RGW-side caching every PUT/GET will cause a request to an external KSM. This not only adds load to the KSM, but also slows down read and writes. Combine WebCache, ceph::async::call_once and LinuxKeyringSecret into KMSCache. WebCache stores async::once_result to wrap results of a KMS secret fetch to mitigate cache stampedes (concurrent cache requests to the same key coalesce into one). The retrieved secrets are stored in the Linux kernel key retention service (LinuxKeyringSecret) for safe keeping and retrial by subsequent requests. KMSCache adds a TTL reaper and life cycle. Cache values and error handling: The cache stores positive fetch results, permanent errors (e.g key does not exists) and transient errors (e.g fetch timeout). Each with a different TTL. Unit tests to cover cached / uncached KMS retrieve and runtime cache disable via config. Add perf counter `kms_fetch_lat` to track KMS fetch request latency and error counters to track permanent, transient and key store errors. Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> Fixes: https://tracker.ceph.com/issues/68524 On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit b6186fc)
Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit aa4ead3)
Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit fb5bbc7)
KMS backends Barbican, Vault KV, and KMIP have a static key per key_id. However, with Vault Transit, each object has a unique DEK wrapped by the transit key. Keying th cache with key_id in Transit mode results in only the first DEK to be cached for all subsequent objects. Fix this by appending a hash of the wrapped DEK to the cache key. Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit 4d7c556)
Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit 78f2ec3)
Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit 898cd5b)
sieve_expire_erase_unmutexed did not update the sieve hand passed as advertised. Make it return the updated hand and use that to update the global _sieve_hand in expire_erase Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit 3518aaf)
Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit f96f7a6)
Reset reaper state to monostate in the async and threaded case. Fixes a possible use after free in the async reaper case. Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit e104372)
1. Don't delete the KMS cache before draining/joining the frontend coroutine threads. They may still depend on the KMS cache. 2. Stop the TTL reaper early to get it off the coroutine pool. Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit 62ba03f)
The testing backend uses a 'keysel' attribute to derive a per object key from the KEK in the config. A single key_id with distinct keysel has different keys and need to be cached as such. Add the keysel to the cache key id to handle these collisions. Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com (cherry picked from commit 12de72b)
Signed-off-by: Casey Bodley <cbodley@redhat.com> (cherry picked from commit be4ddd7)
Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com
Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com
Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com
c826e15 common/perf_counters: track maximum increment value for LONGRUNAVG perf intruduced a return parameter change regression. Since this only affects kms cache unit tests, apply the reversal there. Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com> On-behalf-of: SAP marcel.lauhoff@sap.com
new dout macros use fmt::print() to write output directly to the
underlying ostream. this enables libfmt's printf-style formatting syntax
for ceph log output, without the string allocation overhead of:
dout(10) << fmt::format("str={} count={}", str, count) << dendl;
which becomes:
dout_fmt(10, "str={} count={}", str, count);
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit a58d07a)
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Author
|
all unit tests passed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes cobaltcore-dev/cloud-storage#463
Backport file
release-management/backports/<uuid>.mdadded (or updated) by this PRidin frontmatter matches the filename stemprovenance.upstream_prsset (orprovenance.type: otherwith another:block)Stage-B risk (filled per
release-management/backports/RISK-RUBRIC.md)blast— cosmetic / availability / data-lossconflict— clean / trivial / substantivecoverage— strong / partial / weakhighband)Merge
Land this via
just merge-backport PR=<N>— do not click the green merge button.The just recipe constructs the merge commit's
Backport-Idtrailer.