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