#include "volume.h"
#include <linux/atomic.h>
#include <linux/dm-bufio.h>
#include <linux/err.h>
#include "errors.h"
#include "logger.h"
#include "memory-alloc.h"
#include "permassert.h"
#include "string-utils.h"
#include "thread-utils.h"
#include "chapter-index.h"
#include "config.h"
#include "geometry.h"
#include "hash-utils.h"
#include "index.h"
#include "sparse-cache.h"
#define MAX_BAD_CHAPTERS …
#define VOLUME_CACHE_MAX_ENTRIES …
#define VOLUME_CACHE_QUEUED_FLAG …
#define VOLUME_CACHE_MAX_QUEUED_READS …
static const u64 BAD_CHAPTER = …;
invalidate_counter;
static inline u32 map_to_page_number(struct index_geometry *geometry, u32 physical_page)
{ … }
static inline u32 map_to_chapter_number(struct index_geometry *geometry, u32 physical_page)
{ … }
static inline bool is_record_page(struct index_geometry *geometry, u32 physical_page)
{ … }
static u32 map_to_physical_page(const struct index_geometry *geometry, u32 chapter, u32 page)
{ … }
static inline union invalidate_counter get_invalidate_counter(struct page_cache *cache,
unsigned int zone_number)
{ … }
static inline void set_invalidate_counter(struct page_cache *cache,
unsigned int zone_number,
union invalidate_counter invalidate_counter)
{ … }
static inline bool search_pending(union invalidate_counter invalidate_counter)
{ … }
static void begin_pending_search(struct page_cache *cache, u32 physical_page,
unsigned int zone_number)
{ … }
static void end_pending_search(struct page_cache *cache, unsigned int zone_number)
{ … }
static void wait_for_pending_searches(struct page_cache *cache, u32 physical_page)
{ … }
static void release_page_buffer(struct cached_page *page)
{ … }
static void clear_cache_page(struct page_cache *cache, struct cached_page *page)
{ … }
static void make_page_most_recent(struct page_cache *cache, struct cached_page *page)
{ … }
static struct cached_page *select_victim_in_cache(struct page_cache *cache)
{ … }
static int put_page_in_cache(struct page_cache *cache, u32 physical_page,
struct cached_page *page)
{ … }
static void cancel_page_in_cache(struct page_cache *cache, u32 physical_page,
struct cached_page *page)
{ … }
static inline u16 next_queue_position(u16 position)
{ … }
static inline void advance_queue_position(u16 *position)
{ … }
static inline bool read_queue_is_full(struct page_cache *cache)
{ … }
static bool enqueue_read(struct page_cache *cache, struct uds_request *request,
u32 physical_page)
{ … }
static void enqueue_page_read(struct volume *volume, struct uds_request *request,
u32 physical_page)
{ … }
static struct queued_read *reserve_read_queue_entry(struct page_cache *cache)
{ … }
static inline struct queued_read *wait_to_reserve_read_queue_entry(struct volume *volume)
{ … }
static int init_chapter_index_page(const struct volume *volume, u8 *index_page,
u32 chapter, u32 index_page_number,
struct delta_index_page *chapter_index_page)
{ … }
static int initialize_index_page(const struct volume *volume, u32 physical_page,
struct cached_page *page)
{ … }
static bool search_record_page(const u8 record_page[],
const struct uds_record_name *name,
const struct index_geometry *geometry,
struct uds_record_data *metadata)
{ … }
static int search_page(struct cached_page *page, const struct volume *volume,
struct uds_request *request, u32 physical_page)
{ … }
static int process_entry(struct volume *volume, struct queued_read *entry)
{ … }
static void release_queued_requests(struct volume *volume, struct queued_read *entry,
int result)
{ … }
static void read_thread_function(void *arg)
{ … }
static void get_page_and_index(struct page_cache *cache, u32 physical_page,
int *queue_index, struct cached_page **page_ptr)
{ … }
static void get_page_from_cache(struct page_cache *cache, u32 physical_page,
struct cached_page **page)
{ … }
static int read_page_locked(struct volume *volume, u32 physical_page,
struct cached_page **page_ptr)
{ … }
static int get_volume_page_locked(struct volume *volume, u32 physical_page,
struct cached_page **page_ptr)
{ … }
static int get_volume_page_protected(struct volume *volume, struct uds_request *request,
u32 physical_page, struct cached_page **page_ptr)
{ … }
static int get_volume_page(struct volume *volume, u32 chapter, u32 page_number,
struct cached_page **page_ptr)
{ … }
int uds_get_volume_record_page(struct volume *volume, u32 chapter, u32 page_number,
u8 **data_ptr)
{ … }
int uds_get_volume_index_page(struct volume *volume, u32 chapter, u32 page_number,
struct delta_index_page **index_page_ptr)
{ … }
static int search_cached_index_page(struct volume *volume, struct uds_request *request,
u32 chapter, u32 index_page_number,
u16 *record_page_number)
{ … }
int uds_search_cached_record_page(struct volume *volume, struct uds_request *request,
u32 chapter, u16 record_page_number, bool *found)
{ … }
void uds_prefetch_volume_chapter(const struct volume *volume, u32 chapter)
{ … }
int uds_read_chapter_index_from_volume(const struct volume *volume, u64 virtual_chapter,
struct dm_buffer *volume_buffers[],
struct delta_index_page index_pages[])
{ … }
int uds_search_volume_page_cache(struct volume *volume, struct uds_request *request,
bool *found)
{ … }
int uds_search_volume_page_cache_for_rebuild(struct volume *volume,
const struct uds_record_name *name,
u64 virtual_chapter, bool *found)
{ … }
static void invalidate_page(struct page_cache *cache, u32 physical_page)
{ … }
void uds_forget_chapter(struct volume *volume, u64 virtual_chapter)
{ … }
static int donate_index_page_locked(struct volume *volume, u32 physical_chapter,
u32 index_page_number, struct dm_buffer *page_buffer)
{ … }
static int write_index_pages(struct volume *volume, u32 physical_chapter_number,
struct open_chapter_index *chapter_index)
{ … }
static u32 encode_tree(u8 record_page[],
const struct uds_volume_record *sorted_pointers[],
u32 next_record, u32 node, u32 node_count)
{ … }
static int encode_record_page(const struct volume *volume,
const struct uds_volume_record records[], u8 record_page[])
{ … }
static int write_record_pages(struct volume *volume, u32 physical_chapter_number,
const struct uds_volume_record *records)
{ … }
int uds_write_chapter(struct volume *volume, struct open_chapter_index *chapter_index,
const struct uds_volume_record *records)
{ … }
static void probe_chapter(struct volume *volume, u32 chapter_number,
u64 *virtual_chapter_number)
{ … }
static void find_real_end_of_volume(struct volume *volume, u32 limit, u32 *limit_ptr)
{ … }
static int find_chapter_limits(struct volume *volume, u32 chapter_limit, u64 *lowest_vcn,
u64 *highest_vcn)
{ … }
int uds_find_volume_chapter_boundaries(struct volume *volume, u64 *lowest_vcn,
u64 *highest_vcn, bool *is_empty)
{ … }
int __must_check uds_replace_volume_storage(struct volume *volume,
struct index_layout *layout,
struct block_device *bdev)
{ … }
static int __must_check initialize_page_cache(struct page_cache *cache,
const struct index_geometry *geometry,
u32 chapters_in_cache,
unsigned int zone_count)
{ … }
int uds_make_volume(const struct uds_configuration *config, struct index_layout *layout,
struct volume **new_volume)
{ … }
static void uninitialize_page_cache(struct page_cache *cache)
{ … }
void uds_free_volume(struct volume *volume)
{ … }