From 8610bafb07334f37f61cce423db4fe7b2a104722 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Thu, 6 Sep 2018 15:09:42 +0530 Subject: cluster/afr: Batch writes in same lock even when multiple fds are open Problem: When eager-lock is disabled because of multiple-fds opened and app writes come on conflicting regions, the number of locks grows very fast leading to all the CPU being spent just in locking and unlocking by traversing huge queues in locks xlator for granting locks. Fix: Reduce the number of locks in transit by bundling the writes in the same lock and disable delayed piggy-pack when we learn that multiple fds are open on the file. This will reduce the size of queues in the locks xlator. This also reduces the number of network calls like inodelk/fxattrop. Please note that this problem can still happen if eager-lock is disabled as the writes will not be bundled in the same lock. fixes bz#1635979 Change-Id: I8fd1cf229aed54ce5abd4e6226351a039924dd91 Signed-off-by: Pranith Kumar K --- xlators/cluster/afr/src/afr-transaction.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c index 74fa6e51b99..0cd3373ff3d 100644 --- a/xlators/cluster/afr/src/afr-transaction.c +++ b/xlators/cluster/afr/src/afr-transaction.c @@ -2306,9 +2306,6 @@ __need_previous_lock_unlocked (afr_local_t *local) { afr_lock_t *lock = NULL; - if (!local->transaction.eager_lock_on) - return _gf_true; - lock = &local->inode_ctx->lock[local->transaction.type]; if (!lock->acquired) return _gf_false; @@ -2325,10 +2322,8 @@ __afr_eager_lock_handle (afr_local_t *local, gf_boolean_t *take_lock, afr_local_t *owner_local = NULL; xlator_t *this = local->transaction.frame->this; - if (local->fd && !afr_are_multiple_fds_opened (local, this)) { - local->transaction.eager_lock_on = _gf_true; - afr_set_lk_owner (local->transaction.frame, this, local->inode); - } + local->transaction.eager_lock_on = _gf_true; + afr_set_lk_owner (local->transaction.frame, this, local->inode); lock = &local->inode_ctx->lock[local->transaction.type]; if (__need_previous_lock_unlocked (local)) { @@ -2347,8 +2342,6 @@ __afr_eager_lock_handle (afr_local_t *local, gf_boolean_t *take_lock, lock->delay_timer = NULL; } } - if (!local->transaction.eager_lock_on) - goto out; } if (lock->release) { -- cgit