Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / vol / vg_cache_impl_types.h
1 /*
2 * Copyright 2009-2010, Sine Nomine Associates and others.
3 * All Rights Reserved.
4 *
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
9
10 /*
11 * demand attach fs
12 * volume group membership cache
13 */
14
15 #ifndef _AFS_VOL_VG_CACHE_IMPL_TYPES_H
16 #define _AFS_VOL_VG_CACHE_IMPL_TYPES_H 1
17
18 #ifndef __VOL_VG_CACHE_IMPL
19 #error "do not include this file outside of the volume group cache implementation"
20 #endif
21
22 #include "volume.h"
23 #include <rx/rx_queue.h>
24 #include <signal.h>
25
26
27 /**
28 * volume group cache node.
29 */
30 typedef struct VVGCache_entry {
31 VolumeId rw; /**< rw volume id */
32 VolumeId children[VOL_VG_MAX_VOLS]; /**< vector of children */
33 afs_uint32 refcnt; /**< hash chain refcount */
34 } VVGCache_entry_t;
35
36 /**
37 * volume group hash table.
38 */
39 typedef struct VVGCache_hash_table {
40 struct rx_queue * hash_buckets; /**< variable-length array of
41 * hash buckets */
42 } VVGCache_hash_table_t;
43
44 /**
45 * volume group hash bucket.
46 *
47 * @see VVGCache_hash_table_t
48 */
49 typedef struct VVGCache_hash_entry {
50 struct rx_queue hash_chain; /**< hash chain pointers */
51 VolumeId volid; /**< volume id */
52 struct DiskPartition64 * dp; /**< associated disk partition */
53 VVGCache_entry_t * entry; /**< volume group cache entry */
54 } VVGCache_hash_entry_t;
55
56 /* scanner implementation details */
57
58 /**
59 * scan element.
60 */
61 typedef struct VVGCache_scan_entry {
62 VolumeId volid;
63 VolumeId parent;
64 } VVGCache_scan_entry_t;
65
66 /**
67 * scan table.
68 */
69 typedef struct VVGCache_scan_table {
70 unsigned int idx;
71
72 /* stats */
73 unsigned long newvols;
74 unsigned long newvgs;
75
76 VVGCache_scan_entry_t entries[VVGC_SCAN_TBL_LEN];
77 } VVGCache_scan_table_t;
78
79 /**
80 * VVGC partition state enumeration.
81 */
82 typedef enum VVGCache_part_state {
83 VVGC_PART_STATE_VALID, /**< vvgc data for partition is valid */
84 VVGC_PART_STATE_INVALID, /**< vvgc data for partition is known to be invalid */
85 VVGC_PART_STATE_UPDATING /**< vvgc data for partition is currently updating */
86 } VVGCache_part_state_t;
87
88 /**
89 * entry in the 'to-delete' list.
90 *
91 * @see _VVGC_dlist_add_r
92 */
93 typedef struct VVGCache_dlist_entry {
94 struct rx_queue hash_chain; /**< hash chain pointers */
95 VolumeId child; /**< child volid of the VGC entry */
96 VolumeId parent; /**< parent volid of the VGC entry */
97 } VVGCache_dlist_entry_t;
98
99 /**
100 * VVGC partition state.
101 */
102 typedef struct VVGCache_part {
103 VVGCache_part_state_t state; /**< state of VVGC for this partition */
104 pthread_cond_t cv; /**< state change cv */
105 struct rx_queue *dlist_hash_buckets; /**< variable-length array of hash
106 * buckets. Queues contain
107 * VVGCache_dlist_entry_t's.
108 * This is NULL when we are not
109 * scanning. */
110 } VVGCache_part_t;
111
112 /**
113 * VVGC global state.
114 */
115 typedef struct VVGCache {
116 VVGCache_part_t part[VOLMAXPARTS+1]; /**< state of VVGC for each partition */
117 } VVGCache_t;
118
119 #endif /* _AFS_VOL_VG_CACHE_IMPL_TYPES_H */