/*
Copyright (c) 2007-2011 Gluster, Inc. <http://www.gluster.com>
This file is part of GlusterFS.
GlusterFS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3 of the License,
or (at your option) any later version.
GlusterFS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see
<http://www.gnu.org/licenses/>.
*/
#ifndef _CONFIG_H
#define _CONFIG_H
#include "config.h"
#endif
#include <inttypes.h>
#include "md5.h"
#include "call-stub.h"
#include "mem-types.h"
static call_stub_t *
stub_new (call_frame_t *frame,
char wind,
glusterfs_fop_t fop)
{
call_stub_t *new = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
new = mem_get0 (frame->this->ctx->stub_mem_pool);
GF_VALIDATE_OR_GOTO ("call-stub", new, out);
new->frame = frame;
new->wind = wind;
new->fop = fop;
new->stub_mem_pool = frame->this->ctx->stub_mem_pool;
INIT_LIST_HEAD (&new->list);
out:
return new;
}
call_stub_t *
fop_lookup_stub (call_frame_t *frame,
fop_lookup_t fn,
loc_t *loc,
dict_t *xattr_req)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
GF_VALIDATE_OR_GOTO ("call-stub", loc, out);
stub = stub_new (frame, 1, GF_FOP_LOOKUP);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.lookup.fn = fn;
if (xattr_req)
stub->args.lookup.xattr_req = dict_ref (xattr_req);
loc_copy (&stub->args.lookup.loc, loc);
out:
return stub;
}
call_stub_t *
fop_lookup_cbk_stub (call_frame_t *frame,
fop_lookup_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
inode_t *inode,
struct iatt *buf,
dict_t *dict,
struct iatt *postparent)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_LOOKUP);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.lookup_cbk.fn = fn;
stub->args.lookup_cbk.op_ret = op_ret;
stub->args.lookup_cbk.op_errno = op_errno;
if (inode)
stub->args.lookup_cbk.inode = inode_ref (inode);
if (buf)
stub->args.lookup_cbk.buf = *buf;
if (dict)
stub->args.lookup_cbk.dict = dict_ref (dict);
if (postparent)
stub->args.lookup_cbk.postparent = *postparent;
out:
return stub;
}
call_stub_t *
fop_stat_stub (call_frame_t *frame,
fop_stat_t fn,
loc_t *loc)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
GF_VALIDATE_OR_GOTO ("call-stub", loc, out);
stub = stub_new (frame, 1, GF_FOP_STAT);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.stat.fn = fn;
loc_copy (&stub->args.stat.loc, loc);
out:
return stub;
}
call_stub_t *
fop_stat_cbk_stub (call_frame_t *frame,
fop_stat_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
struct iatt *buf)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_STAT);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.stat_cbk.fn = fn;
stub->args.stat_cbk.op_ret = op_ret;
stub->args.stat_cbk.op_errno = op_errno;
if (op_ret == 0)
stub->args.stat_cbk.buf = *buf;
out:
return stub;
}
call_stub_t *
fop_fstat_stub (call_frame_t *frame,
fop_fstat_t fn,
fd_t *fd)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 1, GF_FOP_FSTAT);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.fstat.fn = fn;
if (fd)
stub->args.fstat.fd = fd_ref (fd);
out:
return stub;
}
call_stub_t *
fop_fstat_cbk_stub (call_frame_t *frame,
fop_fstat_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
struct iatt *buf)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_FSTAT);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.fstat_cbk.fn = fn;
stub->args.fstat_cbk.op_ret = op_ret;
stub->args.fstat_cbk.op_errno = op_errno;
if (buf)
stub->args.fstat_cbk.buf = *buf;
out:
return stub;
}
/* truncate */
call_stub_t *
fop_truncate_stub (call_frame_t *frame,
fop_truncate_t fn,
loc_t *loc,
off_t off)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
GF_VALIDATE_OR_GOTO ("call-stub", loc, out);
stub = stub_new (frame, 1, GF_FOP_TRUNCATE);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.truncate.fn = fn;
loc_copy (&stub->args.truncate.loc, loc);
stub->args.truncate.off = off;
out:
return stub;
}
call_stub_t *
fop_truncate_cbk_stub (call_frame_t *frame,
fop_truncate_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
struct iatt *prebuf,
struct iatt *postbuf)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_TRUNCATE);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.truncate_cbk.fn = fn;
stub->args.truncate_cbk.op_ret = op_ret;
stub->args.truncate_cbk.op_errno = op_errno;
if (prebuf)
stub->args.truncate_cbk.prebuf = *prebuf;
if (postbuf)
stub->args.truncate_cbk.postbuf = *postbuf;
out:
return stub;
}
call_stub_t *
fop_ftruncate_stub (call_frame_t *frame,
fop_ftruncate_t fn,
fd_t *fd,
off_t off)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 1, GF_FOP_FTRUNCATE);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.ftruncate.fn = fn;
if (fd)
stub->args.ftruncate.fd = fd_ref (fd);
stub->args.ftruncate.off = off;
out:
return stub;
}
call_stub_t *
fop_ftruncate_cbk_stub (call_frame_t *frame,
fop_ftruncate_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
struct iatt *prebuf,
struct iatt *postbuf)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_FTRUNCATE);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.ftruncate_cbk.fn = fn;
stub->args.ftruncate_cbk.op_ret = op_ret;
stub->args.ftruncate_cbk.op_errno = op_errno;
if (prebuf)
stub->args.ftruncate_cbk.prebuf = *prebuf;
if (postbuf)
stub->args.ftruncate_cbk.postbuf = *postbuf;
out:
return stub;
}
call_stub_t *
fop_access_stub (call_frame_t *frame,
fop_access_t fn,
loc_t *loc,
int32_t mask)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
GF_VALIDATE_OR_GOTO ("call-stub", loc, out);
stub = stub_new (frame, 1, GF_FOP_ACCESS);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.access.fn = fn;
loc_copy (&stub->args.access.loc, loc);
stub->args.access.mask = mask;
out:
return stub;
}
call_stub_t *
fop_access_cbk_stub (call_frame_t *frame,
fop_access_cbk_t fn,
int32_t op_ret,
int32_t op_errno)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_ACCESS);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.access_cbk.fn = fn;
stub->args.access_cbk.op_ret = op_ret;
stub->args.access_cbk.op_errno = op_errno;
out:
return stub;
}
call_stub_t *
fop_readlink_stub (call_frame_t *frame,
fop_readlink_t fn,
loc_t *loc,
size_t size)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
GF_VALIDATE_OR_GOTO ("call-stub", loc, out);
stub = stub_new (frame, 1, GF_FOP_READLINK);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.readlink.fn = fn;
loc_copy (&stub->args.readlink.loc, loc);
stub->args.readlink.size = size;
out:
return stub;
}
call_stub_t *
fop_readlink_cbk_stub (call_frame_t *frame,
fop_readlink_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
const char *path,
struct iatt *sbuf)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_READLINK);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.readlink_cbk.fn = fn;
stub->args.readlink_cbk.op_ret = op_ret;
stub->args.readlink_cbk.op_errno = op_errno;
if (path)
stub->args.readlink_cbk.buf = gf_strdup (path);
if (sbuf)
stub->args.readlink_cbk.sbuf = *sbuf;
out:
return stub;
}
call_stub_t *
fop_mknod_stub (call_frame_t *frame, fop_mknod_t fn,
loc_t *loc, mode_t mode, dev_t rdev, dict_t *params)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
GF_VALIDATE_OR_GOTO ("call-stub", loc, out);
stub = stub_new (frame, 1, GF_FOP_MKNOD);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.mknod.fn = fn;
loc_copy (&stub->args.mknod.loc, loc);
stub->args.mknod.mode = mode;
stub->args.mknod.rdev = rdev;
if (params)
stub->args.mknod.params = dict_ref (params);
out:
return stub;
}
call_stub_t *
fop_mknod_cbk_stub (call_frame_t *frame,
fop_mknod_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
inode_t *inode,
struct iatt *buf,
struct iatt *preparent,
struct iatt *postparent)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_MKNOD);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.mknod_cbk.fn = fn;
stub->args.mknod_cbk.op_ret = op_ret;
stub->args.mknod_cbk.op_errno = op_errno;
if (inode)
stub->args.mknod_cbk.inode = inode_ref (inode);
if (buf)
stub->args.mknod_cbk.buf = *buf;
if (preparent)
stub->args.mknod_cbk.preparent = *preparent;
if (postparent)
stub->args.mknod_cbk.postparent = *postparent;
out:
return stub;
}
call_stub_t *
fop_mkdir_stub (call_frame_t *frame, fop_mkdir_t fn,
loc_t *loc, mode_t mode, dict_t *params)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
GF_VALIDATE_OR_GOTO ("call-stub", loc, out);
stub = stub_new (frame, 1, GF_FOP_MKDIR);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.mkdir.fn = fn;
loc_copy (&stub->args.mkdir.loc, loc);
stub->args.mkdir.mode = mode;
if (params)
stub->args.mkdir.params = dict_ref (params);
out:
return stub;
}
call_stub_t *
fop_mkdir_cbk_stub (call_frame_t *frame,
fop_mkdir_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
inode_t *inode,
struct iatt *buf,
struct iatt *preparent,
struct iatt *postparent)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_MKDIR);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.mkdir_cbk.fn = fn;
stub->args.mkdir_cbk.op_ret = op_ret;
stub->args.mkdir_cbk.op_errno = op_errno;
if (inode)
stub->args.mkdir_cbk.inode = inode_ref (inode);
if (buf)
stub->args.mkdir_cbk.buf = *buf;
if (preparent)
stub->args.mkdir_cbk.preparent = *preparent;
if (postparent)
stub->args.mkdir_cbk.postparent = *postparent;
out:
return stub;
}
call_stub_t *
fop_unlink_stub (call_frame_t *frame,
fop_unlink_t fn,
loc_t *loc)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
GF_VALIDATE_OR_GOTO ("call-stub", loc, out);
stub = stub_new (frame, 1, GF_FOP_UNLINK);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.unlink.fn = fn;
loc_copy (&stub->args.unlink.loc, loc);
out:
return stub;
}
call_stub_t *
fop_unlink_cbk_stub (call_frame_t *frame,
fop_unlink_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
struct iatt *preparent,
struct iatt *postparent)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_UNLINK);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.unlink_cbk.fn = fn;
stub->args.unlink_cbk.op_ret = op_ret;
stub->args.unlink_cbk.op_errno = op_errno;
if (preparent)
stub->args.unlink_cbk.preparent = *preparent;
if (postparent)
stub->args.unlink_cbk.postparent = *postparent;
out:
return stub;
}
call_stub_t *
fop_rmdir_stub (call_frame_t *frame, fop_rmdir_t fn,
loc_t *loc, int flags)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
GF_VALIDATE_OR_GOTO ("call-stub", loc, out);
stub = stub_new (frame, 1, GF_FOP_RMDIR);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.rmdir.fn = fn;
loc_copy (&stub->args.rmdir.loc, loc);
stub->args.rmdir.flags = flags;
out:
return stub;
}
call_stub_t *
fop_rmdir_cbk_stub (call_frame_t *frame,
fop_rmdir_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
struct iatt *preparent,
struct iatt *postparent)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_RMDIR);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.rmdir_cbk.fn = fn;
stub->args.rmdir_cbk.op_ret = op_ret;
stub->args.rmdir_cbk.op_errno = op_errno;
if (preparent)
stub->args.rmdir_cbk.preparent = *preparent;
if (postparent)
stub->args.rmdir_cbk.postparent = *postparent;
out:
return stub;
}
call_stub_t *
fop_symlink_stub (call_frame_t *frame, fop_symlink_t fn,
const char *linkname, loc_t *loc, dict_t *params)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
GF_VALIDATE_OR_GOTO ("call-stub", loc, out);
GF_VALIDATE_OR_GOTO ("call-stub", linkname, out);
stub = stub_new (frame, 1, GF_FOP_SYMLINK);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.symlink.fn = fn;
stub->args.symlink.linkname = gf_strdup (linkname);
loc_copy (&stub->args.symlink.loc, loc);
if (params)
stub->args.symlink.params = dict_ref (params);
out:
return stub;
}
call_stub_t *
fop_symlink_cbk_stub (call_frame_t *frame,
fop_symlink_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
inode_t *inode,
struct iatt *buf,
struct iatt *preparent,
struct iatt *postparent)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_SYMLINK);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.symlink_cbk.fn = fn;
stub->args.symlink_cbk.op_ret = op_ret;
stub->args.symlink_cbk.op_errno = op_errno;
if (inode)
stub->args.symlink_cbk.inode = inode_ref (inode);
if (buf)
stub->args.symlink_cbk.buf = *buf;
if (preparent)
stub->args.symlink_cbk.preparent = *preparent;
if (postparent)
stub->args.symlink_cbk.postparent = *postparent;
out:
return stub;
}
call_stub_t *
fop_rename_stub (call_frame_t *frame,
fop_rename_t fn,
loc_t *oldloc,
loc_t *newloc)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
GF_VALIDATE_OR_GOTO ("call-stub", oldloc, out);
GF_VALIDATE_OR_GOTO ("call-stub", newloc, out);
stub = stub_new (frame, 1, GF_FOP_RENAME);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.rename.fn = fn;
loc_copy (&stub->args.rename.old, oldloc);
loc_copy (&stub->args.rename.new, newloc);
out:
return stub;
}
call_stub_t *
fop_rename_cbk_stub (call_frame_t *frame,
fop_rename_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
struct iatt *buf,
struct iatt *preoldparent,
struct iatt *postoldparent,
struct iatt *prenewparent,
struct iatt *postnewparent)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_RENAME);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.rename_cbk.fn = fn;
stub->args.rename_cbk.op_ret = op_ret;
stub->args.rename_cbk.op_errno = op_errno;
if (buf)
stub->args.rename_cbk.buf = *buf;
if (preoldparent)
stub->args.rename_cbk.preoldparent = *preoldparent;
if (postoldparent)
stub->args.rename_cbk.postoldparent = *postoldparent;
if (prenewparent)
stub->args.rename_cbk.prenewparent = *prenewparent;
if (postnewparent)
stub->args.rename_cbk.postnewparent = *postnewparent;
out:
return stub;
}
call_stub_t *
fop_link_stub (call_frame_t *frame,
fop_link_t fn,
loc_t *oldloc,
loc_t *newloc)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
GF_VALIDATE_OR_GOTO ("call-stub", oldloc, out);
GF_VALIDATE_OR_GOTO ("call-stub", newloc, out);
stub = stub_new (frame, 1, GF_FOP_LINK);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.link.fn = fn;
loc_copy (&stub->args.link.oldloc, oldloc);
loc_copy (&stub->args.link.newloc, newloc);
out:
return stub;
}
call_stub_t *
fop_link_cbk_stub (call_frame_t *frame,
fop_link_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
inode_t *inode,
struct iatt *buf,
struct iatt *preparent,
struct iatt *postparent)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_LINK);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.link_cbk.fn = fn;
stub->args.link_cbk.op_ret = op_ret;
stub->args.link_cbk.op_errno = op_errno;
if (inode)
stub->args.link_cbk.inode = inode_ref (inode);
if (buf)
stub->args.link_cbk.buf = *buf;
if (preparent)
stub->args.link_cbk.preparent = *preparent;
if (postparent)
stub->args.link_cbk.postparent = *postparent;
out:
return stub;
}
call_stub_t *
fop_create_stub (call_frame_t *frame, fop_create_t fn,
loc_t *loc, int32_t flags, mode_t mode,
fd_t *fd, dict_t *params)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
GF_VALIDATE_OR_GOTO ("call-stub", loc, out);
stub = stub_new (frame, 1, GF_FOP_CREATE);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.create.fn = fn;
loc_copy (&stub->args.create.loc, loc);
stub->args.create.flags = flags;
stub->args.create.mode = mode;
if (fd)
stub->args.create.fd = fd_ref (fd);
if (params)
stub->args.create.params = dict_ref (params);
out:
return stub;
}
call_stub_t *
fop_create_cbk_stub (call_frame_t *frame,
fop_create_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
fd_t *fd,
inode_t *inode,
struct iatt *buf,
struct iatt *preparent,
struct iatt *postparent)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_CREATE);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.create_cbk.fn = fn;
stub->args.create_cbk.op_ret = op_ret;
stub->args.create_cbk.op_errno = op_errno;
if (fd)
stub->args.create_cbk.fd = fd_ref (fd);
if (inode)
stub->args.create_cbk.inode = inode_ref (inode);
if (buf)
stub->args.create_cbk.buf = *buf;
if (preparent)
stub->args.create_cbk.preparent = *preparent;
if (postparent)
stub->args.create_cbk.postparent = *postparent;
out:
return stub;
}
call_stub_t *
fop_open_stub (call_frame_t *frame,
fop_open_t fn,
loc_t *loc,
int32_t flags, fd_t *fd,
int32_t wbflags)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
GF_VALIDATE_OR_GOTO ("call-stub", loc, out);
stub = stub_new (frame, 1, GF_FOP_OPEN);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.open.fn = fn;
loc_copy (&stub->args.open.loc, loc);
stub->args.open.flags = flags;
stub->args.open.wbflags = wbflags;
if (fd)
stub->args.open.fd = fd_ref (fd);
out:
return stub;
}
call_stub_t *
fop_open_cbk_stub (call_frame_t *frame,
fop_open_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
fd_t *fd)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_OPEN);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.open_cbk.fn = fn;
stub->args.open_cbk.op_ret = op_ret;
stub->args.open_cbk.op_errno = op_errno;
if (fd)
stub->args.open_cbk.fd = fd_ref (fd);
out:
return stub;
}
call_stub_t *
fop_readv_stub (call_frame_t *frame,
fop_readv_t fn,
fd_t *fd,
size_t size,
off_t off)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 1, GF_FOP_READ);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.readv.fn = fn;
if (fd)
stub->args.readv.fd = fd_ref (fd);
stub->args.readv.size = size;
stub->args.readv.off = off;
out:
return stub;
}
call_stub_t *
fop_readv_cbk_stub (call_frame_t *frame,
fop_readv_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
struct iovec *vector,
int32_t count,
struct iatt *stbuf,
struct iobref *iobref)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_READ);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.readv_cbk.fn = fn;
stub->args.readv_cbk.op_ret = op_ret;
stub->args.readv_cbk.op_errno = op_errno;
if (op_ret >= 0) {
stub->args.readv_cbk.vector = iov_dup (vector, count);
stub->args.readv_cbk.count = count;
stub->args.readv_cbk.stbuf = *stbuf;
stub->args.readv_cbk.iobref = iobref_ref (iobref);
}
out:
return stub;
}
call_stub_t *
fop_writev_stub (call_frame_t *frame,
fop_writev_t fn,
fd_t *fd,
struct iovec *vector,
int32_t count,
off_t off,
struct iobref *iobref)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
GF_VALIDATE_OR_GOTO ("call-stub", vector, out);
stub = stub_new (frame, 1, GF_FOP_WRITE);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.writev.fn = fn;
if (fd)
stub->args.writev.fd = fd_ref (fd);
stub->args.writev.vector = iov_dup (vector, count);
stub->args.writev.count = count;
stub->args.writev.off = off;
stub->args.writev.iobref = iobref_ref (iobref);
out:
return stub;
}
call_stub_t *
fop_writev_cbk_stub (call_frame_t *frame,
fop_writev_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
struct iatt *prebuf,
struct iatt *postbuf)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_WRITE);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.writev_cbk.fn = fn;
stub->args.writev_cbk.op_ret = op_ret;
stub->args.writev_cbk.op_errno = op_errno;
if (op_ret >= 0)
stub->args.writev_cbk.postbuf = *postbuf;
if (prebuf)
stub->args.writev_cbk.prebuf = *prebuf;
out:
return stub;
}
call_stub_t *
fop_flush_stub (call_frame_t *frame,
fop_flush_t fn,
fd_t *fd)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 1, GF_FOP_FLUSH);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.flush.fn = fn;
if (fd)
stub->args.flush.fd = fd_ref (fd);
out:
return stub;
}
call_stub_t *
fop_flush_cbk_stub (call_frame_t *frame,
fop_flush_cbk_t fn,
int32_t op_ret,
int32_t op_errno)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_FLUSH);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.flush_cbk.fn = fn;
stub->args.flush_cbk.op_ret = op_ret;
stub->args.flush_cbk.op_errno = op_errno;
out:
return stub;
}
call_stub_t *
fop_fsync_stub (call_frame_t *frame,
fop_fsync_t fn,
fd_t *fd,
int32_t datasync)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 1, GF_FOP_FSYNC);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.fsync.fn = fn;
if (fd)
stub->args.fsync.fd = fd_ref (fd);
stub->args.fsync.datasync = datasync;
out:
return stub;
}
call_stub_t *
fop_fsync_cbk_stub (call_frame_t *frame,
fop_fsync_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
struct iatt *prebuf,
struct iatt *postbuf)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_FSYNC);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.fsync_cbk.fn = fn;
stub->args.fsync_cbk.op_ret = op_ret;
stub->args.fsync_cbk.op_errno = op_errno;
if (prebuf)
stub->args.fsync_cbk.prebuf = *prebuf;
if (postbuf)
stub->args.fsync_cbk.postbuf = *postbuf;
out:
return stub;
}
call_stub_t *
fop_opendir_stub (call_frame_t *frame,
fop_opendir_t fn,
loc_t *loc, fd_t *fd)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
GF_VALIDATE_OR_GOTO ("call-stub", loc, out);
stub = stub_new (frame, 1, GF_FOP_OPENDIR);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.opendir.fn = fn;
loc_copy (&stub->args.opendir.loc, loc);
if (fd)
stub->args.opendir.fd = fd_ref (fd);
out:
return stub;
}
call_stub_t *
fop_opendir_cbk_stub (call_frame_t *frame,
fop_opendir_cbk_t fn,
int32_t op_ret,
int32_t op_errno,
fd_t *fd)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_OPENDIR);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.opendir_cbk.fn = fn;
stub->args.opendir_cbk.op_ret = op_ret;
stub->args.opendir_cbk.op_errno = op_errno;
if (fd)
stub->args.opendir_cbk.fd = fd_ref (fd);
out:
return stub;
}
call_stub_t *
fop_fsyncdir_stub (call_frame_t *frame,
fop_fsyncdir_t fn,
fd_t *fd,
int32_t datasync)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 1, GF_FOP_FSYNCDIR);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.fsyncdir.fn = fn;
if (fd)
stub->args.fsyncdir.fd = fd_ref (fd);
stub->args.fsyncdir.datasync = datasync;
out:
return stub;
}
call_stub_t *
fop_fsyncdir_cbk_stub (call_frame_t *frame,
fop_fsyncdir_cbk_t fn,
int32_t op_ret,
int32_t op_errno)
{
call_stub_t *stub = NULL;
GF_VALIDATE_OR_GOTO ("call-stub", frame, out);
stub = stub_new (frame, 0, GF_FOP_FSYNCDIR);
GF_VALIDATE_OR_GOTO ("call-stub", stub, out);
stub->args.fsyncdir_cbk.fn = fn;
stub->args.fsyncdir_cbk.op_ret = op_ret;
stub->args.fsyncdir_cbk.op_errno = op_errno;
out:
return stub;
}
call_stub_t *
fop_statfs_stub (call_frame_t *frame,
fop_statfs_t fn,
loc_t *loc)
{
call_stub_t *stub = NULL;
|