|
|
a3470f |
From 09c73d2c7793d2316c62837a80b41904a2a5b15f Mon Sep 17 00:00:00 2001
|
|
|
a3470f |
From: Xavier Hernandez <jahernan@redhat.com>
|
|
|
a3470f |
Date: Mon, 20 Nov 2017 10:51:09 +0100
|
|
|
a3470f |
Subject: [PATCH 103/128] features/locks: Fix memory leaks
|
|
|
a3470f |
|
|
|
a3470f |
> Upstream patch: https://review.gluster.org/18812
|
|
|
a3470f |
|
|
|
a3470f |
Change-Id: Ic1d2e17a7d14389b6734d1b88bd28c0a2907bbd6
|
|
|
a3470f |
BUG: 1507361
|
|
|
a3470f |
Signed-off-by: Xavier Hernandez <jahernan@redhat.com>
|
|
|
a3470f |
Reviewed-on: https://code.engineering.redhat.com/gerrit/125955
|
|
|
a3470f |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
a3470f |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
a3470f |
---
|
|
|
a3470f |
xlators/features/locks/src/clear.c | 2 +-
|
|
|
a3470f |
xlators/features/locks/src/common.c | 1 +
|
|
|
a3470f |
xlators/features/locks/src/entrylk.c | 3 ++-
|
|
|
a3470f |
xlators/features/locks/src/inodelk.c | 7 ++++---
|
|
|
a3470f |
xlators/features/locks/src/posix.c | 3 +++
|
|
|
a3470f |
5 files changed, 11 insertions(+), 5 deletions(-)
|
|
|
a3470f |
|
|
|
a3470f |
diff --git a/xlators/features/locks/src/clear.c b/xlators/features/locks/src/clear.c
|
|
|
a3470f |
index d7c210f..22c03b5 100644
|
|
|
a3470f |
--- a/xlators/features/locks/src/clear.c
|
|
|
a3470f |
+++ b/xlators/features/locks/src/clear.c
|
|
|
a3470f |
@@ -184,7 +184,7 @@ clrlk_clear_posixlk (xlator_t *this, pl_inode_t *pl_inode, clrlk_args *args,
|
|
|
a3470f |
} else {
|
|
|
a3470f |
gcount++;
|
|
|
a3470f |
}
|
|
|
a3470f |
- GF_FREE (plock);
|
|
|
a3470f |
+ __destroy_lock(plock);
|
|
|
a3470f |
}
|
|
|
a3470f |
}
|
|
|
a3470f |
pthread_mutex_unlock (&pl_inode->mutex);
|
|
|
a3470f |
diff --git a/xlators/features/locks/src/common.c b/xlators/features/locks/src/common.c
|
|
|
a3470f |
index 4b63c43..7311126 100644
|
|
|
a3470f |
--- a/xlators/features/locks/src/common.c
|
|
|
a3470f |
+++ b/xlators/features/locks/src/common.c
|
|
|
a3470f |
@@ -438,6 +438,7 @@ pl_inode_get (xlator_t *this, inode_t *inode)
|
|
|
a3470f |
|
|
|
a3470f |
ret = __inode_ctx_put (inode, this, (uint64_t)(long)(pl_inode));
|
|
|
a3470f |
if (ret) {
|
|
|
a3470f |
+ pthread_mutex_destroy (&pl_inode->mutex);
|
|
|
a3470f |
GF_FREE (pl_inode);
|
|
|
a3470f |
pl_inode = NULL;
|
|
|
a3470f |
goto unlock;
|
|
|
a3470f |
diff --git a/xlators/features/locks/src/entrylk.c b/xlators/features/locks/src/entrylk.c
|
|
|
a3470f |
index 4231d76..8e9008b 100644
|
|
|
a3470f |
--- a/xlators/features/locks/src/entrylk.c
|
|
|
a3470f |
+++ b/xlators/features/locks/src/entrylk.c
|
|
|
a3470f |
@@ -784,7 +784,7 @@ pl_common_entrylk (call_frame_t *frame, xlator_t *this,
|
|
|
a3470f |
break;
|
|
|
a3470f |
|
|
|
a3470f |
default:
|
|
|
a3470f |
- inode_unref (pinode->inode);
|
|
|
a3470f |
+ need_inode_unref = _gf_true;
|
|
|
a3470f |
gf_log (this->name, GF_LOG_ERROR,
|
|
|
a3470f |
"Unexpected case in entrylk (cmd=%d). Please file"
|
|
|
a3470f |
"a bug report at http://bugs.gluster.com", cmd);
|
|
|
a3470f |
@@ -960,6 +960,7 @@ pl_entrylk_client_cleanup (xlator_t *this, pl_ctx_t *ctx)
|
|
|
a3470f |
__pl_entrylk_unref (l);
|
|
|
a3470f |
}
|
|
|
a3470f |
pthread_mutex_unlock (&pinode->mutex);
|
|
|
a3470f |
+
|
|
|
a3470f |
inode_unref (pinode->inode);
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
diff --git a/xlators/features/locks/src/inodelk.c b/xlators/features/locks/src/inodelk.c
|
|
|
a3470f |
index e1702c7..4aebac6 100644
|
|
|
a3470f |
--- a/xlators/features/locks/src/inodelk.c
|
|
|
a3470f |
+++ b/xlators/features/locks/src/inodelk.c
|
|
|
a3470f |
@@ -721,9 +721,6 @@ out:
|
|
|
a3470f |
if (ctx)
|
|
|
a3470f |
pthread_mutex_unlock (&ctx->lock);
|
|
|
a3470f |
|
|
|
a3470f |
- if (need_inode_unref)
|
|
|
a3470f |
- inode_unref (pl_inode->inode);
|
|
|
a3470f |
-
|
|
|
a3470f |
/* The following (extra) unref corresponds to the ref that
|
|
|
a3470f |
* was done at the time the lock was granted.
|
|
|
a3470f |
*/
|
|
|
a3470f |
@@ -732,6 +729,10 @@ out:
|
|
|
a3470f |
grant_blocked_inode_locks (this, pl_inode, dom);
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
+ if (need_inode_unref) {
|
|
|
a3470f |
+ inode_unref (pl_inode->inode);
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+
|
|
|
a3470f |
return ret;
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
|
|
|
a3470f |
index ff9a3da..a158227 100644
|
|
|
a3470f |
--- a/xlators/features/locks/src/posix.c
|
|
|
a3470f |
+++ b/xlators/features/locks/src/posix.c
|
|
|
a3470f |
@@ -2472,6 +2472,7 @@ pl_forget (xlator_t *this,
|
|
|
a3470f |
list) {
|
|
|
a3470f |
|
|
|
a3470f |
list_del (&rw_req->list);
|
|
|
a3470f |
+ call_stub_destroy(rw_req->stub);
|
|
|
a3470f |
GF_FREE (rw_req);
|
|
|
a3470f |
}
|
|
|
a3470f |
}
|
|
|
a3470f |
@@ -2555,6 +2556,8 @@ pl_forget (xlator_t *this,
|
|
|
a3470f |
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
+ pthread_mutex_destroy(&pl_inode->mutex);
|
|
|
a3470f |
+
|
|
|
a3470f |
GF_FREE (pl_inode);
|
|
|
a3470f |
|
|
|
a3470f |
return 0;
|
|
|
a3470f |
--
|
|
|
a3470f |
1.8.3.1
|
|
|
a3470f |
|