|
|
a3470f |
From d08f81216085cda58a64f51872b4d2497958a7ea Mon Sep 17 00:00:00 2001
|
|
|
a3470f |
From: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
a3470f |
Date: Fri, 6 Jul 2018 12:28:53 +0530
|
|
|
a3470f |
Subject: [PATCH 314/325] cluster/afr: Prevent execution of code after
|
|
|
a3470f |
call_count decrementing
|
|
|
a3470f |
|
|
|
a3470f |
Upstream-patch: https://review.gluster.org/20470
|
|
|
a3470f |
|
|
|
a3470f |
Problem:
|
|
|
a3470f |
When call_count is decremented by one thread, another thread can
|
|
|
a3470f |
go ahead with the operation leading to undefined behavior for the
|
|
|
a3470f |
thread executing statements after decrementing call count.
|
|
|
a3470f |
|
|
|
a3470f |
Fix:
|
|
|
a3470f |
Do the operations necessary before decrementing call count.
|
|
|
a3470f |
|
|
|
a3470f |
>fixes bz#1598663
|
|
|
a3470f |
BUG: 1598105
|
|
|
a3470f |
Change-Id: Icc90cd92ac16e5fbdfe534d9f0a61312943393fe
|
|
|
a3470f |
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
a3470f |
Reviewed-on: https://code.engineering.redhat.com/gerrit/143624
|
|
|
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-lk-common.c | 15 ++++++++-------
|
|
|
a3470f |
1 file changed, 8 insertions(+), 7 deletions(-)
|
|
|
a3470f |
|
|
|
a3470f |
diff --git a/xlators/cluster/afr/src/afr-lk-common.c b/xlators/cluster/afr/src/afr-lk-common.c
|
|
|
a3470f |
index be3de01..dff6644 100644
|
|
|
a3470f |
--- a/xlators/cluster/afr/src/afr-lk-common.c
|
|
|
a3470f |
+++ b/xlators/cluster/afr/src/afr-lk-common.c
|
|
|
a3470f |
@@ -970,6 +970,14 @@ afr_nonblocking_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
a3470f |
local = frame->local;
|
|
|
a3470f |
int_lock = &local->internal_lock;
|
|
|
a3470f |
|
|
|
a3470f |
+ if (op_ret == 0 && local->transaction.type == AFR_DATA_TRANSACTION) {
|
|
|
a3470f |
+ LOCK (&local->inode->lock);
|
|
|
a3470f |
+ {
|
|
|
a3470f |
+ local->inode_ctx->lock_count++;
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+ UNLOCK (&local->inode->lock);
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+
|
|
|
a3470f |
LOCK (&frame->lock);
|
|
|
a3470f |
{
|
|
|
a3470f |
if (op_ret < 0) {
|
|
|
a3470f |
@@ -994,13 +1002,6 @@ afr_nonblocking_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
a3470f |
}
|
|
|
a3470f |
UNLOCK (&frame->lock);
|
|
|
a3470f |
|
|
|
a3470f |
- if (op_ret == 0 && local->transaction.type == AFR_DATA_TRANSACTION) {
|
|
|
a3470f |
- LOCK (&local->inode->lock);
|
|
|
a3470f |
- {
|
|
|
a3470f |
- local->inode_ctx->lock_count++;
|
|
|
a3470f |
- }
|
|
|
a3470f |
- UNLOCK (&local->inode->lock);
|
|
|
a3470f |
- }
|
|
|
a3470f |
if (call_count == 0) {
|
|
|
a3470f |
gf_msg_trace (this->name, 0,
|
|
|
a3470f |
"Last inode locking reply received");
|
|
|
a3470f |
--
|
|
|
a3470f |
1.8.3.1
|
|
|
a3470f |
|