7c2869
From d09e4d40ed3a41e1a468a2da851e59c0ce6ea228 Mon Sep 17 00:00:00 2001
7c2869
From: Ravishankar N <ravishankar@redhat.com>
7c2869
Date: Mon, 16 Apr 2018 15:38:34 +0530
7c2869
Subject: [PATCH 674/675] afr: fixes to afr-eager locking
7c2869
7c2869
Upstream patch: https://review.gluster.org/#/c/19879/
7c2869
7c2869
1. If pre-op fails on all bricks,set lock->release to true in
7c2869
afr_handle_lock_acquire_failure so that the GF_ASSERT in afr_unlock() does not
7c2869
crash.
7c2869
7c2869
2. Added a missing 'return' after handling pre-op failure in
7c2869
afr_transaction_perform_fop(), fixing a use-after-free issue.
7c2869
7c2869
BUG: 1583733
7c2869
Change-Id: Iae6572f6ca3c4e9c03becb7eef0fb2033c3ff0e5
7c2869
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
7c2869
Reviewed-on: https://code.engineering.redhat.com/gerrit/140579
7c2869
Tested-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
7c2869
Tested-by: RHGS Build Bot <nigelb@redhat.com>
7c2869
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
7c2869
---
7c2869
 tests/bugs/replicate/bug-1561129-enospc.t | 24 ++++++++++++++++++++++++
7c2869
 xlators/cluster/afr/src/afr-transaction.c |  2 ++
7c2869
 2 files changed, 26 insertions(+)
7c2869
 create mode 100644 tests/bugs/replicate/bug-1561129-enospc.t
7c2869
7c2869
diff --git a/tests/bugs/replicate/bug-1561129-enospc.t b/tests/bugs/replicate/bug-1561129-enospc.t
7c2869
new file mode 100644
7c2869
index 0000000..1b402fc
7c2869
--- /dev/null
7c2869
+++ b/tests/bugs/replicate/bug-1561129-enospc.t
7c2869
@@ -0,0 +1,24 @@
7c2869
+#!/bin/bash
7c2869
+#Tests that sequential write workload doesn't lead to FSYNCs
7c2869
+
7c2869
+. $(dirname $0)/../../include.rc
7c2869
+. $(dirname $0)/../../volume.rc
7c2869
+
7c2869
+cleanup;
7c2869
+
7c2869
+TEST truncate -s 128M $B0/xfs_image
7c2869
+TEST mkfs.xfs -f $B0/xfs_image
7c2869
+TEST mkdir $B0/bricks
7c2869
+TEST mount -t xfs -o loop $B0/xfs_image $B0/bricks
7c2869
+
7c2869
+TEST glusterd
7c2869
+TEST pidof glusterd
7c2869
+TEST $CLI volume create $V0 replica 3 $H0:$B0/bricks/brick{0,1,3}
7c2869
+TEST $CLI volume start $V0
7c2869
+TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0;
7c2869
+
7c2869
+# Write 50MB of data, which will try to consume 50x3=150MB on $B0/bricks.
7c2869
+# Before that, we hit ENOSPC in pre-op cbk, which should not crash the mount.
7c2869
+TEST ! dd if=/dev/zero of=$M0/a bs=1M count=50
7c2869
+TEST stat $M0/a
7c2869
+cleanup;
7c2869
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
7c2869
index caa83c8..d19795d 100644
7c2869
--- a/xlators/cluster/afr/src/afr-transaction.c
7c2869
+++ b/xlators/cluster/afr/src/afr-transaction.c
7c2869
@@ -263,6 +263,7 @@ afr_handle_lock_acquire_failure (afr_local_t *local, gf_boolean_t locked)
7c2869
         INIT_LIST_HEAD (&shared);
7c2869
         LOCK (&local->inode->lock);
7c2869
         {
7c2869
+                lock->release = _gf_true;
7c2869
                 list_splice_init (&lock->waiting, &shared);
7c2869
         }
7c2869
         UNLOCK (&local->inode->lock);
7c2869
@@ -481,6 +482,7 @@ afr_transaction_perform_fop (call_frame_t *frame, xlator_t *this)
7c2869
                                    priv->child_count);
7c2869
         if (failure_count == priv->child_count) {
7c2869
                 afr_handle_lock_acquire_failure (local, _gf_true);
7c2869
+                return 0;
7c2869
         } else {
7c2869
                 lock = &local->inode_ctx->lock[local->transaction.type];
7c2869
                 LOCK (&local->inode->lock);
7c2869
-- 
7c2869
1.8.3.1
7c2869