glusterfs

Форк
0
/
default-args.c 
1644 строки · 37.3 Кб
1
/*
2
  Copyright (c) 2008-2015 Red Hat, Inc. <http://www.redhat.com>
3
  This file is part of GlusterFS.
4

5
  This file is licensed to you under your choice of the GNU Lesser
6
  General Public License, version 3 or any later version (LGPLv3 or
7
  later), or the GNU General Public License, version 2 (GPLv2), in all
8
  cases as published by the Free Software Foundation.
9
*/
10

11
#ifndef _CONFIG_H
12
#define _CONFIG_H
13
#include "config.h"
14
#endif
15

16
#include "glusterfs/defaults.h"
17

18
int
19
args_lookup_store(default_args_t *args, loc_t *loc, dict_t *xdata)
20
{
21
    loc_copy(&args->loc, loc);
22
    if (xdata)
23
        args->xdata = dict_ref(xdata);
24

25
    return 0;
26
}
27

28
int
29
args_lookup_cbk_store(default_args_cbk_t *args, int32_t op_ret,
30
                      int32_t op_errno, inode_t *inode, struct iatt *buf,
31
                      dict_t *xdata, struct iatt *postparent)
32
{
33
    args->op_ret = op_ret;
34
    args->op_errno = op_errno;
35
    if (inode)
36
        args->inode = inode_ref(inode);
37
    if (buf)
38
        args->stat = *buf;
39
    if (postparent)
40
        args->postparent = *postparent;
41
    if (xdata)
42
        args->xdata = dict_ref(xdata);
43

44
    return 0;
45
}
46

47
int
48
args_stat_store(default_args_t *args, loc_t *loc, dict_t *xdata)
49
{
50
    loc_copy(&args->loc, loc);
51
    if (xdata)
52
        args->xdata = dict_ref(xdata);
53

54
    return 0;
55
}
56

57
int
58
args_stat_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
59
                    struct iatt *buf, dict_t *xdata)
60
{
61
    args->op_ret = op_ret;
62
    args->op_errno = op_errno;
63
    if (op_ret == 0)
64
        args->stat = *buf;
65
    if (xdata)
66
        args->xdata = dict_ref(xdata);
67

68
    return 0;
69
}
70

71
int
72
args_fstat_store(default_args_t *args, fd_t *fd, dict_t *xdata)
73
{
74
    if (fd)
75
        args->fd = fd_ref(fd);
76
    if (xdata)
77
        args->xdata = dict_ref(xdata);
78

79
    return 0;
80
}
81

82
int
83
args_fstat_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
84
                     struct iatt *buf, dict_t *xdata)
85
{
86
    args->op_ret = op_ret;
87
    args->op_errno = op_errno;
88
    if (buf)
89
        args->stat = *buf;
90
    if (xdata)
91
        args->xdata = dict_ref(xdata);
92

93
    return 0;
94
}
95

96
int
97
args_truncate_store(default_args_t *args, loc_t *loc, off_t off, dict_t *xdata)
98
{
99
    loc_copy(&args->loc, loc);
100
    args->offset = off;
101
    if (xdata)
102
        args->xdata = dict_ref(xdata);
103

104
    return 0;
105
}
106

107
int
108
args_truncate_cbk_store(default_args_cbk_t *args, int32_t op_ret,
109
                        int32_t op_errno, struct iatt *prebuf,
110
                        struct iatt *postbuf, dict_t *xdata)
111
{
112
    args->op_ret = op_ret;
113
    args->op_errno = op_errno;
114
    if (prebuf)
115
        args->prestat = *prebuf;
116
    if (postbuf)
117
        args->poststat = *postbuf;
118
    if (xdata)
119
        args->xdata = dict_ref(xdata);
120

121
    return 0;
122
}
123

124
int
125
args_ftruncate_store(default_args_t *args, fd_t *fd, off_t off, dict_t *xdata)
126
{
127
    if (fd)
128
        args->fd = fd_ref(fd);
129

130
    args->offset = off;
131
    if (xdata)
132
        args->xdata = dict_ref(xdata);
133

134
    return 0;
135
}
136

137
int
138
args_ftruncate_cbk_store(default_args_cbk_t *args, int32_t op_ret,
139
                         int32_t op_errno, struct iatt *prebuf,
140
                         struct iatt *postbuf, dict_t *xdata)
141
{
142
    args->op_ret = op_ret;
143
    args->op_errno = op_errno;
144
    if (prebuf)
145
        args->prestat = *prebuf;
146
    if (postbuf)
147
        args->poststat = *postbuf;
148
    if (xdata)
149
        args->xdata = dict_ref(xdata);
150

151
    return 0;
152
}
153

154
int
155
args_access_store(default_args_t *args, loc_t *loc, int32_t mask, dict_t *xdata)
156
{
157
    loc_copy(&args->loc, loc);
158
    args->mask = mask;
159
    if (xdata)
160
        args->xdata = dict_ref(xdata);
161

162
    return 0;
163
}
164

165
int
166
args_access_cbk_store(default_args_cbk_t *args, int32_t op_ret,
167
                      int32_t op_errno, dict_t *xdata)
168
{
169
    args->op_ret = op_ret;
170
    args->op_errno = op_errno;
171
    if (xdata)
172
        args->xdata = dict_ref(xdata);
173

174
    return 0;
175
}
176

177
int
178
args_readlink_store(default_args_t *args, loc_t *loc, size_t size,
179
                    dict_t *xdata)
180
{
181
    loc_copy(&args->loc, loc);
182
    args->size = size;
183
    if (xdata)
184
        args->xdata = dict_ref(xdata);
185

186
    return 0;
187
}
188

189
int
190
args_readlink_cbk_store(default_args_cbk_t *args, int32_t op_ret,
191
                        int32_t op_errno, const char *path, struct iatt *stbuf,
192
                        dict_t *xdata)
193
{
194
    args->op_ret = op_ret;
195
    args->op_errno = op_errno;
196
    if (path)
197
        args->buf = gf_strdup(path);
198
    if (stbuf)
199
        args->stat = *stbuf;
200
    if (xdata)
201
        args->xdata = dict_ref(xdata);
202

203
    return 0;
204
}
205

206
int
207
args_mknod_store(default_args_t *args, loc_t *loc, mode_t mode, dev_t rdev,
208
                 mode_t umask, dict_t *xdata)
