1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright 2023 Red Hat
9 #include "index-layout.h"
10 #include "index-session.h"
11 #include "open-chapter.h"
13 #include "volume-index.h"
16 * The index is a high-level structure which represents the totality of the UDS index. It manages
17 * the queues for incoming requests and dispatches them to the appropriate sub-components like the
18 * volume or the volume index. It also manages administrative tasks such as saving and loading the
21 * The index is divided into a number of independent zones and assigns each request to a zone based
22 * on its name. Most sub-components are similarly divided into zones as well so that requests in
23 * each zone usually operate without interference or coordination between zones.
26 typedef void (*index_callback_fn
)(struct uds_request
*request
);
29 struct uds_index
*index
;
30 struct open_chapter_zone
*open_chapter
;
31 struct open_chapter_zone
*writing_chapter
;
32 u64 oldest_virtual_chapter
;
33 u64 newest_virtual_chapter
;
38 bool has_saved_open_chapter
;
40 struct index_load_context
*load_context
;
41 struct index_layout
*layout
;
42 struct volume_index
*volume_index
;
43 struct volume
*volume
;
44 unsigned int zone_count
;
45 struct index_zone
**zones
;
47 u64 oldest_virtual_chapter
;
48 u64 newest_virtual_chapter
;
52 struct chapter_writer
*chapter_writer
;
54 index_callback_fn callback
;
55 struct uds_request_queue
*triage_queue
;
56 struct uds_request_queue
*zone_queues
[];
65 int __must_check
uds_make_index(struct uds_configuration
*config
,
66 enum uds_open_index_type open_type
,
67 struct index_load_context
*load_context
,
68 index_callback_fn callback
, struct uds_index
**new_index
);
70 int __must_check
uds_save_index(struct uds_index
*index
);
72 void uds_free_index(struct uds_index
*index
);
74 int __must_check
uds_replace_index_storage(struct uds_index
*index
,
75 struct block_device
*bdev
);
77 void uds_get_index_stats(struct uds_index
*index
, struct uds_index_stats
*counters
);
79 void uds_enqueue_request(struct uds_request
*request
, enum request_stage stage
);
81 void uds_wait_for_idle_index(struct uds_index
*index
);
83 #endif /* UDS_INDEX_H */