~ubuntu-branches/ubuntu/trusty/glusterfs/trusty

« back to all changes in this revision

Viewing changes to xlators/cluster/afr/src/afr.h

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Matthäi
  • Date: 2010-02-09 18:53:10 UTC
  • mfrom: (1.2.4 upstream) (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100209185310-ww8p82lsbosorg2u
* New upstream release.
* Uploading to unstable.
* Bump Standards-Version to 3.8.4 (no changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
 
46
46
        char **pending_key;
47
47
 
48
 
        gf_boolean_t data_self_heal;       /* on/off */
 
48
        gf_boolean_t data_self_heal;              /* on/off */
 
49
        char *       data_self_heal_algorithm;    /* name of algorithm */
 
50
        unsigned int data_self_heal_window_size;  /* max number of pipelined
 
51
                                                     read/writes */
 
52
 
 
53
        unsigned int background_self_heal_count;
 
54
        unsigned int background_self_heals_started;
49
55
        gf_boolean_t metadata_self_heal;   /* on/off */
50
56
        gf_boolean_t entry_self_heal;      /* on/off */
51
57
 
62
68
        unsigned int entry_lock_server_count;
63
69
 
64
70
        unsigned int wait_count;      /* # of servers to wait for success */
 
71
 
 
72
        uint64_t up_count;      /* number of CHILD_UPs we have seen */
 
73
        uint64_t down_count;    /* number of CHILD_DOWNs we have seen */
65
74
} afr_private_t;
66
75
 
67
76
typedef struct {
 
77
        /* External interface: These are variables (some optional) that
 
78
           are set by whoever has triggered self-heal */
 
79
 
 
80
        gf_boolean_t need_data_self_heal;
 
81
        gf_boolean_t need_metadata_self_heal;
 
82
        gf_boolean_t need_entry_self_heal;
 
83
 
 
84
        gf_boolean_t forced_merge;        /* Is this a self-heal triggered to
 
85
                                             forcibly merge the directories? */
 
86
 
 
87
        gf_boolean_t healing_fd_opened;   /* true if caller has already
 
88
                                             opened fd */
 
89
 
 
90
        gf_boolean_t data_lock_held;      /* true if caller has already
 
91
                                             acquired 0-0 lock */
 
92
 
 
93
        fd_t *healing_fd;                 /* set if callers has opened fd */
 
94
 
 
95
        gf_boolean_t background;          /* do self-heal in background
 
96
                                             if possible */
 
97
 
 
98
        mode_t mode;                      /* st_mode of the entry we're doing
 
99
                                             self-heal on */
 
100
 
 
101
        /* Function to call to unwind. If self-heal is being done in the
 
102
           background, this function will be called as soon as possible. */
 
103
 
 
104
        int (*unwind) (call_frame_t *frame, xlator_t *this);
 
105
 
 
106
        /* End of external interface members */
 
107
 
 
108
 
68
109
        /* array of stat's, one for each child */
69
110
        struct stat *buf;
 
111
        struct stat parentbuf;
70
112
 
71
113
        /* array of xattr's, one for each child */
72
114
        dict_t **xattr;
83
125
        int active_sinks;
84
126
        int *success;
85
127
        int *locked_nodes;
86
 
 
87
 
        fd_t *healing_fd;
 
128
        int lock_count;
 
129
 
 
130
        mode_t impunging_entry_mode;
 
131
        const char *linkname;
 
132
 
88
133
        int   op_failed;
89
134
 
90
135
        int   file_has_holes;
93
138
        off_t offset;
94
139
 
95
140
        loc_t parent_loc;
 
141
 
 
142
        call_frame_t *orig_frame;
 
143
        gf_boolean_t unwound;
 
144
 
 
145
        /* private data for the particular self-heal algorithm */
 
146
        void *private;
 
147
 
 
148
        int (*flush_self_heal_cbk) (call_frame_t *frame, xlator_t *this);
 
149
 
96
150
        int (*completion_cbk) (call_frame_t *frame, xlator_t *this);
 
151
        int (*algo_completion_cbk) (call_frame_t *frame, xlator_t *this);
 
152
        int (*algo_abort_cbk) (call_frame_t *frame, xlator_t *this);
 
153
 
97
154
        call_frame_t *sh_frame;
98
155
} afr_self_heal_t;
99
156
 
135
192
}
136
193
 
137
194
 
 
195
typedef enum {
 
196
        AFR_CHILD_UP_FLUSH,
 
197
        AFR_CHILD_DOWN_FLUSH,
 
198
} afr_flush_type;
 
199
 
 
200
 
