diff options
-rw-r--r-- | tests/bugs/bug-961615.t | 34 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-helper.c | 7 |
2 files changed, 36 insertions, 5 deletions
diff --git a/tests/bugs/bug-961615.t b/tests/bugs/bug-961615.t new file mode 100644 index 00000000000..d183e6c5276 --- /dev/null +++ b/tests/bugs/bug-961615.t @@ -0,0 +1,34 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +#This test tests that an extra fd_unref does not happen in rebalance +#migration completion check code path in dht + +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 +TEST $CLI volume set $V0 performance.quick-read off +TEST $CLI volume set $V0 performance.io-cache off +TEST $CLI volume set $V0 performance.write-behind off +TEST $CLI volume set $V0 performance.stat-prefetch off +TEST $CLI volume set $V0 performance.read-ahead off +TEST $CLI volume start $V0 +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0 +TEST touch $M0/1 +#This rename creates a link file for 10 in the other volume. +TEST mv $M0/1 $M0/10 +#Lets keep writing to the file which will trigger rebalance completion check +dd if=/dev/zero of=$M0/10 bs=1k & +bg_pid=$! +#Now rebalance force will migrate file '10' +TEST $CLI volume rebalance $V0 start force +EXPECT_WITHIN 60 "completed" rebalance_status_field $V0 +#If the bug exists mount would have crashed by now +TEST ls $M0 +kill -9 $bg_pid > /dev/null 2>&1 +wait > /dev/null 2>&1 +cleanup diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c index e91352c4ccb..52a24acc22a 100644 --- a/xlators/cluster/dht/src/dht-helper.c +++ b/xlators/cluster/dht/src/dht-helper.c @@ -802,13 +802,10 @@ dht_migration_complete_check_task (void *data) ret = 0; /* once we detect the migration complete, the fd-ctx is no more - required.. delete the ctx, and do one extra 'fd_unref' for open fd */ + required.. delete the ctx */ ret = fd_ctx_del (local->fd, this, NULL); - if (!ret) { - fd_unref (local->fd); - ret = 0; + if (!ret) goto out; - } /* perform open as root:root. There is window between linkfile * creation(root:root) and setattr with the correct uid/gid |