// SPDX-License-Identifier: GPL-2.0-only /* * Copyright 2023 Red Hat */ #include "logical-zone.h" #include "logger.h" #include "memory-alloc.h" #include "permassert.h" #include "string-utils.h" #include "action-manager.h" #include "admin-state.h" #include "block-map.h" #include "completion.h" #include "constants.h" #include "data-vio.h" #include "flush.h" #include "int-map.h" #include "physical-zone.h" #include "vdo.h" #define ALLOCATIONS_PER_ZONE … /** * as_logical_zone() - Convert a generic vdo_completion to a logical_zone. * @completion: The completion to convert. * * Return: The completion as a logical_zone. */ static struct logical_zone *as_logical_zone(struct vdo_completion *completion) { … } /* get_thread_id_for_zone() - Implements vdo_zone_thread_getter_fn. */ static thread_id_t get_thread_id_for_zone(void *context, zone_count_t zone_number) { … } /** * initialize_zone() - Initialize a logical zone. * @zones: The logical_zones to which this zone belongs. * @zone_number: The logical_zone's index. */ static int initialize_zone(struct logical_zones *zones, zone_count_t zone_number) { … } /** * vdo_make_logical_zones() - Create a set of logical zones. * @vdo: The vdo to which the zones will belong. * @zones_ptr: A pointer to hold the new zones. * * Return: VDO_SUCCESS or an error code. */ int vdo_make_logical_zones(struct vdo *vdo, struct logical_zones **zones_ptr) { … } /** * vdo_free_logical_zones() - Free a set of logical zones. * @zones: The set of zones to free. */ void vdo_free_logical_zones(struct logical_zones *zones) { … } static inline void assert_on_zone_thread(struct logical_zone *zone, const char *what) { … } /** * check_for_drain_complete() - Check whether this zone has drained. * @zone: The zone to check. */ static void check_for_drain_complete(struct logical_zone *zone) { … } /** * initiate_drain() - Initiate a drain. * * Implements vdo_admin_initiator_fn. */ static void initiate_drain(struct admin_state *state) { … } /** * drain_logical_zone() - Drain a logical zone. * * Implements vdo_zone_action_fn. */ static void drain_logical_zone(void *context, zone_count_t zone_number, struct vdo_completion *parent) { … } void vdo_drain_logical_zones(struct logical_zones *zones, const struct admin_state_code *operation, struct vdo_completion *parent) { … } /** * resume_logical_zone() - Resume a logical zone. * * Implements vdo_zone_action_fn. */ static void resume_logical_zone(void *context, zone_count_t zone_number, struct vdo_completion *parent) { … } /** * vdo_resume_logical_zones() - Resume a set of logical zones. * @zones: The logical zones to resume. * @parent: The object to notify when the zones have resumed. */ void vdo_resume_logical_zones(struct logical_zones *zones, struct vdo_completion *parent) { … } /** * update_oldest_active_generation() - Update the oldest active generation. * @zone: The zone. * * Return: true if the oldest active generation has changed. */ static bool update_oldest_active_generation(struct logical_zone *zone) { … } /** * vdo_increment_logical_zone_flush_generation() - Increment the flush generation in a logical * zone. * @zone: The logical zone. * @expected_generation: The expected value of the flush generation before the increment. */ void vdo_increment_logical_zone_flush_generation(struct logical_zone *zone, sequence_number_t expected_generation) { … } /** * vdo_acquire_flush_generation_lock() - Acquire the shared lock on a flush generation by a write * data_vio. * @data_vio: The data_vio. */ void vdo_acquire_flush_generation_lock(struct data_vio *data_vio) { … } static void attempt_generation_complete_notification(struct vdo_completion *completion); /** * notify_flusher() - Notify the flush that at least one generation no longer has active VIOs. * @completion: The zone completion. * * This callback is registered in attempt_generation_complete_notification(). */ static void notify_flusher(struct vdo_completion *completion) { … } /** * attempt_generation_complete_notification() - Notify the flusher if some generation no * longer has active VIOs. * @completion: The zone completion. */ static void attempt_generation_complete_notification(struct vdo_completion *completion) { … } /** * vdo_release_flush_generation_lock() - Release the shared lock on a flush generation held by a * write data_vio. * @data_vio: The data_vio whose lock is to be released. * * If there are pending flushes, and this data_vio completes the oldest generation active in this * zone, an attempt will be made to finish any flushes which may now be complete. */ void vdo_release_flush_generation_lock(struct data_vio *data_vio) { … } struct physical_zone *vdo_get_next_allocation_zone(struct logical_zone *zone) { … } /** * vdo_dump_logical_zone() - Dump information about a logical zone to the log for debugging. * @zone: The zone to dump * * Context: the information is dumped in a thread-unsafe fashion. * */ void vdo_dump_logical_zone(const struct logical_zone *zone) { … }