f338ef
From 0d54bb417e982a100ceefb5eab2a61a17e840f39 Mon Sep 17 00:00:00 2001
f338ef
From: Pranith Kumar K <pkarampu@redhat.com>
f338ef
Date: Thu, 5 Sep 2019 16:12:39 +0530
f338ef
Subject: [PATCH 289/297] cluster/ec: quorum-count implementation
f338ef
f338ef
Upstream-patch: https://review.gluster.org/c/glusterfs/+/23366
f338ef
upstream-issue: #721
f338ef
fixes: bz#1748688
f338ef
Change-Id: I5333540e3c635ccf441cf1f4696e4c8986e38ea8
f338ef
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
f338ef
Reviewed-on: https://code.engineering.redhat.com/gerrit/180674
f338ef
Tested-by: RHGS Build Bot <nigelb@redhat.com>
f338ef
Reviewed-by: Ashish Pandey <aspandey@redhat.com>
f338ef
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
f338ef
---
f338ef
 libglusterfs/src/glusterfs/globals.h             |   4 +-
f338ef
 tests/basic/ec/ec-quorum-count-partial-failure.t |  50 +++++++
f338ef
 tests/basic/ec/ec-quorum-count.t                 | 165 +++++++++++++++++++++++
f338ef
 tests/ec.rc                                      |   9 ++
f338ef
 xlators/cluster/ec/src/ec-common.c               |  13 ++
f338ef
 xlators/cluster/ec/src/ec-common.h               |  24 ++++
f338ef
 xlators/cluster/ec/src/ec-dir-write.c            |  57 ++++----
f338ef
 xlators/cluster/ec/src/ec-inode-write.c          |  61 ++++-----
f338ef
 xlators/cluster/ec/src/ec-types.h                |   1 +
f338ef
 xlators/cluster/ec/src/ec.c                      |  13 ++
f338ef
 xlators/mgmt/glusterd/src/glusterd-volume-set.c  |  46 +++++++
f338ef
 11 files changed, 383 insertions(+), 60 deletions(-)
f338ef
 create mode 100755 tests/basic/ec/ec-quorum-count-partial-failure.t
f338ef
 create mode 100644 tests/basic/ec/ec-quorum-count.t
f338ef
f338ef
diff --git a/libglusterfs/src/glusterfs/globals.h b/libglusterfs/src/glusterfs/globals.h
f338ef
index 55476f6..bdc8b3d 100644
f338ef
--- a/libglusterfs/src/glusterfs/globals.h
f338ef
+++ b/libglusterfs/src/glusterfs/globals.h
f338ef
@@ -50,7 +50,7 @@
f338ef
     1 /* MIN is the fresh start op-version, mostly                             \
f338ef
          should not change */
f338ef
 #define GD_OP_VERSION_MAX                                                      \
f338ef
-    GD_OP_VERSION_7_0 /* MAX VERSION is the maximum                            \
f338ef
+    GD_OP_VERSION_8_0 /* MAX VERSION is the maximum                            \
f338ef
                          count in VME table, should                            \
f338ef
                          keep changing with                                    \
f338ef
                          introduction of newer                                 \
f338ef
@@ -136,6 +136,8 @@
f338ef
 
f338ef
 #define GD_OP_VERSION_7_0 70000 /* Op-version for GlusterFS 7.0 */
f338ef
 
f338ef
+#define GD_OP_VERSION_8_0 80000 /* Op-version for GlusterFS 8.0 */
f338ef
+
f338ef
 #include "glusterfs/xlator.h"
f338ef
 #include "glusterfs/options.h"
f338ef
 
