887953
From 8f270fceed4c03ab4405ae65e7e9ce7fce9e008c Mon Sep 17 00:00:00 2001
887953
From: Pranith Kumar K <pkarampu@redhat.com>
887953
Date: Thu, 6 Sep 2018 15:09:42 +0530
887953
Subject: [PATCH 380/385] cluster/afr: Batch writes in same lock even when
887953
 multiple fds are open
887953
887953
Problem:
887953
When eager-lock is disabled because of multiple-fds opened and app
887953
writes come on conflicting regions, the number of locks grows very
887953
fast leading to all the CPU being spent just in locking and unlocking
887953
by traversing huge queues in locks xlator for granting locks.
887953
887953
Fix:
887953
Reduce the number of locks in transit by bundling the writes in the
887953
same lock and disable delayed piggy-pack when we learn that multiple
887953
fds are open on the file. This will reduce the size of queues in the
887953
locks xlator.  This also reduces the number of network calls like
887953
inodelk/fxattrop.
887953
887953
Please note that this problem can still happen if eager-lock is
887953
disabled as the writes will not be bundled in the same lock.
887953
887953
Upstream-patch: https://review.gluster.org/c/glusterfs/+/21107
887953
BUG: 1630688
887953
Change-Id: I8fd1cf229aed54ce5abd4e6226351a039924dd91
887953
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
887953
Reviewed-on: https://code.engineering.redhat.com/gerrit/150700
887953
Tested-by: RHGS Build Bot <nigelb@redhat.com>
887953
Reviewed-by: Ravishankar Narayanankutty <ravishankar@redhat.com>
887953
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
887953
---
887953
 xlators/cluster/afr/src/afr-transaction.c | 11 ++---------
887953
 1 file changed, 2 insertions(+), 9 deletions(-)
887953
887953
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
887953
index 3f55070..85b00a8 100644
887953
--- a/xlators/cluster/afr/src/afr-transaction.c
887953
+++ b/xlators/cluster/afr/src/afr-transaction.c
887953
@@ -2241,9 +2241,6 @@ __need_previous_lock_unlocked (afr_local_t *local)
887953
 {
887953
         afr_lock_t      *lock = NULL;
887953
 
887953
-        if (!local->transaction.eager_lock_on)
887953
-                return _gf_true;
887953
-
887953
         lock = &local->inode_ctx->lock[local->transaction.type];
887953
         if (!lock->acquired)
887953
                 return _gf_false;
887953
@@ -2260,10 +2257,8 @@ __afr_eager_lock_handle (afr_local_t *local, gf_boolean_t *take_lock,
887953
         afr_local_t     *owner_local = NULL;
887953
         xlator_t        *this = local->transaction.frame->this;
887953
 
887953
-        if (local->fd && !afr_are_multiple_fds_opened (local, this)) {
887953
-                local->transaction.eager_lock_on = _gf_true;
887953
-                afr_set_lk_owner (local->transaction.frame, this, local->inode);
887953
-        }
887953
+        local->transaction.eager_lock_on = _gf_true;
887953
+        afr_set_lk_owner (local->transaction.frame, this, local->inode);
887953
 
887953
         lock = &local->inode_ctx->lock[local->transaction.type];
887953
         if (__need_previous_lock_unlocked (local)) {
887953
@@ -2282,8 +2277,6 @@ __afr_eager_lock_handle (afr_local_t *local, gf_boolean_t *take_lock,
887953
                                 lock->delay_timer = NULL;
887953
                         }
887953
                 }
887953
-                if (!local->transaction.eager_lock_on)
887953
-                        goto out;
887953
         }
887953
 
887953
         if (lock->release) {
887953
-- 
887953
1.8.3.1
887953