1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright 2023 Red Hat
6 #ifndef UDS_SPARSE_CACHE_H
7 #define UDS_SPARSE_CACHE_H
13 * The sparse cache is a cache of entire chapter indexes from sparse chapters used for searching
14 * for names after all other search paths have failed. It contains only complete chapter indexes;
15 * record pages from sparse chapters and single index pages used for resolving hooks are kept in
16 * the regular page cache in the volume.
18 * The most important property of this cache is the absence of synchronization for read operations.
19 * Safe concurrent access to the cache by the zone threads is controlled by the triage queue and
20 * the barrier requests it issues to the zone queues. The set of cached chapters does not and must
21 * not change between the carefully coordinated calls to uds_update_sparse_cache() from the zone
22 * threads. Outside of updates, every zone will get the same result when calling
23 * uds_sparse_cache_contains() as every other zone.
29 int __must_check
uds_make_sparse_cache(const struct index_geometry
*geometry
,
30 unsigned int capacity
, unsigned int zone_count
,
31 struct sparse_cache
**cache_ptr
);
33 void uds_free_sparse_cache(struct sparse_cache
*cache
);
35 bool uds_sparse_cache_contains(struct sparse_cache
*cache
, u64 virtual_chapter
,
36 unsigned int zone_number
);
38 int __must_check
uds_update_sparse_cache(struct index_zone
*zone
, u64 virtual_chapter
);
40 void uds_invalidate_sparse_cache(struct sparse_cache
*cache
);
42 int __must_check
uds_search_sparse_cache(struct index_zone
*zone
,
43 const struct uds_record_name
*name
,
44 u64
*virtual_chapter_ptr
, u16
*record_page_ptr
);
46 #endif /* UDS_SPARSE_CACHE_H */