138
201
typedef struct _afr_local {
139
202
        unsigned int call_count;
140
203
        unsigned int success_count;
141
204
        unsigned int enoent_count;
142
205
 
143
 
        unsigned int need_metadata_self_heal;
144
 
        unsigned int need_entry_self_heal;
145
 
        unsigned int need_data_self_heal;
146
206
        unsigned int govinda_gOvinda;
147
207
 
148
208
        unsigned int read_child_index;
164
224
        glusterfs_fop_t fop;
165
225
 
166
226
        unsigned char *child_up; 
167
 
        int            child_count;
168
227
 
169
228
        int32_t *child_errno;
170
229
        
171
230
        dict_t  *xattr_req;
172
231
        int      open_fd_count;
 
232
 
173
233
        int32_t  inodelk_count;
174
234
        int32_t  entrylk_count;
175
235
 
 
236
        int (*up_down_flush_cbk) (call_frame_t *, xlator_t *);
 
237
 
176
238
        /* 
177
239
           This struct contains the arguments for the "continuation"
178
240
           (scheme-like) of fops
189
251
                        inode_t *inode;
190
252
                        struct stat buf;
191
253
                        struct stat read_child_buf;
 
254
                        struct stat postparent;
192
255
                        ino_t ino;
 
256
                        uint64_t gen;
 
257
                        ino_t parent_ino;
193
258
                        dict_t *xattr;
 
259
                        dict_t **xattrs;
 
260
                        gf_boolean_t is_revalidate;
194
261
                } lookup;
195
262
 
196
263
                struct {
197
264
                        int32_t flags;
 
265
                        int32_t wbflags;
198
266
                } open;
199
267
 
200
268
                struct {
228
296
                struct {
229
297
                        size_t size;
230
298
                        int last_tried;
 
299
                        ino_t ino;
231
300
                } readlink;
232
301
 
233
302
                struct {
248
317
                        int success_count;
249
318
                        int32_t op_ret;
250
319
                        int32_t op_errno;
 
320
 
 
321
                        uint32_t *checksum;
251
322
                } opendir;
252
323
 
253
324
                struct {
274
345
 
275
346
                struct {
276
347
                        ino_t ino;
277
 
                        mode_t mode;
278
 
                        struct stat buf;
279
 
                        struct stat read_child_buf;
280
 
                } chmod;
281
 
 
282
 
                struct {
283
 
                        ino_t ino;
284
 
                        mode_t mode;
285
 
                        struct stat buf;
286
 
                        struct stat read_child_buf;
287
 
                } fchmod;
288
 
 
289
 
                struct {
290
 
                        ino_t ino;
291
 
                        uid_t uid;
292
 
                        gid_t gid;
293
 
                        struct stat buf;
294
 
                        struct stat read_child_buf;
295
 
                } chown;
296
 
 
297
 
                struct {
298
 
                        ino_t ino;
299
 
                        uid_t uid;
300
 
                        gid_t gid;
301
 
                        struct stat buf;
302
 
                        struct stat read_child_buf;
303
 
                } fchown;
304
 
                
305
 
                struct {
306
 
                        ino_t ino;
307
 
                        struct stat buf;
308
 
                        struct stat read_child_buf;
 
348
                        struct stat prebuf;
 
349
                        struct stat postbuf;
309
350
 
310
351
                        int32_t op_ret;
311
352
 
315
356
                        off_t offset;
316
357
                } writev;
317
358
 
 
359
                struct {
 
360
                        ino_t ino;
 
361
                        struct stat prebuf;
 
362
                        struct stat postbuf;
 
363
                } fsync;
 
364
 
318
365
                struct {
319
366
                        ino_t ino;
320
367
                        off_t offset;
321
 
                        struct stat buf;
322
 
                        struct stat read_child_buf;
 
368
                        struct stat prebuf;
 
369
                        struct stat postbuf;
323
370
                } truncate;
324
371
 
325
372
                struct {
326
373
                        ino_t ino;
327
374
                        off_t offset;
328
 
                        struct stat buf;
329
 
                        struct stat read_child_buf;
 
375
                        struct stat prebuf;
 
376
                        struct stat postbuf;
330
377
                } ftruncate;
331
378
 
332
379
                struct {
333
380
                        ino_t ino;
334
 
                        struct timespec tv[2];
335
 
                        struct stat buf;
336
 
                        struct stat read_child_buf;
337
 
                } utimens;
 
381
                        struct stat in_buf;
 
382
                        int32_t valid;
 
383
                        struct stat preop_buf;
 
384
                        struct stat postop_buf;
 
385
                } setattr;
 
386
 
 
387
                struct {
 
388
                        ino_t ino;
 
389
                        struct stat in_buf;
 
390
                        int32_t valid;
 
391
                        struct stat preop_buf;
 
392
                        struct stat postop_buf;
 
393
                } fsetattr;
338
394
 
339
395
                struct {
340
396
                        dict_t *dict;
349
405
                
350
406
                struct {
351
407
                        ino_t ino;
 
408
                        uint64_t gen;
 
409
                        ino_t parent_ino;
352
410
                        fd_t *fd;
353
411
                        int32_t flags;
354
412
                        mode_t mode;
355
413
                        inode_t *inode;
356
414
                        struct stat buf;
 
415
                        struct stat preparent;
 
416
                        struct stat postparent;
357
417
                        struct stat read_child_buf;
358
418
                } create;
359
419
 
360
420
                struct {
361
421
                        ino_t ino;
 
422
                        uint64_t gen;
 
423
                        ino_t parent_ino;
362
424
                        dev_t dev;
363
425
                        mode_t mode;
364
426
                        inode_t *inode;
365
427
                        struct stat buf;
 
428
                        struct stat preparent;
 
429
                        struct stat postparent;
366
430
                        struct stat read_child_buf;
367
431
                } mknod;
368
432
 
369
433
                struct {
370
434
                        ino_t ino;
 
435
                        uint64_t gen;
 
436
                        ino_t parent_ino;
371
437
                        int32_t mode;
372
438
                        inode_t *inode;
373
439
                        struct stat buf;
374
440
                        struct stat read_child_buf;
 
441
                        struct stat preparent;
 
442
                        struct stat postparent;
375
443
                } mkdir;
376
444
 
377
445
                struct {
 
446
                        ino_t parent_ino;
378
447
                        int32_t op_ret;
379
448
                        int32_t op_errno;
 
449
                        struct stat preparent;
 
450
                        struct stat postparent;
380
451
                } unlink;
381
452
 
382
453
                struct {
 
454
                        ino_t parent_ino;
383
455
                        int32_t op_ret;
384
456
                        int32_t op_errno;
 
457
                        struct stat preparent;
 
458
                        struct stat postparent;
385
459
                } rmdir;
386
460
 
387
461
                struct {
 
462
                        ino_t oldparent_ino;
 
463
                        ino_t newparent_ino;
388
464
                        ino_t ino;
389
465
                        struct stat buf;
390
466
                        struct stat read_child_buf;
 
467
                        struct stat preoldparent;
 
468
                        struct stat prenewparent;
 
469
                        struct stat postoldparent;
 
470
                        struct stat postnewparent;
391
471
                } rename;
392
472
 
393
473
                struct {
394
474
                        ino_t ino;
 
475
                        uint64_t gen;
 
476
                        ino_t parent_ino;
395
477
                        inode_t *inode;
396
478
                        struct stat buf;
397
479
                        struct stat read_child_buf;
 
480
                        struct stat preparent;
 
481
                        struct stat postparent;
398
482
                } link;
399
483
 
400
484
                struct {
401
485
                        ino_t ino;
 
486
                        uint64_t gen;
 
487
                        ino_t parent_ino;
402
488
                        inode_t *inode;
403
489
                        struct stat buf;
404
490
                        struct stat read_child_buf;
405
491
                        char *linkpath;
 
492
                        struct stat preparent;
 
493
                        struct stat postparent;
406
494
                } symlink;
407
495
 
408
496
                struct {
442
530
                int (*resume) (call_frame_t *frame, xlator_t *this);
443
531
 
444
532
                int (*unwind) (call_frame_t *frame, xlator_t *this);
 
533
 
 
534
                /* post-op hook */
 
535
                int (*post_post_op) (call_frame_t *frame, xlator_t *this);
445
536
        } transaction;
