summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-inode-read.c
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2015-06-21 20:29:07 +0200
committerJeff Darcy <jdarcy@redhat.com>2016-02-05 05:05:26 -0800
commitc8bbc24a8f3db253d9514210f8505e927bbbe7b0 (patch)
tree1349faf44bff0cb4a6277945864bbb0bc989beb3 /xlators/cluster/afr/src/afr-inode-read.c
parent10da9812d83425cb3f2cc8385f94b2a4537d348f (diff)
afr: add seek() FOP
seek() is like a read(), copied the same semantics. Change-Id: I100b741d9bfacb799df318bb081f2497c0664927 BUG: 1220173 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/11483 Smoke: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-inode-read.c')
-rw-r--r--xlators/cluster/afr/src/afr-inode-read.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/xlators/cluster/afr/src/afr-inode-read.c b/xlators/cluster/afr/src/afr-inode-read.c
index 7fd37aee341..caa2a97d6d8 100644
--- a/xlators/cluster/afr/src/afr-inode-read.c
+++ b/xlators/cluster/afr/src/afr-inode-read.c
@@ -1779,3 +1779,81 @@ out:
}
/* }}} */
+
+/* {{{ seek */
+
+int
+afr_seek_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, off_t offset, dict_t *xdata)
+{
+ afr_local_t *local = NULL;
+
+ local = frame->local;
+
+ if (op_ret < 0) {
+ local->op_ret = -1;
+ local->op_errno = op_errno;
+
+ afr_read_txn_continue (frame, this, (long) cookie);
+ return 0;
+ }
+
+ AFR_STACK_UNWIND (seek, frame, op_ret, op_errno, offset, xdata);
+ return 0;
+}
+
+
+int
+afr_seek_wind (call_frame_t *frame, xlator_t *this, int subvol)
+{
+ afr_local_t *local = NULL;
+ afr_private_t *priv = NULL;
+
+ local = frame->local;
+ priv = this->private;
+
+ if (subvol == -1) {
+ AFR_STACK_UNWIND (seek, frame, local->op_ret, local->op_errno,
+ 0, NULL);
+ return 0;
+ }
+
+ STACK_WIND_COOKIE (frame, afr_seek_cbk, (void *) (long) subvol,
+ priv->children[subvol],
+ priv->children[subvol]->fops->seek,
+ local->fd, local->cont.seek.offset,
+ local->cont.seek.what, local->xdata_req);
+ return 0;
+}
+
+
+int
+afr_seek (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ gf_seek_what_t what, dict_t *xdata)
+{
+ afr_local_t *local = NULL;
+ int32_t op_errno = 0;
+
+ local = AFR_FRAME_INIT (frame, op_errno);
+ if (!local)
+ goto out;
+
+ local->op = GF_FOP_SEEK;
+ local->fd = fd_ref (fd);
+ local->cont.seek.offset = offset;
+ local->cont.seek.what = what;
+ if (xdata)
+ local->xdata_req = dict_ref (xdata);
+
+ afr_fix_open (fd, this);
+
+ afr_read_txn (frame, this, fd->inode, afr_seek_wind,
+ AFR_DATA_TRANSACTION);
+
+ return 0;
+out:
+ AFR_STACK_UNWIND (seek, frame, -1, op_errno, 0, NULL);
+
+ return 0;
+}
+/* }}} */