diff options
| -rw-r--r-- | tests/basic/tier/legacy-many.t | 19 | ||||
| -rwxr-xr-x | tests/basic/tier/tier.t | 17 | ||||
| -rw-r--r-- | tests/tier.rc | 13 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/tier.c | 12 | 
4 files changed, 39 insertions, 22 deletions
diff --git a/tests/basic/tier/legacy-many.t b/tests/basic/tier/legacy-many.t index 2c7ff3e5407..6e1147aec2d 100644 --- a/tests/basic/tier/legacy-many.t +++ b/tests/basic/tier/legacy-many.t @@ -9,13 +9,12 @@ LAST_BRICK=3  CACHE_BRICK_FIRST=4  CACHE_BRICK_LAST=5  DEMOTE_TIMEOUT=12 -PROMOTE_TIMEOUT=5 +PROMOTE_TIMEOUT=12  MIGRATION_TIMEOUT=10  DEMOTE_FREQ=60 -PROMOTE_FREQ=4 +PROMOTE_FREQ=10  TEST_DIR="test_files" -NUM_FILES=20 - +NUM_FILES=15  function read_all {      for file in * @@ -49,19 +48,25 @@ wait  TEST $CLI volume attach-tier $V0 replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST  TEST $CLI volume rebalance $V0 tier status +  TEST $CLI volume set $V0 cluster.tier-demote-frequency $DEMOTE_FREQ  TEST $CLI volume set $V0 cluster.tier-promote-frequency $PROMOTE_FREQ  TEST $CLI volume set $V0 cluster.read-freq-threshold 0  TEST $CLI volume set $V0 cluster.write-freq-threshold 0 +# wait a little for lookup heal to finish +sleep 10 +  # Read "legacy" files  drop_cache $M0 -cd ${TEST_DIR} + +sleep_until_mid_cycle $DEMOTE_FREQ +  TEST read_all  # Test to make sure files were promoted as expected -sleep $DEMOTE_TIMEOUT -EXPECT_WITHIN $DEMOTE_TIMEOUT "0" check_counters $NUM_FILES 0 +sleep $PROMOTE_TIMEOUT +EXPECT_WITHIN $PROMOTE_TIMEOUT "0" check_counters $NUM_FILES 0  cd;  cleanup diff --git a/tests/basic/tier/tier.t b/tests/basic/tier/tier.t index f38aa898c11..a197d6eb127 100755 --- a/tests/basic/tier/tier.t +++ b/tests/basic/tier/tier.t @@ -11,15 +11,7 @@ DEMOTE_TIMEOUT=12  PROMOTE_TIMEOUT=5  MIGRATION_TIMEOUT=10  DEMOTE_FREQ=4 -PROMOTE_FREQ=4 - - -# Timing adjustment to avoid spurious errors with first instances of file_on_fast_tier -function sleep_first_cycle { -    startTime=$(date +%s) -    mod=$(( ( $startTime % $DEMOTE_FREQ ) + 1 )) -    sleep $mod -} +PROMOTE_FREQ=12  function file_on_slow_tier { @@ -127,7 +119,7 @@ TEST $CLI volume start $V0  TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0;  cd $M0 -sleep_first_cycle +sleep_first_cycle $DEMOTE_FREQ  $CLI volume tier $V0 status  #Tier options expect non-negative value @@ -176,10 +168,11 @@ sleep $DEMOTE_TIMEOUT  UUID=$(uuidgen)  echo $UUID >> /tmp/d1/data2.txt  md5data2=$(fingerprint /tmp/d1/data2.txt) -echo $UUID >> ./d1/data2.txt -# Check promotion on read to slow tier +sleep_until_mid_cycle $DEMOTE_FREQ  drop_cache $M0 + +echo $UUID >> ./d1/data2.txt  cat "./d1/$SPACE_FILE"  sleep $PROMOTE_TIMEOUT diff --git a/tests/tier.rc b/tests/tier.rc index 3fa6af6a40f..4fd24de0659 100644 --- a/tests/tier.rc +++ b/tests/tier.rc @@ -99,3 +99,16 @@ function confirm_vol_stopped {      fi  } + +function sleep_first_cycle { +    startTime=$(date +%s) +    mod=$(( ( $startTime % $1 ) + 1 )) +    sleep $mod +} + +function sleep_until_mid_cycle { +    startTime=$(date +%s) +    mod=$(( ( $startTime % $1 ) + 1 )) +    mod=$(( $mod + $1 / 2 )) +    sleep $mod +} diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c index 51642e48970..b37c8edfdd5 100644 --- a/xlators/cluster/dht/src/tier.c +++ b/xlators/cluster/dht/src/tier.c @@ -28,7 +28,6 @@ static void *libhandle;  static gfdb_methods_t gfdb_methods;  #define DB_QUERY_RECORD_SIZE 4096 -#define  PROMOTION_CYCLE_CNT 4  static int @@ -1025,7 +1024,14 @@ tier_build_migration_qfile (demotion_args_t *args,                  goto out;          }          time_in_past.tv_sec = current_time.tv_sec - time_in_past.tv_sec; -        time_in_past.tv_usec = current_time.tv_usec - time_in_past.tv_usec; + +        /* The migration daemon may run a varrying numberof usec after the sleep */ +        /* call triggers. A file may be registered in CTR some number of usec X */ +        /* after the daemon started and missed in the subsequent cycle if the */ +        /* daemon starts Y usec after the period in seconds where Y>X. Normalize */ +        /* away this problem by always setting usec to 0. */ +        time_in_past.tv_usec = 0; +          gfdb_brick_info.time_stamp = &time_in_past;          gfdb_brick_info._gfdb_promote = is_promotion;          gfdb_brick_info._query_cbk_args = query_cbk_args; @@ -1439,7 +1445,7 @@ tier_start (xlator_t *this, gf_defrag_info_t *defrag)                          promotion_args.this = this;                          promotion_args.brick_list = &bricklist_cold;                          promotion_args.defrag = defrag; -                        promotion_args.freq_time = freq_promote *  PROMOTION_CYCLE_CNT; +                        promotion_args.freq_time = freq_promote;                          ret_promotion = pthread_create (&promote_thread,                                                  NULL, &tier_promote,                                                  &promotion_args);  | 