209
{
210
    loc_copy(&args->loc, loc);
211
    args->mode = mode;
212
    args->rdev = rdev;
213
    args->umask = umask;
214
    if (xdata)
215
        args->xdata = dict_ref(xdata);
216

217
    return 0;
218
}
219

220
int
221
args_mknod_cbk_store(default_args_cbk_t *args, int op_ret, int32_t op_errno,
222
                     inode_t *inode, struct iatt *buf, struct iatt *preparent,
223
                     struct iatt *postparent, dict_t *xdata)
224
{
225
    args->op_ret = op_ret;
226
    args->op_errno = op_errno;
227
    if (inode)
228
        args->inode = inode_ref(inode);
229
    if (buf)
230
        args->stat = *buf;
231
    if (preparent)
232
        args->preparent = *preparent;
233
    if (postparent)
234
        args->postparent = *postparent;
235
    if (xdata)
236
        args->xdata = dict_ref(xdata);
237

238
    return 0;
239
}
240

241
int
242
args_mkdir_store(default_args_t *args, loc_t *loc, mode_t mode, mode_t umask,
243
                 dict_t *xdata)
244
{
245
    loc_copy(&args->loc, loc);
246
    args->mode = mode;
247
    args->umask = umask;
248

249
    if (xdata)
250
        args->xdata = dict_ref(xdata);
251

252
    return 0;
253
}
254

255
int
256
args_mkdir_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
257
                     inode_t *inode, struct iatt *buf, struct iatt *preparent,
258
                     struct iatt *postparent, dict_t *xdata)
259
{
260
    args->op_ret = op_ret;
261
    args->op_errno = op_errno;
262
    if (inode)
263
        args->inode = inode_ref(inode);
264
    if (buf)
265
        args->stat = *buf;
266
    if (preparent)
267
        args->preparent = *preparent;
268
    if (postparent)
269
        args->postparent = *postparent;
270
    if (xdata)
271
        args->xdata = dict_ref(xdata);
272

273
    return 0;
274
}
275

276
int
277
args_unlink_store(default_args_t *args, loc_t *loc, int xflag, dict_t *xdata)
278
{
279
    loc_copy(&args->loc, loc);
280
    args->xflag = xflag;
281
    if (xdata)
282
        args->xdata = dict_ref(xdata);
283

284
    return 0;
285
}
286

287
int
288
args_unlink_cbk_store(default_args_cbk_t *args, int32_t op_ret,
289
                      int32_t op_errno, struct iatt *preparent,
290
                      struct iatt *postparent, dict_t *xdata)
291
{
292
    args->op_ret = op_ret;
293
    args->op_errno = op_errno;
294
    if (preparent)
295
        args->preparent = *preparent;
296
    if (postparent)
297
        args->postparent = *postparent;
298
    if (xdata)
299
        args->xdata = dict_ref(xdata);
300

301
    return 0;
302
}
303

304
int
305
args_rmdir_store(default_args_t *args, loc_t *loc, int flags, dict_t *xdata)
306
{
307
    loc_copy(&args->loc, loc);
308
    args->flags = flags;
309
    if (xdata)
310
        args->xdata = dict_ref(xdata);
311
    return 0;
312
}
313

314
int
315
args_rmdir_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
316
                     struct iatt *preparent, struct iatt *postparent,
317
                     dict_t *xdata)
318
{
319
    args->op_ret = op_ret;
320
    args->op_errno = op_errno;
321
    if (preparent)
322
        args->preparent = *preparent;
323
    if (postparent)
324
        args->postparent = *postparent;
325
    if (xdata)
326
        args->xdata = dict_ref(xdata);
327

328
    return 0;
329
}
330

331
int
332
args_symlink_store(default_args_t *args, const char *linkname, loc_t *loc,
333
                   mode_t umask, dict_t *xdata)
334
{
335
    args->linkname = gf_strdup(linkname);
336
    args->umask = umask;
337
    loc_copy(&args->loc, loc);
338
    if (xdata)
339
        args->xdata = dict_ref(xdata);
340

341
    return 0;
342
}
343

344
int
345
args_symlink_cbk_store(default_args_cbk_t *args, int32_t op_ret,
346
                       int32_t op_errno, inode_t *inode, struct iatt *buf,
347
                       struct iatt *preparent, struct iatt *postparent,
348
                       dict_t *xdata)
349
{
350
    args->op_ret = op_ret;
351
    args->op_errno = op_errno;
352
    if (inode)
353
        args->inode = inode_ref(inode);
354
    if (buf)
355
        args->stat = *buf;
356
    if (preparent)
357
        args->preparent = *preparent;
358
    if (postparent)
359
        args->postparent = *postparent;
360
    if (xdata)
361
        args->xdata = dict_ref(xdata);
362

363
    return 0;
364
}
365

366
int
367
args_rename_store(default_args_t *args, loc_t *oldloc, loc_t *newloc,
368
                  dict_t *xdata)
369
{
370
    loc_copy(&args->loc, oldloc);
371
    loc_copy(&args->loc2, newloc);
372
    if (xdata)
373
        args->xdata = dict_ref(xdata);
374

375
    return 0;
376
}
377

378
int
379
args_rename_cbk_store(default_args_cbk_t *args, int32_t op_ret,
380
                      int32_t op_errno, struct iatt *buf,
381
                      struct iatt *preoldparent, struct iatt *postoldparent,
382
                      struct iatt *prenewparent, struct iatt *postnewparent,
383
                      dict_t *xdata)
384
{
385
    args->op_ret = op_ret;
386
    args->op_errno = op_errno;
387
    if (buf)
388
        args->stat = *buf;
389
    if (preoldparent)
390
        args->preparent = *preoldparent;
391
    if (postoldparent)
392
        args->postparent = *postoldparent;
393
    if (prenewparent)
394
        args->preparent2 = *prenewparent;
395
    if (postnewparent)
396
        args->postparent2 = *postnewparent;
397
    if (xdata)
398
        args->xdata = dict_ref(xdata);
399

400
    return 0;
401
}
402

403
int
404
args_link_store(default_args_t *args, loc_t *oldloc, loc_t *newloc,
405
                dict_t *xdata)
406
{
407
    loc_copy(&args->loc, oldloc);
408
    loc_copy(&args->loc2, newloc);
409

410
    if (xdata)
411
        args->xdata = dict_ref(xdata);
412

413
    return 0;
414
}
415

