glusterfs
1644 строки · 37.3 Кб
1/*
2Copyright (c) 2008-2015 Red Hat, Inc. <http://www.redhat.com>
3This file is part of GlusterFS.
4
5This file is licensed to you under your choice of the GNU Lesser
6General Public License, version 3 or any later version (LGPLv3 or
7later), or the GNU General Public License, version 2 (GPLv2), in all
8cases 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
18int
19args_lookup_store(default_args_t *args, loc_t *loc, dict_t *xdata)
20{
21loc_copy(&args->loc, loc);
22if (xdata)
23args->xdata = dict_ref(xdata);
24
25return 0;
26}
27
28int
29args_lookup_cbk_store(default_args_cbk_t *args, int32_t op_ret,
30int32_t op_errno, inode_t *inode, struct iatt *buf,
31dict_t *xdata, struct iatt *postparent)
32{
33args->op_ret = op_ret;
34args->op_errno = op_errno;
35if (inode)
36args->inode = inode_ref(inode);
37if (buf)
38args->stat = *buf;
39if (postparent)
40args->postparent = *postparent;
41if (xdata)
42args->xdata = dict_ref(xdata);
43
44return 0;
45}
46
47int
48args_stat_store(default_args_t *args, loc_t *loc, dict_t *xdata)
49{
50loc_copy(&args->loc, loc);
51if (xdata)
52args->xdata = dict_ref(xdata);
53
54return 0;
55}
56
57int
58args_stat_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
59struct iatt *buf, dict_t *xdata)
60{
61args->op_ret = op_ret;
62args->op_errno = op_errno;
63if (op_ret == 0)
64args->stat = *buf;
65if (xdata)
66args->xdata = dict_ref(xdata);
67
68return 0;
69}
70
71int
72args_fstat_store(default_args_t *args, fd_t *fd, dict_t *xdata)
73{
74if (fd)
75args->fd = fd_ref(fd);
76if (xdata)
77args->xdata = dict_ref(xdata);
78
79return 0;
80}
81
82int
83args_fstat_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
84struct iatt *buf, dict_t *xdata)
85{
86args->op_ret = op_ret;
87args->op_errno = op_errno;
88if (buf)
89args->stat = *buf;
90if (xdata)
91args->xdata = dict_ref(xdata);
92
93return 0;
94}
95
96int
97args_truncate_store(default_args_t *args, loc_t *loc, off_t off, dict_t *xdata)
98{
99loc_copy(&args->loc, loc);
100args->offset = off;
101if (xdata)
102args->xdata = dict_ref(xdata);
103
104return 0;
105}
106
107int
108args_truncate_cbk_store(default_args_cbk_t *args, int32_t op_ret,
109int32_t op_errno, struct iatt *prebuf,
110struct iatt *postbuf, dict_t *xdata)
111{
112args->op_ret = op_ret;
113args->op_errno = op_errno;
114if (prebuf)
115args->prestat = *prebuf;
116if (postbuf)
117args->poststat = *postbuf;
118if (xdata)
119args->xdata = dict_ref(xdata);
120
121return 0;
122}
123
124int
125args_ftruncate_store(default_args_t *args, fd_t *fd, off_t off, dict_t *xdata)
126{
127if (fd)
128args->fd = fd_ref(fd);
129
130args->offset = off;
131if (xdata)
132args->xdata = dict_ref(xdata);
133
134return 0;
135}
136
137int
138args_ftruncate_cbk_store(default_args_cbk_t *args, int32_t op_ret,
139int32_t op_errno, struct iatt *prebuf,
140struct iatt *postbuf, dict_t *xdata)
141{
142args->op_ret = op_ret;
143args->op_errno = op_errno;
144if (prebuf)
145args->prestat = *prebuf;
146if (postbuf)
147args->poststat = *postbuf;
148if (xdata)
149args->xdata = dict_ref(xdata);
150
151return 0;
152}
153
154int
155args_access_store(default_args_t *args, loc_t *loc, int32_t mask, dict_t *xdata)
156{
157loc_copy(&args->loc, loc);
158args->mask = mask;
159if (xdata)
160args->xdata = dict_ref(xdata);
161
162return 0;
163}
164
165int
166args_access_cbk_store(default_args_cbk_t *args, int32_t op_ret,
167int32_t op_errno, dict_t *xdata)
168{
169args->op_ret = op_ret;
170args->op_errno = op_errno;
171if (xdata)
172args->xdata = dict_ref(xdata);
173
174return 0;
175}
176
177int
178args_readlink_store(default_args_t *args, loc_t *loc, size_t size,
179dict_t *xdata)
180{
181loc_copy(&args->loc, loc);
182args->size = size;
183if (xdata)
184args->xdata = dict_ref(xdata);
185
186return 0;
187}
188
189int
190args_readlink_cbk_store(default_args_cbk_t *args, int32_t op_ret,
191int32_t op_errno, const char *path, struct iatt *stbuf,
192dict_t *xdata)
193{
194args->op_ret = op_ret;
195args->op_errno = op_errno;
196if (path)
197args->buf = gf_strdup(path);
198if (stbuf)
199args->stat = *stbuf;
200if (xdata)
201args->xdata = dict_ref(xdata);
202
203return 0;
204}
205
206int
207args_mknod_store(default_args_t *args, loc_t *loc, mode_t mode, dev_t rdev,
208mode_t umask, dict_t *xdata)
209{
210loc_copy(&args->loc, loc);
211args->mode = mode;
212args->rdev = rdev;
213args->umask = umask;
214if (xdata)
215args->xdata = dict_ref(xdata);
216
217return 0;
218}
219
220int
221args_mknod_cbk_store(default_args_cbk_t *args, int op_ret, int32_t op_errno,
222inode_t *inode, struct iatt *buf, struct iatt *preparent,
223struct iatt *postparent, dict_t *xdata)
224{
225args->op_ret = op_ret;
226args->op_errno = op_errno;
227if (inode)
228args->inode = inode_ref(inode);
229if (buf)
230args->stat = *buf;
231if (preparent)
232args->preparent = *preparent;
233if (postparent)
234args->postparent = *postparent;
235if (xdata)
236args->xdata = dict_ref(xdata);
237
238return 0;
239}
240
241int
242args_mkdir_store(default_args_t *args, loc_t *loc, mode_t mode, mode_t umask,
243dict_t *xdata)
244{
245loc_copy(&args->loc, loc);
246args->mode = mode;
247args->umask = umask;
248
249if (xdata)
250args->xdata = dict_ref(xdata);
251
252return 0;
253}
254
255int
256args_mkdir_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
257inode_t *inode, struct iatt *buf, struct iatt *preparent,
258struct iatt *postparent, dict_t *xdata)
259{
260args->op_ret = op_ret;
261args->op_errno = op_errno;
262if (inode)
263args->inode = inode_ref(inode);
264if (buf)
265args->stat = *buf;
266if (preparent)
267args->preparent = *preparent;
268if (postparent)
269args->postparent = *postparent;
270if (xdata)
271args->xdata = dict_ref(xdata);
272
273return 0;
274}
275
276int
277args_unlink_store(default_args_t *args, loc_t *loc, int xflag, dict_t *xdata)
278{
279loc_copy(&args->loc, loc);
280args->xflag = xflag;
281if (xdata)
282args->xdata = dict_ref(xdata);
283
284return 0;
285}
286
287int
288args_unlink_cbk_store(default_args_cbk_t *args, int32_t op_ret,
289int32_t op_errno, struct iatt *preparent,
290struct iatt *postparent, dict_t *xdata)
291{
292args->op_ret = op_ret;
293args->op_errno = op_errno;
294if (preparent)
295args->preparent = *preparent;
296if (postparent)
297args->postparent = *postparent;
298if (xdata)
299args->xdata = dict_ref(xdata);
300
301return 0;
302}
303
304int
305args_rmdir_store(default_args_t *args, loc_t *loc, int flags, dict_t *xdata)
306{
307loc_copy(&args->loc, loc);
308args->flags = flags;
309if (xdata)
310args->xdata = dict_ref(xdata);
311return 0;
312}
313
314int
315args_rmdir_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
316struct iatt *preparent, struct iatt *postparent,
317dict_t *xdata)
318{
319args->op_ret = op_ret;
320args->op_errno = op_errno;
321if (preparent)
322args->preparent = *preparent;
323if (postparent)
324args->postparent = *postparent;
325if (xdata)
326args->xdata = dict_ref(xdata);
327
328return 0;
329}
330
331int
332args_symlink_store(default_args_t *args, const char *linkname, loc_t *loc,
333mode_t umask, dict_t *xdata)
334{
335args->linkname = gf_strdup(linkname);
336args->umask = umask;
337loc_copy(&args->loc, loc);
338if (xdata)
339args->xdata = dict_ref(xdata);
340
341return 0;
342}
343
344int
345args_symlink_cbk_store(default_args_cbk_t *args, int32_t op_ret,
346int32_t op_errno, inode_t *inode, struct iatt *buf,
347struct iatt *preparent, struct iatt *postparent,
348dict_t *xdata)
349{
350args->op_ret = op_ret;
351args->op_errno = op_errno;
352if (inode)
353args->inode = inode_ref(inode);
354if (buf)
355args->stat = *buf;
356if (preparent)
357args->preparent = *preparent;
358if (postparent)
359args->postparent = *postparent;
360if (xdata)
361args->xdata = dict_ref(xdata);
362
363return 0;
364}
365
366int
367args_rename_store(default_args_t *args, loc_t *oldloc, loc_t *newloc,
368dict_t *xdata)
369{
370loc_copy(&args->loc, oldloc);
371loc_copy(&args->loc2, newloc);
372if (xdata)
373args->xdata = dict_ref(xdata);
374
375return 0;
376}
377
378int
379args_rename_cbk_store(default_args_cbk_t *args, int32_t op_ret,
380int32_t op_errno, struct iatt *buf,
381struct iatt *preoldparent, struct iatt *postoldparent,
382struct iatt *prenewparent, struct iatt *postnewparent,
383dict_t *xdata)
384{
385args->op_ret = op_ret;
386args->op_errno = op_errno;
387if (buf)
388args->stat = *buf;
389if (preoldparent)
390args->preparent = *preoldparent;
391if (postoldparent)
392args->postparent = *postoldparent;
393if (prenewparent)
394args->preparent2 = *prenewparent;
395if (postnewparent)
396args->postparent2 = *postnewparent;
397if (xdata)
398args->xdata = dict_ref(xdata);
399
400return 0;
401}
402
403int
404args_link_store(default_args_t *args, loc_t *oldloc, loc_t *newloc,
405dict_t *xdata)
406{
407loc_copy(&args->loc, oldloc);
408loc_copy(&args->loc2, newloc);
409
410if (xdata)
411args->xdata = dict_ref(xdata);
412
413return 0;
414}
415
416int
417args_link_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
418inode_t *inode, struct iatt *buf, struct iatt *preparent,
419struct iatt *postparent, dict_t *xdata)
420{
421args->op_ret = op_ret;
422args->op_errno = op_errno;
423if (inode)
424args->inode = inode_ref(inode);
425if (buf)
426args->stat = *buf;
427if (preparent)
428args->preparent = *preparent;
429if (postparent)
430args->postparent = *postparent;
431if (xdata)
432args->xdata = dict_ref(xdata);
433
434return 0;
435}
436
437int
438args_create_store(default_args_t *args, loc_t *loc, int32_t flags, mode_t mode,
439mode_t umask, fd_t *fd, dict_t *xdata)
440{
441loc_copy(&args->loc, loc);
442args->flags = flags;
443args->mode = mode;
444args->umask = umask;
445if (fd)
446args->fd = fd_ref(fd);
447if (xdata)
448args->xdata = dict_ref(xdata);
449return 0;
450}
451
452int
453args_create_cbk_store(default_args_cbk_t *args, int32_t op_ret,
454int32_t op_errno, fd_t *fd, inode_t *inode,
455struct iatt *buf, struct iatt *preparent,
456struct iatt *postparent, dict_t *xdata)
457{
458args->op_ret = op_ret;
459args->op_errno = op_errno;
460if (fd)
461args->fd = fd_ref(fd);
462if (inode)
463args->inode = inode_ref(inode);
464if (buf)
465args->stat = *buf;
466if (preparent)
467args->preparent = *preparent;
468if (postparent)
469args->postparent = *postparent;
470if (xdata)
471args->xdata = dict_ref(xdata);
472
473return 0;
474}
475
476int
477args_open_store(default_args_t *args, loc_t *loc, int32_t flags, fd_t *fd,
478dict_t *xdata)
479{
480loc_copy(&args->loc, loc);
481args->flags = flags;
482if (fd)
483args->fd = fd_ref(fd);
484if (xdata)
485args->xdata = dict_ref(xdata);
486
487return 0;
488}
489
490int
491args_open_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
492fd_t *fd, dict_t *xdata)
493{
494args->op_ret = op_ret;
495args->op_errno = op_errno;
496if (fd)
497args->fd = fd_ref(fd);
498if (xdata)
499args->xdata = dict_ref(xdata);
500
501return 0;
502}
503
504int
505args_readv_store(default_args_t *args, fd_t *fd, size_t size, off_t off,
506uint32_t flags, dict_t *xdata)
507{
508if (fd)
509args->fd = fd_ref(fd);
510args->size = size;
511args->offset = off;
512args->flags = flags;
513
514if (xdata)
515args->xdata = dict_ref(xdata);
516
517return 0;
518}
519
520int
521args_readv_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
522struct iovec *vector, int32_t count, struct iatt *stbuf,
523struct iobref *iobref, dict_t *xdata)
524{
525args->op_ret = op_ret;
526args->op_errno = op_errno;
527if (op_ret >= 0) {
528args->vector = iov_dup(vector, count);
529args->count = count;
530args->stat = *stbuf;
531args->iobref = iobref_ref(iobref);
532}
533if (xdata)
534args->xdata = dict_ref(xdata);
535
536return 0;
537}
538
539int
540args_writev_store(default_args_t *args, fd_t *fd, struct iovec *vector,
541int32_t count, off_t off, uint32_t flags,
542struct iobref *iobref, dict_t *xdata)
543{
544if (fd)
545args->fd = fd_ref(fd);
546args->vector = iov_dup(vector, count);
547args->count = count;
548args->offset = off;
549args->flags = flags;
550args->iobref = iobref_ref(iobref);
551if (xdata)
552args->xdata = dict_ref(xdata);
553return 0;
554}
555
556int
557args_writev_cbk_store(default_args_cbk_t *args, int32_t op_ret,
558int32_t op_errno, struct iatt *prebuf,
559struct iatt *postbuf, dict_t *xdata)
560{
561args->op_ret = op_ret;
562args->op_errno = op_errno;
563if (op_ret >= 0)
564args->poststat = *postbuf;
565if (prebuf)
566args->prestat = *prebuf;
567if (xdata)
568args->xdata = dict_ref(xdata);
569
570return 0;
571}
572
573int
574args_put_store(default_args_t *args, loc_t *loc, mode_t mode, mode_t umask,
575uint32_t flags, struct iovec *vector, int32_t count, off_t off,
576struct iobref *iobref, dict_t *xattr, dict_t *xdata)
577{
578loc_copy(&args->loc, loc);
579args->mode = mode;
580args->umask = umask;
581args->flags = flags;
582args->vector = iov_dup(vector, count);
583args->count = count;
584args->offset = off;
585args->iobref = iobref_ref(iobref);
586if (xattr)
587args->xattr = dict_ref(xattr);
588if (xdata)
589args->xdata = dict_ref(xdata);
590return 0;
591}
592
593int
594args_put_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
595inode_t *inode, struct iatt *buf, struct iatt *preparent,
596struct iatt *postparent, dict_t *xdata)
597{
598args->op_ret = op_ret;
599args->op_errno = op_errno;
600if (op_ret >= 0)
601args->stat = *buf;
602if (inode)
603args->inode = inode_ref(inode);
604if (preparent)
605args->preparent = *preparent;
606if (postparent)
607args->postparent = *postparent;
608if (xdata)
609args->xdata = dict_ref(xdata);
610
611return 0;
612}
613int
614args_flush_store(default_args_t *args, fd_t *fd, dict_t *xdata)
615{
616if (fd)
617args->fd = fd_ref(fd);
618if (xdata)
619args->xdata = dict_ref(xdata);
620return 0;
621}
622
623int
624args_flush_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
625dict_t *xdata)
626{
627args->op_ret = op_ret;
628args->op_errno = op_errno;
629if (xdata)
630args->xdata = dict_ref(xdata);
631
632return 0;
633}
634
635int
636args_fsync_store(default_args_t *args, fd_t *fd, int32_t datasync,
637dict_t *xdata)
638{
639if (fd)
640args->fd = fd_ref(fd);
641args->datasync = datasync;
642if (xdata)
643args->xdata = dict_ref(xdata);
644return 0;
645}
646
647int
648args_fsync_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
649struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata)
650{
651args->op_ret = op_ret;
652args->op_errno = op_errno;
653if (prebuf)
654args->prestat = *prebuf;
655if (postbuf)
656args->poststat = *postbuf;
657if (xdata)
658args->xdata = dict_ref(xdata);
659
660return 0;
661}
662
663int
664args_opendir_store(default_args_t *args, loc_t *loc, fd_t *fd, dict_t *xdata)
665{
666loc_copy(&args->loc, loc);
667if (fd)
668args->fd = fd_ref(fd);
669if (xdata)
670args->xdata = dict_ref(xdata);
671
672return 0;
673}
674
675int
676args_opendir_cbk_store(default_args_cbk_t *args, int32_t op_ret,
677int32_t op_errno, fd_t *fd, dict_t *xdata)
678{
679args->op_ret = op_ret;
680args->op_errno = op_errno;
681if (fd)
682args->fd = fd_ref(fd);
683if (xdata)
684args->xdata = dict_ref(xdata);
685
686return 0;
687}
688
689int
690args_fsyncdir_store(default_args_t *args, fd_t *fd, int32_t datasync,
691dict_t *xdata)
692{
693if (fd)
694args->fd = fd_ref(fd);
695args->datasync = datasync;
696if (xdata)
697args->xdata = dict_ref(xdata);
698return 0;
699}
700int
701args_fsyncdir_cbk_store(default_args_cbk_t *args, int32_t op_ret,
702int32_t op_errno, dict_t *xdata)
703{
704args->op_ret = op_ret;
705args->op_errno = op_errno;
706if (xdata)
707args->xdata = dict_ref(xdata);
708
709return 0;
710}
711
712int
713args_statfs_store(default_args_t *args, loc_t *loc, dict_t *xdata)
714{
715loc_copy(&args->loc, loc);
716if (xdata)
717args->xdata = dict_ref(xdata);
718return 0;
719}
720
721int
722args_statfs_cbk_store(default_args_cbk_t *args, int32_t op_ret,
723int32_t op_errno, struct statvfs *buf, dict_t *xdata)
724{
725args->op_ret = op_ret;
726args->op_errno = op_errno;
727if (op_ret == 0)
728args->statvfs = *buf;
729if (xdata)
730args->xdata = dict_ref(xdata);
731
732return 0;
733}
734
735int
736args_setxattr_store(default_args_t *args, loc_t *loc, dict_t *dict,
737int32_t flags, dict_t *xdata)
738{
739loc_copy(&args->loc, loc);
740/* TODO */
741if (dict)
742args->xattr = dict_ref(dict);
743args->flags = flags;
744if (xdata)
745args->xdata = dict_ref(xdata);
746return 0;
747}
748
749int
750args_setxattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
751int32_t op_errno, dict_t *xdata)
752{
753args->op_ret = op_ret;
754args->op_errno = op_errno;
755if (xdata)
756args->xdata = dict_ref(xdata);
757
758return 0;
759}
760
761int
762args_getxattr_store(default_args_t *args, loc_t *loc, const char *name,
763dict_t *xdata)
764{
765loc_copy(&args->loc, loc);
766
767if (name)
768args->name = gf_strdup(name);
769if (xdata)
770args->xdata = dict_ref(xdata);
771return 0;
772}
773
774int
775args_getxattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
776int32_t op_errno, dict_t *dict, dict_t *xdata)
777{
778args->op_ret = op_ret;
779args->op_errno = op_errno;
780if (dict)
781args->xattr = dict_ref(dict);
782if (xdata)
783args->xdata = dict_ref(xdata);
784
785return 0;
786}
787
788int
789args_fsetxattr_store(default_args_t *args, fd_t *fd, dict_t *dict,
790int32_t flags, dict_t *xdata)
791{
792args->fd = fd_ref(fd);
793
794if (dict)
795args->xattr = dict_ref(dict);
796args->flags = flags;
797if (xdata)
798args->xdata = dict_ref(xdata);
799return 0;
800}
801
802int
803args_fsetxattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
804int32_t op_errno, dict_t *xdata)
805{
806args->op_ret = op_ret;
807args->op_errno = op_errno;
808if (xdata)
809args->xdata = dict_ref(xdata);
810
811return 0;
812}
813
814int
815args_fgetxattr_store(default_args_t *args, fd_t *fd, const char *name,
816dict_t *xdata)
817{
818args->fd = fd_ref(fd);
819
820if (name)
821args->name = gf_strdup(name);
822if (xdata)
823args->xdata = dict_ref(xdata);
824return 0;
825}
826
827int
828args_fgetxattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
829int32_t op_errno, dict_t *dict, dict_t *xdata)
830{
831args->op_ret = op_ret;
832args->op_errno = op_errno;
833if (dict)
834args->xattr = dict_ref(dict);
835if (xdata)
836args->xdata = dict_ref(xdata);
837
838return 0;
839}
840
841int
842args_removexattr_store(default_args_t *args, loc_t *loc, const char *name,
843dict_t *xdata)
844{
845loc_copy(&args->loc, loc);
846args->name = gf_strdup(name);
847if (xdata)
848args->xdata = dict_ref(xdata);
849return 0;
850}
851
852int
853args_removexattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
854int32_t op_errno, dict_t *xdata)
855{
856args->op_ret = op_ret;
857args->op_errno = op_errno;
858if (xdata)
859args->xdata = dict_ref(xdata);
860
861return 0;
862}
863
864int
865args_fremovexattr_store(default_args_t *args, fd_t *fd, const char *name,
866dict_t *xdata)
867{
868args->fd = fd_ref(fd);
869args->name = gf_strdup(name);
870if (xdata)
871args->xdata = dict_ref(xdata);
872return 0;
873}
874
875int
876args_fremovexattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
877int32_t op_errno, dict_t *xdata)
878{
879args->op_ret = op_ret;
880args->op_errno = op_errno;
881if (xdata)
882args->xdata = dict_ref(xdata);
883
884return 0;
885}
886
887int
888args_lk_store(default_args_t *args, fd_t *fd, int32_t cmd,
889struct gf_flock *lock, dict_t *xdata)
890{
891if (fd)
892args->fd = fd_ref(fd);
893args->cmd = cmd;
894gf_flock_copy(&args->lock, lock);
895if (xdata)
896args->xdata = dict_ref(xdata);
897return 0;
898}
899
900int
901args_lk_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
902struct gf_flock *lock, dict_t *xdata)
903{
904args->op_ret = op_ret;
905args->op_errno = op_errno;
906if (op_ret == 0)
907gf_flock_copy(&args->lock, lock);
908if (xdata)
909args->xdata = dict_ref(xdata);
910
911return 0;
912}
913
914int
915args_inodelk_store(default_args_t *args, const char *volume, loc_t *loc,
916int32_t cmd, struct gf_flock *lock, dict_t *xdata)
917{
918if (volume)
919args->volume = gf_strdup(volume);
920
921loc_copy(&args->loc, loc);
922args->cmd = cmd;
923gf_flock_copy(&args->lock, lock);
924if (xdata)
925args->xdata = dict_ref(xdata);
926return 0;
927}
928
929int
930args_inodelk_cbk_store(default_args_cbk_t *args, int32_t op_ret,
931int32_t op_errno, dict_t *xdata)
932{
933args->op_ret = op_ret;
934args->op_errno = op_errno;
935if (xdata)
936args->xdata = dict_ref(xdata);
937
938return 0;
939}
940
941int
942args_finodelk_store(default_args_t *args, const char *volume, fd_t *fd,
943int32_t cmd, struct gf_flock *lock, dict_t *xdata)
944{
945if (fd)
946args->fd = fd_ref(fd);
947
948if (volume)
949args->volume = gf_strdup(volume);
950
951args->cmd = cmd;
952gf_flock_copy(&args->lock, lock);
953
954if (xdata)
955args->xdata = dict_ref(xdata);
956return 0;
957}
958
959int
960args_finodelk_cbk_store(default_args_cbk_t *args, int32_t op_ret,
961int32_t op_errno, dict_t *xdata)
962{
963args->op_ret = op_ret;
964args->op_errno = op_errno;
965if (xdata)
966args->xdata = dict_ref(xdata);
967
968return 0;
969}
970
971int
972args_entrylk_store(default_args_t *args, const char *volume, loc_t *loc,
973const char *name, entrylk_cmd cmd, entrylk_type type,
974dict_t *xdata)
975{
976if (volume)
977args->volume = gf_strdup(volume);
978
979loc_copy(&args->loc, loc);
980
981args->entrylkcmd = cmd;
982args->entrylktype = type;
983
984if (name)
985args->name = gf_strdup(name);
986
987if (xdata)
988args->xdata = dict_ref(xdata);
989return 0;
990}
991
992int
993args_entrylk_cbk_store(default_args_cbk_t *args, int32_t op_ret,
994int32_t op_errno, dict_t *xdata)
995{
996args->op_ret = op_ret;
997args->op_errno = op_errno;
998if (xdata)
999args->xdata = dict_ref(xdata);
1000
1001return 0;
1002}
1003
1004int
1005args_fentrylk_store(default_args_t *args, const char *volume, fd_t *fd,
1006const char *name, entrylk_cmd cmd, entrylk_type type,
1007dict_t *xdata)
1008{
1009if (volume)
1010args->volume = gf_strdup(volume);
1011
1012if (fd)
1013args->fd = fd_ref(fd);
1014args->entrylkcmd = cmd;
1015args->entrylktype = type;
1016if (name)
1017args->name = gf_strdup(name);
1018
1019if (xdata)
1020args->xdata = dict_ref(xdata);
1021return 0;
1022}
1023
1024int
1025args_fentrylk_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1026int32_t op_errno, dict_t *xdata)
1027{
1028args->op_ret = op_ret;
1029args->op_errno = op_errno;
1030if (xdata)
1031args->xdata = dict_ref(xdata);
1032
1033return 0;
1034}
1035
1036int
1037args_readdirp_store(default_args_t *args, fd_t *fd, size_t size, off_t off,
1038dict_t *xdata)
1039{
1040args->fd = fd_ref(fd);
1041args->size = size;
1042args->offset = off;
1043if (xdata)
1044args->xdata = dict_ref(xdata);
1045return 0;
1046}
1047
1048int
1049args_readdirp_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1050int32_t op_errno, gf_dirent_t *entries, dict_t *xdata)
1051{
1052gf_dirent_t *stub_entry = NULL, *entry = NULL;
1053
1054args->op_ret = op_ret;
1055args->op_errno = op_errno;
1056if (op_ret > 0) {
1057list_for_each_entry(entry, &entries->list, list)
1058{
1059stub_entry = entry_copy(entry);
1060if (!stub_entry)
1061goto out;
1062list_add_tail(&stub_entry->list, &args->entries.list);
1063}
1064}
1065if (xdata)
1066args->xdata = dict_ref(xdata);
1067out:
1068return 0;
1069}
1070
1071int
1072args_readdir_store(default_args_t *args, fd_t *fd, size_t size, off_t off,
1073dict_t *xdata)
1074{
1075args->fd = fd_ref(fd);
1076args->size = size;
1077args->offset = off;
1078
1079if (xdata)
1080args->xdata = dict_ref(xdata);
1081return 0;
1082}
1083
1084int
1085args_readdir_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1086int32_t op_errno, gf_dirent_t *entries, dict_t *xdata)
1087{
1088gf_dirent_t *stub_entry = NULL, *entry = NULL;
1089
1090args->op_ret = op_ret;
1091args->op_errno = op_errno;
1092if (op_ret > 0) {
1093list_for_each_entry(entry, &entries->list, list)
1094{
1095stub_entry = gf_dirent_for_name2(entry->d_name, entry->d_len,
1096entry->d_ino, entry->d_off,
1097entry->d_type, NULL);
1098if (!stub_entry)
1099goto out;
1100list_add_tail(&stub_entry->list, &args->entries.list);
1101}
1102}
1103if (xdata)
1104args->xdata = dict_ref(xdata);
1105out:
1106return 0;
1107}
1108
1109int
1110args_rchecksum_store(default_args_t *args, fd_t *fd, off_t offset, int32_t len,
1111dict_t *xdata)
1112{
1113args->fd = fd_ref(fd);
1114args->offset = offset;
1115args->size = len;
1116if (xdata)
1117args->xdata = dict_ref(xdata);
1118return 0;
1119}
1120
1121int
1122args_rchecksum_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1123int32_t op_errno, uint32_t weak_checksum,
1124uint8_t *strong_checksum, dict_t *xdata)
1125{
1126args->op_ret = op_ret;
1127args->op_errno = op_errno;
1128if (op_ret >= 0) {
1129args->weak_checksum = weak_checksum;
1130args->strong_checksum = gf_memdup(strong_checksum,
1131SHA256_DIGEST_LENGTH);
1132}
1133if (xdata)
1134args->xdata = dict_ref(xdata);
1135
1136return 0;
1137}
1138
1139int
1140args_xattrop_store(default_args_t *args, loc_t *loc, gf_xattrop_flags_t optype,
1141dict_t *xattr, dict_t *xdata)
1142{
1143loc_copy(&args->loc, loc);
1144
1145args->optype = optype;
1146args->xattr = dict_ref(xattr);
1147
1148if (xdata)
1149args->xdata = dict_ref(xdata);
1150return 0;
1151}
1152
1153int
1154args_xattrop_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1155int32_t op_errno, dict_t *xattr, dict_t *xdata)
1156{
1157args->op_ret = op_ret;
1158args->op_errno = op_errno;
1159if (xattr)
1160args->xattr = dict_ref(xattr);
1161if (xdata)
1162args->xdata = dict_ref(xdata);
1163
1164return 0;
1165}
1166
1167int
1168args_fxattrop_store(default_args_t *args, fd_t *fd, gf_xattrop_flags_t optype,
1169dict_t *xattr, dict_t *xdata)
1170{
1171args->fd = fd_ref(fd);
1172
1173args->optype = optype;
1174args->xattr = dict_ref(xattr);
1175
1176if (xdata)
1177args->xdata = dict_ref(xdata);
1178return 0;
1179}
1180
1181int
1182args_fxattrop_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1183int32_t op_errno, dict_t *xattr, dict_t *xdata)
1184{
1185args->op_ret = op_ret;
1186args->op_errno = op_errno;
1187if (xattr)
1188args->xattr = dict_ref(xattr);
1189if (xdata)
1190args->xdata = dict_ref(xdata);
1191
1192return 0;
1193}
1194
1195int
1196args_setattr_store(default_args_t *args, loc_t *loc, struct iatt *stbuf,
1197int32_t valid, dict_t *xdata)
1198{
1199loc_copy(&args->loc, loc);
1200
1201if (stbuf)
1202args->stat = *stbuf;
1203
1204args->valid = valid;
1205
1206if (xdata)
1207args->xdata = dict_ref(xdata);
1208return 0;
1209}
1210
1211int
1212args_setattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1213int32_t op_errno, struct iatt *statpre,
1214struct iatt *statpost, dict_t *xdata)
1215{
1216args->op_ret = op_ret;
1217args->op_errno = op_errno;
1218if (statpre)
1219args->prestat = *statpre;
1220if (statpost)
1221args->poststat = *statpost;
1222if (xdata)
1223args->xdata = dict_ref(xdata);
1224
1225return 0;
1226}
1227
1228int
1229args_fsetattr_store(default_args_t *args, fd_t *fd, struct iatt *stbuf,
1230int32_t valid, dict_t *xdata)
1231{
1232if (fd)
1233args->fd = fd_ref(fd);
1234
1235if (stbuf)
1236args->stat = *stbuf;
1237
1238args->valid = valid;
1239
1240if (xdata)
1241args->xdata = dict_ref(xdata);
1242return 0;
1243}
1244int
1245args_fsetattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1246int32_t op_errno, struct iatt *statpre,
1247struct iatt *statpost, dict_t *xdata)
1248{
1249args->op_ret = op_ret;
1250args->op_errno = op_errno;
1251if (statpre)
1252args->prestat = *statpre;
1253if (statpost)
1254args->poststat = *statpost;
1255if (xdata)
1256args->xdata = dict_ref(xdata);
1257
1258return 0;
1259}
1260
1261int
1262args_fallocate_store(default_args_t *args, fd_t *fd, int32_t mode, off_t offset,
1263size_t len, dict_t *xdata)
1264{
1265if (fd)
1266args->fd = fd_ref(fd);
1267
1268args->flags = mode;
1269args->offset = offset;
1270args->size = len;
1271
1272if (xdata)
1273args->xdata = dict_ref(xdata);
1274return 0;
1275}
1276
1277int
1278args_fallocate_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1279int32_t op_errno, struct iatt *statpre,
1280struct iatt *statpost, dict_t *xdata)
1281{
1282args->op_ret = op_ret;
1283args->op_errno = op_errno;
1284if (statpre)
1285args->prestat = *statpre;
1286if (statpost)
1287args->poststat = *statpost;
1288if (xdata)
1289args->xdata = dict_ref(xdata);
1290
1291return 0;
1292}
1293
1294int
1295args_discard_store(default_args_t *args, fd_t *fd, off_t offset, size_t len,
1296dict_t *xdata)
1297{
1298if (fd)
1299args->fd = fd_ref(fd);
1300
1301args->offset = offset;
1302args->size = len;
1303
1304if (xdata)
1305args->xdata = dict_ref(xdata);
1306return 0;
1307}
1308
1309int
1310args_discard_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1311int32_t op_errno, struct iatt *statpre,
1312struct iatt *statpost, dict_t *xdata)
1313{
1314args->op_ret = op_ret;
1315args->op_errno = op_errno;
1316if (statpre)
1317args->prestat = *statpre;
1318if (statpost)
1319args->poststat = *statpost;
1320if (xdata)
1321args->xdata = dict_ref(xdata);
1322
1323return 0;
1324}
1325
1326int
1327args_zerofill_store(default_args_t *args, fd_t *fd, off_t offset, off_t len,
1328dict_t *xdata)
1329{
1330if (fd)
1331args->fd = fd_ref(fd);
1332
1333args->offset = offset;
1334args->size = len;
1335
1336if (xdata)
1337args->xdata = dict_ref(xdata);
1338return 0;
1339}
1340
1341int
1342args_zerofill_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1343int32_t op_errno, struct iatt *statpre,
1344struct iatt *statpost, dict_t *xdata)
1345{
1346args->op_ret = op_ret;
1347args->op_errno = op_errno;
1348if (statpre)
1349args->prestat = *statpre;
1350if (statpost)
1351args->poststat = *statpost;
1352if (xdata)
1353args->xdata = dict_ref(xdata);
1354
1355return 0;
1356}
1357
1358int
1359args_ipc_store(default_args_t *args, int32_t op, dict_t *xdata)
1360{
1361args->cmd = op;
1362
1363if (xdata)
1364args->xdata = dict_ref(xdata);
1365return 0;
1366}
1367
1368int
1369args_ipc_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
1370dict_t *xdata)
1371{
1372args->op_ret = op_ret;
1373args->op_errno = op_errno;
1374if (xdata)
1375args->xdata = dict_ref(xdata);
1376
1377return 0;
1378}
1379
1380int
1381args_seek_store(default_args_t *args, fd_t *fd, off_t offset,
1382gf_seek_what_t what, dict_t *xdata)
1383{
1384if (fd)
1385args->fd = fd_ref(fd);
1386
1387args->offset = offset;
1388args->what = what;
1389
1390if (xdata)
1391args->xdata = dict_ref(xdata);
1392return 0;
1393}
1394
1395int
1396args_seek_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
1397off_t offset, dict_t *xdata)
1398{
1399args->op_ret = op_ret;
1400args->op_errno = op_errno;
1401args->offset = offset;
1402if (xdata)
1403args->xdata = dict_ref(xdata);
1404
1405return 0;
1406}
1407
1408int
1409args_getactivelk_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1410int32_t op_errno, lock_migration_info_t *locklist,
1411dict_t *xdata)
1412{
1413lock_migration_info_t *stub_entry = NULL, *entry = NULL;
1414int ret = 0;
1415
1416args->op_ret = op_ret;
1417args->op_errno = op_errno;
1418/*op_ret needs to carry the number of locks present in the list*/
1419if (op_ret > 0) {
1420list_for_each_entry(entry, &locklist->list, list)
1421{
1422/* TODO: move to GF_MALLOC() */
1423stub_entry = GF_CALLOC(1, sizeof(*stub_entry), gf_common_mt_char);
1424if (!stub_entry) {
1425ret = -1;
1426goto out;
1427}
1428
1429INIT_LIST_HEAD(&stub_entry->list);
1430gf_flock_copy(&stub_entry->flock, &entry->flock);
1431
1432stub_entry->lk_flags = entry->lk_flags;
1433
1434stub_entry->client_uid = gf_strdup(entry->client_uid);
1435if (!stub_entry->client_uid) {
1436GF_FREE(stub_entry);
1437ret = -1;
1438goto out;
1439}
1440
1441list_add_tail(&stub_entry->list, &args->locklist.list);
1442}
1443}
1444
1445if (xdata)
1446args->xdata = dict_ref(xdata);
1447out:
1448return ret;
1449}
1450
1451int
1452args_setactivelk_store(default_args_t *args, loc_t *loc,
1453lock_migration_info_t *locklist, dict_t *xdata)
1454{
1455lock_migration_info_t *stub_entry = NULL, *entry = NULL;
1456int ret = 0;
1457
1458list_for_each_entry(entry, &locklist->list, list)
1459{
1460/* TODO: move to GF_MALLOC() */
1461stub_entry = GF_CALLOC(1, sizeof(*stub_entry), gf_common_mt_lock_mig);
1462if (!stub_entry) {
1463ret = -1;
1464goto out;
1465}
1466
1467INIT_LIST_HEAD(&stub_entry->list);
1468gf_flock_copy(&stub_entry->flock, &entry->flock);
1469
1470stub_entry->lk_flags = entry->lk_flags;
1471
1472stub_entry->client_uid = gf_strdup(entry->client_uid);
1473if (!stub_entry->client_uid) {
1474GF_FREE(stub_entry);
1475ret = -1;
1476goto out;
1477}
1478
1479list_add_tail(&stub_entry->list, &args->locklist.list);
1480}
1481
1482loc_copy(&args->loc, loc);
1483
1484if (xdata)
1485args->xdata = dict_ref(xdata);
1486
1487out:
1488return ret;
1489}
1490
1491void
1492args_lease_store(default_args_t *args, loc_t *loc, struct gf_lease *lease,
1493dict_t *xdata)
1494{
1495loc_copy(&args->loc, loc);
1496args->lease = *lease;
1497
1498if (xdata)
1499args->xdata = dict_ref(xdata);
1500
1501return;
1502}
1503
1504void
1505args_lease_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
1506struct gf_lease *lease, dict_t *xdata)
1507{
1508args->op_ret = op_ret;
1509args->op_errno = op_errno;
1510if (op_ret == 0)
1511args->lease = *lease;
1512if (xdata)
1513args->xdata = dict_ref(xdata);
1514}
1515
1516int
1517args_icreate_store(default_args_t *args, loc_t *loc, mode_t mode, dict_t *xdata)
1518{
1519loc_copy(&args->loc, loc);
1520args->mode = mode;
1521
1522if (xdata)
1523args->xdata = dict_ref(xdata);
1524return 0;
1525}
1526
1527int
1528args_namelink_store(default_args_t *args, loc_t *loc, dict_t *xdata)
1529{
1530loc_copy(&args->loc, loc);
1531
1532if (xdata)
1533args->xdata = dict_ref(xdata);
1534return 0;
1535}
1536
1537int
1538args_copy_file_range_store(default_args_t *args, fd_t *fd_in, off64_t off_in,
1539fd_t *fd_out, off64_t off_out, size_t len,
1540uint32_t flags, dict_t *xdata)
1541{
1542if (fd_in)
1543args->fd = fd_ref(fd_in);
1544if (fd_out)
1545args->fd_dst = fd_ref(fd_out);
1546args->size = len;
1547args->off_in = off_in;
1548args->off_out = off_out;
1549args->flags = flags;
1550
1551if (xdata)
1552args->xdata = dict_ref(xdata);
1553
1554return 0;
1555}
1556
1557int
1558args_copy_file_range_cbk_store(default_args_cbk_t *args, int32_t op_ret,
1559int32_t op_errno, struct iatt *stbuf,
1560struct iatt *prebuf_dst,
1561struct iatt *postbuf_dst, dict_t *xdata)
1562{
1563args->op_ret = op_ret;
1564args->op_errno = op_errno;
1565if (op_ret >= 0) {
1566if (postbuf_dst)
1567args->poststat = *postbuf_dst;
1568if (prebuf_dst)
1569args->prestat = *prebuf_dst;
1570if (stbuf)
1571args->stat = *stbuf;
1572}
1573if (xdata)
1574args->xdata = dict_ref(xdata);
1575
1576return 0;
1577}
1578
1579void
1580args_cbk_wipe(default_args_cbk_t *args_cbk)
1581{
1582if (!args_cbk)
1583return;
1584if (args_cbk->inode)
1585inode_unref(args_cbk->inode);
1586
1587GF_FREE((char *)args_cbk->buf);
1588
1589GF_FREE(args_cbk->vector);
1590
1591if (args_cbk->iobref)
1592iobref_unref(args_cbk->iobref);
1593
1594if (args_cbk->fd)
1595fd_unref(args_cbk->fd);
1596
1597if (args_cbk->xattr)
1598dict_unref(args_cbk->xattr);
1599
1600GF_FREE(args_cbk->strong_checksum);
1601
1602if (args_cbk->xdata)
1603dict_unref(args_cbk->xdata);
1604
1605if (!list_empty(&args_cbk->entries.list))
1606gf_dirent_free(&args_cbk->entries);
1607}
1608
1609void
1610args_wipe(default_args_t *args)
1611{
1612if (!args)
1613return;
1614
1615loc_wipe(&args->loc);
1616
1617loc_wipe(&args->loc2);
1618
1619if (args->fd)
1620fd_unref(args->fd);
1621
1622GF_FREE((char *)args->linkname);
1623
1624GF_FREE(args->vector);
1625
1626if (args->iobref)
1627iobref_unref(args->iobref);
1628
1629if (args->xattr)
1630dict_unref(args->xattr);
1631
1632if (args->xdata)
1633dict_unref(args->xdata);
1634
1635GF_FREE((char *)args->name);
1636
1637GF_FREE((char *)args->volume);
1638}
1639
1640void
1641args_cbk_init(default_args_cbk_t *args_cbk)
1642{
1643INIT_LIST_HEAD(&args_cbk->entries);
1644}
1645