|
|
d1681e |
From 37897f0b72617e442e4799b35ebda94294218e05 Mon Sep 17 00:00:00 2001
|
|
|
d1681e |
From: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
d1681e |
Date: Wed, 28 Feb 2018 17:58:31 +0530
|
|
|
d1681e |
Subject: [PATCH 183/201] cluster/afr: Fix dict-leak in pre-op
|
|
|
d1681e |
|
|
|
d1681e |
At the time of pre-op, pre_op_xdata is populted with the xattrs we get from the
|
|
|
d1681e |
disk and at the time of post-op it gets over-written without unreffing the
|
|
|
d1681e |
previous value stored leading to a leak.
|
|
|
d1681e |
This is a regression we missed in
|
|
|
d1681e |
https://review.gluster.org/#/q/ba149bac92d169ae2256dbc75202dc9e5d06538e
|
|
|
d1681e |
|
|
|
d1681e |
>BUG: 1550078
|
|
|
d1681e |
>Change-Id: I0456f9ad6f77ce6248b747964a037193af3a3da7
|
|
|
d1681e |
>Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
d1681e |
>Upstream: https://review.gluster.org/19647
|
|
|
d1681e |
|
|
|
d1681e |
BUG: 1552360
|
|
|
d1681e |
Change-Id: I0456f9ad6f77ce6248b747964a037193af3a3da7
|
|
|
d1681e |
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
d1681e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/131936
|
|
|
d1681e |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
d1681e |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
d1681e |
---
|
|
|
d1681e |
xlators/cluster/afr/src/afr-common.c | 16 ++++++++--------
|
|
|
d1681e |
xlators/cluster/afr/src/afr-transaction.c | 20 ++++++++++----------
|
|
|
d1681e |
xlators/cluster/afr/src/afr.h | 4 ++--
|
|
|
d1681e |
3 files changed, 20 insertions(+), 20 deletions(-)
|
|
|
d1681e |
|
|
|
d1681e |
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
|
|
|
d1681e |
index 6e6f5fa..855e568 100644
|
|
|
d1681e |
--- a/xlators/cluster/afr/src/afr-common.c
|
|
|
d1681e |
+++ b/xlators/cluster/afr/src/afr-common.c
|
|
|
d1681e |
@@ -1039,7 +1039,7 @@ afr_readables_fill (call_frame_t *frame, xlator_t *this, inode_t *inode,
|
|
|
d1681e |
xdata = replies[i].xdata;
|
|
|
d1681e |
ia_type = replies[i].poststat.ia_type;
|
|
|
d1681e |
} else {/* pre-op xattrop */
|
|
|
d1681e |
- xdata = local->transaction.pre_op_xdata[i];
|
|
|
d1681e |
+ xdata = local->transaction.changelog_xdata[i];
|
|
|
d1681e |
ia_type = inode->ia_type;
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
@@ -1757,13 +1757,13 @@ afr_local_transaction_cleanup (afr_local_t *local, xlator_t *this)
|
|
|
d1681e |
GF_FREE (local->transaction.pre_op);
|
|
|
d1681e |
|
|
|
d1681e |
GF_FREE (local->transaction.pre_op_sources);
|
|
|
d1681e |
- if (local->transaction.pre_op_xdata) {
|
|
|
d1681e |
+ if (local->transaction.changelog_xdata) {
|
|
|
d1681e |
for (i = 0; i < priv->child_count; i++) {
|
|
|
d1681e |
- if (!local->transaction.pre_op_xdata[i])
|
|
|
d1681e |
+ if (!local->transaction.changelog_xdata[i])
|
|
|
d1681e |
continue;
|
|
|
d1681e |
- dict_unref (local->transaction.pre_op_xdata[i]);
|
|
|
d1681e |
+ dict_unref (local->transaction.changelog_xdata[i]);
|
|
|
d1681e |
}
|
|
|
d1681e |
- GF_FREE (local->transaction.pre_op_xdata);
|
|
|
d1681e |
+ GF_FREE (local->transaction.changelog_xdata);
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
GF_FREE (local->transaction.eager_lock);
|
|
|
d1681e |
@@ -5531,10 +5531,10 @@ afr_transaction_local_init (afr_local_t *local, xlator_t *this)
|
|
|
d1681e |
if (!local->transaction.pre_op)
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
|
|
|
d1681e |
- local->transaction.pre_op_xdata =
|
|
|
d1681e |
- GF_CALLOC (sizeof (*local->transaction.pre_op_xdata),
|
|
|
d1681e |
+ local->transaction.changelog_xdata =
|
|
|
d1681e |
+ GF_CALLOC (sizeof (*local->transaction.changelog_xdata),
|
|
|
d1681e |
priv->child_count, gf_afr_mt_dict_t);
|
|
|
d1681e |
- if (!local->transaction.pre_op_xdata)
|
|
|
d1681e |
+ if (!local->transaction.changelog_xdata)
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
|
|
|
d1681e |
if (priv->arbiter_count == 1) {
|
|
|
d1681e |
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
|
|
|
d1681e |
index 19740e1..97f9dd4 100644
|
|
|
d1681e |
--- a/xlators/cluster/afr/src/afr-transaction.c
|
|
|
d1681e |
+++ b/xlators/cluster/afr/src/afr-transaction.c
|
|
|
d1681e |
@@ -276,9 +276,9 @@ afr_compute_pre_op_sources (call_frame_t *frame, xlator_t *this)
|
|
|
d1681e |
matrix = ALLOC_MATRIX (priv->child_count, int);
|
|
|
d1681e |
|
|
|
d1681e |
for (i = 0; i < priv->child_count; i++) {
|
|
|
d1681e |
- if (!local->transaction.pre_op_xdata[i])
|
|
|
d1681e |
+ if (!local->transaction.changelog_xdata[i])
|
|
|
d1681e |
continue;
|
|
|
d1681e |
- xdata = local->transaction.pre_op_xdata[i];
|
|
|
d1681e |
+ xdata = local->transaction.changelog_xdata[i];
|
|
|
d1681e |
afr_selfheal_fill_matrix (this, matrix, i, idx, xdata);
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
@@ -295,13 +295,6 @@ afr_compute_pre_op_sources (call_frame_t *frame, xlator_t *this)
|
|
|
d1681e |
for (j = 0; j < priv->child_count; j++)
|
|
|
d1681e |
if (matrix[i][j] != 0)
|
|
|
d1681e |
local->transaction.pre_op_sources[j] = 0;
|
|
|
d1681e |
-
|
|
|
d1681e |
- /*We don't need the xattrs any more. */
|
|
|
d1681e |
- for (i = 0; i < priv->child_count; i++)
|
|
|
d1681e |
- if (local->transaction.pre_op_xdata[i]) {
|
|
|
d1681e |
- dict_unref (local->transaction.pre_op_xdata[i]);
|
|
|
d1681e |
- local->transaction.pre_op_xdata[i] = NULL;
|
|
|
d1681e |
- }
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
gf_boolean_t
|
|
|
d1681e |
@@ -1173,7 +1166,7 @@ afr_changelog_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
if (xattr)
|
|
|
d1681e |
- local->transaction.pre_op_xdata[child_index] = dict_ref (xattr);
|
|
|
d1681e |
+ local->transaction.changelog_xdata[child_index] = dict_ref (xattr);
|
|
|
d1681e |
|
|
|
d1681e |
call_count = afr_frame_return (frame);
|
|
|
d1681e |
|
|
|
d1681e |
@@ -1605,6 +1598,13 @@ afr_changelog_do (call_frame_t *frame, xlator_t *this, dict_t *xattr,
|
|
|
d1681e |
local = frame->local;
|
|
|
d1681e |
priv = this->private;
|
|
|
d1681e |
|
|
|
d1681e |
+ for (i = 0; i < priv->child_count; i++) {
|
|
|
d1681e |
+ if (local->transaction.changelog_xdata[i]) {
|
|
|
d1681e |
+ dict_unref (local->transaction.changelog_xdata[i]);
|
|
|
d1681e |
+ local->transaction.changelog_xdata[i] = NULL;
|
|
|
d1681e |
+ }
|
|
|
d1681e |
+ }
|
|
|
d1681e |
+
|
|
|
d1681e |
ret = afr_changelog_prepare (this, frame, &call_count, changelog_resume,
|
|
|
d1681e |
op, &xdata, &newloc_xdata);
|
|
|
d1681e |
|
|
|
d1681e |
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
|
|
|
d1681e |
index 96fefb1..c822221 100644
|
|
|
d1681e |
--- a/xlators/cluster/afr/src/afr.h
|
|
|
d1681e |
+++ b/xlators/cluster/afr/src/afr.h
|
|
|
d1681e |
@@ -748,8 +748,8 @@ typedef struct _afr_local {
|
|
|
d1681e |
|
|
|
d1681e |
unsigned char *pre_op;
|
|
|
d1681e |
|
|
|
d1681e |
- /* For arbiter configuration only. */
|
|
|
d1681e |
- dict_t **pre_op_xdata;
|
|
|
d1681e |
+ /* Changelog xattr dict for [f]xattrop*/
|
|
|
d1681e |
+ dict_t **changelog_xdata;
|
|
|
d1681e |
unsigned char *pre_op_sources;
|
|
|
d1681e |
|
|
|
d1681e |
/* @failed_subvols: subvolumes on which a pre-op or a
|
|
|
d1681e |
--
|
|
|
d1681e |
1.8.3.1
|
|
|
d1681e |
|