416
int
417
args_link_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
418
                    inode_t *inode, struct iatt *buf, struct iatt *preparent,
419
                    struct iatt *postparent, dict_t *xdata)
420
{
421
    args->op_ret = op_ret;
422
    args->op_errno = op_errno;
423
    if (inode)
424
        args->inode = inode_ref(inode);
425
    if (buf)
426
        args->stat = *buf;
427
    if (preparent)
428
        args->preparent = *preparent;
429
    if (postparent)
430
        args->postparent = *postparent;
431
    if (xdata)
432
        args->xdata = dict_ref(xdata);
433

434
    return 0;
435
}
436

437
int
438
args_create_store(default_args_t *args, loc_t *loc, int32_t flags, mode_t mode,
439
                  mode_t umask, fd_t *fd, dict_t *xdata)
440
{
441
    loc_copy(&args->loc, loc);
442
    args->flags = flags;
443
    args->mode = mode;
444
    args->umask = umask;
445
    if (fd)
446
        args->fd = fd_ref(fd);
447
    if (xdata)
448
        args->xdata = dict_ref(xdata);
449
    return 0;
450
}
451

452
int
453
args_create_cbk_store(default_args_cbk_t *args, int32_t op_ret,
454
                      int32_t op_errno, fd_t *fd, inode_t *inode,
455
                      struct iatt *buf, struct iatt *preparent,
456
                      struct iatt *postparent, dict_t *xdata)
457
{
458
    args->op_ret = op_ret;
459
    args->op_errno = op_errno;
460
    if (fd)
461
        args->fd = fd_ref(fd);
462
    if (inode)
463
        args->inode = inode_ref(inode);
464
    if (buf)
465
        args->stat = *buf;
466
    if (preparent)
467
        args->preparent = *preparent;
468
    if (postparent)
469
        args->postparent = *postparent;
470
    if (xdata)
471
        args->xdata = dict_ref(xdata);
472

473
    return 0;
474
}
475

476
int
477
args_open_store(default_args_t *args, loc_t *loc, int32_t flags, fd_t *fd,
478
                dict_t *xdata)
479
{
480
    loc_copy(&args->loc, loc);
481
    args->flags = flags;
482
    if (fd)
483
        args->fd = fd_ref(fd);
484
    if (xdata)
485
        args->xdata = dict_ref(xdata);
486

487
    return 0;
488
}
489

490
int
491
args_open_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
492
                    fd_t *fd, dict_t *xdata)
493
{
494
    args->op_ret = op_ret;
495
    args->op_errno = op_errno;
496
    if (fd)
497
        args->fd = fd_ref(fd);
498
    if (xdata)
499
        args->xdata = dict_ref(xdata);
500

501
    return 0;
502
}
503

504
int
505
args_readv_store(default_args_t *args, fd_t *fd, size_t size, off_t off,
506
                 uint32_t flags, dict_t *xdata)
507
{
508
    if (fd)
509
        args->fd = fd_ref(fd);
510
    args->size = size;
511
    args->offset = off;
512
    args->flags = flags;
513

514
    if (xdata)
515
        args->xdata = dict_ref(xdata);
516

517
    return 0;
518
}
519

520
int
521
args_readv_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
522
                     struct iovec *vector, int32_t count, struct iatt *stbuf,
523
                     struct iobref *iobref, dict_t *xdata)
524
{
525
    args->op_ret = op_ret;
526
    args->op_errno = op_errno;
527
    if (op_ret >= 0) {
528
        args->vector = iov_dup(vector, count);
529
        args->count = count;
530
        args->stat = *stbuf;
531
        args->iobref = iobref_ref(iobref);
532
    }
533
    if (xdata)
534
        args->xdata = dict_ref(xdata);
535

536
    return 0;
537
}
538

539
int
540
args_writev_store(default_args_t *args, fd_t *fd, struct iovec *vector,
541
                  int32_t count, off_t off, uint32_t flags,
542
                  struct iobref *iobref, dict_t *xdata)
543
{
544
    if (fd)
545
        args->fd = fd_ref(fd);
546
    args->vector = iov_dup(vector, count);
547
    args->count = count;
548
    args->offset = off;
549
    args->flags = flags;
550
    args->iobref = iobref_ref(iobref);
551
    if (xdata)
552
        args->xdata = dict_ref(xdata);
553
    return 0;
554
}
555

556
int
557
args_writev_cbk_store(default_args_cbk_t *args, int32_t op_ret,
558
                      int32_t op_errno, struct iatt *prebuf,
559
                      struct iatt *postbuf, dict_t *xdata)
560
{
561
    args->op_ret = op_ret;
562
    args->op_errno = op_errno;
563
    if (op_ret >= 0)
564
        args->poststat = *postbuf;
565
    if (prebuf)
566
        args->prestat = *prebuf;
567
    if (xdata)
568
        args->xdata = dict_ref(xdata);
569

570
    return 0;
571
}
572

573
int
574
args_put_store(default_args_t *args, loc_t *loc, mode_t mode, mode_t umask,
575
               uint32_t flags, struct iovec *vector, int32_t count, off_t off,
576
               struct iobref *iobref, dict_t *xattr, dict_t *xdata)
577
{
578
    loc_copy(&args->loc, loc);
579
    args->mode = mode;
580
    args->umask = umask;
581
    args->flags = flags;
582
    args->vector = iov_dup(vector, count);
583
    args->count = count;
584
    args->offset = off;
585
    args->iobref = iobref_ref(iobref);
586
    if (xattr)
587
        args->xattr = dict_ref(xattr);
588
    if (xdata)
589
        args->xdata = dict_ref(xdata);
590
    return 0;
591
}
592

593
int
594
args_put_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
595
                   inode_t *inode, struct iatt *buf, struct iatt *preparent,
596
                   struct iatt *postparent, dict_t *xdata)
597
{
598
    args->op_ret = op_ret;
599
    args->op_errno = op_errno;
600
    if (op_ret >= 0)
601
        args->stat = *buf;
602
    if (inode)
603
        args->inode = inode_ref(inode);
604
    if (preparent)
605
        args->preparent = *preparent;
606
    if (postparent)
607
        args->postparent = *postparent;
608
    if (xdata)
609
        args->xdata = dict_ref(xdata);
610

611
    return 0;
612
}
613
int
614
args_flush_store(default_args_t *args, fd_t *fd, dict_t *xdata)
615
{
616
    if (fd)
617
        args->fd = fd_ref(fd);
618
    if (xdata)
619
        args->xdata = dict_ref(xdata);
620
    return 0;
621
}
622