f338ef
diff --git a/tests/basic/ec/ec-quorum-count-partial-failure.t b/tests/basic/ec/ec-quorum-count-partial-failure.t
f338ef
new file mode 100755
f338ef
index 0000000..79f5825
f338ef
--- /dev/null
f338ef
+++ b/tests/basic/ec/ec-quorum-count-partial-failure.t
f338ef
@@ -0,0 +1,50 @@
f338ef
+#!/bin/bash
f338ef
+
f338ef
+. $(dirname $0)/../../include.rc
f338ef
+. $(dirname $0)/../../volume.rc
f338ef
+
f338ef
+#This test checks that partial failure of fop results in main fop failure only
f338ef
+cleanup;
f338ef
+
f338ef
+TEST glusterd
f338ef
+TEST pidof glusterd
f338ef
+TEST $CLI volume create $V0 disperse 6 redundancy 2 $H0:$B0/${V0}{0..5}
f338ef
+TEST $CLI volume create $V1 $H0:$B0/${V1}{0..5}
f338ef
+TEST $CLI volume set $V0 performance.flush-behind off
f338ef
+TEST $CLI volume start $V0
f338ef
+TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id=/$V0 $M0
f338ef
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "6" ec_child_up_count $V0 0
f338ef
+
f338ef
+TEST dd if=/dev/urandom of=$M0/a bs=12347 count=1
f338ef
+TEST dd if=/dev/urandom of=$M0/b bs=12347 count=1
f338ef
+TEST cp $M0/b $M0/c
f338ef
+TEST fallocate -p -l 101 $M0/c
f338ef
+TEST $CLI volume stop $V0
f338ef
+TEST $CLI volume set $V0 debug.delay-gen posix;
f338ef
+TEST $CLI volume set $V0 delay-gen.delay-duration 10000000;
f338ef
+TEST $CLI volume set $V0 delay-gen.enable WRITE;
f338ef
+TEST $CLI volume set $V0 delay-gen.delay-percentage 100
f338ef
+TEST $CLI volume set $V0 disperse.quorum-count 6
f338ef
+TEST $CLI volume start $V0
f338ef
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "6" ec_child_up_count $V0 0
f338ef
+cksum=$(dd if=$M0/a bs=12345 count=1 | md5sum | awk '{print $1}')
f338ef
+truncate -s 12345 $M0/a & #While write is waiting for 5 seconds, introduce failure
f338ef
+fallocate -p -l 101 $M0/b &
f338ef
+sleep 1
f338ef
+TEST kill_brick $V0 $H0 $B0/${V0}0
f338ef
+TEST wait
f338ef
+TEST $CLI volume start $V0 force
f338ef
+EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count ${V0}
f338ef
+EXPECT "12345" stat --format=%s $M0/a
f338ef
+TEST kill_brick $V0 $H0 $B0/${V0}1
f338ef
+TEST kill_brick $V0 $H0 $B0/${V0}2
f338ef
+EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0;
f338ef
+TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0
f338ef
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "4" ec_child_up_count $V0 0
f338ef
+cksum_after_heal=$(dd if=$M0/a | md5sum | awk '{print $1}')
f338ef
+TEST [[ $cksum == $cksum_after_heal ]]
f338ef
+cksum=$(dd if=$M0/c | md5sum | awk '{print $1}')
f338ef
+cksum_after_heal=$(dd if=$M0/b | md5sum | awk '{print $1}')
f338ef
+TEST [[ $cksum == $cksum_after_heal ]]
f338ef
+
f338ef
+cleanup;
f338ef
diff --git a/tests/basic/ec/ec-quorum-count.t b/tests/basic/ec/ec-quorum-count.t
f338ef
new file mode 100644
f338ef
index 0000000..56b5329
f338ef
--- /dev/null
f338ef
+++ b/tests/basic/ec/ec-quorum-count.t
f338ef
@@ -0,0 +1,165 @@
f338ef
+ #!/bin/bash
f338ef
+
f338ef
+. $(dirname $0)/../../include.rc
f338ef
+. $(dirname $0)/../../volume.rc
f338ef
+. $(dirname $0)/../../ec.rc
f338ef
+
f338ef
+cleanup
f338ef
+TEST glusterd
f338ef
+TEST pidof glusterd
f338ef
+TEST $CLI volume create $V0 disperse 6 redundancy 2 $H0:$B0/${V0}{0..5}
f338ef
+TEST $CLI volume create $V1 $H0:$B0/${V1}{0..5}
f338ef
+TEST $CLI volume set $V0 disperse.eager-lock-timeout 5
f338ef
+TEST $CLI volume set $V0 performance.flush-behind off
f338ef
+
f338ef
+#Should fail on non-disperse volume
f338ef
+TEST ! $CLI volume set $V1 disperse.quorum-count 5
f338ef
+
f338ef
+#Should succeed on a valid range
f338ef
+TEST ! $CLI volume set $V0 disperse.quorum-count 0
f338ef
+TEST ! $CLI volume set $V0 disperse.quorum-count -0
f338ef
+TEST ! $CLI volume set $V0 disperse.quorum-count abc
f338ef
+TEST ! $CLI volume set $V0 disperse.quorum-count 10abc
f338ef
+TEST ! $CLI volume set $V0 disperse.quorum-count 1
f338ef
+TEST ! $CLI volume set $V0 disperse.quorum-count 2
f338ef
+TEST ! $CLI volume set $V0 disperse.quorum-count 3
f338ef
+TEST $CLI volume set $V0 disperse.quorum-count 4
f338ef
+TEST $CLI volume start $V0
f338ef
+TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0
f338ef
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "6" ec_child_up_count $V0 0
f338ef
+
f338ef
+#Test that the option is reflected in the mount
f338ef
+EXPECT_WITHIN $CONFIG_UPDATE_TIMEOUT "^4$" ec_option_value $V0 $M0 0 quorum-count
f338ef
+TEST $CLI volume reset $V0 disperse.quorum-count
f338ef
+EXPECT_WITHIN $CONFIG_UPDATE_TIMEOUT "^0$" ec_option_value $V0 $M0 0 quorum-count
f338ef
+TEST $CLI volume set $V0 disperse.quorum-count 6
f338ef
+EXPECT_WITHIN $CONFIG_UPDATE_TIMEOUT "^6$" ec_option_value $V0 $M0 0 quorum-count
f338ef
+
f338ef
+TEST touch $M0/a
f338ef
+TEST touch $M0/data
f338ef
+TEST setfattr -n trusted.def -v def $M0/a
f338ef
+TEST touch $M0/src
f338ef
+TEST touch $M0/del-me
f338ef
+TEST mkdir $M0/dir1
f338ef
+TEST dd if=/dev/zero of=$M0/read-file bs=1M count=1 oflag=direct
f338ef
+TEST dd if=/dev/zero of=$M0/del-file bs=1M count=1 oflag=direct
f338ef
+TEST gf_rm_file_and_gfid_link $B0/${V0}0 del-file
f338ef
+#modify operations should fail as the file is not in quorum
f338ef
+TEST ! dd if=/dev/zero of=$M0/del-file bs=1M count=1 oflag=direct
f338ef
+TEST kill_brick $V0 $H0 $B0/${V0}0
f338ef
+#Read should succeed even when quorum-count is not met
f338ef
+TEST dd if=$M0/read-file of=/dev/null iflag=direct
f338ef
+TEST ! touch $M0/a2
f338ef
+TEST ! mkdir $M0/dir2
f338ef
+TEST ! mknod  $M0/b2 b 4 5
f338ef
+TEST ! ln -s $M0/a $M0/symlink
f338ef
+TEST ! ln $M0/a $M0/link
f338ef
+TEST ! mv $M0/src $M0/dst
f338ef
+TEST ! rm -f $M0/del-me
f338ef
+TEST ! rmdir $M0/dir1
f338ef
+TEST ! dd if=/dev/zero of=$M0/a bs=1M count=1 conv=notrunc
f338ef
+TEST ! dd if=/dev/zero of=$M0/data bs=1M count=1 conv=notrunc
f338ef
+TEST ! truncate -s 0 $M0/a
f338ef
+TEST ! setfattr -n trusted.abc -v abc $M0/a
f338ef
+TEST ! setfattr -x trusted.def $M0/a
f338ef
+TEST ! chmod +x $M0/a
f338ef
+TEST ! fallocate -l 2m -n $M0/a
f338ef
+TEST ! fallocate -p -l 512k $M0/a
f338ef
+TEST $CLI volume start $V0 force
f338ef
+EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count ${V0}
f338ef
+
f338ef
+# reset the option and check whether the default redundancy count is
f338ef
+# accepted or not.
f338ef
+TEST $CLI volume reset $V0 disperse.quorum-count
f338ef
+EXPECT_WITHIN $CONFIG_UPDATE_TIMEOUT "^0$" ec_option_value $V0 $M0 0 quorum-count
f338ef
+TEST touch $M0/a1
f338ef
+TEST touch $M0/data1
f338ef
+TEST setfattr -n trusted.def -v def $M0/a1
f338ef
+TEST touch $M0/src1
f338ef
+TEST touch $M0/del-me1
f338ef
+TEST mkdir $M0/dir11
f338ef
+TEST kill_brick $V0 $H0 $B0/${V0}0
f338ef
+TEST kill_brick $V0 $H0 $B0/${V0}1
f338ef
+TEST touch $M0/a21
f338ef
+TEST mkdir $M0/dir21
f338ef
+TEST mknod  $M0/b21 b 4 5
f338ef
+TEST ln -s $M0/a1 $M0/symlink1
f338ef
+TEST ln $M0/a1 $M0/link1
f338ef
+TEST mv $M0/src1 $M0/dst1
f338ef
+TEST rm -f $M0/del-me1
f338ef
+TEST rmdir $M0/dir11
f338ef
+TEST dd if=/dev/zero of=$M0/a1 bs=1M count=1 conv=notrunc
f338ef
+TEST dd if=/dev/zero of=$M0/data1 bs=1M count=1 conv=notrunc
f338ef
+TEST truncate -s 0 $M0/a1
f338ef
+TEST setfattr -n trusted.abc -v abc $M0/a1
f338ef
+TEST setfattr -x trusted.def $M0/a1
f338ef
+TEST chmod +x $M0/a1
f338ef
+TEST fallocate -l 2m -n $M0/a1
f338ef
+TEST fallocate -p -l 512k $M0/a1
f338ef
+TEST $CLI volume start $V0 force
f338ef
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "6" ec_child_up_count $V0 0
f338ef
+
f338ef
+TEST touch $M0/a2
f338ef
+TEST touch $M0/data2
f338ef
+TEST setfattr -n trusted.def -v def $M0/a1
f338ef
+TEST touch $M0/src2
f338ef
+TEST touch $M0/del-me2
f338ef
+TEST mkdir $M0/dir12
f338ef
+TEST kill_brick $V0 $H0 $B0/${V0}0
f338ef
+TEST kill_brick $V0 $H0 $B0/${V0}1
f338ef
+TEST kill_brick $V0 $H0 $B0/${V0}2
f338ef
+TEST ! touch $M0/a22
f338ef
+TEST ! mkdir $M0/dir22
f338ef
+TEST ! mknod  $M0/b22 b 4 5
f338ef
+TEST ! ln -s $M0/a2 $M0/symlink2
f338ef
+TEST ! ln $M0/a2 $M0/link2
f338ef
+TEST ! mv $M0/src2 $M0/dst2
f338ef
+TEST ! rm -f $M0/del-me2
f338ef
+TEST ! rmdir $M0/dir12
f338ef
+TEST ! dd if=/dev/zero of=$M0/a2 bs=1M count=1 conv=notrunc
f338ef
+TEST ! dd if=/dev/zero of=$M0/data2 bs=1M count=1 conv=notrunc
f338ef
+TEST ! truncate -s 0 $M0/a2
f338ef
+TEST ! setfattr -n trusted.abc -v abc $M0/a2
f338ef
+TEST ! setfattr -x trusted.def $M0/a2
f338ef
+TEST ! chmod +x $M0/a2
f338ef
+TEST ! fallocate -l 2m -n $M0/a2
f338ef
+TEST ! fallocate -p -l 512k $M0/a2
f338ef
+TEST $CLI volume start $V0 force
f338ef
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "6" ec_child_up_count $V0 0
f338ef
+EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count ${V0}
f338ef
+
f338ef
+# Set quorum-count to 5 and kill 1 brick and the fops should pass
f338ef
+TEST $CLI volume set $V0 disperse.quorum-count 5
f338ef
+EXPECT_WITHIN $CONFIG_UPDATE_TIMEOUT "^5$" ec_option_value $V0 $M0 0 quorum-count
f338ef
+TEST touch $M0/a3
f338ef
+TEST touch $M0/data3
f338ef
+TEST setfattr -n trusted.def -v def $M0/a3
f338ef
+TEST touch $M0/src3
f338ef
+TEST touch $M0/del-me3
f338ef
+TEST mkdir $M0/dir13
f338ef
+TEST kill_brick $V0 $H0 $B0/${V0}0
f338ef
+TEST touch $M0/a31
f338ef
+TEST mkdir $M0/dir31
f338ef
+TEST mknod  $M0/b31 b 4 5
f338ef
+TEST ln -s $M0/a3 $M0/symlink3
f338ef
+TEST ln $M0/a3 $M0/link3
f338ef
+TEST mv $M0/src3 $M0/dst3
f338ef
+TEST rm -f $M0/del-me3
f338ef
+TEST rmdir $M0/dir13
f338ef
+TEST dd if=/dev/zero of=$M0/a3 bs=1M count=1 conv=notrunc
f338ef
+TEST dd if=/dev/zero of=$M0/data3 bs=1M count=1 conv=notrunc
f338ef
+TEST truncate -s 0 $M0/a3
f338ef
+TEST setfattr -n trusted.abc -v abc $M0/a3
f338ef
+TEST setfattr -x trusted.def $M0/a3
f338ef
+TEST chmod +x $M0/a3
f338ef
+TEST fallocate -l 2m -n $M0/a3
f338ef
+TEST fallocate -p -l 512k $M0/a3
f338ef
+TEST dd if=/dev/urandom of=$M0/heal-file bs=1M count=1 oflag=direct
f338ef
+cksum_before_heal="$(md5sum $M0/heal-file | awk '{print $1}')"
f338ef
+TEST $CLI volume start $V0 force
f338ef
+EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count ${V0}
f338ef
+TEST kill_brick $V0 $H0 $B0/${V0}4
f338ef
+TEST kill_brick $V0 $H0 $B0/${V0}5
f338ef
+cksum_after_heal=$(dd if=$M0/heal-file iflag=direct | md5sum | awk '{print $1}')
f338ef
+TEST [[ $cksum_before_heal == $cksum_after_heal ]]
f338ef
+cleanup;
f338ef
diff --git a/tests/ec.rc b/tests/ec.rc
f338ef
index 04405ec..f18752f 100644
f338ef
--- a/tests/ec.rc
f338ef
+++ b/tests/ec.rc
f338ef
@@ -7,3 +7,12 @@ function ec_up_status()
f338ef
         local ec_id=$3
