dm vdo: remove unnecessary indexer.h includes
[linux-2.6-block.git] / drivers / md / dm-vdo / chapter-index.h
CommitLineData
6afc7bca
MS
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright 2023 Red Hat
4 */
5
6#ifndef UDS_CHAPTER_INDEX_H
7#define UDS_CHAPTER_INDEX_H
8
9#include <linux/limits.h>
10
11#include "delta-index.h"
12#include "geometry.h"
13
14/*
15 * A chapter index for an open chapter is a mutable structure that tracks all the records that have
16 * been added to the chapter. A chapter index for a closed chapter is similar except that it is
17 * immutable because the contents of a closed chapter can never change, and the immutable structure
18 * is more efficient. Both types of chapter index are implemented with a delta index.
19 */
20
fbbd7a25
MS
21/* The value returned when no entry is found in the chapter index. */
22#define NO_CHAPTER_INDEX_ENTRY U16_MAX
6afc7bca
MS
23
24struct open_chapter_index {
7f67d0f1 25 const struct index_geometry *geometry;
6afc7bca
MS
26 struct delta_index delta_index;
27 u64 virtual_chapter_number;
28 u64 volume_nonce;
29 size_t memory_size;
30};
31
32int __must_check uds_make_open_chapter_index(struct open_chapter_index **chapter_index,
7f67d0f1 33 const struct index_geometry *geometry,
6afc7bca
MS
34 u64 volume_nonce);
35
36void uds_free_open_chapter_index(struct open_chapter_index *chapter_index);
37
38void uds_empty_open_chapter_index(struct open_chapter_index *chapter_index,
39 u64 virtual_chapter_number);
40
41int __must_check uds_put_open_chapter_index_record(struct open_chapter_index *chapter_index,
42 const struct uds_record_name *name,
43 u32 page_number);
44
45int __must_check uds_pack_open_chapter_index_page(struct open_chapter_index *chapter_index,
46 u8 *memory, u32 first_list,
47 bool last_page, u32 *lists_packed);
48
49int __must_check uds_initialize_chapter_index_page(struct delta_index_page *index_page,
7f67d0f1 50 const struct index_geometry *geometry,
6afc7bca
MS
51 u8 *page_buffer, u64 volume_nonce);
52
53int __must_check uds_validate_chapter_index_page(const struct delta_index_page *index_page,
7f67d0f1 54 const struct index_geometry *geometry);
6afc7bca
MS
55
56int __must_check uds_search_chapter_index_page(struct delta_index_page *index_page,
7f67d0f1 57 const struct index_geometry *geometry,
6afc7bca
MS
58 const struct uds_record_name *name,
59 u16 *record_page_ptr);
60
61#endif /* UDS_CHAPTER_INDEX_H */