e7a346
From 5b32d4317968581f217c82e893822852d63eeae8 Mon Sep 17 00:00:00 2001
e7a346
From: Pranith Kumar K <pkarampu@redhat.com>
e7a346
Date: Mon, 19 Mar 2018 15:26:40 +0530
e7a346
Subject: [PATCH 196/201] cluster/afr: Switch to active-fd-count for open-fd
e7a346
 checks
e7a346
e7a346
 >BUG: 1557932
e7a346
e7a346
Upstream-patch: https://review.gluster.org/19741
e7a346
BUG: 1491785
e7a346
Change-Id: I3783e41b3812267bc10c0d05d062a31396ce135b
e7a346
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
e7a346
Reviewed-on: https://code.engineering.redhat.com/gerrit/133660
e7a346
Tested-by: RHGS Build Bot <nigelb@redhat.com>
e7a346
---
e7a346
 tests/basic/afr/afr-no-fsync.t            | 20 ++++++++++++++++++++
e7a346
 xlators/cluster/afr/src/afr-inode-write.c | 16 ++++++++--------
e7a346
 2 files changed, 28 insertions(+), 8 deletions(-)
e7a346
 create mode 100644 tests/basic/afr/afr-no-fsync.t
e7a346
e7a346
diff --git a/tests/basic/afr/afr-no-fsync.t b/tests/basic/afr/afr-no-fsync.t
e7a346
new file mode 100644
e7a346
index 0000000..0966d9b
e7a346
--- /dev/null
e7a346
+++ b/tests/basic/afr/afr-no-fsync.t
e7a346
@@ -0,0 +1,20 @@
e7a346
+#!/bin/bash
e7a346
+#Tests that sequential write workload doesn't lead to FSYNCs
e7a346
+
e7a346
+. $(dirname $0)/../../include.rc
e7a346
+. $(dirname $0)/../../volume.rc
e7a346
+
e7a346
+cleanup;
e7a346
+
e7a346
+TEST glusterd
e7a346
+TEST pidof glusterd
e7a346
+TEST $CLI volume create $V0 replica 3 $H0:$B0/brick{0,1,3}
e7a346
+TEST $CLI volume set $V0 features.shard on
e7a346
+TEST $CLI volume set $V0 performance.flush-behind off
e7a346
+TEST $CLI volume start $V0
e7a346
+TEST $CLI volume profile $V0 start
e7a346
+TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0;
e7a346
+TEST dd if=/dev/zero of=$M0/a bs=1M count=500
e7a346
+TEST ! "$CLI volume profile $V0 info incremental | grep FSYNC"
e7a346
+
e7a346
+cleanup;
e7a346
diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c
e7a346
index b52b6ca..9e6ba35 100644
e7a346
--- a/xlators/cluster/afr/src/afr-inode-write.c
e7a346
+++ b/xlators/cluster/afr/src/afr-inode-write.c
e7a346
@@ -314,10 +314,10 @@ afr_inode_write_fill (call_frame_t *frame, xlator_t *this, int child_index,
e7a346
 		if (ret || !write_is_append)
e7a346
 			local->append_write = _gf_false;
e7a346
 
e7a346
-		ret = dict_get_uint32 (xdata, GLUSTERFS_OPEN_FD_COUNT,
e7a346
-				       &open_fd_count);
e7a346
-		if (ret == -1)
e7a346
-			goto unlock;
e7a346
+                ret = dict_get_uint32 (xdata, GLUSTERFS_ACTIVE_FD_COUNT,
e7a346
+                                       &open_fd_count);
e7a346
+                if (ret < 0)
e7a346
+                        goto unlock;
e7a346
 		if (open_fd_count > local->open_fd_count) {
e7a346
                         local->open_fd_count = open_fd_count;
e7a346
                         local->update_open_fd_count = _gf_true;
e7a346
@@ -529,10 +529,10 @@ afr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
e7a346
         if (ret)
e7a346
                 goto out;
e7a346
 
e7a346
-	if (dict_set_uint32 (local->xdata_req, GLUSTERFS_OPEN_FD_COUNT, 4)) {
e7a346
-		op_errno = ENOMEM;
e7a346
-		goto out;
e7a346
-	}
e7a346
+        if (dict_set_uint32 (local->xdata_req, GLUSTERFS_ACTIVE_FD_COUNT, 4)) {
e7a346
+                op_errno = ENOMEM;
e7a346
+                goto out;
e7a346
+        }
e7a346
 
e7a346
 	if (dict_set_uint32 (local->xdata_req, GLUSTERFS_WRITE_IS_APPEND, 4)) {
e7a346
 		op_errno = ENOMEM;
e7a346
-- 
e7a346
1.8.3.1
e7a346