Blob Blame History Raw
From 8e820e1170faa0fe1f4f2a2bd056a8b74431da0b Mon Sep 17 00:00:00 2001
From: Ravishankar N <ravishankar@redhat.com>
Date: Tue, 23 May 2017 10:15:41 +0530
Subject: [PATCH 472/473] protocol/server: capture offset in seek

Backport of https://review.gluster.org/#/c/15920/

Problem: http://review.gluster.org/11482 implemented seek FOP but
http://review.gluster.org/#/c/14137/ 'undid' the change where we pack
the offset returned by seek in server xlator before sending it to the
client. As a result, seek always returns zero to the client for
SEEK_HOLE/ SEEK_DATA.

Fix: 14137 removed it unintentionally, hence adding it back again.

Change-Id: Ia0be4b09ff76849d7ae366d676c43fbe6c748984
BUG: 1454558
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/106934
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 xlators/protocol/server/src/server-common.c   | 6 ++++++
 xlators/protocol/server/src/server-common.h   | 3 +++
 xlators/protocol/server/src/server-rpc-fops.c | 2 ++
 3 files changed, 11 insertions(+)

diff --git a/xlators/protocol/server/src/server-common.c b/xlators/protocol/server/src/server-common.c
index 9a023aa..2cabcf9 100644
--- a/xlators/protocol/server/src/server-common.c
+++ b/xlators/protocol/server/src/server-common.c
@@ -226,6 +226,12 @@ server_post_fallocate (gfs3_fallocate_rsp *rsp, struct iatt *statpre,
         gf_stat_from_iatt (&rsp->statpost, statpost);
 }
 
+void
+server_post_seek (gfs3_seek_rsp *rsp, off_t offset)
+{
+        rsp->offset = offset;
+}
+
 int
 server_post_readdirp (gfs3_readdirp_rsp *rsp, gf_dirent_t *entries)
 {
diff --git a/xlators/protocol/server/src/server-common.h b/xlators/protocol/server/src/server-common.h
index afd9fb8..f3b9ced 100644
--- a/xlators/protocol/server/src/server-common.h
+++ b/xlators/protocol/server/src/server-common.h
@@ -81,6 +81,9 @@ void
 server_post_fallocate (gfs3_fallocate_rsp *rsp, struct iatt *statpre,
                        struct iatt *statpost);
 
+void
+server_post_seek (gfs3_seek_rsp *rsp, off_t offset);
+
 int
 server_post_readdirp (gfs3_readdirp_rsp *rsp, gf_dirent_t *entries);
 
diff --git a/xlators/protocol/server/src/server-rpc-fops.c b/xlators/protocol/server/src/server-rpc-fops.c
index 94e756c..a9f5d86 100644
--- a/xlators/protocol/server/src/server-rpc-fops.c
+++ b/xlators/protocol/server/src/server-rpc-fops.c
@@ -2010,6 +2010,8 @@ server_seek_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
                 goto out;
         }
 
+        server_post_seek (&rsp, offset);
+
 out:
         rsp.op_ret    = op_ret;
         rsp.op_errno  = gf_errno_to_error (op_errno);
-- 
1.8.3.1