d1681e
From fef5fb73545bed5a4040db1f8e4e855286c1981d Mon Sep 17 00:00:00 2001
d1681e
From: Ravishankar N <ravishankar@redhat.com>
d1681e
Date: Wed, 18 Jul 2018 14:16:46 +0530
d1681e
Subject: [PATCH 327/333] afr: switch lk_owner only when pre-op succeeds
d1681e
d1681e
Backport of https://review.gluster.org/#/c/20527/
d1681e
d1681e
Problem:
d1681e
In a disk full scenario, we take a failure path in afr_transaction_perform_fop()
d1681e
and go to unlock phase. But we change the lk-owner before that, causing unlock
d1681e
to fail. When mount issues another fop that takes locks on that file, it hangs.
d1681e
d1681e
Fix:
d1681e
Change lk-owner only when we are about to perform the fop phase.
d1681e
Also fix the same issue for arbiters when afr_txn_arbitrate_fop() fails the fop.
d1681e
d1681e
Also removed the DISK_SPACE_CHECK_AND_GOTO in posix_xattrop. Otherwise truncate
d1681e
to zero will fail pre-op phase with ENOSPC when the user is actually trying to
d1681e
freee up space.
d1681e
d1681e
Change-Id: I8663003fa7d472e93fe61cc1e39c78084d3de81f
d1681e
BUG: 1599998
d1681e
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
d1681e
Reviewed-on: https://code.engineering.redhat.com/gerrit/144275
d1681e
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d1681e
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
d1681e
---
d1681e
 xlators/cluster/afr/src/afr-transaction.c | 20 ++++++++++----------
d1681e
 xlators/storage/posix/src/posix.c         |  5 -----
d1681e
 2 files changed, 10 insertions(+), 15 deletions(-)
d1681e
d1681e
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
d1681e
index 321b6f1..3f55070 100644
d1681e
--- a/xlators/cluster/afr/src/afr-transaction.c
d1681e
+++ b/xlators/cluster/afr/src/afr-transaction.c
d1681e
@@ -495,11 +495,10 @@ afr_txn_arbitrate_fop (call_frame_t *frame, xlator_t *this)
d1681e
                 local->op_errno =  ENOTCONN;
d1681e
                 for (i = 0; i < priv->child_count; i++)
d1681e
                         local->transaction.failed_subvols[i] = 1;
d1681e
-                afr_changelog_post_op (frame, this);/*uninherit should happen*/
d1681e
-        } else {
d1681e
-                afr_transaction_fop (frame, this);
d1681e
         }
d1681e
 
d1681e
+        afr_transaction_fop (frame, this);
d1681e
+
d1681e
         return;
d1681e
 }
d1681e
 
d1681e
@@ -529,13 +528,6 @@ afr_transaction_perform_fop (call_frame_t *frame, xlator_t *this)
d1681e
                                 local->transaction.failed_subvols[i] = 1;
d1681e
                 }
d1681e
         }
d1681e
-        /*  Perform fops with the lk-owner from top xlator.
d1681e
-         *  Eg: lk-owner of posix-lk and flush should be same,
d1681e
-         *  flush cant clear the  posix-lks without that lk-owner.
d1681e
-         */
d1681e
-        afr_save_lk_owner (frame);
d1681e
-        frame->root->lk_owner =
d1681e
-                local->transaction.main_frame->root->lk_owner;
d1681e
 
d1681e
 	if (local->pre_op_compat)
d1681e
 		/* old mode, pre-op was done as afr_changelog_do()
d1681e
@@ -561,6 +553,14 @@ afr_transaction_perform_fop (call_frame_t *frame, xlator_t *this)
d1681e
         }
d1681e
 
d1681e
 fop:
d1681e
+        /*  Perform fops with the lk-owner from top xlator.
d1681e
+         *  Eg: lk-owner of posix-lk and flush should be same,
d1681e
+         *  flush cant clear the  posix-lks without that lk-owner.
d1681e
+         */
d1681e
+        afr_save_lk_owner (frame);
d1681e
+        frame->root->lk_owner =
d1681e
+                local->transaction.main_frame->root->lk_owner;
d1681e
+
d1681e
         if (priv->arbiter_count == 1) {
d1681e
                 afr_txn_arbitrate_fop (frame, this);
d1681e
         } else {
d1681e
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
d1681e
index 01f472b..ddb875c 100644
d1681e
--- a/xlators/storage/posix/src/posix.c
d1681e
+++ b/xlators/storage/posix/src/posix.c
d1681e
@@ -6147,16 +6147,11 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
d1681e
         dict_t               *xattr_rsp = NULL;
d1681e
         dict_t               *xdata_rsp = NULL;
d1681e
         struct iatt           stbuf = {0};
d1681e
-        struct  posix_private *priv     = NULL;
d1681e
-
d1681e
 
d1681e
         VALIDATE_OR_GOTO (frame, out);
d1681e
         VALIDATE_OR_GOTO (xattr, out);
d1681e
         VALIDATE_OR_GOTO (this, out);
d1681e
 
d1681e
-        priv = this->private;
d1681e
-        DISK_SPACE_CHECK_AND_GOTO (frame, priv, xdata, op_ret, op_errno, out);
d1681e
-
d1681e
         if (fd) {
d1681e
                 op_ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
d1681e
                 if (op_ret < 0) {
d1681e
-- 
d1681e
1.8.3.1
d1681e