f338ef
         grep -E "^up =" $m/.meta/graphs/active/${v}-disperse-${ec_id}/private | cut -f2 -d'='
f338ef
 }
f338ef
+
f338ef
+function ec_option_value()
f338ef
+{
f338ef
+    local v=$1
f338ef
+    local m=$2
f338ef
+    local ec_id=$3
f338ef
+    local opt=$4
f338ef
+    grep -E "^$opt =" $m/.meta/graphs/active/${v}-disperse-${ec_id}/private | cut -f2 -d'='| awk '{print $1}'
f338ef
+}
f338ef
diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c
f338ef
index 92d4e5d..2e59180 100644
f338ef
--- a/xlators/cluster/ec/src/ec-common.c
f338ef
+++ b/xlators/cluster/ec/src/ec-common.c
f338ef
@@ -707,6 +707,19 @@ ec_child_select(ec_fop_data_t *fop)
f338ef
         return 0;
f338ef
     }
f338ef
 
f338ef
+    if (!fop->parent && fop->lock_count &&
f338ef
+        (fop->locks[0].update[EC_DATA_TXN] ||
f338ef
+         fop->locks[0].update[EC_METADATA_TXN])) {
f338ef
+        if (ec->quorum_count && (num < ec->quorum_count)) {
f338ef
+            gf_msg(ec->xl->name, GF_LOG_ERROR, 0, EC_MSG_CHILDS_INSUFFICIENT,
f338ef
+                   "Insufficient available children "
f338ef
+                   "for this request (have %d, need "
f338ef
+                   "%d). %s",
f338ef
+                   num, ec->quorum_count, ec_msg_str(fop));
f338ef
+            return 0;
f338ef
+        }
f338ef
+    }
f338ef
+
f338ef
     return 1;
