1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright 2023 Red Hat
9 #include <linux/list.h>
10 #include <linux/timer.h>
14 #include "admin-state.h"
15 #include "constants.h"
16 #include "statistics.h"
18 #include "wait-queue.h"
20 struct dedupe_context
{
21 struct hash_zone
*zone
;
22 struct uds_request request
;
23 struct list_head list_entry
;
24 struct funnel_queue_entry queue_entry
;
25 u64 submission_jiffies
;
26 struct data_vio
*requestor
;
33 /* Which hash zone this is */
34 zone_count_t zone_number
;
36 /* The administrative state of the zone */
37 struct admin_state state
;
39 /* The thread ID for this zone */
40 thread_id_t thread_id
;
42 /* Mapping from record name fields to hash_locks */
43 struct int_map
*hash_lock_map
;
45 /* List containing all unused hash_locks */
46 struct list_head lock_pool
;
49 * Statistics shared by all hash locks in this zone. Only modified on the hash zone thread,
50 * but queried by other threads.
52 struct hash_lock_statistics statistics
;
54 /* Array of all hash_locks */
55 struct hash_lock
*lock_array
;
57 /* These fields are used to manage the dedupe contexts */
58 struct list_head available
;
59 struct list_head pending
;
60 struct funnel_queue
*timed_out_complete
;
61 struct timer_list timer
;
62 struct vdo_completion completion
;
66 /* The dedupe contexts for querying the index from this zone */
67 struct dedupe_context contexts
[MAXIMUM_VDO_USER_VIOS
];
72 struct pbn_lock
* __must_check
vdo_get_duplicate_lock(struct data_vio
*data_vio
);
74 void vdo_acquire_hash_lock(struct vdo_completion
*completion
);
75 void vdo_continue_hash_lock(struct vdo_completion
*completion
);
76 void vdo_release_hash_lock(struct data_vio
*data_vio
);
77 void vdo_clean_failed_hash_lock(struct data_vio
*data_vio
);
78 void vdo_share_compressed_write_lock(struct data_vio
*data_vio
,
79 struct pbn_lock
*pbn_lock
);
81 int __must_check
vdo_make_hash_zones(struct vdo
*vdo
, struct hash_zones
**zones_ptr
);
83 void vdo_free_hash_zones(struct hash_zones
*zones
);
85 void vdo_drain_hash_zones(struct hash_zones
*zones
, struct vdo_completion
*parent
);
87 void vdo_get_dedupe_statistics(struct hash_zones
*zones
, struct vdo_statistics
*stats
);
89 struct hash_zone
* __must_check
vdo_select_hash_zone(struct hash_zones
*zones
,
90 const struct uds_record_name
*name
);
92 void vdo_dump_hash_zones(struct hash_zones
*zones
);
94 const char *vdo_get_dedupe_index_state_name(struct hash_zones
*zones
);
96 u64
vdo_get_dedupe_index_timeout_count(struct hash_zones
*zones
);
98 int vdo_message_dedupe_index(struct hash_zones
*zones
, const char *name
);
100 void vdo_set_dedupe_state_normal(struct hash_zones
*zones
);
102 void vdo_start_dedupe_index(struct hash_zones
*zones
, bool create_flag
);
104 void vdo_resume_hash_zones(struct hash_zones
*zones
, struct vdo_completion
*parent
);
106 void vdo_finish_dedupe_index(struct hash_zones
*zones
);
108 /* Interval (in milliseconds) from submission until switching to fast path and skipping UDS. */
109 extern unsigned int vdo_dedupe_index_timeout_interval
;
112 * Minimum time interval (in milliseconds) between timer invocations to check for requests waiting
113 * for UDS that should now time out.
115 extern unsigned int vdo_dedupe_index_min_timer_interval
;
117 void vdo_set_dedupe_index_timeout_interval(unsigned int value
);
118 void vdo_set_dedupe_index_min_timer_interval(unsigned int value
);
120 #endif /* VDO_DEDUPE_H */