Loading...
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright 2023 Red Hat
4 */
5
6#ifndef VDO_LOGICAL_ZONE_H
7#define VDO_LOGICAL_ZONE_H
8
9#include <linux/list.h>
10
11#include "admin-state.h"
12#include "int-map.h"
13#include "types.h"
14
15struct physical_zone;
16
17struct logical_zone {
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;
32 /*
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.
35 */
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 */
42 bool notifying;
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;
51 /* The next zone */
52 struct logical_zone *next;
53};
54
55struct logical_zones {
56 /* The vdo whose zones these are */
57 struct vdo *vdo;
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[];
64};
65
66int __must_check vdo_make_logical_zones(struct vdo *vdo,
67 struct logical_zones **zones_ptr);
68
69void vdo_free_logical_zones(struct logical_zones *zones);
70
71void vdo_drain_logical_zones(struct logical_zones *zones,
72 const struct admin_state_code *operation,
73 struct vdo_completion *completion);
74
75void vdo_resume_logical_zones(struct logical_zones *zones,
76 struct vdo_completion *parent);
77
78void vdo_increment_logical_zone_flush_generation(struct logical_zone *zone,
79 sequence_number_t expected_generation);
80
81void vdo_acquire_flush_generation_lock(struct data_vio *data_vio);
82
83void vdo_release_flush_generation_lock(struct data_vio *data_vio);
84
85struct physical_zone * __must_check vdo_get_next_allocation_zone(struct logical_zone *zone);
86
87void vdo_dump_logical_zone(const struct logical_zone *zone);
88
89#endif /* VDO_LOGICAL_ZONE_H */