623
int
624
args_flush_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
625
                     dict_t *xdata)
626
{
627
    args->op_ret = op_ret;
628
    args->op_errno = op_errno;
629
    if (xdata)
630
        args->xdata = dict_ref(xdata);
631

632
    return 0;
633
}
634

635
int
636
args_fsync_store(default_args_t *args, fd_t *fd, int32_t datasync,
637
                 dict_t *xdata)
638
{
639
    if (fd)
640
        args->fd = fd_ref(fd);
641
    args->datasync = datasync;
642
    if (xdata)
643
        args->xdata = dict_ref(xdata);
644
    return 0;
645
}
646

647
int
648
args_fsync_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
649
                     struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata)
650
{
651
    args->op_ret = op_ret;
652
    args->op_errno = op_errno;
653
    if (prebuf)
654
        args->prestat = *prebuf;
655
    if (postbuf)
656
        args->poststat = *postbuf;
657
    if (xdata)
658
        args->xdata = dict_ref(xdata);
659

660
    return 0;
661
}
662

663
int
664
args_opendir_store(default_args_t *args, loc_t *loc, fd_t *fd, dict_t *xdata)
665
{
666
    loc_copy(&args->loc, loc);
667
    if (fd)
668
        args->fd = fd_ref(fd);
669
    if (xdata)
670
        args->xdata = dict_ref(xdata);
671

672
    return 0;
673
}
674

675
int
676
args_opendir_cbk_store(default_args_cbk_t *args, int32_t op_ret,
677
                       int32_t op_errno, fd_t *fd, dict_t *xdata)
678
{
679
    args->op_ret = op_ret;
680
    args->op_errno = op_errno;
681
    if (fd)
682
        args->fd = fd_ref(fd);
683
    if (xdata)
684
        args->xdata = dict_ref(xdata);
685

686
    return 0;
687
}
688

689
int
690
args_fsyncdir_store(default_args_t *args, fd_t *fd, int32_t datasync,
691
                    dict_t *xdata)
692
{
693
    if (fd)
694
        args->fd = fd_ref(fd);
695
    args->datasync = datasync;
696
    if (xdata)
697
        args->xdata = dict_ref(xdata);
698
    return 0;
699
}
700
int
701
args_fsyncdir_cbk_store(default_args_cbk_t *args, int32_t op_ret,
702
                        int32_t op_errno, dict_t *xdata)
703
{
704
    args->op_ret = op_ret;
705
    args->op_errno = op_errno;
706
    if (xdata)
707
        args->xdata = dict_ref(xdata);
708

709
    return 0;
710
}
711

712
int
713
args_statfs_store(default_args_t *args, loc_t *loc, dict_t *xdata)
714
{
715
    loc_copy(&args->loc, loc);
716
    if (xdata)
717
        args->xdata = dict_ref(xdata);
718
    return 0;
719
}
720

721
int
722
args_statfs_cbk_store(default_args_cbk_t *args, int32_t op_ret,
723
                      int32_t op_errno, struct statvfs *buf, dict_t *xdata)
724
{
725
    args->op_ret = op_ret;
726
    args->op_errno = op_errno;
727
    if (op_ret == 0)
728
        args->statvfs = *buf;
729
    if (xdata)
730
        args->xdata = dict_ref(xdata);
731

732
    return 0;
733
}
734

735
int
736
args_setxattr_store(default_args_t *args, loc_t *loc, dict_t *dict,
737
                    int32_t flags, dict_t *xdata)
738
{
739
    loc_copy(&args->loc, loc);
740
    /* TODO */
741
    if (dict)
742
        args->xattr = dict_ref(dict);
743
    args->flags = flags;
744
    if (xdata)
745
        args->xdata = dict_ref(xdata);
746
    return 0;
747
}
748

749
int
750
args_setxattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
751
                        int32_t op_errno, dict_t *xdata)
752
{
753
    args->op_ret = op_ret;
754
    args->op_errno = op_errno;
755
    if (xdata)
756
        args->xdata = dict_ref(xdata);
757

758
    return 0;
759
}
760

761
int
762
args_getxattr_store(default_args_t *args, loc_t *loc, const char *name,
763
                    dict_t *xdata)
764
{
765
    loc_copy(&args->loc, loc);
766

767
    if (name)
768
        args->name = gf_strdup(name);
769
    if (xdata)
770
        args->xdata = dict_ref(xdata);
771
    return 0;
772
}
773

774
int
775
args_getxattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
776
                        int32_t op_errno, dict_t *dict, dict_t *xdata)
777
{
778
    args->op_ret = op_ret;
779
    args->op_errno = op_errno;
780
    if (dict)
781
        args->xattr = dict_ref(dict);
782
    if (xdata)
783
        args->xdata = dict_ref(xdata);
784

785
    return 0;
786
}
787

788
int
789
args_fsetxattr_store(default_args_t *args, fd_t *fd, dict_t *dict,
790
                     int32_t flags, dict_t *xdata)
791
{
792
    args->fd = fd_ref(fd);
793

794
    if (dict)
795
        args->xattr = dict_ref(dict);
796
    args->flags = flags;
797
    if (xdata)
798
        args->xdata = dict_ref(xdata);
799
    return 0;
800
}
801

802
int
803
args_fsetxattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
804
                         int32_t op_errno, dict_t *xdata)
805
{
806
    args->op_ret = op_ret;
807
    args->op_errno = op_errno;
808
    if (xdata)
809
        args->xdata = dict_ref(xdata);
810

811
    return 0;
812
}
813

814
int
815
args_fgetxattr_store(default_args_t *args, fd_t *fd, const char *name,
816
                     dict_t *xdata)
817
{
818
    args->fd = fd_ref(fd);
819

820
    if (name)
821
        args->name = gf_strdup(name);
822
    if (xdata)
823
        args->xdata = dict_ref(xdata);
824
    return 0;
825
}
826

827
int
828
args_fgetxattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
829
                         int32_t op_errno, dict_t *dict, dict_t *xdata)