f338ef
 }
f338ef
 
f338ef
diff --git a/xlators/cluster/ec/src/ec-common.h b/xlators/cluster/ec/src/ec-common.h
f338ef
index 3c69471..eab86ee 100644
f338ef
--- a/xlators/cluster/ec/src/ec-common.h
f338ef
+++ b/xlators/cluster/ec/src/ec-common.h
f338ef
@@ -26,6 +26,30 @@ typedef enum { EC_DATA_TXN, EC_METADATA_TXN } ec_txn_t;
f338ef
 
f338ef
 #define EC_FLAG_LOCK_SHARED 0x0001
f338ef
 
f338ef
+#define QUORUM_CBK(fn, fop, frame, cookie, this, op_ret, op_errno, params...)  \
f338ef
+    do {                                                                       \
f338ef
+        ec_t *__ec = fop->xl->private;                                         \
f338ef
+        int32_t __op_ret = 0;                                                  \
f338ef
+        int32_t __op_errno = 0;                                                \
f338ef
+        int32_t __success_count = gf_bits_count(fop->good);                    \
f338ef
+                                                                               \
f338ef
+        __op_ret = op_ret;                                                     \
f338ef
+        __op_errno = op_errno;                                                 \
f338ef
+        if (!fop->parent && frame &&                                           \
f338ef
+            (GF_CLIENT_PID_SELF_HEALD != frame->root->pid) &&                  \
f338ef
+            __ec->quorum_count && (__success_count < __ec->quorum_count) &&    \
f338ef
+            op_ret >= 0) {                                                     \
f338ef
+            __op_ret = -1;                                                     \
f338ef
+            __op_errno = EIO;                                                  \
f338ef
+            gf_msg(__ec->xl->name, GF_LOG_ERROR, 0,                            \
f338ef
+                   EC_MSG_CHILDS_INSUFFICIENT,                                 \
f338ef
+                   "Insufficient available children for this request "         \
f338ef
+                   "(have %d, need %d). %s",                                   \
f338ef
+                   __success_count, __ec->quorum_count, ec_msg_str(fop));      \
f338ef
+        }                                                                      \
f338ef
+        fn(frame, cookie, this, __op_ret, __op_errno, params);                 \
f338ef
+    } while (0)
f338ef
+
f338ef
 enum _ec_xattrop_flags {
f338ef
     EC_FLAG_XATTROP,
f338ef
     EC_FLAG_DATA_DIRTY,
f338ef
diff --git a/xlators/cluster/ec/src/ec-dir-write.c b/xlators/cluster/ec/src/ec-dir-write.c
f338ef
index 0b8ee21..8192462 100644
f338ef
--- a/xlators/cluster/ec/src/ec-dir-write.c
f338ef
+++ b/xlators/cluster/ec/src/ec-dir-write.c
f338ef
@@ -218,10 +218,10 @@ ec_manager_create(ec_fop_data_t *fop, int32_t state)
f338ef
             GF_ASSERT(cbk != NULL);
f338ef
 
f338ef
             if (fop->cbks.create != NULL) {
f338ef
-                fop->cbks.create(fop->req_frame, fop, fop->xl, cbk->op_ret,
f338ef
-                                 cbk->op_errno, fop->fd, fop->loc[0].inode,
f338ef
-                                 &cbk->iatt[0], &cbk->iatt[1], &cbk->iatt[2],
f338ef
-                                 cbk->xdata);
f338ef
+                QUORUM_CBK(fop->cbks.create, fop, fop->req_frame, fop, fop->xl,
f338ef
+                           cbk->op_ret, cbk->op_errno, fop->fd,
f338ef
+                           fop->loc[0].inode, &cbk->iatt[0], &cbk->iatt[1],
f338ef
+                           &cbk->iatt[2], cbk->xdata);
f338ef
             }
f338ef
 
f338ef
             return EC_STATE_LOCK_REUSE;
f338ef
@@ -390,9 +390,10 @@ ec_manager_link(ec_fop_data_t *fop, int32_t state)
f338ef
             GF_ASSERT(cbk != NULL);
f338ef
 
f338ef
             if (fop->cbks.link != NULL) {
f338ef
-                fop->cbks.link(fop->req_frame, fop, fop->xl, cbk->op_ret,
f338ef
-                               cbk->op_errno, fop->loc[0].inode, &cbk->iatt[0],
f338ef
-                               &cbk->iatt[1], &cbk->iatt[2], cbk->xdata);
f338ef
+                QUORUM_CBK(fop->cbks.link, fop, fop->req_frame, fop, fop->xl,
f338ef
+                           cbk->op_ret, cbk->op_errno, fop->loc[0].inode,
f338ef
+                           &cbk->iatt[0], &cbk->iatt[1], &cbk->iatt[2],
f338ef
+                           cbk->xdata);
f338ef
             }
f338ef
 
f338ef
             return EC_STATE_LOCK_REUSE;
f338ef
@@ -569,9 +570,10 @@ ec_manager_mkdir(ec_fop_data_t *fop, int32_t state)
f338ef
             GF_ASSERT(cbk != NULL);
f338ef
 
f338ef
             if (fop->cbks.mkdir != NULL) {
f338ef
-                fop->cbks.mkdir(fop->req_frame, fop, fop->xl, cbk->op_ret,
f338ef
-                                cbk->op_errno, fop->loc[0].inode, &cbk->iatt[0],
f338ef
-                                &cbk->iatt[1], &cbk->iatt[2], cbk->xdata);
f338ef
+                QUORUM_CBK(fop->cbks.mkdir, fop, fop->req_frame, fop, fop->xl,
f338ef
+                           cbk->op_ret, cbk->op_errno, fop->loc[0].inode,
f338ef
+                           &cbk->iatt[0], &cbk->iatt[1], &cbk->iatt[2],
f338ef
+                           cbk->xdata);
f338ef
             }
f338ef
 
f338ef
             return EC_STATE_LOCK_REUSE;
f338ef
@@ -773,9 +775,10 @@ ec_manager_mknod(ec_fop_data_t *fop, int32_t state)
f338ef
             GF_ASSERT(cbk != NULL);
f338ef
 
f338ef
             if (fop->cbks.mknod != NULL) {
f338ef
-                fop->cbks.mknod(fop->req_frame, fop, fop->xl, cbk->op_ret,
f338ef
-                                cbk->op_errno, fop->loc[0].inode, &cbk->iatt[0],
f338ef
-                                &cbk->iatt[1], &cbk->iatt[2], cbk->xdata);
f338ef
+                QUORUM_CBK(fop->cbks.mknod, fop, fop->req_frame, fop, fop->xl,
f338ef
+                           cbk->op_ret, cbk->op_errno, fop->loc[0].inode,
f338ef
+                           &cbk->iatt[0], &cbk->iatt[1], &cbk->iatt[2],
f338ef
+                           cbk->xdata);
f338ef
             }
f338ef
 
f338ef
             return EC_STATE_LOCK_REUSE;
f338ef
@@ -931,10 +934,10 @@ ec_manager_rename(ec_fop_data_t *fop, int32_t state)
f338ef
             GF_ASSERT(cbk != NULL);
f338ef
 
f338ef
             if (fop->cbks.rename != NULL) {
f338ef
-                fop->cbks.rename(fop->req_frame, fop, fop->xl, cbk->op_ret,
f338ef
-                                 cbk->op_errno, &cbk->iatt[0], &cbk->iatt[1],
f338ef
-                                 &cbk->iatt[2], &cbk->iatt[3], &cbk->iatt[4],
f338ef
-                                 cbk->xdata);
f338ef
+                QUORUM_CBK(fop->cbks.rename, fop, fop->req_frame, fop, fop->xl,
f338ef
+                           cbk->op_ret, cbk->op_errno, &cbk->iatt[0],
f338ef
+                           &cbk->iatt[1], &cbk->iatt[2], &cbk->iatt[3],
f338ef
+                           &cbk->iatt[4], cbk->xdata);
f338ef
             }
f338ef
 
f338ef
             return EC_STATE_LOCK_REUSE;
f338ef
@@ -1083,9 +1086,9 @@ ec_manager_rmdir(ec_fop_data_t *fop, int32_t state)
f338ef
             GF_ASSERT(cbk != NULL);
f338ef
 
f338ef
             if (fop->cbks.rmdir != NULL) {
f338ef
-                fop->cbks.rmdir(fop->req_frame, fop, fop->xl, cbk->op_ret,
f338ef
-                                cbk->op_errno, &cbk->iatt[0], &cbk->iatt[1],
f338ef
-                                cbk->xdata);
f338ef
+                QUORUM_CBK(fop->cbks.rmdir, fop, fop->req_frame, fop, fop->xl,
f338ef
+                           cbk->op_ret, cbk->op_errno, &cbk->iatt[0],
f338ef
+                           &cbk->iatt[1], cbk->xdata);
f338ef
             }
f338ef
 
f338ef
             return EC_STATE_LOCK_REUSE;
f338ef
@@ -1237,10 +1240,10 @@ ec_manager_symlink(ec_fop_data_t *fop, int32_t state)
f338ef
             GF_ASSERT(cbk != NULL);
f338ef
 
f338ef
             if (fop->cbks.symlink != NULL) {
f338ef
-                fop->cbks.symlink(fop->req_frame, fop, fop->xl, cbk->op_ret,
f338ef
-                                  cbk->op_errno, fop->loc[0].inode,
f338ef
-                                  &cbk->iatt[0], &cbk->iatt[1], &cbk->iatt[2],
f338ef
-                                  cbk->xdata);
f338ef
+                QUORUM_CBK(fop->cbks.symlink, fop, fop->req_frame, fop, fop->xl,
f338ef
+                           cbk->op_ret, cbk->op_errno, fop->loc[0].inode,
f338ef
+                           &cbk->iatt[0], &cbk->iatt[1], &cbk->iatt[2],
f338ef
+                           cbk->xdata);
f338ef
             }
f338ef
 
f338ef
             return EC_STATE_LOCK_REUSE;
f338ef
@@ -1392,9 +1395,9 @@ ec_manager_unlink(ec_fop_data_t *fop, int32_t state)
f338ef
             GF_ASSERT(cbk != NULL);
f338ef
 
f338ef
             if (fop->cbks.unlink != NULL) {
f338ef
-                fop->cbks.unlink(fop->req_frame, fop, fop->xl, cbk->op_ret,
f338ef
-                                 cbk->op_errno, &cbk->iatt[0], &cbk->iatt[1],
f338ef
-                                 cbk->xdata);
f338ef
+                QUORUM_CBK(fop->cbks.unlink, fop, fop->req_frame, fop, fop->xl,
f338ef
+                           cbk->op_ret, cbk->op_errno, &cbk->iatt[0],
f338ef
+                           &cbk->iatt[1], cbk->xdata);
f338ef
             }
f338ef
 
f338ef
             return EC_STATE_LOCK_REUSE;
f338ef
diff --git a/xlators/cluster/ec/src/ec-inode-write.c b/xlators/cluster/ec/src/ec-inode-write.c
f338ef
index 8bfa3b4..2dbb4db 100644
f338ef
--- a/xlators/cluster/ec/src/ec-inode-write.c
f338ef
+++ b/xlators/cluster/ec/src/ec-inode-write.c
f338ef
@@ -185,26 +185,26 @@ ec_xattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
f338ef
     switch (fop->id) {
f338ef
         case GF_FOP_SETXATTR:
f338ef
             if (fop->cbks.setxattr) {
f338ef
-                fop->cbks.setxattr(frame, cookie, this, op_ret, op_errno,
f338ef
-                                   xdata);
f338ef
+                QUORUM_CBK(fop->cbks.setxattr, fop, frame, cookie, this, op_ret,
f338ef
+                           op_errno, xdata);
f338ef
             }
f338ef
             break;
f338ef
         case GF_FOP_REMOVEXATTR:
f338ef
             if (fop->cbks.removexattr) {
f338ef
-                fop->cbks.removexattr(frame, cookie, this, op_ret, op_errno,
f338ef
-                                      xdata);
f338ef
+                QUORUM_CBK(fop->cbks.removexattr, fop, frame, cookie, this,
f338ef
+                           op_ret, op_errno, xdata);
f338ef
             }
f338ef
             break;
f338ef
         case GF_FOP_FSETXATTR:
f338ef
             if (fop->cbks.fsetxattr) {
f338ef
-                fop->cbks.fsetxattr(frame, cookie, this, op_ret, op_errno,
f338ef
-                                    xdata);
f338ef
+                QUORUM_CBK(fop->cbks.fsetxattr, fop, frame, cookie, this,
f338ef
+                           op_ret, op_errno, xdata);
f338ef
             }
f338ef
             break;
f338ef
         case GF_FOP_FREMOVEXATTR:
f338ef
             if (fop->cbks.fremovexattr) {
f338ef
-                fop->cbks.fremovexattr(frame, cookie, this, op_ret, op_errno,
f338ef
-                                       xdata);
f338ef
+                QUORUM_CBK(fop->cbks.fremovexattr, fop, frame, cookie, this,
f338ef
+                           op_ret, op_errno, xdata);
f338ef
             }
f338ef
             break;
f338ef
     }
f338ef
@@ -494,16 +494,15 @@ ec_manager_setattr(ec_fop_data_t *fop, int32_t state)
f338ef
 
f338ef
             if (fop->id == GF_FOP_SETATTR) {
f338ef
                 if (fop->cbks.setattr != NULL) {
f338ef
-                    fop->cbks.setattr(fop->req_frame, fop, fop->xl, cbk->op_ret,
f338ef
-                                      cbk->op_errno, &cbk->iatt[0],
f338ef
-                                      &cbk->iatt[1], cbk->xdata);
f338ef
+                    QUORUM_CBK(fop->cbks.setattr, fop, fop->req_frame, fop,
f338ef
+                               fop->xl, cbk->op_ret, cbk->op_errno,
f338ef
+                               &cbk->iatt[0], &cbk->iatt[1], cbk->xdata);
f338ef
                 }
f338ef
             } else {
f338ef
                 if (fop->cbks.fsetattr != NULL) {
f338ef
-                    fop->cbks.fsetattr(fop->req_frame, fop, fop->xl,
f338ef
-                                       cbk->op_ret, cbk->op_errno,
f338ef
-                                       &cbk->iatt[0], &cbk->iatt[1],
f338ef
-                                       cbk->xdata);
f338ef
+                    QUORUM_CBK(fop->cbks.fsetattr, fop, fop->req_frame, fop,
f338ef
+                               fop->xl, cbk->op_ret, cbk->op_errno,
f338ef
+                               &cbk->iatt[0], &cbk->iatt[1], cbk->xdata);
f338ef
                 }
f338ef
             }
f338ef
 
f338ef
@@ -994,9 +993,9 @@ ec_manager_fallocate(ec_fop_data_t *fop, int32_t state)
f338ef
             GF_ASSERT(cbk != NULL);
f338ef
 
f338ef
             if (fop->cbks.fallocate != NULL) {
f338ef
-                fop->cbks.fallocate(fop->req_frame, fop, fop->xl, cbk->op_ret,
f338ef
-                                    cbk->op_errno, &cbk->iatt[0], &cbk->iatt[1],
f338ef
-                                    cbk->xdata);
f338ef
+                QUORUM_CBK(fop->cbks.fallocate, fop, fop->req_frame, fop,
f338ef
+                           fop->xl, cbk->op_ret, cbk->op_errno, &cbk->iatt[0],
f338ef
+                           &cbk->iatt[1], cbk->xdata);
f338ef
             }
f338ef
 
f338ef
             return EC_STATE_LOCK_REUSE;
f338ef
@@ -1247,9 +1246,9 @@ ec_manager_discard(ec_fop_data_t *fop, int32_t state)
f338ef
             GF_ASSERT(cbk != NULL);
f338ef
 
f338ef
             if (fop->cbks.discard != NULL) {
f338ef
-                fop->cbks.discard(fop->req_frame, fop, fop->xl, cbk->op_ret,
f338ef
-                                  cbk->op_errno, &cbk->iatt[0], &cbk->iatt[1],
f338ef
-                                  cbk->xdata);
f338ef
+                QUORUM_CBK(fop->cbks.discard, fop, fop->req_frame, fop, fop->xl,
f338ef
+                           cbk->op_ret, cbk->op_errno, &cbk->iatt[0],
f338ef
+                           &cbk->iatt[1], cbk->xdata);
f338ef
             }
f338ef
 
f338ef
             return EC_STATE_LOCK_REUSE;
f338ef
@@ -1477,17 +1476,15 @@ ec_manager_truncate(ec_fop_data_t *fop, int32_t state)
f338ef
 
f338ef
             if (fop->id == GF_FOP_TRUNCATE) {
f338ef
                 if (fop->cbks.truncate != NULL) {
f338ef
-                    fop->cbks.truncate(fop->req_frame, fop, fop->xl,
f338ef
-                                       cbk->op_ret, cbk->op_errno,
f338ef
-                                       &cbk->iatt[0], &cbk->iatt[1],
f338ef
-                                       cbk->xdata);
f338ef
+                    QUORUM_CBK(fop->cbks.truncate, fop, fop->req_frame, fop,
f338ef
+                               fop->xl, cbk->op_ret, cbk->op_errno,
f338ef
+                               &cbk->iatt[0], &cbk->iatt[1], cbk->xdata);
f338ef
                 }
f338ef
             } else {
f338ef
                 if (fop->cbks.ftruncate != NULL) {
f338ef
-                    fop->cbks.ftruncate(fop->req_frame, fop, fop->xl,
f338ef
-                                        cbk->op_ret, cbk->op_errno,
f338ef
-                                        &cbk->iatt[0], &cbk->iatt[1],
f338ef
-                                        cbk->xdata);
f338ef
+                    QUORUM_CBK(fop->cbks.ftruncate, fop, fop->req_frame, fop,
f338ef
+                               fop->xl, cbk->op_ret, cbk->op_errno,
f338ef
+                               &cbk->iatt[0], &cbk->iatt[1], cbk->xdata);
f338ef
                 }
f338ef
             }
f338ef
 
f338ef
@@ -2245,9 +2242,9 @@ ec_manager_writev(ec_fop_data_t *fop, int32_t state)
f338ef
             GF_ASSERT(cbk != NULL);
f338ef
 
f338ef
             if (fop->cbks.writev != NULL) {
f338ef
-                fop->cbks.writev(fop->req_frame, fop, fop->xl, cbk->op_ret,
f338ef
-                                 cbk->op_errno, &cbk->iatt[0], &cbk->iatt[1],
f338ef
-                                 cbk->xdata);
f338ef
+                QUORUM_CBK(fop->cbks.writev, fop, fop->req_frame, fop, fop->xl,
f338ef
+                           cbk->op_ret, cbk->op_errno, &cbk->iatt[0],
f338ef
+                           &cbk->iatt[1], cbk->xdata);
f338ef
             }
f338ef
 
f338ef
             return EC_STATE_LOCK_REUSE;
f338ef
diff --git a/xlators/cluster/ec/src/ec-types.h b/xlators/cluster/ec/src/ec-types.h
f338ef
index f27f2ec..ea4f6ad 100644
f338ef
--- a/xlators/cluster/ec/src/ec-types.h
f338ef
+++ b/xlators/cluster/ec/src/ec-types.h
f338ef
@@ -654,6 +654,7 @@ struct _ec {
f338ef
     gf_boolean_t optimistic_changelog;
f338ef
     gf_boolean_t parallel_writes;
f338ef
     uint32_t stripe_cache;
f338ef
+    uint32_t quorum_count;
f338ef
     uint32_t background_heals;
f338ef
     uint32_t heal_wait_qlen;
f338ef
     uint32_t self_heal_window_size; /* max size of read/writes */
f338ef
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
f338ef
index 3c8013e..19094c4 100644
f338ef
--- a/xlators/cluster/ec/src/ec.c
f338ef
+++ b/xlators/cluster/ec/src/ec.c
f338ef
@@ -285,6 +285,7 @@ reconfigure(xlator_t *this, dict_t *options)
f338ef
     GF_OPTION_RECONF("parallel-writes", ec->parallel_writes, options, bool,
f338ef
                      failed);
f338ef
     GF_OPTION_RECONF("stripe-cache", ec->stripe_cache, options, uint32, failed);
f338ef
+    GF_OPTION_RECONF("quorum-count", ec->quorum_count, options, uint32, failed);
f338ef
     ret = 0;
f338ef
     if (ec_assign_read_policy(ec, read_policy)) {
f338ef
         ret = -1;
f338ef
@@ -720,6 +721,7 @@ init(xlator_t *this)
f338ef
                    failed);
f338ef
     GF_OPTION_INIT("parallel-writes", ec->parallel_writes, bool, failed);
f338ef
     GF_OPTION_INIT("stripe-cache", ec->stripe_cache, uint32, failed);
f338ef
+    GF_OPTION_INIT("quorum-count", ec->quorum_count, uint32, failed);
f338ef
 
f338ef
     this->itable = inode_table_new(EC_SHD_INODE_LRU_LIMIT, this);
f338ef
     if (!this->itable)
f338ef
@@ -1402,6 +1404,7 @@ ec_dump_private(xlator_t *this)
f338ef
     gf_proc_dump_write("heal-waiters", "%d", ec->heal_waiters);
f338ef
     gf_proc_dump_write("read-policy", "%s", ec_read_policies[ec->read_policy]);
f338ef
     gf_proc_dump_write("parallel-writes", "%d", ec->parallel_writes);
f338ef
+    gf_proc_dump_write("quorum-count", "%u", ec->quorum_count);
f338ef
 
f338ef
     snprintf(key_prefix, GF_DUMP_MAX_BUF_LEN, "%s.%s.stats.stripe_cache",
f338ef
              this->type, this->name);
f338ef
@@ -1672,6 +1675,16 @@ struct volume_options options[] = {
f338ef
                     "lead to extra memory consumption, maximum "
f338ef
                     "(cache size * stripe size) Bytes per open file."},
f338ef
     {
f338ef
+        .key = {"quorum-count"},
f338ef
+        .type = GF_OPTION_TYPE_INT,
f338ef
+        .default_value = "0",
f338ef
+        .description =
f338ef
+            "This option can be used to define how many successes on"
f338ef
+            "the bricks constitute a success to the application. This"
f338ef
+            " count should be in the range"
f338ef
+            "[disperse-data-count,  disperse-count] (inclusive)",
f338ef
+    },
f338ef
+    {
f338ef
         .key = {NULL},
f338ef
     },
f338ef
 };
f338ef
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
f338ef
index 8ce338e..7ca47a6 100644
f338ef
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
f338ef
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
f338ef
@@ -1128,6 +1128,42 @@ out:
f338ef
 }