446
537
 
447
538
        afr_self_heal_t self_heal;
449
540
 
450
541
 
451
542
typedef struct {
452
 
        unsigned char pre_op_done;
 
543
        unsigned char *pre_op_done;
 
544
        unsigned char *opened_on;     /* which subvolumes the fd is open on */
453
545
        unsigned char *child_failed;
 
546
        int flags;
 
547
        int32_t wbflags;
 
548
        uint64_t up_count;   /* number of CHILD_UPs this fd has seen */
 
549
        uint64_t down_count; /* number of CHILD_DOWNs this fd has seen */
454
550
} afr_fd_ctx_t;
455
551
 
456
552
 
506
602
int
507
603
afr_frame_return (call_frame_t *frame);
508
604
 
509
 
#define AFR_STACK_UNWIND(frame, params ...)             \
 
605
uint64_t
 
606
afr_is_split_brain (xlator_t *this, inode_t *inode);
 
607
 
 
608
void
 
609
afr_set_split_brain (xlator_t *this, inode_t *inode);
 
610
 
 
611
int
 
612
afr_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
 
613
          fd_t *fd, int32_t wbflags);
 
614
 
 
615
int
 
616
afr_up_down_flush (call_frame_t *frame, xlator_t *this, fd_t *fd, afr_flush_type type);
 
617
 
 
618
void
 
619
afr_set_opendir_done (xlator_t *this, inode_t *inode);
 
620
 
 
621
uint64_t
 
622
afr_is_opendir_done (xlator_t *this, inode_t *inode);
 
623
 
 
624
void
 
625
afr_local_transaction_cleanup (afr_local_t *local, xlator_t *this);
 
626
 
 
627
#define AFR_STACK_UNWIND(fop, frame, params ...)        \
510
628
        do {                                            \
511
629
                afr_local_t *__local = NULL;            \
512
630
                xlator_t    *__this = NULL;             \
513
631
                __local = frame->local;                 \
514
632
                __this = frame->this;                   \
515
633
                frame->local = NULL;                    \
516
 
                STACK_UNWIND (frame, params);           \
 
634
                STACK_UNWIND_STRICT (fop, frame, params);       \
517
635
                afr_local_cleanup (__local, __this);    \
518
636
                free (__local);                         \
519
637
} while (0);