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