1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright 2023 Red Hat
6 #ifndef VDO_LOGICAL_ZONE_H
7 #define VDO_LOGICAL_ZONE_H
9 #include <linux/list.h>
11 #include "admin-state.h"
18 /* The completion for flush notifications */
19 struct vdo_completion completion
;
20 /* The owner of this zone */
21 struct logical_zones
*zones
;
22 /* Which logical zone this is */
23 zone_count_t zone_number
;
24 /* The thread id for this zone */
25 thread_id_t thread_id
;
26 /* In progress operations keyed by LBN */
27 struct int_map
*lbn_operations
;
28 /* The logical to physical map */
29 struct block_map_zone
*block_map_zone
;
30 /* The current flush generation */
31 sequence_number_t flush_generation
;
33 * The oldest active generation in this zone. This is mutated only on the logical zone
34 * thread but is queried from the flusher thread.
36 sequence_number_t oldest_active_generation
;
37 /* The number of IOs in the current flush generation */
38 block_count_t ios_in_flush_generation
;
39 /* The youngest generation of the current notification */
40 sequence_number_t notification_generation
;
41 /* Whether a notification is in progress */
43 /* The queue of active data write VIOs */
44 struct list_head write_vios
;
45 /* The administrative state of the zone */
46 struct admin_state state
;
47 /* The physical zone from which to allocate */
48 struct physical_zone
*allocation_zone
;
49 /* The number of allocations done from the current allocation_zone */
50 block_count_t allocation_count
;
52 struct logical_zone
*next
;
55 struct logical_zones
{
56 /* The vdo whose zones these are */
58 /* The manager for administrative actions */
59 struct action_manager
*manager
;
60 /* The number of zones */
61 zone_count_t zone_count
;
62 /* The logical zones themselves */
63 struct logical_zone zones
[];
66 int __must_check
vdo_make_logical_zones(struct vdo
*vdo
,
67 struct logical_zones
**zones_ptr
);
69 void vdo_free_logical_zones(struct logical_zones
*zones
);
71 void vdo_drain_logical_zones(struct logical_zones
*zones
,
72 const struct admin_state_code
*operation
,
73 struct vdo_completion
*completion
);
75 void vdo_resume_logical_zones(struct logical_zones
*zones
,
76 struct vdo_completion
*parent
);
78 void vdo_increment_logical_zone_flush_generation(struct logical_zone
*zone
,
79 sequence_number_t expected_generation
);
81 void vdo_acquire_flush_generation_lock(struct data_vio
*data_vio
);
83 void vdo_release_flush_generation_lock(struct data_vio
*data_vio
);
85 struct physical_zone
* __must_check
vdo_get_next_allocation_zone(struct logical_zone
*zone
);
87 void vdo_dump_logical_zone(const struct logical_zone
*zone
);
89 #endif /* VDO_LOGICAL_ZONE_H */