summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-transaction.c
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2018-02-28 17:58:31 +0530
committerPranith Kumar K <pkarampu@redhat.com>2018-02-28 18:53:59 +0530
commite7b79c59590c203c65f7ac8548b30d068c232d33 (patch)
tree8831e942399bd33da6cbff53a7e21c9b1fb6202a /xlators/cluster/afr/src/afr-transaction.c
parente2766c32631d27519e688ebec48c408b36e3cc79 (diff)
cluster/afr: Fix dict-leak in pre-op
At the time of pre-op, pre_op_xdata is populted with the xattrs we get from the disk and at the time of post-op it gets over-written without unreffing the previous value stored leading to a leak. This is a regression we missed in https://review.gluster.org/#/q/ba149bac92d169ae2256dbc75202dc9e5d06538e BUG: 1550078 Change-Id: I0456f9ad6f77ce6248b747964a037193af3a3da7 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-transaction.c')
-rw-r--r--xlators/cluster/afr/src/afr-transaction.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
index 3e5326b7753..1f4ba71d5f8 100644
--- a/xlators/cluster/afr/src/afr-transaction.c
+++ b/xlators/cluster/afr/src/afr-transaction.c
@@ -276,9 +276,9 @@ afr_compute_pre_op_sources (call_frame_t *frame, xlator_t *this)
matrix = ALLOC_MATRIX (priv->child_count, int);
for (i = 0; i < priv->child_count; i++) {
- if (!local->transaction.pre_op_xdata[i])
+ if (!local->transaction.changelog_xdata[i])
continue;
- xdata = local->transaction.pre_op_xdata[i];
+ xdata = local->transaction.changelog_xdata[i];
afr_selfheal_fill_matrix (this, matrix, i, idx, xdata);
}
@@ -295,13 +295,6 @@ afr_compute_pre_op_sources (call_frame_t *frame, xlator_t *this)
for (j = 0; j < priv->child_count; j++)
if (matrix[i][j] != 0)
local->transaction.pre_op_sources[j] = 0;
-
- /*We don't need the xattrs any more. */
- for (i = 0; i < priv->child_count; i++)
- if (local->transaction.pre_op_xdata[i]) {
- dict_unref (local->transaction.pre_op_xdata[i]);
- local->transaction.pre_op_xdata[i] = NULL;
- }
}
gf_boolean_t
@@ -1173,7 +1166,7 @@ afr_changelog_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
if (xattr)
- local->transaction.pre_op_xdata[child_index] = dict_ref (xattr);
+ local->transaction.changelog_xdata[child_index] = dict_ref (xattr);
call_count = afr_frame_return (frame);
@@ -1603,6 +1596,13 @@ afr_changelog_do (call_frame_t *frame, xlator_t *this, dict_t *xattr,
local = frame->local;
priv = this->private;
+ for (i = 0; i < priv->child_count; i++) {
+ if (local->transaction.changelog_xdata[i]) {
+ dict_unref (local->transaction.changelog_xdata[i]);
+ local->transaction.changelog_xdata[i] = NULL;
+ }
+ }
+
ret = afr_changelog_prepare (this, frame, &call_count, changelog_resume,
op, &xdata, &newloc_xdata);