830
{
831
    args->op_ret = op_ret;
832
    args->op_errno = op_errno;
833
    if (dict)
834
        args->xattr = dict_ref(dict);
835
    if (xdata)
836
        args->xdata = dict_ref(xdata);
837

838
    return 0;
839
}
840

841
int
842
args_removexattr_store(default_args_t *args, loc_t *loc, const char *name,
843
                       dict_t *xdata)
844
{
845
    loc_copy(&args->loc, loc);
846
    args->name = gf_strdup(name);
847
    if (xdata)
848
        args->xdata = dict_ref(xdata);
849
    return 0;
850
}
851

852
int
853
args_removexattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
854
                           int32_t op_errno, dict_t *xdata)
855
{
856
    args->op_ret = op_ret;
857
    args->op_errno = op_errno;
858
    if (xdata)
859
        args->xdata = dict_ref(xdata);
860

861
    return 0;
862
}
863

864
int
865
args_fremovexattr_store(default_args_t *args, fd_t *fd, const char *name,
866
                        dict_t *xdata)
867
{
868
    args->fd = fd_ref(fd);
869
    args->name = gf_strdup(name);
870
    if (xdata)
871
        args->xdata = dict_ref(xdata);
872
    return 0;
873
}
874

875
int
876
args_fremovexattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
877
                            int32_t op_errno, dict_t *xdata)
878
{
879
    args->op_ret = op_ret;
880
    args->op_errno = op_errno;
881
    if (xdata)
882
        args->xdata = dict_ref(xdata);
883

884
    return 0;
885
}
886

887
int
888
args_lk_store(default_args_t *args, fd_t *fd, int32_t cmd,
889
              struct gf_flock *lock, dict_t *xdata)
890
{
891
    if (fd)
892
        args->fd = fd_ref(fd);
893
    args->cmd = cmd;
894
    gf_flock_copy(&args->lock, lock);
895
    if (xdata)
896
        args->xdata = dict_ref(xdata);
897
    return 0;
898
}
899

900
int
901
args_lk_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
902
                  struct gf_flock *lock, dict_t *xdata)
903
{
904
    args->op_ret = op_ret;
905
    args->op_errno = op_errno;
906
    if (op_ret == 0)
907
        gf_flock_copy(&args->lock, lock);
908
    if (xdata)
909
        args->xdata = dict_ref(xdata);
910

911
    return 0;
912
}
913

914
int
915
args_inodelk_store(default_args_t *args, const char *volume, loc_t *loc,
916
                   int32_t cmd, struct gf_flock *lock, dict_t *xdata)
917
{
918
    if (volume)
919
        args->volume = gf_strdup(volume);
920

921
    loc_copy(&args->loc, loc);
922
    args->cmd = cmd;
923
    gf_flock_copy(&args->lock, lock);
924
    if (xdata)
925
        args->xdata = dict_ref(xdata);
926
    return 0;
927
}
928

929
int
930
args_inodelk_cbk_store(default_args_cbk_t *args, int32_t op_ret,
931
                       int32_t op_errno, dict_t *xdata)
932
{
933
    args->op_ret = op_ret;
934
    args->op_errno = op_errno;
935
    if (xdata)
936
        args->xdata = dict_ref(xdata);
937

938
    return 0;
939
}
940

941
int
942
args_finodelk_store(default_args_t *args, const char *volume, fd_t *fd,
943
                    int32_t cmd, struct gf_flock *lock, dict_t *xdata)
944
{
945
    if (fd)
946
        args->fd = fd_ref(fd);
947

948
    if (volume)
949
        args->volume = gf_strdup(volume);
950

951
    args->cmd = cmd;
952
    gf_flock_copy(&args->lock, lock);
953

954
    if (xdata)
955
        args->xdata = dict_ref(xdata);
956
    return 0;
957
}
958

959
int
960
args_finodelk_cbk_store(default_args_cbk_t *args, int32_t op_ret,
961
                        int32_t op_errno, dict_t *xdata)
962
{
963
    args->op_ret = op_ret;
964
    args->op_errno = op_errno;
965
    if (xdata)
966
        args->xdata = dict_ref(xdata);
967

968
    return 0;
969
}
970

971
int
972
args_entrylk_store(default_args_t *args, const char *volume, loc_t *loc,
973
                   const char *name, entrylk_cmd cmd, entrylk_type type,
974
                   dict_t *xdata)
975
{
976
    if (volume)
977
        args->volume = gf_strdup(volume);
978

979
    loc_copy(&args->loc, loc);
980

981
    args->entrylkcmd = cmd;
982
    args->entrylktype = type;
983

984
    if (name)
985
        args->name = gf_strdup(name);
986

987
    if (xdata)
988
        args->xdata = dict_ref(xdata);
989
    return 0;
990
}
991

992
int
993
args_entrylk_cbk_store(default_args_cbk_t *args, int32_t op_ret,
994
                       int32_t op_errno, dict_t *xdata)
995
{
996
    args->op_ret = op_ret;
997
    args->op_errno = op_errno;
998
    if (xdata)
999
        args->xdata = dict_ref(xdata);
1000

1001
    return 0;
1002
}
1003

1004
int
1005
args_fentrylk_store(default_args_t *args, const char *volume, fd_t *fd,
1006
                    const char *name, entrylk_cmd cmd, entrylk_type type,
1007
                    dict_t *xdata)
1008
{
1009
    if (volume)
1010
        args->volume = gf_strdup(volume);
1011

1012
    if (fd)
1013
        args->fd = fd_ref(fd);
1014
    args->entrylkcmd = cmd;
1015
    args->entrylktype = type;
1016
    if (name)
1017
        args->name = gf_strdup(name);
1018

1019
    if (xdata)
1020
        args->xdata = dict_ref(xdata);
1021
    return 0;
1022
}
1023

1024
int
1025
args_fentrylk_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1026
                        int32_t op_errno, dict_t *xdata)
1027
{
1028
    args->op_ret = op_ret;
1029
    args->op_errno = op_errno;
1030
    if (xdata)
1031
        args->xdata = dict_ref(xdata);
1032

1033
    return 0;
1034
}
1035

1036
int
1037
args_readdirp_store(default_args_t *args, fd_t *fd, size_t size, off_t off,
1038
                    dict_t *xdata)
1039
{
1040
    args->fd = fd_ref(fd);
1041
    args->size = size;
1042
    args->offset = off;
1043
    if (xdata)
1044
        args->xdata = dict_ref(xdata);
1045
    return 0;
1046
}
1047

