This source file includes following definitions.
- drbd_request_state
1
2 #ifndef DRBD_STATE_H
3 #define DRBD_STATE_H
4
5 struct drbd_device;
6 struct drbd_connection;
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #define role_MASK R_MASK
27 #define peer_MASK R_MASK
28 #define disk_MASK D_MASK
29 #define pdsk_MASK D_MASK
30 #define conn_MASK C_MASK
31 #define susp_MASK 1
32 #define user_isp_MASK 1
33 #define aftr_isp_MASK 1
34 #define susp_nod_MASK 1
35 #define susp_fen_MASK 1
36
37 #define NS(T, S) \
38 ({ union drbd_state mask; mask.i = 0; mask.T = T##_MASK; mask; }), \
39 ({ union drbd_state val; val.i = 0; val.T = (S); val; })
40 #define NS2(T1, S1, T2, S2) \
41 ({ union drbd_state mask; mask.i = 0; mask.T1 = T1##_MASK; \
42 mask.T2 = T2##_MASK; mask; }), \
43 ({ union drbd_state val; val.i = 0; val.T1 = (S1); \
44 val.T2 = (S2); val; })
45 #define NS3(T1, S1, T2, S2, T3, S3) \
46 ({ union drbd_state mask; mask.i = 0; mask.T1 = T1##_MASK; \
47 mask.T2 = T2##_MASK; mask.T3 = T3##_MASK; mask; }), \
48 ({ union drbd_state val; val.i = 0; val.T1 = (S1); \
49 val.T2 = (S2); val.T3 = (S3); val; })
50
51 #define _NS(D, T, S) \
52 D, ({ union drbd_state __ns; __ns = drbd_read_state(D); __ns.T = (S); __ns; })
53 #define _NS2(D, T1, S1, T2, S2) \
54 D, ({ union drbd_state __ns; __ns = drbd_read_state(D); __ns.T1 = (S1); \
55 __ns.T2 = (S2); __ns; })
56 #define _NS3(D, T1, S1, T2, S2, T3, S3) \
57 D, ({ union drbd_state __ns; __ns = drbd_read_state(D); __ns.T1 = (S1); \
58 __ns.T2 = (S2); __ns.T3 = (S3); __ns; })
59
60 enum chg_state_flags {
61 CS_HARD = 1 << 0,
62 CS_VERBOSE = 1 << 1,
63 CS_WAIT_COMPLETE = 1 << 2,
64 CS_SERIALIZE = 1 << 3,
65 CS_ORDERED = CS_WAIT_COMPLETE + CS_SERIALIZE,
66 CS_LOCAL_ONLY = 1 << 4,
67 CS_DC_ROLE = 1 << 5,
68 CS_DC_PEER = 1 << 6,
69 CS_DC_CONN = 1 << 7,
70 CS_DC_DISK = 1 << 8,
71 CS_DC_PDSK = 1 << 9,
72 CS_DC_SUSP = 1 << 10,
73 CS_DC_MASK = CS_DC_ROLE + CS_DC_PEER + CS_DC_CONN + CS_DC_DISK + CS_DC_PDSK,
74 CS_IGN_OUTD_FAIL = 1 << 11,
75
76
77
78 CS_INHIBIT_MD_IO = 1 << 12,
79 };
80
81
82
83
84 union drbd_dev_state {
85 struct {
86 #if defined(__LITTLE_ENDIAN_BITFIELD)
87 unsigned role:2 ;
88 unsigned peer:2 ;
89 unsigned conn:5 ;
90 unsigned disk:4 ;
91 unsigned pdsk:4 ;
92 unsigned _unused:1 ;
93 unsigned aftr_isp:1 ;
94 unsigned peer_isp:1 ;
95 unsigned user_isp:1 ;
96 unsigned _pad:11;
97 #elif defined(__BIG_ENDIAN_BITFIELD)
98 unsigned _pad:11;
99 unsigned user_isp:1 ;
100 unsigned peer_isp:1 ;
101 unsigned aftr_isp:1 ;
102 unsigned _unused:1 ;
103 unsigned pdsk:4 ;
104 unsigned disk:4 ;
105 unsigned conn:5 ;
106 unsigned peer:2 ;
107 unsigned role:2 ;
108 #else
109 # error "this endianess is not supported"
110 #endif
111 };
112 unsigned int i;
113 };
114
115 extern enum drbd_state_rv drbd_change_state(struct drbd_device *device,
116 enum chg_state_flags f,
117 union drbd_state mask,
118 union drbd_state val);
119 extern void drbd_force_state(struct drbd_device *, union drbd_state,
120 union drbd_state);
121 extern enum drbd_state_rv _drbd_request_state(struct drbd_device *,
122 union drbd_state,
123 union drbd_state,
124 enum chg_state_flags);
125
126 extern enum drbd_state_rv
127 _drbd_request_state_holding_state_mutex(struct drbd_device *, union drbd_state,
128 union drbd_state, enum chg_state_flags);
129
130 extern enum drbd_state_rv _drbd_set_state(struct drbd_device *, union drbd_state,
131 enum chg_state_flags,
132 struct completion *done);
133 extern void print_st_err(struct drbd_device *, union drbd_state,
134 union drbd_state, enum drbd_state_rv);
135
136 enum drbd_state_rv
137 _conn_request_state(struct drbd_connection *connection, union drbd_state mask, union drbd_state val,
138 enum chg_state_flags flags);
139
140 enum drbd_state_rv
141 conn_request_state(struct drbd_connection *connection, union drbd_state mask, union drbd_state val,
142 enum chg_state_flags flags);
143
144 extern void drbd_resume_al(struct drbd_device *device);
145 extern bool conn_all_vols_unconf(struct drbd_connection *connection);
146
147
148
149
150
151
152
153
154
155
156
157 static inline int drbd_request_state(struct drbd_device *device,
158 union drbd_state mask,
159 union drbd_state val)
160 {
161 return _drbd_request_state(device, mask, val, CS_VERBOSE + CS_ORDERED);
162 }
163
164
165 int drbd_request_detach_interruptible(struct drbd_device *device);
166
167 enum drbd_role conn_highest_role(struct drbd_connection *connection);
168 enum drbd_role conn_highest_peer(struct drbd_connection *connection);
169 enum drbd_disk_state conn_highest_disk(struct drbd_connection *connection);
170 enum drbd_disk_state conn_lowest_disk(struct drbd_connection *connection);
171 enum drbd_disk_state conn_highest_pdsk(struct drbd_connection *connection);
172 enum drbd_conns conn_lowest_conn(struct drbd_connection *connection);
173
174 #endif