summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-06-27 07:59:52 +0000
committerAnand Avati <avati@gluster.com>2011-07-11 23:18:48 -0700
commitbf4a7bed6420377aac26693f450a450bc54d005c (patch)
tree717a4b28cb06381a3c9cfd6ea06e8fc1750d7964 /libglusterfs
parenta879613637f54a7a2016549b308b359b7577b5ad (diff)
libglusterfs/syncop: add more functions
do proper 'ref's and implement 'write()' and 'ftruncate()' 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')
-rw-r--r--libglusterfs/src/syncop.c59
-rw-r--r--libglusterfs/src/syncop.h7
2 files changed, 59 insertions, 7 deletions
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index ce6613845..93ce67176 100644
--- a/libglusterfs/src/syncop.c
+++ b/libglusterfs/src/syncop.c
@@ -298,8 +298,9 @@ syncop_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (op_ret == 0) {
args->iatt1 = *iatt;
- args->xattr = dict_ref (xattr);
args->iatt2 = *parent;
+ if (xattr)
+ args->xattr = dict_ref (xattr);
}
__wake (args);
@@ -673,8 +674,9 @@ syncop_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
args->op_errno = op_errno;
if (args->op_ret >= 0) {
- args->iobref = iobref;
- args->vector = vector;
+ if (iobref)
+ args->iobref = iobref_ref (iobref);
+ args->vector = iov_dup (vector, count);
args->count = count;
}
@@ -686,7 +688,7 @@ syncop_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int
syncop_readv (xlator_t *subvol, fd_t *fd, size_t size, off_t off,
- struct iovec *vector, int *count, struct iobref *iobref)
+ struct iovec **vector, int *count, struct iobref **iobref)
{
struct syncargs args = {0, };
@@ -694,14 +696,14 @@ syncop_readv (xlator_t *subvol, fd_t *fd, size_t size, off_t off,
fd, size, off);
if (vector)
- vector = iov_dup (args.vector, args.count);
+ *vector = args.vector;
if (count)
*count = args.count;
/* Do we need a 'ref' here? */
if (iobref)
- iobref = args.iobref;
+ *iobref = args.iobref;
errno = args.op_errno;
return args.op_ret;
@@ -738,6 +740,22 @@ syncop_writev (xlator_t *subvol, fd_t *fd, struct iovec *vector,
return args.op_ret;
}
+int syncop_write (xlator_t *subvol, fd_t *fd, const char *buf, int size,
+ off_t offset, struct iobref *iobref)
+{
+ struct syncargs args = {0,};
+ struct iovec vec = {0,};
+
+ vec.iov_len = size;
+ vec.iov_base = (void *)buf;
+
+ SYNCOP (subvol, (&args), syncop_writev_cbk, subvol->fops->writev,
+ fd, &vec, 1, offset, iobref);
+
+ errno = args.op_errno;
+ return args.op_ret;
+}
+
int
syncop_close (fd_t *fd)
@@ -809,3 +827,32 @@ syncop_unlink (xlator_t *subvol, loc_t *loc)
errno = args.op_errno;
return args.op_ret;
}
+
+int
+syncop_ftruncate_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_ftruncate (xlator_t *subvol, fd_t *fd, off_t offset)
+{
+ struct syncargs args = {0, };
+
+ SYNCOP (subvol, (&args), syncop_ftruncate_cbk, subvol->fops->ftruncate,
+ fd, offset);
+
+ errno = args.op_errno;
+ return args.op_ret;
+}
diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h
index 34844899c..fb8fd9e11 100644
--- a/libglusterfs/src/syncop.h
+++ b/libglusterfs/src/syncop.h
@@ -188,11 +188,16 @@ int syncop_create (xlator_t *subvol, loc_t *loc, int32_t flags, mode_t mode,
int syncop_open (xlator_t *subvol, loc_t *loc, int32_t flags, fd_t *fd);
int syncop_close (fd_t *fd);
+int syncop_write (xlator_t *subvol, fd_t *fd, const char *buf, int size,
+ off_t offset, struct iobref *iobref);
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);
+ struct iovec **vector, int *count, struct iobref **iobref);
+
+int syncop_ftruncate (xlator_t *subvol, fd_t *fd, off_t offset);
+
int syncop_unlink (xlator_t *subvol, loc_t *loc);