/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright 2023 Red Hat */ #ifndef VDO_TYPES_H #define VDO_TYPES_H #include <linux/bio.h> #include <linux/blkdev.h> #include <linux/device-mapper.h> #include <linux/list.h> #include <linux/compiler_attributes.h> #include <linux/types.h> #include "funnel-queue.h" /* A size type in blocks. */ block_count_t; /* The size of a block. */ block_size_t; /* A counter for data_vios */ data_vio_count_t; /* A height within a tree. */ height_t; /* The logical block number as used by the consumer. */ logical_block_number_t; /* The type of the nonce used to identify instances of VDO. */ nonce_t; /* A size in pages. */ page_count_t; /* A page number. */ page_number_t; /* * The physical (well, less logical) block number at which the block is found on the underlying * device. */ physical_block_number_t; /* A count of tree roots. */ root_count_t; /* A number of sectors. */ sector_count_t; /* A sequence number. */ sequence_number_t; /* The offset of a block within a slab. */ slab_block_number; /* A size type in slabs. */ slab_count_t; /* A slot in a bin or block map page. */ slot_number_t; /* typedef thread_count_t - A thread counter. */ thread_count_t; /* typedef thread_id_t - A thread ID, vdo threads are numbered sequentially from 0. */ thread_id_t; /* A zone counter */ zone_count_t; /* The following enums are persisted on storage, so the values must be preserved. */ /* The current operating mode of the VDO. */ enum vdo_state { … }; /** * vdo_state_requires_read_only_rebuild() - Check whether a vdo_state indicates * that a read-only rebuild is required. * @state: The vdo_state to check. * * Return: true if the state indicates a rebuild is required */ static inline bool __must_check vdo_state_requires_read_only_rebuild(enum vdo_state state) { … } /** * vdo_state_requires_recovery() - Check whether a vdo state indicates that recovery is needed. * @state: The state to check. * * Return: true if the state indicates a recovery is required */ static inline bool __must_check vdo_state_requires_recovery(enum vdo_state state) { … } /* * The current operation on a physical block (from the point of view of the recovery journal, slab * journals, and reference counts. */ enum journal_operation { … } __packed; /* Partition IDs encoded in the volume layout in the super block. */ enum partition_id { … } __packed; /* Metadata types for the vdo. */ enum vdo_metadata_type { … } __packed; /* A position in the block map where a block map entry is stored. */ struct block_map_slot { … }; /* * Four bits of each five-byte block map entry contain a mapping state value used to distinguish * unmapped or discarded logical blocks (which are treated as mapped to the zero block) from entries * that have been mapped to a physical block, including the zero block. * * FIXME: these should maybe be defines. */ enum block_mapping_state { … }; enum { … }; struct data_location { … }; /* The configuration of a single slab derived from the configured block size and slab size. */ struct slab_config { … } __packed; /* * This structure is memcmp'd for equality. Keep it packed and don't add any fields that are not * properly set in both extant and parsed configs. */ struct thread_count_config { … } __packed; struct device_config { … }; enum vdo_completion_type { … } __packed; struct vdo_completion; /** * typedef vdo_action_fn - An asynchronous VDO operation. * @completion: The completion of the operation. */ vdo_action_fn; enum vdo_completion_priority { … }; struct vdo_completion { … }; struct block_allocator; struct data_vio; struct vdo; struct vdo_config; /* vio types for statistics and instrumentation. */ enum vio_type { … } __packed; /* Priority levels for asynchronous I/O operations performed on a vio. */ enum vio_priority { … } __packed; /* * A wrapper for a bio. All I/O to the storage below a vdo is conducted via vios. */ struct vio { … }; #endif /* VDO_TYPES_H */