1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright 2023 Red Hat
6 #ifndef UDS_INDEX_SESSION_H
7 #define UDS_INDEX_SESSION_H
9 #include <linux/atomic.h>
10 #include <linux/cache.h>
12 #include "thread-utils.h"
18 * The index session mediates all interactions with a UDS index. Once the index session is created,
19 * it can be used to open, close, suspend, or recreate an index. It implements the majority of the
20 * functions in the top-level UDS API.
22 * If any deduplication request fails due to an internal error, the index is marked disabled. It
23 * will not accept any further requests and can only be closed. Closing the index will clear the
24 * disabled flag, and the index can then be reopened and recovered using the same index session.
27 struct __aligned(L1_CACHE_BYTES
) session_stats
{
28 /* Post requests that found an entry */
30 /* Post requests found in the open chapter */
31 u64 posts_found_open_chapter
;
32 /* Post requests found in the dense index */
33 u64 posts_found_dense
;
34 /* Post requests found in the sparse index */
35 u64 posts_found_sparse
;
36 /* Post requests that did not find an entry */
38 /* Update requests that found an entry */
40 /* Update requests that did not find an entry */
41 u64 updates_not_found
;
42 /* Delete requests that found an entry */
44 /* Delete requests that did not find an entry */
45 u64 deletions_not_found
;
46 /* Query requests that found an entry */
48 /* Query requests that did not find an entry */
49 u64 queries_not_found
;
50 /* Total number of requests */
54 enum index_suspend_status
{
55 /* An index load has started but the index is not ready for use. */
57 /* The index is able to handle requests. */
59 /* The index is attempting to suspend a rebuild. */
61 /* An index rebuild has been suspended. */
63 /* An index rebuild is being stopped in order to shut down. */
67 struct index_load_context
{
70 enum index_suspend_status status
;
73 struct uds_index_session
{
75 struct uds_index
*index
;
76 struct uds_request_queue
*callback_queue
;
77 struct uds_parameters parameters
;
78 struct index_load_context load_context
;
79 struct mutex request_mutex
;
80 struct cond_var request_cond
;
82 struct session_stats stats
;
85 #endif /* UDS_INDEX_SESSION_H */