dedupe.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright 2023 Red Hat
  4. */
  5. #ifndef VDO_DEDUPE_H
  6. #define VDO_DEDUPE_H
  7. #include <linux/list.h>
  8. #include <linux/timer.h>
  9. #include "indexer.h"
  10. #include "admin-state.h"
  11. #include "constants.h"
  12. #include "statistics.h"
  13. #include "types.h"
  14. #include "wait-queue.h"
  15. struct dedupe_context {
  16. struct hash_zone *zone;
  17. struct uds_request request;
  18. struct list_head list_entry;
  19. struct funnel_queue_entry queue_entry;
  20. u64 submission_jiffies;
  21. struct data_vio *requestor;
  22. atomic_t state;
  23. };
  24. struct hash_lock;
  25. struct hash_zone {
  26. /* Which hash zone this is */
  27. zone_count_t zone_number;
  28. /* The administrative state of the zone */
  29. struct admin_state state;
  30. /* The thread ID for this zone */
  31. thread_id_t thread_id;
  32. /* Mapping from record name fields to hash_locks */
  33. struct int_map *hash_lock_map;
  34. /* List containing all unused hash_locks */
  35. struct list_head lock_pool;
  36. /*
  37. * Statistics shared by all hash locks in this zone. Only modified on the hash zone thread,
  38. * but queried by other threads.
  39. */
  40. struct hash_lock_statistics statistics;
  41. /* Array of all hash_locks */
  42. struct hash_lock *lock_array;
  43. /* These fields are used to manage the dedupe contexts */
  44. struct list_head available;
  45. struct list_head pending;
  46. struct funnel_queue *timed_out_complete;
  47. struct timer_list timer;
  48. struct vdo_completion completion;
  49. unsigned int active;
  50. atomic_t timer_state;
  51. /* The dedupe contexts for querying the index from this zone */
  52. struct dedupe_context contexts[MAXIMUM_VDO_USER_VIOS];
  53. };
  54. struct hash_zones;
  55. struct pbn_lock * __must_check vdo_get_duplicate_lock(struct data_vio *data_vio);
  56. void vdo_acquire_hash_lock(struct vdo_completion *completion);
  57. void vdo_continue_hash_lock(struct vdo_completion *completion);
  58. void vdo_release_hash_lock(struct data_vio *data_vio);
  59. void vdo_clean_failed_hash_lock(struct data_vio *data_vio);
  60. void vdo_share_compressed_write_lock(struct data_vio *data_vio,
  61. struct pbn_lock *pbn_lock);
  62. int __must_check vdo_make_hash_zones(struct vdo *vdo, struct hash_zones **zones_ptr);
  63. void vdo_free_hash_zones(struct hash_zones *zones);
  64. void vdo_drain_hash_zones(struct hash_zones *zones, struct vdo_completion *parent);
  65. void vdo_get_dedupe_statistics(struct hash_zones *zones, struct vdo_statistics *stats);
  66. struct hash_zone * __must_check vdo_select_hash_zone(struct hash_zones *zones,
  67. const struct uds_record_name *name);
  68. void vdo_dump_hash_zones(struct hash_zones *zones);
  69. const char *vdo_get_dedupe_index_state_name(struct hash_zones *zones);
  70. u64 vdo_get_dedupe_index_timeout_count(struct hash_zones *zones);
  71. int vdo_message_dedupe_index(struct hash_zones *zones, const char *name);
  72. void vdo_set_dedupe_state_normal(struct hash_zones *zones);
  73. void vdo_start_dedupe_index(struct hash_zones *zones, bool create_flag);
  74. void vdo_resume_hash_zones(struct hash_zones *zones, struct vdo_completion *parent);
  75. void vdo_finish_dedupe_index(struct hash_zones *zones);
  76. /* Interval (in milliseconds) from submission until switching to fast path and skipping UDS. */
  77. extern unsigned int vdo_dedupe_index_timeout_interval;
  78. /*
  79. * Minimum time interval (in milliseconds) between timer invocations to check for requests waiting
  80. * for UDS that should now time out.
  81. */
  82. extern unsigned int vdo_dedupe_index_min_timer_interval;
  83. void vdo_set_dedupe_index_timeout_interval(unsigned int value);
  84. void vdo_set_dedupe_index_min_timer_interval(unsigned int value);
  85. #endif /* VDO_DEDUPE_H */