1048
int
1049
args_readdirp_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1050
                        int32_t op_errno, gf_dirent_t *entries, dict_t *xdata)
1051
{
1052
    gf_dirent_t *stub_entry = NULL, *entry = NULL;
1053

1054
    args->op_ret = op_ret;
1055
    args->op_errno = op_errno;
1056
    if (op_ret > 0) {
1057
        list_for_each_entry(entry, &entries->list, list)
1058
        {
1059
            stub_entry = entry_copy(entry);
1060
            if (!stub_entry)
1061
                goto out;
1062
            list_add_tail(&stub_entry->list, &args->entries.list);
1063
        }
1064
    }
1065
    if (xdata)
1066
        args->xdata = dict_ref(xdata);
1067
out:
1068
    return 0;
1069
}
1070

1071
int
1072
args_readdir_store(default_args_t *args, fd_t *fd, size_t size, off_t off,
1073
                   dict_t *xdata)
1074
{
1075
    args->fd = fd_ref(fd);
1076
    args->size = size;
1077
    args->offset = off;
1078

1079
    if (xdata)
1080
        args->xdata = dict_ref(xdata);
1081
    return 0;
1082
}
1083

1084
int
1085
args_readdir_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1086
                       int32_t op_errno, gf_dirent_t *entries, dict_t *xdata)
1087
{
1088
    gf_dirent_t *stub_entry = NULL, *entry = NULL;
1089

1090
    args->op_ret = op_ret;
1091
    args->op_errno = op_errno;
1092
    if (op_ret > 0) {
1093
        list_for_each_entry(entry, &entries->list, list)
1094
        {
1095
            stub_entry = gf_dirent_for_name2(entry->d_name, entry->d_len,
1096
                                             entry->d_ino, entry->d_off,
1097
                                             entry->d_type, NULL);
1098
            if (!stub_entry)
1099
                goto out;
1100
            list_add_tail(&stub_entry->list, &args->entries.list);
1101
        }
1102
    }
1103
    if (xdata)
1104
        args->xdata = dict_ref(xdata);
1105
out:
1106
    return 0;
1107
}
1108

1109
int
1110
args_rchecksum_store(default_args_t *args, fd_t *fd, off_t offset, int32_t len,
1111
                     dict_t *xdata)
1112
{
1113
    args->fd = fd_ref(fd);
1114
    args->offset = offset;
1115
    args->size = len;
1116
    if (xdata)
1117
        args->xdata = dict_ref(xdata);
1118
    return 0;
1119
}
1120

1121
int
1122
args_rchecksum_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1123
                         int32_t op_errno, uint32_t weak_checksum,
1124
                         uint8_t *strong_checksum, dict_t *xdata)
1125
{
1126
    args->op_ret = op_ret;
1127
    args->op_errno = op_errno;
1128
    if (op_ret >= 0) {
1129
        args->weak_checksum = weak_checksum;
1130
        args->strong_checksum = gf_memdup(strong_checksum,
1131
                                          SHA256_DIGEST_LENGTH);
1132
    }
1133
    if (xdata)
1134
        args->xdata = dict_ref(xdata);
1135

1136
    return 0;
1137
}
1138

1139
int
1140
args_xattrop_store(default_args_t *args, loc_t *loc, gf_xattrop_flags_t optype,
1141
                   dict_t *xattr, dict_t *xdata)
1142
{
1143
    loc_copy(&args->loc, loc);
1144

1145
    args->optype = optype;
1146
    args->xattr = dict_ref(xattr);
1147

1148
    if (xdata)
1149
        args->xdata = dict_ref(xdata);
1150
    return 0;
1151
}
1152

1153
int
1154
args_xattrop_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1155
                       int32_t op_errno, dict_t *xattr, dict_t *xdata)
1156
{
1157
    args->op_ret = op_ret;
1158
    args->op_errno = op_errno;
1159
    if (xattr)
1160
        args->xattr = dict_ref(xattr);
1161
    if (xdata)
1162
        args->xdata = dict_ref(xdata);
1163

1164
    return 0;
1165
}
1166

1167
int
1168
args_fxattrop_store(default_args_t *args, fd_t *fd, gf_xattrop_flags_t optype,
1169
                    dict_t *xattr, dict_t *xdata)
1170
{
1171
    args->fd = fd_ref(fd);
1172

1173
    args->optype = optype;
1174
    args->xattr = dict_ref(xattr);
1175

1176
    if (xdata)
1177
        args->xdata = dict_ref(xdata);
1178
    return 0;
1179
}
1180

1181
int
1182
args_fxattrop_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1183
                        int32_t op_errno, dict_t *xattr, dict_t *xdata)
1184
{
1185
    args->op_ret = op_ret;
1186
    args->op_errno = op_errno;
1187
    if (xattr)
1188
        args->xattr = dict_ref(xattr);
1189
    if (xdata)
1190
        args->xdata = dict_ref(xdata);
1191

1192
    return 0;
1193
}
1194

1195
int
1196
args_setattr_store(default_args_t *args, loc_t *loc, struct iatt *stbuf,
1197
                   int32_t valid, dict_t *xdata)
1198
{
1199
    loc_copy(&args->loc, loc);
1200

1201
    if (stbuf)
1202
        args->stat = *stbuf;
1203

1204
    args->valid = valid;
1205

1206
    if (xdata)
1207
        args->xdata = dict_ref(xdata);
1208
    return 0;
1209
}
1210

1211
int
1212
args_setattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1213
                       int32_t op_errno, struct iatt *statpre,
1214
                       struct iatt *statpost, dict_t *xdata)
1215
{
1216
    args->op_ret = op_ret;
1217
    args->op_errno = op_errno;
1218
    if (statpre)
1219
        args->prestat = *statpre;
1220
    if (statpost)
1221
        args->poststat = *statpost;
1222
    if (xdata)
1223
        args->xdata = dict_ref(xdata);
1224

1225
    return 0;
1226
}
1227

1228
int
1229
args_fsetattr_store(default_args_t *args, fd_t *fd, struct iatt *stbuf,
1230
                    int32_t valid, dict_t *xdata)
1231
{
1232
    if (fd)
1233
        args->fd = fd_ref(fd);
1234

1235
    if (stbuf)
1236
        args->stat = *stbuf;
1237

1238
    args->valid = valid;
1239

1240
    if (xdata)
1241
        args->xdata = dict_ref(xdata);
1242
    return 0;
1243
}
1244
int
1245
args_fsetattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1246
                        int32_t op_errno, struct iatt *statpre,
