From 268bb635aca729a24242412c6f9dd9d5ba2a2654 Mon Sep 17 00:00:00 2001 From: N Balachandran Date: Wed, 30 Aug 2017 10:36:45 +0530 Subject: cluster/dht: Aggregate xattrs only for dirs in dht_discover_cbk If dht_discover finds data files on more than one subvol, racing calls to dht_discover_cbk could end up calling dht_aggregate_xattr which could delete dictionary data that is being accessed by higher layer translators. Fixed to call dht_aggregate_xattr only for directories and consider only the first file to be found. > BUG: 1484709 > Signed-off-by: N Balachandran > Reviewed-on: https://review.gluster.org/18137 > Smoke: Gluster Build System > CentOS-regression: Gluster Build System > Reviewed-by: Raghavendra G Change-Id: I4f3d2a405ec735d4f1bb33a04b7255eb2d179f8a BUG: 1486538 (cherry picked from commit 9420022df0962b1fa4f3ea3774249be81bc945cc) Signed-off-by: N Balachandran Reviewed-on: https://review.gluster.org/18146 Smoke: Gluster Build System Reviewed-by: Raghavendra G Reviewed-by: Amar Tumballi CentOS-regression: Gluster Build System --- xlators/cluster/dht/src/dht-common.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 9643caa0e17..b8a860d8049 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -639,6 +639,7 @@ dht_discover_cbk (call_frame_t *frame, void *cookie, xlator_t *this, else mkdir/chmod/chown and fix */ + ret = dht_layout_merge (this, layout, prev, op_ret, op_errno, xattr); if (ret) @@ -665,8 +666,14 @@ dht_discover_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } else { local->file_count ++; - if (!is_linkfile) { + if (!is_linkfile && !local->cached_subvol) { /* real file */ + /* Ok, we somehow managed to find a file on + * more than one subvol. ignore this or we + * will end up overwriting information while a + * a thread is potentially unwinding from + * dht_discover_complete + */ local->cached_subvol = prev; attempt_unwind = 1; } else { @@ -679,7 +686,9 @@ dht_discover_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (local->xattr == NULL) { local->xattr = dict_ref (xattr); } else { - dht_aggregate_xattr (local->xattr, xattr); + /* Don't aggregate for files. See BZ#1484113 */ + if (is_dir) + dht_aggregate_xattr (local->xattr, xattr); } if (local->inode == NULL) -- cgit