1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
/*
Copyright (c) 2013 Red Hat, Inc. <http://www.redhat.com>
This file is part of GlusterFS.
This file is licensed to you under your choice of the GNU Lesser
General Public License, version 3 or any later version (LGPLv3 or
later), or the GNU General Public License, version 2 (GPLv2), in all
cases as published by the Free Software Foundation.
*/
#ifndef _AFR_SELFHEAL_H
#define _AFR_SELFHEAL_H
#define AFR_SH_MIN_PARTICIPANTS 2
/* Perform fop on all UP subvolumes and wait for all callbacks to return */
#define AFR_ONALL(frame, rfn, fop, args...) \
do { \
afr_local_t *__local = frame->local; \
afr_private_t *__priv = frame->this->private; \
int __i = 0, __count = 0; \
unsigned char *__child_up = alloca(__priv->child_count); \
\
memcpy(__child_up, __priv->child_up, \
sizeof(*__child_up) * __priv->child_count); \
__count = AFR_COUNT(__child_up, __priv->child_count); \
\
__local->barrier.waitfor = __count; \
afr_local_replies_wipe(__local, __priv); \
\
for (__i = 0; __i < __priv->child_count; __i++) { \
if (!__child_up[__i]) \
continue; \
STACK_WIND_COOKIE(frame, rfn, (void *)(long)__i, \
__priv->children[__i], \
__priv->children[__i]->fops->fop, args); \
} \
syncbarrier_wait(&__local->barrier, __count); \
} while (0)
/* Perform fop on all subvolumes represented by list[] array and wait
for all callbacks to return */
#define AFR_ONLIST(list, frame, rfn, fop, args...) \
do { \
afr_local_t *__local = frame->local; \
afr_private_t *__priv = frame->this->private; \
int __i = 0; \
int __count = AFR_COUNT(list, __priv->child_count); \
\
__local->barrier.waitfor = __count; \
afr_local_replies_wipe(__local, __priv); \
\
for (__i = 0; __i < __priv->child_count; __i++) { \
if (!list[__i]) \
continue; \
STACK_WIND_COOKIE(frame, rfn, (void *)(long)__i, \
__priv->children[__i], \
__priv->children[__i]->fops->fop, args); \
} \
syncbarrier_wait(&__local->barrier, __count); \
} while (0)
#define AFR_SEQ(frame, rfn, fop, args...) \
do { \
afr_local_t *__local = frame->local; \
afr_private_t *__priv = frame->this->private; \
int __i = 0; \
\
afr_local_replies_wipe(__local, __priv); \
\
for (__i = 0; __i < __priv->child_count; __i++) { \
if (!__priv->child_up[__i]) \
continue; \
STACK_WIND_COOKIE(frame, rfn, (void *)(long)__i, \
__priv->children[__i], \
__priv->children[__i]->fops->fop, args); \
syncbarrier_wait(&__local->barrier, 1); \
} \
} while (0)
#define ALLOC_MATRIX(n, type) \
({ \
int __i; \
type **__ptr = alloca(n * sizeof(type *)); \
\
for (__i = 0; __i < n; __i++) \
__ptr[__i] = alloca0(n * sizeof(type)); \
__ptr; \
})
#define IA_EQUAL(f, s, field) \
(memcmp(&(f.ia_##field), &(s.ia_##field), sizeof(s.ia_##field)) == 0)
#define SBRAIN_HEAL_NO_GO_MSG \
"Failed to obtain replies from all bricks of " \
"the replica (are they up?). Cannot resolve split-brain."
#define SFILE_NOT_IN_SPLIT_BRAIN "File not in split-brain"
#define SNO_BIGGER_FILE "No bigger file"
#define SNO_DIFF_IN_MTIME "No difference in mtime"
#define SUSE_SOURCE_BRICK_TO_HEAL \
"Use source-brick option to heal metadata" \
" split-brain"
#define SINVALID_BRICK_NAME "Invalid brick name"
#define SBRICK_IS_NOT_UP "Brick is not up"
#define SBRICK_NOT_CONNECTED "Brick is not connected"
#define SLESS_THAN2_BRICKS_in_REP "< 2 bricks in replica are up"
#define SBRICK_IS_REMOTE "Brick is remote"
#define SSTARTED_SELF_HEAL "Started self-heal"
#define SOP_NOT_SUPPORTED "Operation Not Supported"
#define SFILE_NOT_UNDER_DATA \
"The file is not under data or metadata " \
"split-brain"
#define SFILE_NOT_IN_SPLIT_BRAIN "File not in split-brain"
#define SALL_BRICKS_UP_TO_RESOLVE \
"All the bricks should be up to resolve the" \
" gfid split brain"
#define SERROR_GETTING_SRC_BRICK "Error getting the source brick"
int
afr_selfheal(xlator_t *this, uuid_t gfid);
gf_boolean_t
afr_throttled_selfheal(call_frame_t *frame, xlator_t *this);
int
afr_selfheal_name(xlator_t *this, uuid_t gfid, const char *name, void *gfid_req,
dict_t *xdata);
int
afr_selfheal_data(call_frame_t *frame, xlator_t *this, fd_t *fd);
int
afr_selfheal_metadata(call_frame_t *frame, xlator_t *this, inode_t *inode);
int
afr_selfheal_entry(call_frame_t *frame, xlator_t *this, inode_t *inode);
int
afr_lookup_and_heal_gfid(xlator_t *this, inode_t *parent, const char *name,
inode_t *inode, struct afr_reply *replies, int source,
unsigned char *sources, void *gfid, int *gfid_idx);
int
afr_selfheal_inodelk(call_frame_t *frame, xlator_t *this, inode_t *inode,
char *dom, off_t off, size_t size,
unsigned char *locked_on);
int
afr_selfheal_tryinodelk(call_frame_t *frame, xlator_t *this, inode_t *inode,
char *dom, off_t off, size_t size,
unsigned char *locked_on);
int
afr_selfheal_tie_breaker_inodelk(call_frame_t *frame, xlator_t *this,
inode_t *inode, char *dom, off_t off,
size_t size, unsigned char *locked_on);
int
afr_selfheal_uninodelk(call_frame_t *frame, xlator_t *this, inode_t *inode,
char *dom, off_t off, size_t size,
const unsigned char *locked_on);
int
afr_selfheal_entrylk(call_frame_t *frame, xlator_t *this, inode_t *inode,
char *dom, const char *name, unsigned char *locked_on);
int
afr_selfheal_tryentrylk(call_frame_t *frame, xlator_t *this, inode_t *inode,
char *dom, const char *name, unsigned char *locked_on);
int
afr_selfheal_tie_breaker_entrylk(call_frame_t *frame, xlator_t *this,
inode_t *inode, char *dom, const char *name,
unsigned char *locked_on);
int
afr_selfheal_unentrylk(call_frame_t *frame, xlator_t *this, inode_t *inode,
char *dom, const char *name, unsigned char *locked_on,
dict_t *xdata);
int
afr_selfheal_unlocked_discover(call_frame_t *frame, inode_t *inode, uuid_t gfid,
struct afr_reply *replies);
int
afr_selfheal_unlocked_discover_on(call_frame_t *frame, inode_t *inode,
uuid_t gfid, struct afr_reply *replies,
unsigned char *discover_on, dict_t *dict);
inode_t *
afr_selfheal_unlocked_lookup_on(call_frame_t *frame, inode_t *parent,
const char *name, struct afr_reply *replies,
unsigned char *lookup_on, dict_t *xattr);
int
afr_selfheal_find_direction(call_frame_t *frame, xlator_t *this,
struct afr_reply *replies,
afr_transaction_type type, unsigned char *locked_on,
unsigned char *sources, unsigned char *sinks,
uint64_t *witness, unsigned char *flag);
int
afr_selfheal_fill_matrix(xlator_t *this, int **matrix, int subvol, int idx,
dict_t *xdata);
int
afr_selfheal_extract_xattr(xlator_t *this, struct afr_reply *replies,
afr_transaction_type type, int *dirty, int **matrix);
int
afr_sh_generic_fop_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
int op_ret, int op_errno, struct iatt *pre,
struct iatt *post, dict_t *xdata);
int
afr_selfheal_restore_time(call_frame_t *frame, xlator_t *this, inode_t *inode,
int source, unsigned char *healed_sinks,
struct afr_reply *replies);
int
afr_selfheal_undo_pending(call_frame_t *frame, xlator_t *this, inode_t *inode,
unsigned char *sources, unsigned char *sinks,
unsigned char *healed_sinks,
unsigned char *undid_pending,
afr_transaction_type type, struct afr_reply *replies,
unsigned char *locked_on);
int
afr_selfheal_recreate_entry(call_frame_t *frame, int dst, int source,
unsigned char *sources, inode_t *dir,
const char *name, inode_t *inode,
struct afr_reply *replies);
int
afr_selfheal_post_op(call_frame_t *frame, xlator_t *this, inode_t *inode,
int subvol, dict_t *xattr, dict_t *xdata);
call_frame_t *
afr_frame_create(xlator_t *this, int32_t *op_errno);
inode_t *
afr_inode_find(xlator_t *this, uuid_t gfid);
int
afr_selfheal_discover_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
int op_ret, int op_errno, inode_t *inode,
struct iatt *buf, dict_t *xdata, struct iatt *parbuf);
void
afr_reply_copy(struct afr_reply *dst, struct afr_reply *src);
void
afr_replies_copy(struct afr_reply *dst, struct afr_reply *src, int count);
int
afr_selfheal_newentry_mark(call_frame_t *frame, xlator_t *this, inode_t *inode,
int source, struct afr_reply *replies,
unsigned char *sources, unsigned char *newentry);
unsigned int
afr_success_count(struct afr_reply *replies, unsigned int count);
void
afr_log_selfheal(uuid_t gfid, xlator_t *this, int ret, char *type, int source,
unsigned char *sources, unsigned char *healed_sinks);
void
afr_mark_largest_file_as_source(xlator_t *this, unsigned char *sources,
struct afr_reply *replies);
void
afr_mark_active_sinks(xlator_t *this, unsigned char *sources,
unsigned char *locked_on, unsigned char *sinks);
gf_boolean_t
afr_dict_contains_heal_op(call_frame_t *frame);
gf_boolean_t
afr_can_decide_split_brain_source_sinks(struct afr_reply *replies,
int child_count);
int
afr_mark_split_brain_source_sinks(
call_frame_t *frame, xlator_t *this, inode_t *inode, unsigned char *sources,
unsigned char *sinks, unsigned char *healed_sinks, unsigned char *locked_on,
struct afr_reply *replies, afr_transaction_type type);
int
afr_sh_get_fav_by_policy(xlator_t *this, struct afr_reply *replies,
inode_t *inode, char **policy_str);
int
_afr_fav_child_reset_sink_xattrs(call_frame_t *frame, xlator_t *this,
inode_t *inode, int source,
unsigned char *healed_sinks,
unsigned char *undid_pending,
afr_transaction_type type,
unsigned char *locked_on,
struct afr_reply *replies);
int
afr_get_child_index_from_name(xlator_t *this, char *name);
gf_boolean_t
afr_does_witness_exist(xlator_t *this, uint64_t *witness);
int
__afr_selfheal_data_prepare(call_frame_t *frame, xlator_t *this, inode_t *inode,
unsigned char *locked_on, unsigned char *sources,
unsigned char *sinks, unsigned char *healed_sinks,
unsigned char *undid_pending,
struct afr_reply *replies, unsigned char *flag);
int
__afr_selfheal_metadata_prepare(call_frame_t *frame, xlator_t *this,
inode_t *inode, unsigned char *locked_on,
unsigned char *sources, unsigned char *sinks,
unsigned char *healed_sinks,
unsigned char *undid_pending,
struct afr_reply *replies, unsigned char *flag);
int
__afr_selfheal_entry_prepare(call_frame_t *frame, xlator_t *this,
inode_t *inode, unsigned char *locked_on,
unsigned char *sources, unsigned char *sinks,
unsigned char *healed_sinks,
struct afr_reply *replies, int *source_p,
unsigned char *flag);
int
afr_selfheal_unlocked_inspect(call_frame_t *frame, xlator_t *this, uuid_t gfid,
inode_t **link_inode, gf_boolean_t *data_selfheal,
gf_boolean_t *metadata_selfheal,
gf_boolean_t *entry_selfheal);
int
afr_selfheal_do(call_frame_t *frame, xlator_t *this, uuid_t gfid);
int
afr_selfheal_lock_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
int op_ret, int op_errno, dict_t *xdata);
int
afr_locked_fill(call_frame_t *frame, xlator_t *this, unsigned char *locked_on);
int
afr_choose_source_by_policy(afr_private_t *priv, unsigned char *sources,
afr_transaction_type type);
int
afr_selfheal_metadata_by_stbuf(xlator_t *this, struct iatt *stbuf);
int
afr_sh_fav_by_size(xlator_t *this, struct afr_reply *replies, inode_t *inode);
int
afr_sh_fav_by_mtime(xlator_t *this, struct afr_reply *replies, inode_t *inode);
int
afr_sh_fav_by_ctime(xlator_t *this, struct afr_reply *replies, inode_t *inode);
int
afr_gfid_split_brain_source(xlator_t *this, struct afr_reply *replies,
inode_t *inode, uuid_t pargfid, const char *bname,
int src_idx, int child_idx,
unsigned char *locked_on, int *src, dict_t *xdata);
int
afr_mark_source_sinks_if_file_empty(xlator_t *this, unsigned char *sources,
unsigned char *sinks,
unsigned char *healed_sinks,
unsigned char *locked_on,
struct afr_reply *replies,
afr_transaction_type type);
gf_boolean_t
afr_is_file_empty_on_all_children(afr_private_t *priv,
struct afr_reply *replies);
#endif /* !_AFR_SELFHEAL_H */
|