1247
                        struct iatt *statpost, dict_t *xdata)
1248
{
1249
    args->op_ret = op_ret;
1250
    args->op_errno = op_errno;
1251
    if (statpre)
1252
        args->prestat = *statpre;
1253
    if (statpost)
1254
        args->poststat = *statpost;
1255
    if (xdata)
1256
        args->xdata = dict_ref(xdata);
1257

1258
    return 0;
1259
}
1260

1261
int
1262
args_fallocate_store(default_args_t *args, fd_t *fd, int32_t mode, off_t offset,
1263
                     size_t len, dict_t *xdata)
1264
{
1265
    if (fd)
1266
        args->fd = fd_ref(fd);
1267

1268
    args->flags = mode;
1269
    args->offset = offset;
1270
    args->size = len;
1271

1272
    if (xdata)
1273
        args->xdata = dict_ref(xdata);
1274
    return 0;
1275
}
1276

1277
int
1278
args_fallocate_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1279
                         int32_t op_errno, struct iatt *statpre,
1280
                         struct iatt *statpost, dict_t *xdata)
1281
{
1282
    args->op_ret = op_ret;
1283
    args->op_errno = op_errno;
1284
    if (statpre)
1285
        args->prestat = *statpre;
1286
    if (statpost)
1287
        args->poststat = *statpost;
1288
    if (xdata)
1289
        args->xdata = dict_ref(xdata);
1290

1291
    return 0;
1292
}
1293

1294
int
1295
args_discard_store(default_args_t *args, fd_t *fd, off_t offset, size_t len,
1296
                   dict_t *xdata)
1297
{
1298
    if (fd)
1299
        args->fd = fd_ref(fd);
1300

1301
    args->offset = offset;
1302
    args->size = len;
1303

1304
    if (xdata)
1305
        args->xdata = dict_ref(xdata);
1306
    return 0;
1307
}
1308

1309
int
1310
args_discard_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1311
                       int32_t op_errno, struct iatt *statpre,
1312
                       struct iatt *statpost, dict_t *xdata)
1313
{
1314
    args->op_ret = op_ret;
1315
    args->op_errno = op_errno;
1316
    if (statpre)
1317
        args->prestat = *statpre;
1318
    if (statpost)
1319
        args->poststat = *statpost;
1320
    if (xdata)
1321
        args->xdata = dict_ref(xdata);
1322

1323
    return 0;
1324
}
1325

1326
int
1327
args_zerofill_store(default_args_t *args, fd_t *fd, off_t offset, off_t len,
1328
                    dict_t *xdata)
1329
{
1330
    if (fd)
1331
        args->fd = fd_ref(fd);
1332

1333
    args->offset = offset;
1334
    args->size = len;
1335

1336
    if (xdata)
1337
        args->xdata = dict_ref(xdata);
1338
    return 0;
1339
}
1340

1341
int
1342
args_zerofill_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1343
                        int32_t op_errno, struct iatt *statpre,
1344
                        struct iatt *statpost, dict_t *xdata)
1345
{
1346
    args->op_ret = op_ret;
1347
    args->op_errno = op_errno;
1348
    if (statpre)
1349
        args->prestat = *statpre;
1350
    if (statpost)
1351
        args->poststat = *statpost;
1352
    if (xdata)
1353
        args->xdata = dict_ref(xdata);
1354

1355
    return 0;
1356
}
1357

1358
int
1359
args_ipc_store(default_args_t *args, int32_t op, dict_t *xdata)
1360
{
1361
    args->cmd = op;
1362

1363
    if (xdata)
1364
        args->xdata = dict_ref(xdata);
1365
    return 0;
1366
}
1367

1368
int
1369
args_ipc_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
1370
                   dict_t *xdata)
1371
{
1372
    args->op_ret = op_ret;
1373
    args->op_errno = op_errno;
1374
    if (xdata)
1375
        args->xdata = dict_ref(xdata);
1376

1377
    return 0;
1378
}
1379

1380
int
1381
args_seek_store(default_args_t *args, fd_t *fd, off_t offset,
1382
                gf_seek_what_t what, dict_t *xdata)
1383
{
1384
    if (fd)
1385
        args->fd = fd_ref(fd);
1386

1387
    args->offset = offset;
1388
    args->what = what;
1389

1390
    if (xdata)
1391
        args->xdata = dict_ref(xdata);
1392
    return 0;
1393
}
1394

1395
int
1396
args_seek_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
1397
                    off_t offset, dict_t *xdata)
1398
{
1399
    args->op_ret = op_ret;
1400
    args->op_errno = op_errno;
1401
    args->offset = offset;
1402
    if (xdata)
1403
        args->xdata = dict_ref(xdata);
1404

1405
    return 0;
1406
}
1407

1408
int
1409
args_getactivelk_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1410
                           int32_t op_errno, lock_migration_info_t *locklist,
1411
                           dict_t *xdata)
1412
{
1413
    lock_migration_info_t *stub_entry = NULL, *entry = NULL;
1414
    int ret = 0;
1415

1416
    args->op_ret = op_ret;
1417
    args->op_errno = op_errno;
1418
    /*op_ret needs to carry the number of locks present in the list*/
1419
    if (op_ret > 0) {
1420
        list_for_each_entry(entry, &locklist->list, list)
1421
        {
1422
            /* TODO: move to GF_MALLOC() */
1423
            stub_entry = GF_CALLOC(1, sizeof(*stub_entry), gf_common_mt_char);
1424
            if (!stub_entry) {
1425
                ret = -1;
1426
                goto out;
1427
            }
1428

1429
            INIT_LIST_HEAD(&stub_entry->list);
1430
            gf_flock_copy(&stub_entry->flock, &entry->flock);
1431

1432
            stub_entry->lk_flags = entry->lk_flags;
1433

1434
            stub_entry->client_uid = gf_strdup(entry->client_uid);
1435
            if (!stub_entry->client_uid) {
1436
                GF_FREE(stub_entry);
1437
                ret = -1;
1438
                goto out;
1439
            }
1440

1441
            list_add_tail(&stub_entry->list, &args->locklist.list);
1442
        }
1443
    }
1444

1445
    if (xdata)
1446
        args->xdata = dict_ref(xdata);
1447
out:
1448
    return ret;
1449
}
1450

