diff options
author | Amar Tumballi <amar@gluster.com> | 2011-06-23 08:07:23 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-06-23 21:31:10 -0700 |
commit | 308668c055b542724d226a3b7a835e7ea06082ed (patch) | |
tree | c4782f336e31c5f3bf8e3a8df3ee389642af9507 /libglusterfs/src | |
parent | f948a24e51e447642c35bff881057f306768a5e0 (diff) |
libglusterfs: added syncop_* functions
* implemented open,close,readv,writev,listxattr,create,unlink
* also fixed a dictionary ref issue with lookup_cbk
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 3081 (synchronous operations should be enhanced)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=3081
Diffstat (limited to 'libglusterfs/src')
-rw-r--r-- | libglusterfs/src/syncop.c | 241 | ||||
-rw-r--r-- | libglusterfs/src/syncop.h | 21 |
2 files changed, 260 insertions, 2 deletions
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c index 938fa35854d..ce6613845fa 100644 --- a/libglusterfs/src/syncop.c +++ b/libglusterfs/src/syncop.c @@ -298,7 +298,7 @@ syncop_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret == 0) { args->iatt1 = *iatt; - args->xattr = xattr; + args->xattr = dict_ref (xattr); args->iatt2 = *parent; } @@ -435,7 +435,6 @@ syncop_opendir (xlator_t *subvol, } - int syncop_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno) @@ -494,6 +493,39 @@ syncop_setxattr (xlator_t *subvol, loc_t *loc, dict_t *dict, int32_t flags) } int +syncop_listxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, dict_t *dict) +{ + struct syncargs *args = NULL; + + args = cookie; + + args->op_ret = op_ret; + args->op_errno = op_errno; + if (op_ret >= 0) + args->xattr = dict_ref (dict); + + __wake (args); + + return 0; +} + +int +syncop_listxattr (xlator_t *subvol, loc_t *loc, dict_t **dict) +{ + struct syncargs args = {0, }; + + SYNCOP (subvol, (&args), syncop_listxattr_cbk, subvol->fops->getxattr, + loc, NULL); + + if (dict) + *dict = args.xattr; + + errno = args.op_errno; + return args.op_ret; +} + +int syncop_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct statvfs *buf) @@ -572,3 +604,208 @@ syncop_setattr (xlator_t *subvol, loc_t *loc, struct iatt *iatt, int valid, errno = args.op_errno; return args.op_ret; } + + +int +syncop_fsetattr (xlator_t *subvol, fd_t *fd, struct iatt *iatt, int valid, + struct iatt *preop, struct iatt *postop) +{ + struct syncargs args = {0, }; + + SYNCOP (subvol, (&args), syncop_setattr_cbk, subvol->fops->fsetattr, + fd, iatt, valid); + + if (preop) + *preop = args.iatt1; + if (postop) + *postop = args.iatt2; + + errno = args.op_errno; + return args.op_ret; +} + + +int32_t +syncop_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, fd_t *fd) +{ + struct syncargs *args = NULL; + + args = cookie; + + args->op_ret = op_ret; + args->op_errno = op_errno; + + if (op_ret != -1) + fd_ref (fd); + + __wake (args); + + return 0; +} + +int +syncop_open (xlator_t *subvol, loc_t *loc, int32_t flags, fd_t *fd) +{ + struct syncargs args = {0, }; + + SYNCOP (subvol, (&args), syncop_open_cbk, subvol->fops->open, + loc, flags, fd, 0); + + errno = args.op_errno; + return args.op_ret; + +} + + +int32_t +syncop_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iovec *vector, + int32_t count, struct iatt *stbuf, struct iobref *iobref) +{ + struct syncargs *args = NULL; + + args = cookie; + + INIT_LIST_HEAD (&args->entries.list); + + args->op_ret = op_ret; + args->op_errno = op_errno; + + if (args->op_ret >= 0) { + args->iobref = iobref; + args->vector = vector; + args->count = count; + } + + __wake (args); + + return 0; + +} + +int +syncop_readv (xlator_t *subvol, fd_t *fd, size_t size, off_t off, + struct iovec *vector, int *count, struct iobref *iobref) +{ + struct syncargs args = {0, }; + + SYNCOP (subvol, (&args), syncop_readv_cbk, subvol->fops->readv, + fd, size, off); + + if (vector) + vector = iov_dup (args.vector, args.count); + + if (count) + *count = args.count; + + /* Do we need a 'ref' here? */ + if (iobref) + iobref = args.iobref; + + errno = args.op_errno; + return args.op_ret; + +} + +int +syncop_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, struct iatt *prebuf, + struct iatt *postbuf) +{ + struct syncargs *args = NULL; + + args = cookie; + + args->op_ret = op_ret; + args->op_errno = op_errno; + + __wake (args); + + return 0; +} + +int +syncop_writev (xlator_t *subvol, fd_t *fd, struct iovec *vector, + int32_t count, off_t offset, struct iobref *iobref) +{ + struct syncargs args = {0, }; + + SYNCOP (subvol, (&args), syncop_writev_cbk, subvol->fops->writev, + fd, vector, count, offset, iobref); + + errno = args.op_errno; + return args.op_ret; +} + + +int +syncop_close (fd_t *fd) +{ + if (fd) + fd_unref (fd); + return 0; +} + +int32_t +syncop_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, fd_t *fd, inode_t *inode, + struct iatt *buf, struct iatt *preparent, + struct iatt *postparent) +{ + struct syncargs *args = NULL; + + args = cookie; + + args->op_ret = op_ret; + args->op_errno = op_errno; + + if (op_ret != -1) + fd_ref (fd); + + __wake (args); + + return 0; +} + +int +syncop_create (xlator_t *subvol, loc_t *loc, int32_t flags, mode_t mode, + fd_t *fd, dict_t *dict) +{ + struct syncargs args = {0, }; + + SYNCOP (subvol, (&args), syncop_create_cbk, subvol->fops->create, + loc, flags, mode, fd, dict); + + errno = args.op_errno; + return args.op_ret; + +} + +int +syncop_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, struct iatt *preparent, + struct iatt *postparent) +{ + struct syncargs *args = NULL; + + args = cookie; + + args->op_ret = op_ret; + args->op_errno = op_errno; + + __wake (args); + + return 0; +} + +int +syncop_unlink (xlator_t *subvol, loc_t *loc) +{ + struct syncargs args = {0, }; + + SYNCOP (subvol, (&args), syncop_unlink_cbk, subvol->fops->unlink, loc); + + errno = args.op_errno; + return args.op_ret; +} diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h index ac913c870e1..34844899c2d 100644 --- a/libglusterfs/src/syncop.h +++ b/libglusterfs/src/syncop.h @@ -79,6 +79,9 @@ struct syncargs { dict_t *xattr; gf_dirent_t entries; struct statvfs statvfs_buf; + struct iovec *vector; + int count; + struct iobref *iobref; /* do not touch */ pthread_mutex_t mutex; @@ -170,9 +173,27 @@ int syncop_setattr (xlator_t *subvol, loc_t *loc, struct iatt *iatt, int valid, /* out */ struct iatt *preop, struct iatt *postop); +int syncop_fsetattr (xlator_t *subvol, fd_t *fd, struct iatt *iatt, int valid, + /* out */ + struct iatt *preop, struct iatt *postop); + int syncop_statfs (xlator_t *subvol, loc_t *loc, struct statvfs *buf); int syncop_setxattr (xlator_t *subvol, loc_t *loc, dict_t *dict, int32_t flags); +int syncop_listxattr (xlator_t *subvol, loc_t *loc, dict_t **dict); int syncop_removexattr (xlator_t *subvol, loc_t *loc, const char *name); +int syncop_create (xlator_t *subvol, loc_t *loc, int32_t flags, mode_t mode, + fd_t *fd, dict_t *dict); +int syncop_open (xlator_t *subvol, loc_t *loc, int32_t flags, fd_t *fd); +int syncop_close (fd_t *fd); + +int syncop_writev (xlator_t *subvol, fd_t *fd, struct iovec *vector, + int32_t count, off_t offset, struct iobref *iobref); +int syncop_readv (xlator_t *subvol, fd_t *fd, size_t size, off_t off, + /* out */ + struct iovec *vector, int *count, struct iobref *iobref); +int syncop_unlink (xlator_t *subvol, loc_t *loc); + + #endif /* _SYNCOP_H */ |