f338ef
 
f338ef
 static int
f338ef
+validate_disperse_quorum_count(glusterd_volinfo_t *volinfo, dict_t *dict,
f338ef
+                               char *key, char *value, char **op_errstr)
f338ef
+{
f338ef
+    int ret = -1;
f338ef
+    int quorum_count = 0;
f338ef
+    int data_count = 0;
f338ef
+
f338ef
+    ret = gf_string2int(value, &quorum_count);
f338ef
+    if (ret) {
f338ef
+        gf_asprintf(op_errstr,
f338ef
+                    "%s is not an integer. %s expects a "
f338ef
+                    "valid integer value.",
f338ef
+                    value, key);
f338ef
+        goto out;
f338ef
+    }
f338ef
+
f338ef
+    if (volinfo->type != GF_CLUSTER_TYPE_DISPERSE) {
f338ef
+        gf_asprintf(op_errstr, "Cannot set %s for a non-disperse volume.", key);
f338ef
+        ret = -1;
f338ef
+        goto out;
f338ef
+    }
f338ef
+
f338ef
+    data_count = volinfo->disperse_count - volinfo->redundancy_count;
f338ef
+    if (quorum_count < data_count || quorum_count > volinfo->disperse_count) {
f338ef
+        gf_asprintf(op_errstr, "%d for %s is out of range [%d - %d]",
f338ef
+                    quorum_count, key, data_count, volinfo->disperse_count);
f338ef
+        ret = -1;
f338ef
+        goto out;
f338ef
+    }
f338ef
+
f338ef
+    ret = 0;
f338ef
+out:
f338ef
+    return ret;
f338ef
+}
f338ef
+
f338ef
+static int
f338ef
 validate_parallel_readdir(glusterd_volinfo_t *volinfo, dict_t *dict, char *key,
f338ef
                           char *value, char **op_errstr)
f338ef
 {
f338ef
@@ -3663,6 +3699,16 @@ struct volopt_map_entry glusterd_volopt_map[] = {
f338ef
      .type = NO_DOC,
f338ef
      .op_version = GD_OP_VERSION_3_13_0,
f338ef
      .flags = VOLOPT_FLAG_CLIENT_OPT},
f338ef
+    {.key = "disperse.quorum-count",
f338ef
+     .voltype = "cluster/disperse",
f338ef
+     .type = NO_DOC,
f338ef
+     .op_version = GD_OP_VERSION_8_0,
f338ef
+     .validate_fn = validate_disperse_quorum_count,
f338ef
+     .description = "This option can be used to define how many successes on"
f338ef
+                    "the bricks constitute a success to the application. This"
f338ef
+                    " count should be in the range"
f338ef
+                    "[disperse-data-count,  disperse-count] (inclusive)",
f338ef
+     .flags = VOLOPT_FLAG_CLIENT_OPT},
f338ef
     {
f338ef
         .key = "features.sdfs",
f338ef
         .voltype = "features/sdfs",
f338ef
-- 
f338ef
1.8.3.1
f338ef