1451
int
1452
args_setactivelk_store(default_args_t *args, loc_t *loc,
1453
                       lock_migration_info_t *locklist, dict_t *xdata)
1454
{
1455
    lock_migration_info_t *stub_entry = NULL, *entry = NULL;
1456
    int ret = 0;
1457

1458
    list_for_each_entry(entry, &locklist->list, list)
1459
    {
1460
        /* TODO: move to GF_MALLOC() */
1461
        stub_entry = GF_CALLOC(1, sizeof(*stub_entry), gf_common_mt_lock_mig);
1462
        if (!stub_entry) {
1463
            ret = -1;
1464
            goto out;
1465
        }
1466

1467
        INIT_LIST_HEAD(&stub_entry->list);
1468
        gf_flock_copy(&stub_entry->flock, &entry->flock);
1469

1470
        stub_entry->lk_flags = entry->lk_flags;
1471

1472
        stub_entry->client_uid = gf_strdup(entry->client_uid);
1473
        if (!stub_entry->client_uid) {
1474
            GF_FREE(stub_entry);
1475
            ret = -1;
1476
            goto out;
1477
        }
1478

1479
        list_add_tail(&stub_entry->list, &args->locklist.list);
1480
    }
1481

1482
    loc_copy(&args->loc, loc);
1483

1484
    if (xdata)
1485
        args->xdata = dict_ref(xdata);
1486

1487
out:
1488
    return ret;
1489
}
1490

1491
void
1492
args_lease_store(default_args_t *args, loc_t *loc, struct gf_lease *lease,
1493
                 dict_t *xdata)
1494
{
1495
    loc_copy(&args->loc, loc);
1496
    args->lease = *lease;
1497

1498
    if (xdata)
1499
        args->xdata = dict_ref(xdata);
1500

1501
    return;
1502
}
1503

1504
void
1505
args_lease_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
1506
                     struct gf_lease *lease, dict_t *xdata)
1507
{
1508
    args->op_ret = op_ret;
1509
    args->op_errno = op_errno;
1510
    if (op_ret == 0)
1511
        args->lease = *lease;
1512
    if (xdata)
1513
        args->xdata = dict_ref(xdata);
1514
}
1515

1516
int
1517
args_icreate_store(default_args_t *args, loc_t *loc, mode_t mode, dict_t *xdata)
1518
{
1519
    loc_copy(&args->loc, loc);
1520
    args->mode = mode;
1521

1522
    if (xdata)
1523
        args->xdata = dict_ref(xdata);
1524
    return 0;
1525
}
1526

1527
int
1528
args_namelink_store(default_args_t *args, loc_t *loc, dict_t *xdata)
1529
{
1530
    loc_copy(&args->loc, loc);
1531

1532
    if (xdata)
1533
        args->xdata = dict_ref(xdata);
1534
    return 0;
1535
}
1536

1537
int
1538
args_copy_file_range_store(default_args_t *args, fd_t *fd_in, off64_t off_in,
1539
                           fd_t *fd_out, off64_t off_out, size_t len,
1540
                           uint32_t flags, dict_t *xdata)
1541
{
1542
    if (fd_in)
1543
        args->fd = fd_ref(fd_in);
1544
    if (fd_out)
1545
        args->fd_dst = fd_ref(fd_out);
1546
    args->size = len;
1547
    args->off_in = off_in;
1548
    args->off_out = off_out;
1549
    args->flags = flags;
1550

1551
    if (xdata)
1552
        args->xdata = dict_ref(xdata);
1553

1554
    return 0;
1555
}
1556

1557
int
1558
args_copy_file_range_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1559
                               int32_t op_errno, struct iatt *stbuf,
1560
                               struct iatt *prebuf_dst,
1561
                               struct iatt *postbuf_dst, dict_t *xdata)
1562
{
1563
    args->op_ret = op_ret;
1564
    args->op_errno = op_errno;
1565
    if (op_ret >= 0) {
1566
        if (postbuf_dst)
1567
            args->poststat = *postbuf_dst;
1568
        if (prebuf_dst)
1569
            args->prestat = *prebuf_dst;
1570
        if (stbuf)
1571
            args->stat = *stbuf;
1572
    }
1573
    if (xdata)
1574
        args->xdata = dict_ref(xdata);
1575

1576
    return 0;
1577
}
1578

1579
void
1580
args_cbk_wipe(default_args_cbk_t *args_cbk)
1581
{
1582
    if (!args_cbk)
1583
        return;
1584
    if (args_cbk->inode)
1585
        inode_unref(args_cbk->inode);
1586

1587
    GF_FREE((char *)args_cbk->buf);
1588

1589
    GF_FREE(args_cbk->vector);
1590

1591
    if (args_cbk->iobref)
1592
        iobref_unref(args_cbk->iobref);
1593

1594
    if (args_cbk->fd)
1595
        fd_unref(args_cbk->fd);
1596

1597
    if (args_cbk->xattr)
1598
        dict_unref(args_cbk->xattr);
1599

1600
    GF_FREE(args_cbk->strong_checksum);
1601

1602
    if (args_cbk->xdata)
1603
        dict_unref(args_cbk->xdata);
1604

1605
    if (!list_empty(&args_cbk->entries.list))
1606
        gf_dirent_free(&args_cbk->entries);
1607
}
1608

1609
void
1610
args_wipe(default_args_t *args)
1611
{
1612
    if (!args)
1613
        return;
1614

1615
    loc_wipe(&args->loc);
1616

1617
    loc_wipe(&args->loc2);
1618

1619
    if (args->fd)
1620
        fd_unref(args->fd);
1621

1622
    GF_FREE((char *)args->linkname);
1623

1624
    GF_FREE(args->vector);
1625

1626
    if (args->iobref)
1627
        iobref_unref(args->iobref);
1628

1629
    if (args->xattr)
1630
        dict_unref(args->xattr);
1631

1632
    if (args->xdata)
1633
        dict_unref(args->xdata);
1634

1635
    GF_FREE((char *)args->name);
1636

1637
    GF_FREE((char *)args->volume);
1638
}
1639

1640
void
1641
args_cbk_init(default_args_cbk_t *args_cbk)
1642
{
1643
    INIT_LIST_HEAD(&args_cbk->entries);
1644
}
1645

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.