"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/libglusterfs/src/default-args.c" (16 Sep 2020, 38371 Bytes) of package /linux/misc/glusterfs-8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "default-args.c" see the Fossies "Dox" file reference documentation.

    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     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         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     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     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 = gf_dirent_for_name(entry->d_name);
 1060             if (!stub_entry)
 1061                 goto out;
 1062             stub_entry->d_off = entry->d_off;
 1063             stub_entry->d_ino = entry->d_ino;
 1064             stub_entry->d_stat = entry->d_stat;
 1065             stub_entry->d_type = entry->d_type;
 1066             if (entry->inode)
 1067                 stub_entry->inode = inode_ref(entry->inode);
 1068             if (entry->dict)
 1069                 stub_entry->dict = dict_ref(entry->dict);
 1070             list_add_tail(&stub_entry->list, &args->entries.list);
 1071         }
 1072     }
 1073     if (xdata)
 1074         args->xdata = dict_ref(xdata);
 1075 out:
 1076     return 0;
 1077 }
 1078 
 1079 int
 1080 args_readdir_store(default_args_t *args, fd_t *fd, size_t size, off_t off,
 1081                    dict_t *xdata)
 1082 {
 1083     args->fd = fd_ref(fd);
 1084     args->size = size;
 1085     args->offset = off;
 1086 
 1087     if (xdata)
 1088         args->xdata = dict_ref(xdata);
 1089     return 0;
 1090 }
 1091 
 1092 int
 1093 args_readdir_cbk_store(default_args_cbk_t *args, int32_t op_ret,
 1094                        int32_t op_errno, gf_dirent_t *entries, dict_t *xdata)
 1095 {
 1096     gf_dirent_t *stub_entry = NULL, *entry = NULL;
 1097 
 1098     args->op_ret = op_ret;
 1099     args->op_errno = op_errno;
 1100     if (op_ret > 0) {
 1101         list_for_each_entry(entry, &entries->list, list)
 1102         {
 1103             stub_entry = gf_dirent_for_name(entry->d_name);
 1104             if (!stub_entry)
 1105                 goto out;
 1106             stub_entry->d_off = entry->d_off;
 1107             stub_entry->d_ino = entry->d_ino;
 1108             stub_entry->d_type = entry->d_type;
 1109             list_add_tail(&stub_entry->list, &args->entries.list);
 1110         }
 1111     }
 1112     if (xdata)
 1113         args->xdata = dict_ref(xdata);
 1114 out:
 1115     return 0;
 1116 }
 1117 
 1118 int
 1119 args_rchecksum_store(default_args_t *args, fd_t *fd, off_t offset, int32_t len,
 1120                      dict_t *xdata)
 1121 {
 1122     args->fd = fd_ref(fd);
 1123     args->offset = offset;
 1124     args->size = len;
 1125     if (xdata)
 1126         args->xdata = dict_ref(xdata);
 1127     return 0;
 1128 }
 1129 
 1130 int
 1131 args_rchecksum_cbk_store(default_args_cbk_t *args, int32_t op_ret,
 1132                          int32_t op_errno, uint32_t weak_checksum,
 1133                          uint8_t *strong_checksum, dict_t *xdata)
 1134 {
 1135     args->op_ret = op_ret;
 1136     args->op_errno = op_errno;
 1137     if (op_ret >= 0) {
 1138         args->weak_checksum = weak_checksum;
 1139         args->strong_checksum = gf_memdup(strong_checksum,
 1140                                           SHA256_DIGEST_LENGTH);
 1141     }
 1142     if (xdata)
 1143         args->xdata = dict_ref(xdata);
 1144 
 1145     return 0;
 1146 }
 1147 
 1148 int
 1149 args_xattrop_store(default_args_t *args, loc_t *loc, gf_xattrop_flags_t optype,
 1150                    dict_t *xattr, dict_t *xdata)
 1151 {
 1152     loc_copy(&args->loc, loc);
 1153 
 1154     args->optype = optype;
 1155     args->xattr = dict_ref(xattr);
 1156 
 1157     if (xdata)
 1158         args->xdata = dict_ref(xdata);
 1159     return 0;
 1160 }
 1161 
 1162 int
 1163 args_xattrop_cbk_store(default_args_cbk_t *args, int32_t op_ret,
 1164                        int32_t op_errno, dict_t *xattr, dict_t *xdata)
 1165 {
 1166     args->op_ret = op_ret;
 1167     args->op_errno = op_errno;
 1168     if (xattr)
 1169         args->xattr = dict_ref(xattr);
 1170     if (xdata)
 1171         args->xdata = dict_ref(xdata);
 1172 
 1173     return 0;
 1174 }
 1175 
 1176 int
 1177 args_fxattrop_store(default_args_t *args, fd_t *fd, gf_xattrop_flags_t optype,
 1178                     dict_t *xattr, dict_t *xdata)
 1179 {
 1180     args->fd = fd_ref(fd);
 1181 
 1182     args->optype = optype;
 1183     args->xattr = dict_ref(xattr);
 1184 
 1185     if (xdata)
 1186         args->xdata = dict_ref(xdata);
 1187     return 0;
 1188 }
 1189 
 1190 int
 1191 args_fxattrop_cbk_store(default_args_cbk_t *args, int32_t op_ret,
 1192                         int32_t op_errno, dict_t *xattr, dict_t *xdata)
 1193 {
 1194     args->op_ret = op_ret;
 1195     args->op_errno = op_errno;
 1196     if (xattr)
 1197         args->xattr = dict_ref(xattr);
 1198     if (xdata)
 1199         args->xdata = dict_ref(xdata);
 1200 
 1201     return 0;
 1202 }
 1203 
 1204 int
 1205 args_setattr_store(default_args_t *args, loc_t *loc, struct iatt *stbuf,
 1206                    int32_t valid, dict_t *xdata)
 1207 {
 1208     loc_copy(&args->loc, loc);
 1209 
 1210     if (stbuf)
 1211         args->stat = *stbuf;
 1212 
 1213     args->valid = valid;
 1214 
 1215     if (xdata)
 1216         args->xdata = dict_ref(xdata);
 1217     return 0;
 1218 }
 1219 
 1220 int
 1221 args_setattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
 1222                        int32_t op_errno, struct iatt *statpre,
 1223                        struct iatt *statpost, dict_t *xdata)
 1224 {
 1225     args->op_ret = op_ret;
 1226     args->op_errno = op_errno;
 1227     if (statpre)
 1228         args->prestat = *statpre;
 1229     if (statpost)
 1230         args->poststat = *statpost;
 1231     if (xdata)
 1232         args->xdata = dict_ref(xdata);
 1233 
 1234     return 0;
 1235 }
 1236 
 1237 int
 1238 args_fsetattr_store(default_args_t *args, fd_t *fd, struct iatt *stbuf,
 1239                     int32_t valid, dict_t *xdata)
 1240 {
 1241     if (fd)
 1242         args->fd = fd_ref(fd);
 1243 
 1244     if (stbuf)
 1245         args->stat = *stbuf;
 1246 
 1247     args->valid = valid;
 1248 
 1249     if (xdata)
 1250         args->xdata = dict_ref(xdata);
 1251     return 0;
 1252 }
 1253 int
 1254 args_fsetattr_cbk_store(default_args_cbk_t *args, int32_t op_ret,
 1255                         int32_t op_errno, struct iatt *statpre,
 1256                         struct iatt *statpost, dict_t *xdata)
 1257 {
 1258     args->op_ret = op_ret;
 1259     args->op_errno = op_errno;
 1260     if (statpre)
 1261         args->prestat = *statpre;
 1262     if (statpost)
 1263         args->poststat = *statpost;
 1264     if (xdata)
 1265         args->xdata = dict_ref(xdata);
 1266 
 1267     return 0;
 1268 }
 1269 
 1270 int
 1271 args_fallocate_store(default_args_t *args, fd_t *fd, int32_t mode, off_t offset,
 1272                      size_t len, dict_t *xdata)
 1273 {
 1274     if (fd)
 1275         args->fd = fd_ref(fd);
 1276 
 1277     args->flags = mode;
 1278     args->offset = offset;
 1279     args->size = len;
 1280 
 1281     if (xdata)
 1282         args->xdata = dict_ref(xdata);
 1283     return 0;
 1284 }
 1285 
 1286 int
 1287 args_fallocate_cbk_store(default_args_cbk_t *args, int32_t op_ret,
 1288                          int32_t op_errno, struct iatt *statpre,
 1289                          struct iatt *statpost, dict_t *xdata)
 1290 {
 1291     args->op_ret = op_ret;
 1292     args->op_errno = op_errno;
 1293     if (statpre)
 1294         args->prestat = *statpre;
 1295     if (statpost)
 1296         args->poststat = *statpost;
 1297     if (xdata)
 1298         args->xdata = dict_ref(xdata);
 1299 
 1300     return 0;
 1301 }
 1302 
 1303 int
 1304 args_discard_store(default_args_t *args, fd_t *fd, off_t offset, size_t len,
 1305                    dict_t *xdata)
 1306 {
 1307     if (fd)
 1308         args->fd = fd_ref(fd);
 1309 
 1310     args->offset = offset;
 1311     args->size = len;
 1312 
 1313     if (xdata)
 1314         args->xdata = dict_ref(xdata);
 1315     return 0;
 1316 }
 1317 
 1318 int
 1319 args_discard_cbk_store(default_args_cbk_t *args, int32_t op_ret,
 1320                        int32_t op_errno, struct iatt *statpre,
 1321                        struct iatt *statpost, dict_t *xdata)
 1322 {
 1323     args->op_ret = op_ret;
 1324     args->op_errno = op_errno;
 1325     if (statpre)
 1326         args->prestat = *statpre;
 1327     if (statpost)
 1328         args->poststat = *statpost;
 1329     if (xdata)
 1330         args->xdata = dict_ref(xdata);
 1331 
 1332     return 0;
 1333 }
 1334 
 1335 int
 1336 args_zerofill_store(default_args_t *args, fd_t *fd, off_t offset, off_t len,
 1337                     dict_t *xdata)
 1338 {
 1339     if (fd)
 1340         args->fd = fd_ref(fd);
 1341 
 1342     args->offset = offset;
 1343     args->size = len;
 1344 
 1345     if (xdata)
 1346         args->xdata = dict_ref(xdata);
 1347     return 0;
 1348 }
 1349 
 1350 int
 1351 args_zerofill_cbk_store(default_args_cbk_t *args, int32_t op_ret,
 1352                         int32_t op_errno, struct iatt *statpre,
 1353                         struct iatt *statpost, dict_t *xdata)
 1354 {
 1355     args->op_ret = op_ret;
 1356     args->op_errno = op_errno;
 1357     if (statpre)
 1358         args->prestat = *statpre;
 1359     if (statpost)
 1360         args->poststat = *statpost;
 1361     if (xdata)
 1362         args->xdata = dict_ref(xdata);
 1363 
 1364     return 0;
 1365 }
 1366 
 1367 int
 1368 args_ipc_store(default_args_t *args, int32_t op, dict_t *xdata)
 1369 {
 1370     args->cmd = op;
 1371 
 1372     if (xdata)
 1373         args->xdata = dict_ref(xdata);
 1374     return 0;
 1375 }
 1376 
 1377 int
 1378 args_ipc_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
 1379                    dict_t *xdata)
 1380 {
 1381     args->op_ret = op_ret;
 1382     args->op_errno = op_errno;
 1383     if (xdata)
 1384         args->xdata = dict_ref(xdata);
 1385 
 1386     return 0;
 1387 }
 1388 
 1389 int
 1390 args_seek_store(default_args_t *args, fd_t *fd, off_t offset,
 1391                 gf_seek_what_t what, dict_t *xdata)
 1392 {
 1393     if (fd)
 1394         args->fd = fd_ref(fd);
 1395 
 1396     args->offset = offset;
 1397     args->what = what;
 1398 
 1399     if (xdata)
 1400         args->xdata = dict_ref(xdata);
 1401     return 0;
 1402 }
 1403 
 1404 int
 1405 args_seek_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
 1406                     off_t offset, dict_t *xdata)
 1407 {
 1408     args->op_ret = op_ret;
 1409     args->op_errno = op_errno;
 1410     args->offset = offset;
 1411     if (xdata)
 1412         args->xdata = dict_ref(xdata);
 1413 
 1414     return 0;
 1415 }
 1416 
 1417 int
 1418 args_getactivelk_cbk_store(default_args_cbk_t *args, int32_t op_ret,
 1419                            int32_t op_errno, lock_migration_info_t *locklist,
 1420                            dict_t *xdata)
 1421 {
 1422     lock_migration_info_t *stub_entry = NULL, *entry = NULL;
 1423     int ret = 0;
 1424 
 1425     args->op_ret = op_ret;
 1426     args->op_errno = op_errno;
 1427     /*op_ret needs to carry the number of locks present in the list*/
 1428     if (op_ret > 0) {
 1429         list_for_each_entry(entry, &locklist->list, list)
 1430         {
 1431             stub_entry = GF_CALLOC(1, sizeof(*stub_entry), gf_common_mt_char);
 1432             if (!stub_entry) {
 1433                 ret = -1;
 1434                 goto out;
 1435             }
 1436 
 1437             INIT_LIST_HEAD(&stub_entry->list);
 1438             stub_entry->flock = entry->flock;
 1439 
 1440             stub_entry->lk_flags = entry->lk_flags;
 1441 
 1442             stub_entry->client_uid = gf_strdup(entry->client_uid);
 1443             if (!stub_entry->client_uid) {
 1444                 GF_FREE(stub_entry);
 1445                 ret = -1;
 1446                 goto out;
 1447             }
 1448 
 1449             list_add_tail(&stub_entry->list, &args->locklist.list);
 1450         }
 1451     }
 1452 
 1453     if (xdata)
 1454         args->xdata = dict_ref(xdata);
 1455 out:
 1456     return ret;
 1457 }
 1458 
 1459 int
 1460 args_setactivelk_store(default_args_t *args, loc_t *loc,
 1461                        lock_migration_info_t *locklist, dict_t *xdata)
 1462 {
 1463     lock_migration_info_t *stub_entry = NULL, *entry = NULL;
 1464     int ret = 0;
 1465 
 1466     list_for_each_entry(entry, &locklist->list, list)
 1467     {
 1468         stub_entry = GF_CALLOC(1, sizeof(*stub_entry), gf_common_mt_lock_mig);
 1469         if (!stub_entry) {
 1470             ret = -1;
 1471             goto out;
 1472         }
 1473 
 1474         INIT_LIST_HEAD(&stub_entry->list);
 1475         stub_entry->flock = entry->flock;
 1476 
 1477         stub_entry->lk_flags = entry->lk_flags;
 1478 
 1479         stub_entry->client_uid = gf_strdup(entry->client_uid);
 1480         if (!stub_entry->client_uid) {
 1481             GF_FREE(stub_entry);
 1482             ret = -1;
 1483             goto out;
 1484         }
 1485 
 1486         list_add_tail(&stub_entry->list, &args->locklist.list);
 1487     }
 1488 
 1489     loc_copy(&args->loc, loc);
 1490 
 1491     if (xdata)
 1492         args->xdata = dict_ref(xdata);
 1493 
 1494 out:
 1495     return ret;
 1496 }
 1497 
 1498 void
 1499 args_lease_store(default_args_t *args, loc_t *loc, struct gf_lease *lease,
 1500                  dict_t *xdata)
 1501 {
 1502     loc_copy(&args->loc, loc);
 1503     args->lease = *lease;
 1504 
 1505     if (xdata)
 1506         args->xdata = dict_ref(xdata);
 1507 
 1508     return;
 1509 }
 1510 
 1511 void
 1512 args_lease_cbk_store(default_args_cbk_t *args, int32_t op_ret, int32_t op_errno,
 1513                      struct gf_lease *lease, dict_t *xdata)
 1514 {
 1515     args->op_ret = op_ret;
 1516     args->op_errno = op_errno;
 1517     if (op_ret == 0)
 1518         args->lease = *lease;
 1519     if (xdata)
 1520         args->xdata = dict_ref(xdata);
 1521 }
 1522 
 1523 int
 1524 args_icreate_store(default_args_t *args, loc_t *loc, mode_t mode, dict_t *xdata)
 1525 {
 1526     loc_copy(&args->loc, loc);
 1527     args->mode = mode;
 1528 
 1529     if (xdata)
 1530         args->xdata = dict_ref(xdata);
 1531     return 0;
 1532 }
 1533 
 1534 int
 1535 args_namelink_store(default_args_t *args, loc_t *loc, dict_t *xdata)
 1536 {
 1537     loc_copy(&args->loc, loc);
 1538 
 1539     if (xdata)
 1540         args->xdata = dict_ref(xdata);
 1541     return 0;
 1542 }
 1543 
 1544 int
 1545 args_copy_file_range_store(default_args_t *args, fd_t *fd_in, off64_t off_in,
 1546                            fd_t *fd_out, off64_t off_out, size_t len,
 1547                            uint32_t flags, dict_t *xdata)
 1548 {
 1549     if (fd_in)
 1550         args->fd = fd_ref(fd_in);
 1551     if (fd_out)
 1552         args->fd_dst = fd_ref(fd_out);
 1553     args->size = len;
 1554     args->off_in = off_in;
 1555     args->off_out = off_out;
 1556     args->flags = flags;
 1557 
 1558     if (xdata)
 1559         args->xdata = dict_ref(xdata);
 1560 
 1561     return 0;
 1562 }
 1563 
 1564 int
 1565 args_copy_file_range_cbk_store(default_args_cbk_t *args, int32_t op_ret,
 1566                                int32_t op_errno, struct iatt *stbuf,
 1567                                struct iatt *prebuf_dst,
 1568                                struct iatt *postbuf_dst, dict_t *xdata)
 1569 {
 1570     args->op_ret = op_ret;
 1571     args->op_errno = op_errno;
 1572     if (op_ret >= 0) {
 1573         if (postbuf_dst)
 1574             args->poststat = *postbuf_dst;
 1575         if (prebuf_dst)
 1576             args->prestat = *prebuf_dst;
 1577         if (stbuf)
 1578             args->stat = *stbuf;
 1579     }
 1580     if (xdata)
 1581         args->xdata = dict_ref(xdata);
 1582 
 1583     return 0;
 1584 }
 1585 
 1586 void
 1587 args_cbk_wipe(default_args_cbk_t *args_cbk)
 1588 {
 1589     if (!args_cbk)
 1590         return;
 1591     if (args_cbk->inode)
 1592         inode_unref(args_cbk->inode);
 1593 
 1594     GF_FREE((char *)args_cbk->buf);
 1595 
 1596     GF_FREE(args_cbk->vector);
 1597 
 1598     if (args_cbk->iobref)
 1599         iobref_unref(args_cbk->iobref);
 1600 
 1601     if (args_cbk->fd)
 1602         fd_unref(args_cbk->fd);
 1603 
 1604     if (args_cbk->xattr)
 1605         dict_unref(args_cbk->xattr);
 1606 
 1607     GF_FREE(args_cbk->strong_checksum);
 1608 
 1609     if (args_cbk->xdata)
 1610         dict_unref(args_cbk->xdata);
 1611 
 1612     if (!list_empty(&args_cbk->entries.list))
 1613         gf_dirent_free(&args_cbk->entries);
 1614 }
 1615 
 1616 void
 1617 args_wipe(default_args_t *args)
 1618 {
 1619     if (!args)
 1620         return;
 1621 
 1622     loc_wipe(&args->loc);
 1623 
 1624     loc_wipe(&args->loc2);
 1625 
 1626     if (args->fd)
 1627         fd_unref(args->fd);
 1628 
 1629     GF_FREE((char *)args->linkname);
 1630 
 1631     GF_FREE(args->vector);
 1632 
 1633     if (args->iobref)
 1634         iobref_unref(args->iobref);
 1635 
 1636     if (args->xattr)
 1637         dict_unref(args->xattr);
 1638 
 1639     if (args->xdata)
 1640         dict_unref(args->xdata);
 1641 
 1642     GF_FREE((char *)args->name);
 1643 
 1644     GF_FREE((char *)args->volume);
 1645 }
 1646 
 1647 void
 1648 args_cbk_init(default_args_cbk_t *args_cbk)
 1649 {
 1650     INIT_LIST_HEAD(&args_cbk->entries);
 1651 }