50dc83
From 06adac5dbac7b2067232270cbee12931400f7824 Mon Sep 17 00:00:00 2001
50dc83
From: Hari Gowtham <hgowtham@redhat.com>
50dc83
Date: Sat, 6 Apr 2019 17:00:47 +0530
50dc83
Subject: [PATCH 086/124] Revert "tiering: remove the translator from build and
50dc83
 glusterd"
50dc83
50dc83
This reverts commit 55a6ba56bea9ec0d3316c005300c514ea3ab0e54.
50dc83
Add the test files and glusterd related changes.
50dc83
50dc83
Label: DOWNSTREAM ONLY
50dc83
50dc83
Change-Id: Ib704b7142a82cb1e94538a48af916730992a5701
50dc83
Signed-off-by: Hari Gowtham <hgowtham@redhat.com>
50dc83
Reviewed-on: https://code.engineering.redhat.com/gerrit/166246
50dc83
Reviewed-by: Sanju Rakonde <srakonde@redhat.com>
50dc83
Reviewed-by: Nithya Balachandran <nbalacha@redhat.com>
50dc83
Tested-by: RHGS Build Bot <nigelb@redhat.com>
50dc83
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
50dc83
---
50dc83
 MAINTAINERS                                        |  18 +
50dc83
 tests/basic/afr/granular-esh/cli.t                 |  30 +-
50dc83
 ...1214222-directories_missing_after_attach_tier.t |  61 ++
50dc83
 ...60185-donot-allow-detach-commit-unnecessarily.t |  47 ++
50dc83
 tests/basic/tier/ctr-rename-overwrite.t            |  50 ++
50dc83
 tests/basic/tier/file_lock.c                       |  72 ++
50dc83
 tests/basic/tier/file_with_spaces.t                |  71 ++
50dc83
 tests/basic/tier/fops-during-migration-pause.t     |  89 +++
50dc83
 tests/basic/tier/fops-during-migration.t           | 105 +++
50dc83
 tests/basic/tier/frequency-counters.t              |  82 +++
50dc83
 tests/basic/tier/legacy-many.t                     |  92 +++
50dc83
 tests/basic/tier/locked_file_migration.t           |  80 +++
50dc83
 tests/basic/tier/new-tier-cmds.t                   | 129 ++++
50dc83
 tests/basic/tier/readdir-during-migration.t        |  65 ++
50dc83
 tests/basic/tier/record-metadata-heat.t            | 106 +++
50dc83
 tests/basic/tier/tier-heald.t                      |  98 +++
50dc83
 tests/basic/tier/tier-snapshot.t                   |  47 ++
50dc83
 tests/basic/tier/tier.t                            | 219 +++++++
50dc83
 tests/basic/tier/tier_lookup_heal.t                |  69 ++
50dc83
 tests/basic/tier/tierd_check.t                     | 128 ++++
50dc83
 tests/basic/tier/unlink-during-migration.t         |  92 +++
50dc83
 ...03028-Rebalance-glusterd-rpc-connection-issue.t |  78 +++
50dc83
 tests/bugs/quota/bug-1288474.t                     |  51 ++
50dc83
 .../bug-1290965-detect-bitrotten-objects.t         |  53 ++
50dc83
 .../tier/bug-1205545-CTR-and-trash-integration.t   |  72 ++
50dc83
 tests/bugs/tier/bug-1279376-rename-demoted-file.t  |  93 +++
50dc83
 xlators/mgmt/glusterd/src/glusterd-volgen.c        |  75 +++
50dc83
 xlators/mgmt/glusterd/src/glusterd-volume-set.c    | 723 +++++++++++++++++++++
50dc83
 28 files changed, 2894 insertions(+), 1 deletion(-)
50dc83
 create mode 100755 tests/basic/tier/bug-1214222-directories_missing_after_attach_tier.t
50dc83
 create mode 100644 tests/basic/tier/bug-1260185-donot-allow-detach-commit-unnecessarily.t
50dc83
 create mode 100755 tests/basic/tier/ctr-rename-overwrite.t
50dc83
 create mode 100644 tests/basic/tier/file_lock.c
50dc83
 create mode 100755 tests/basic/tier/file_with_spaces.t
50dc83
 create mode 100755 tests/basic/tier/fops-during-migration-pause.t
50dc83
 create mode 100755 tests/basic/tier/fops-during-migration.t
50dc83
 create mode 100644 tests/basic/tier/frequency-counters.t
50dc83
 create mode 100644 tests/basic/tier/legacy-many.t
50dc83
 create mode 100755 tests/basic/tier/locked_file_migration.t
50dc83
 create mode 100644 tests/basic/tier/new-tier-cmds.t
50dc83
 create mode 100644 tests/basic/tier/readdir-during-migration.t
50dc83
 create mode 100755 tests/basic/tier/record-metadata-heat.t
50dc83
 create mode 100644 tests/basic/tier/tier-heald.t
50dc83
 create mode 100644 tests/basic/tier/tier-snapshot.t
50dc83
 create mode 100755 tests/basic/tier/tier.t
50dc83
 create mode 100755 tests/basic/tier/tier_lookup_heal.t
50dc83
 create mode 100644 tests/basic/tier/tierd_check.t
50dc83
 create mode 100755 tests/basic/tier/unlink-during-migration.t
50dc83
 create mode 100644 tests/bugs/glusterd/bug-1303028-Rebalance-glusterd-rpc-connection-issue.t
50dc83
 create mode 100755 tests/bugs/quota/bug-1288474.t
50dc83
 create mode 100644 tests/bugs/replicate/bug-1290965-detect-bitrotten-objects.t
50dc83
 create mode 100644 tests/bugs/tier/bug-1205545-CTR-and-trash-integration.t
50dc83
 create mode 100755 tests/bugs/tier/bug-1279376-rename-demoted-file.t
50dc83
50dc83
diff --git a/MAINTAINERS b/MAINTAINERS
50dc83
index b1fc0ee..1f4c93a 100644
50dc83
--- a/MAINTAINERS
50dc83
+++ b/MAINTAINERS
50dc83
@@ -103,6 +103,12 @@ P: Kotresh HR <khiremat@redhat.com>
50dc83
 S: Maintained
50dc83
 F: xlators/features/changelog/
50dc83
 
50dc83
+Changetimerecorder
50dc83
+M: Shyamsundar Ranganathan <srangana@redhat.com>
50dc83
+P: Hari Gowtham <hgowtham@redhat.com>
50dc83
+S: Maintained
50dc83
+F: xlators/features/changetimerecorder/
50dc83
+
50dc83
 Decompounder
50dc83
 M: Krutika Dhananjay <kdhananj@redhat.com>
50dc83
 P: Pranith Karampuri <pkarampu@redhat.com>
50dc83
@@ -248,6 +254,12 @@ P: Xavier Hernandez  <xhernandez@redhat.com>
50dc83
 S: Maintained
50dc83
 F: xlators/features/shard/
50dc83
 
50dc83
+Tiering
50dc83
+M: Shyamsundar Ranganathan <srangana@redhat.com>
50dc83
+P: Hari Gowtham <hgowtham@redhat.com>
50dc83
+S: Maintained
50dc83
+F: xlators/cluster/dht/src/tier.c
50dc83
+
50dc83
 Trash
50dc83
 M: Anoop C S <anoopcs@redhat.com>
50dc83
 M: Jiffin Tony Thottan <jthottan@redhat.com>
50dc83
@@ -327,6 +339,12 @@ P: Soumya Koduri <skoduri@redhat.com>
50dc83
 S: Maintained
50dc83
 F: api/
50dc83
 
50dc83
+libgfdb
50dc83
+M: Shyamsundar Ranganathan <srangana@redhat.com>
50dc83
+P: Hari Gowtham <hgowtham@redhat.com>
50dc83
+S: Maintained
50dc83
+F: libglusterfs/src/gfdb/
50dc83
+
50dc83
 libglusterfs
50dc83
 M: Amar Tumballi <amarts@redhat.com>
50dc83
 M: Jeff Darcy <jeff@pl.atyp.us>
50dc83
diff --git a/tests/basic/afr/granular-esh/cli.t b/tests/basic/afr/granular-esh/cli.t
50dc83
index 10b6c63..995d93e 100644
50dc83
--- a/tests/basic/afr/granular-esh/cli.t
50dc83
+++ b/tests/basic/afr/granular-esh/cli.t
50dc83
@@ -11,7 +11,7 @@ TESTS_EXPECTED_IN_LOOP=4
50dc83
 TEST glusterd
50dc83
 TEST pidof glusterd
50dc83
 
50dc83
-TEST   $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2}
50dc83
+TEST   $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1}
50dc83
 # Test that enabling the option should work on a newly created volume
50dc83
 TEST   $CLI volume set $V0 cluster.granular-entry-heal on
50dc83
 TEST   $CLI volume set $V0 cluster.granular-entry-heal off
50dc83
@@ -25,6 +25,34 @@ TEST $CLI volume start $V1
50dc83
 TEST ! $CLI volume heal $V1 granular-entry-heal enable
50dc83
 TEST ! $CLI volume heal $V1 granular-entry-heal disable
50dc83
 
50dc83
+#######################
50dc83
+###### TIER TEST ######
50dc83
+#######################
50dc83
+# Execute the same command on a disperse + replicate tiered volume and make
50dc83
+# sure the option is set on the replicate leg of the volume
50dc83
+TEST $CLI volume tier $V1 attach replica 2 $H0:$B0/${V1}{3,4}
50dc83
+TEST $CLI volume heal $V1 granular-entry-heal enable
50dc83
+EXPECT "enable" volume_get_field $V1 cluster.granular-entry-heal
50dc83
+TEST $CLI volume heal $V1 granular-entry-heal disable
50dc83
+EXPECT "disable" volume_get_field $V1 cluster.granular-entry-heal
50dc83
+
50dc83
+# Kill a disperse brick and make heal be pending on the volume.
50dc83
+TEST kill_brick $V1 $H0 $B0/${V1}0
50dc83
+
50dc83
+# Now make sure that one offline brick in disperse does not affect enabling the
50dc83
+# option on the volume.
50dc83
+TEST $CLI volume heal $V1 granular-entry-heal enable
50dc83
+EXPECT "enable" volume_get_field $V1 cluster.granular-entry-heal
50dc83
+TEST $CLI volume heal $V1 granular-entry-heal disable
50dc83
+EXPECT "disable" volume_get_field $V1 cluster.granular-entry-heal
50dc83
+
50dc83
+# Now kill a replicate brick.
50dc83
+TEST kill_brick $V1 $H0 $B0/${V1}3
50dc83
+# Now make sure that one offline brick in replicate causes the command to be
50dc83
+# failed.
50dc83
+TEST ! $CLI volume heal $V1 granular-entry-heal enable
50dc83
+EXPECT "disable" volume_get_field $V1 cluster.granular-entry-heal
50dc83
+
50dc83
 ######################
50dc83
 ### REPLICATE TEST ###
50dc83
 ######################
50dc83
diff --git a/tests/basic/tier/bug-1214222-directories_missing_after_attach_tier.t b/tests/basic/tier/bug-1214222-directories_missing_after_attach_tier.t
50dc83
new file mode 100755
50dc83
index 0000000..f9166d7
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/bug-1214222-directories_missing_after_attach_tier.t
50dc83
@@ -0,0 +1,61 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+
50dc83
+LAST_BRICK=3
50dc83
+CACHE_BRICK_FIRST=4
50dc83
+CACHE_BRICK_LAST=5
50dc83
+DEMOTE_TIMEOUT=12
50dc83
+PROMOTE_TIMEOUT=5
50dc83
+
50dc83
+
50dc83
+LAST_BRICK=1
50dc83
+CACHE_BRICK=2
50dc83
+DEMOTE_TIMEOUT=12
50dc83
+PROMOTE_TIMEOUT=5
50dc83
+MIGRATION_TIMEOUT=10
50dc83
+cleanup
50dc83
+
50dc83
+
50dc83
+TEST glusterd
50dc83
+
50dc83
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0..$LAST_BRICK}
50dc83
+TEST $CLI volume start $V0
50dc83
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0;
50dc83
+
50dc83
+# Basic operations.
50dc83
+cd $M0
50dc83
+TEST stat .
50dc83
+TEST mkdir d1
50dc83
+TEST [ -d d1 ]
50dc83
+TEST touch file1
50dc83
+TEST [ -e file1 ]
50dc83
+
50dc83
+TEST $CLI volume tier $V0 attach replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
50dc83
+TEST $CLI volume set $V0 features.ctr-enabled on
50dc83
+
50dc83
+#check whether the directory's and files are present on mount or not.
50dc83
+TEST [ -d d1 ]
50dc83
+TEST [ -e file1 ]
50dc83
+
50dc83
+cd
50dc83
+EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0;
50dc83
+
50dc83
+tier_status ()
50dc83
+{
50dc83
+	$CLI volume tier $V0 detach status | grep progress | wc -l
50dc83
+}
50dc83
+
50dc83
+TEST $CLI volume tier $V0 detach start
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" tier_status
50dc83
+TEST $CLI volume tier $V0 detach commit
50dc83
+
50dc83
+EXPECT "0" confirm_tier_removed ${V0}${CACHE_BRICK_FIRST}
50dc83
+
50dc83
+EXPECT_WITHIN $REBALANCE_TIMEOUT "0" confirm_vol_stopped $V0
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=BAD_TEST,BUG=000000
50dc83
diff --git a/tests/basic/tier/bug-1260185-donot-allow-detach-commit-unnecessarily.t b/tests/basic/tier/bug-1260185-donot-allow-detach-commit-unnecessarily.t
50dc83
new file mode 100644
50dc83
index 0000000..6efbe32
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/bug-1260185-donot-allow-detach-commit-unnecessarily.t
50dc83
@@ -0,0 +1,47 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+## Test case for BZ: 1260185
50dc83
+## Do not allow detach-tier commit without "force" option or without
50dc83
+## user have not started "detach-tier start" operation
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../cluster.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+## Start glusterd
50dc83
+TEST glusterd;
50dc83
+TEST pidof glusterd;
50dc83
+
50dc83
+## Lets create and start the volume
50dc83
+TEST $CLI volume create $V0 $H0:$B0/${V0}{1..2}
50dc83
+TEST $CLI volume start $V0
50dc83
+
50dc83
+## Perform attach-tier operation on volume $V0
50dc83
+TEST $CLI volume tier $V0 attach $H0:$B0/${V0}{3..4}
50dc83
+
50dc83
+## detach-tier commit operation without force option on volume $V0
50dc83
+## should not succeed
50dc83
+TEST ! $CLI --mode=script volume tier $V0 detach commit
50dc83
+
50dc83
+## detach-tier commit operation with force option on volume $V0
50dc83
+## should succeed
50dc83
+TEST  $CLI volume tier $V0 detach force
50dc83
+
50dc83
+sleep 3
50dc83
+
50dc83
+## Again performing attach-tier operation on volume $V0
50dc83
+TEST $CLI volume tier $V0 attach $H0:$B0/${V0}{5..6}
50dc83
+
50dc83
+## Do detach-tier start on volume $V0
50dc83
+TEST $CLI volume tier $V0 detach start
50dc83
+
50dc83
+## Now detach-tier commit on volume $V0 should succeed.
50dc83
+## wait for the detach to complete
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" tier_detach_commit_for_single_node
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=KNOWN_ISSUE,BUG=1517961
50dc83
diff --git a/tests/basic/tier/ctr-rename-overwrite.t b/tests/basic/tier/ctr-rename-overwrite.t
50dc83
new file mode 100755
50dc83
index 0000000..73ee758
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/ctr-rename-overwrite.t
50dc83
@@ -0,0 +1,50 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+
50dc83
+LAST_BRICK=1
50dc83
+CACHE_BRICK_FIRST=4
50dc83
+CACHE_BRICK_LAST=5
50dc83
+
50dc83
+DEMOTE_FREQ=5
50dc83
+PROMOTE_FREQ=5
50dc83
+
50dc83
+cleanup
50dc83
+
50dc83
+# Start glusterd
50dc83
+TEST glusterd
50dc83
+TEST pidof glusterd
50dc83
+
50dc83
+# Set-up tier cluster
50dc83
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0..$LAST_BRICK}
50dc83
+TEST $CLI volume start $V0
50dc83
+TEST $CLI volume tier $V0 attach replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
50dc83
+
50dc83
+TEST $CLI volume set $V0 cluster.tier-demote-frequency $DEMOTE_FREQ
50dc83
+TEST $CLI volume set $V0 cluster.tier-promote-frequency $PROMOTE_FREQ
50dc83
+
50dc83
+# Start and mount the volume after enabling CTR
50dc83
+TEST $CLI volume set $V0 features.ctr-enabled on
50dc83
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0;
50dc83
+
50dc83
+# create two files
50dc83
+echo "hello world" > $M0/file1
50dc83
+echo "hello world" > $M0/file2
50dc83
+
50dc83
+# db in hot brick shows 4 record. 2 for file1 and 2 for file2
50dc83
+ENTRY_COUNT=$(echo "select * from gf_file_tb; select * from gf_flink_tb;" | \
50dc83
+        sqlite3 $B0/${V0}5/.glusterfs/${V0}5.db | wc -l )
50dc83
+TEST [ $ENTRY_COUNT -eq 4 ]
50dc83
+
50dc83
+#overwrite file2 with file1
50dc83
+mv -f $M0/file1 $M0/file2
50dc83
+
50dc83
+# Now the db in hot tier should have only 2 records for file1.
50dc83
+ENTRY_COUNT=$(echo "select * from gf_file_tb; select * from gf_flink_tb;" | \
50dc83
+        sqlite3 $B0/${V0}5/.glusterfs/${V0}5.db | wc -l )
50dc83
+TEST [ $ENTRY_COUNT -eq 2 ]
50dc83
+
50dc83
+cleanup
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=KNOWN_ISSUE,BUG=000000
50dc83
diff --git a/tests/basic/tier/file_lock.c b/tests/basic/tier/file_lock.c
50dc83
new file mode 100644
50dc83
index 0000000..20fdbc0
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/file_lock.c
50dc83
@@ -0,0 +1,72 @@
50dc83
+#include <stdio.h>
50dc83
+#include <stdlib.h>
50dc83
+#include <unistd.h>
50dc83
+#include <fcntl.h>
50dc83
+
50dc83
+void
50dc83
+usage(void)
50dc83
+{
50dc83
+    printf("Usage: testlock <filepath> [R|W]\n");
50dc83
+    return;
50dc83
+}
50dc83
+
50dc83
+int
50dc83
+main(int argc, char *argv[])
50dc83
+{
50dc83
+    char *file_path = NULL;
50dc83
+    int fd = -1;
50dc83
+    struct flock lock = {0};
50dc83
+    int ret = -1;
50dc83
+    int c = 0;
50dc83
+
50dc83
+    if (argc != 3) {
50dc83
+        usage();
50dc83
+        exit(1);
50dc83
+    }
50dc83
+
50dc83
+    file_path = argv[1];
50dc83
+    fd = open(file_path, O_RDWR);
50dc83
+
50dc83
+    if (-1 == fd) {
50dc83
+        printf("Failed to open file %s. %m\n", file_path);
50dc83
+        exit(1);
50dc83
+    }
50dc83
+
50dc83
+    /* TODO: Check for invalid input*/
50dc83
+
50dc83
+    if (!strcmp(argv[2], "W")) {
50dc83
+        lock.l_type = F_WRLCK;
50dc83
+        printf("Taking write lock\n");
50dc83
+
50dc83
+    } else {
50dc83
+        lock.l_type = F_RDLCK;
50dc83
+        printf("Taking read lock\n");
50dc83
+    }
50dc83
+
50dc83
+    lock.l_whence = SEEK_SET;
50dc83
+    lock.l_start = 0;
50dc83
+    lock.l_len = 0;
50dc83
+    lock.l_pid = getpid();
50dc83
+
50dc83
+    printf("Acquiring lock on %s\n", file_path);
50dc83
+    ret = fcntl(fd, F_SETLK, &lock);
50dc83
+    if (ret) {
50dc83
+        printf("Failed to acquire lock on %s (%m)\n", file_path);
50dc83
+        close(fd);
50dc83
+        exit(1);
50dc83
+    }
50dc83
+
50dc83
+    sleep(10);
50dc83
+
50dc83
+    /*Unlock*/
50dc83
+
50dc83
+    printf("Releasing lock on %s\n", file_path);
50dc83
+    lock.l_type = F_UNLCK;
50dc83
+    ret = fcntl(fd, F_SETLK, &lock);
50dc83
+    if (ret) {
50dc83
+        printf("Failed to release lock on %s (%m)\n", file_path);
50dc83
+    }
50dc83
+
50dc83
+    close(fd);
50dc83
+    return ret;
50dc83
+}
50dc83
diff --git a/tests/basic/tier/file_with_spaces.t b/tests/basic/tier/file_with_spaces.t
50dc83
new file mode 100755
50dc83
index 0000000..919b900
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/file_with_spaces.t
50dc83
@@ -0,0 +1,71 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+
50dc83
+NUM_BRICKS=3
50dc83
+DEMOTE_FREQ=5
50dc83
+DEMOTE_TIMEOUT=10
50dc83
+PROMOTE_FREQ=5
50dc83
+
50dc83
+FILE_SPACE="Testing filenames with spaces.log"
50dc83
+
50dc83
+
50dc83
+# Creates a tiered volume with pure distribute hot and cold tiers
50dc83
+# Both hot and cold tiers will have an equal number of bricks.
50dc83
+
50dc83
+function create_dist_tier_vol () {
50dc83
+        mkdir $B0/cold
50dc83
+        mkdir $B0/hot
50dc83
+        TEST $CLI volume create $V0 $H0:$B0/cold/${V0}{0..$1}
50dc83
+        TEST $CLI volume set $V0 performance.quick-read off
50dc83
+        TEST $CLI volume set $V0 performance.io-cache off
50dc83
+        TEST $CLI volume set $V0 features.ctr-enabled on
50dc83
+        TEST $CLI volume start $V0
50dc83
+        TEST $CLI volume tier $V0 attach $H0:$B0/hot/${V0}{0..$1}
50dc83
+        TEST $CLI volume set $V0 cluster.tier-demote-frequency $DEMOTE_FREQ
50dc83
+        TEST $CLI volume set $V0 cluster.tier-promote-frequency $PROMOTE_FREQ
50dc83
+        TEST $CLI volume set $V0 cluster.read-freq-threshold 0
50dc83
+        TEST $CLI volume set $V0 cluster.write-freq-threshold 0
50dc83
+        TEST $CLI volume set $V0 cluster.tier-mode test
50dc83
+}
50dc83
+
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#Basic checks
50dc83
+TEST glusterd
50dc83
+TEST pidof glusterd
50dc83
+TEST $CLI volume info
50dc83
+
50dc83
+
50dc83
+#Create and start a tiered volume
50dc83
+create_dist_tier_vol $NUM_BRICKS
50dc83
+
50dc83
+# Mount FUSE
50dc83
+TEST glusterfs -s $H0 --volfile-id $V0 $M0
50dc83
+
50dc83
+
50dc83
+# The file will be created on the hot tier
50dc83
+
50dc83
+touch "$M0/$FILE_SPACE"
50dc83
+
50dc83
+# Get the path of the file on the hot tier
50dc83
+HPATH=`find $B0/hot/ -name  "$FILE_SPACE"`
50dc83
+echo "File path on hot tier: "$HPATH
50dc83
+
50dc83
+EXPECT "yes" exists_and_regular_file $HPATH
50dc83
+
50dc83
+# Wait for the tier process to demote the file
50dc83
+sleep $DEMOTE_TIMEOUT
50dc83
+
50dc83
+# Get the path of the file on the cold tier
50dc83
+CPATH=`find $B0/cold/ -name  "$FILE_SPACE"`
50dc83
+echo "File path on cold tier: "$CPATH
50dc83
+
50dc83
+EXPECT "yes" exists_and_regular_file $CPATH
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=KNOWN_ISSUE,BUG=000000
50dc83
diff --git a/tests/basic/tier/fops-during-migration-pause.t b/tests/basic/tier/fops-during-migration-pause.t
50dc83
new file mode 100755
50dc83
index 0000000..46fc6e4
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/fops-during-migration-pause.t
50dc83
@@ -0,0 +1,89 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+
50dc83
+NUM_BRICKS=3
50dc83
+DEMOTE_FREQ=10
50dc83
+PROMOTE_FREQ=10
50dc83
+
50dc83
+TEST_STR="Testing write and truncate fops on tier migration"
50dc83
+
50dc83
+function is_sticky_set () {
50dc83
+        echo $1
50dc83
+        if [ -k $1 ];
50dc83
+        then
50dc83
+                echo "yes"
50dc83
+        else
50dc83
+                echo "no"
50dc83
+        fi
50dc83
+}
50dc83
+
50dc83
+
50dc83
+# Creates a tiered volume with pure distribute hot and cold tiers
50dc83
+# Both hot and cold tiers will have an equal number of bricks.
50dc83
+
50dc83
+function create_dist_tier_vol () {
50dc83
+        mkdir $B0/cold
50dc83
+        mkdir $B0/hot
50dc83
+        TEST $CLI volume create $V0 $H0:$B0/cold/${V0}{0..$1}
50dc83
+        TEST $CLI volume set $V0 performance.quick-read off
50dc83
+        TEST $CLI volume set $V0 performance.io-cache off
50dc83
+        TEST $CLI volume set $V0 features.ctr-enabled on
50dc83
+        TEST $CLI volume start $V0
50dc83
+        TEST $CLI volume tier $V0 attach $H0:$B0/hot/${V0}{0..$1}
50dc83
+        TEST $CLI volume set $V0 cluster.tier-demote-frequency $DEMOTE_FREQ
50dc83
+        TEST $CLI volume set $V0 cluster.tier-promote-frequency $PROMOTE_FREQ
50dc83
+        TEST $CLI volume set $V0 cluster.read-freq-threshold 0
50dc83
+        TEST $CLI volume set $V0 cluster.write-freq-threshold 0
50dc83
+        TEST $CLI volume set $V0 cluster.tier-mode test
50dc83
+}
50dc83
+
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#Basic checks
50dc83
+TEST glusterd
50dc83
+TEST pidof glusterd
50dc83
+TEST $CLI volume info
50dc83
+
50dc83
+
50dc83
+#Create and start a tiered volume
50dc83
+create_dist_tier_vol $NUM_BRICKS
50dc83
+
50dc83
+# Mount FUSE
50dc83
+TEST glusterfs -s $H0 --volfile-id $V0 $M0
50dc83
+
50dc83
+TEST mkdir $M0/dir1
50dc83
+
50dc83
+# Create a large file (800MB), so that rebalance takes time
50dc83
+# The file will be created on the hot tier
50dc83
+sleep_until_mid_cycle $DEMOTE_FREQ
50dc83
+dd if=/dev/zero of=$M0/dir1/FILE1 bs=256k count=5120
50dc83
+
50dc83
+# Get the path of the file on the hot tier
50dc83
+HPATH=`find $B0/hot/ -name  FILE1`
50dc83
+echo "File path on hot tier: "$HPATH
50dc83
+
50dc83
+
50dc83
+# Wait for the tier process to demote the file
50dc83
+EXPECT_WITHIN $REBALANCE_TIMEOUT "yes" is_sticky_set $HPATH
50dc83
+
50dc83
+TEST $CLI volume set $V0 cluster.tier-pause on
50dc83
+
50dc83
+# Wait for the tier process to finish migrating the file
50dc83
+EXPECT_WITHIN $REBALANCE_TIMEOUT "no" is_sticky_set $HPATH
50dc83
+
50dc83
+# Get the path of the file on the cold tier
50dc83
+CPATH=`find $B0/cold/ -name  FILE1`
50dc83
+
50dc83
+# make sure destination is empty
50dc83
+TEST ! test -s $CPATH
50dc83
+
50dc83
+# make sure source exists and not empty
50dc83
+TEST test -s $HPATH
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=KNOWN_ISSUE,BUG=000000
50dc83
diff --git a/tests/basic/tier/fops-during-migration.t b/tests/basic/tier/fops-during-migration.t
50dc83
new file mode 100755
50dc83
index 0000000..458c01e
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/fops-during-migration.t
50dc83
@@ -0,0 +1,105 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+
50dc83
+
50dc83
+NUM_BRICKS=3
50dc83
+DEMOTE_FREQ=5
50dc83
+PROMOTE_FREQ=5
50dc83
+
50dc83
+TEST_STR="Testing write and truncate fops on tier migration"
50dc83
+
50dc83
+
50dc83
+# Creates a tiered volume with pure distribute hot and cold tiers
50dc83
+# Both hot and cold tiers will have an equal number of bricks.
50dc83
+
50dc83
+function create_dist_tier_vol () {
50dc83
+        mkdir $B0/cold
50dc83
+        mkdir $B0/hot
50dc83
+        TEST $CLI volume create $V0 $H0:$B0/cold/${V0}{0..$1}
50dc83
+        TEST $CLI volume set $V0 performance.quick-read off
50dc83
+        TEST $CLI volume set $V0 performance.io-cache off
50dc83
+        TEST $CLI volume set $V0 features.ctr-enabled on
50dc83
+        TEST $CLI volume set $V0 cluster.force-migration on
50dc83
+        TEST $CLI volume start $V0
50dc83
+        TEST $CLI volume tier $V0 attach $H0:$B0/hot/${V0}{0..$1}
50dc83
+        TEST $CLI volume set $V0 cluster.tier-demote-frequency $DEMOTE_FREQ
50dc83
+        TEST $CLI volume set $V0 cluster.tier-promote-frequency $PROMOTE_FREQ
50dc83
+        TEST $CLI volume set $V0 cluster.read-freq-threshold 0
50dc83
+        TEST $CLI volume set $V0 cluster.write-freq-threshold 0
50dc83
+        TEST $CLI volume set $V0 cluster.tier-mode test
50dc83
+}
50dc83
+
50dc83
+
50dc83
+# Checks that the contents of the file matches the input string
50dc83
+#$1 : file_path
50dc83
+#$2 : comparison string
50dc83
+
50dc83
+function check_file_content () {
50dc83
+        contents=`cat $1`
50dc83
+        echo $contents
50dc83
+        if [ "$contents" = "$2" ]; then
50dc83
+                echo "1"
50dc83
+        else
50dc83
+                echo "0"
50dc83
+        fi
50dc83
+}
50dc83
+
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#Basic checks
50dc83
+TEST glusterd
50dc83
+
50dc83
+#Create and start a tiered volume
50dc83
+create_dist_tier_vol $NUM_BRICKS
50dc83
+
50dc83
+# Mount FUSE
50dc83
+TEST glusterfs -s $H0 --volfile-id $V0 $M0
50dc83
+
50dc83
+$CLI volume set $V0 diagnostics.client-log-level DEBUG
50dc83
+
50dc83
+TEST mkdir $M0/dir1
50dc83
+
50dc83
+# Create a large file (320MB), so that rebalance takes time
50dc83
+# The file will be created on the hot tier
50dc83
+
50dc83
+dd if=/dev/zero of=$M0/dir1/FILE1 bs=64k count=5120
50dc83
+
50dc83
+# Get the path of the file on the hot tier
50dc83
+HPATH=`find $B0/hot/ -name  FILE1`
50dc83
+echo "File path on hot tier: "$HPATH
50dc83
+
50dc83
+
50dc83
+# Wait for the tier process to demote the file
50dc83
+EXPECT_WITHIN $REBALANCE_TIMEOUT "yes" is_sticky_set $HPATH
50dc83
+
50dc83
+# Get the path of the file on the cold tier
50dc83
+CPATH=`find $B0/cold/ -name  FILE1`
50dc83
+echo "File path on cold tier: "$CPATH
50dc83
+
50dc83
+# Test setxattr
50dc83
+TEST setfattr -n "user.test_xattr" -v "qwerty" $M0/dir1/FILE1
50dc83
+
50dc83
+# Change the file contents while it is being migrated
50dc83
+echo $TEST_STR > $M0/dir1/FILE1
50dc83
+
50dc83
+# The file contents should have changed even if the file
50dc83
+# is not done migrating
50dc83
+EXPECT "1" check_file_content $M0/dir1/FILE1 "$TEST_STR"
50dc83
+
50dc83
+
50dc83
+# Wait for the tier process to finish migrating the file
50dc83
+EXPECT_WITHIN $REBALANCE_TIMEOUT "no" is_sticky_set $CPATH
50dc83
+
50dc83
+# The file contents should have changed
50dc83
+EXPECT "1" check_file_content $M0/dir1/FILE1 "$TEST_STR"
50dc83
+
50dc83
+
50dc83
+TEST getfattr -n "user.test_xattr" $M0/dir1/FILE1
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=BAD_TEST,BUG=000000
50dc83
diff --git a/tests/basic/tier/frequency-counters.t b/tests/basic/tier/frequency-counters.t
50dc83
new file mode 100644
50dc83
index 0000000..08e05df
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/frequency-counters.t
50dc83
@@ -0,0 +1,82 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+
50dc83
+
50dc83
+NUM_BRICKS=3
50dc83
+DEMOTE_FREQ=10
50dc83
+PROMOTE_FREQ=10
50dc83
+NUM_FILES=5
50dc83
+TEST_DIR=test
50dc83
+# Creates a tiered volume with pure distribute hot and cold tiers
50dc83
+# Both hot and cold tiers will have an equal number of bricks.
50dc83
+
50dc83
+function create_dist_vol () {
50dc83
+        mkdir $B0/cold
50dc83
+        mkdir $B0/hot
50dc83
+        TEST $CLI volume create $V0 $H0:$B0/cold/${V0}{0..$1}
50dc83
+        TEST $CLI volume set $V0 performance.quick-read off
50dc83
+        TEST $CLI volume set $V0 performance.io-cache off
50dc83
+        TEST $CLI volume start $V0
50dc83
+}
50dc83
+
50dc83
+function create_dist_tier_vol () {
50dc83
+        TEST $CLI volume tier $V0 attach $H0:$B0/hot/${V0}{0..$1}
50dc83
+        TEST $CLI volume set $V0 cluster.tier-mode test
50dc83
+        TEST $CLI volume set $V0 cluster.tier-demote-frequency $DEMOTE_FREQ
50dc83
+        TEST $CLI volume set $V0 cluster.tier-promote-frequency $PROMOTE_FREQ
50dc83
+        TEST $CLI volume set $V0 features.record-counters on
50dc83
+        TEST $CLI volume set $V0 cluster.read-freq-threshold 2
50dc83
+        TEST $CLI volume set $V0 cluster.write-freq-threshold 2
50dc83
+}
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+
50dc83
+TEST glusterd
50dc83
+
50dc83
+#Create and start a tiered volume
50dc83
+create_dist_vol $NUM_BRICKS
50dc83
+
50dc83
+# Mount FUSE
50dc83
+TEST glusterfs -s $H0 --volfile-id $V0 $M0
50dc83
+
50dc83
+# create some files
50dc83
+mkdir $M0/$TEST_DIR
50dc83
+cd $M0/${TEST_DIR}
50dc83
+
50dc83
+date > file1
50dc83
+touch file2
50dc83
+
50dc83
+# attach tier
50dc83
+create_dist_tier_vol $NUM_BRICKS
50dc83
+
50dc83
+sleep_until_mid_cycle $PROMOTE_FREQ
50dc83
+
50dc83
+# check if promotion on single hit, should fail
50dc83
+date >> file2
50dc83
+cat file1
50dc83
+drop_cache $M0
50dc83
+sleep $PROMOTE_FREQ
50dc83
+EXPECT "0" check_counters 0 0
50dc83
+
50dc83
+# check if promotion on double hit, should suceed
50dc83
+sleep_until_mid_cycle $PROMOTE_FREQ
50dc83
+date >> file2
50dc83
+drop_cache $M0
50dc83
+cat file1
50dc83
+date >> file2
50dc83
+drop_cache $M0
50dc83
+cat file1
50dc83
+
50dc83
+EXPECT_WITHIN $PROMOTE_FREQ "0" check_counters 2 0
50dc83
+
50dc83
+TEST ! $CLI volume set $V0 features.record-counters off
50dc83
+
50dc83
+cd /
50dc83
+
50dc83
+cleanup
50dc83
+
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=KNOWN_ISSUE,BUG=000000
50dc83
diff --git a/tests/basic/tier/legacy-many.t b/tests/basic/tier/legacy-many.t
50dc83
new file mode 100644
50dc83
index 0000000..5795428
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/legacy-many.t
50dc83
@@ -0,0 +1,92 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+
50dc83
+
50dc83
+LAST_BRICK=3
50dc83
+CACHE_BRICK_FIRST=4
50dc83
+CACHE_BRICK_LAST=5
50dc83
+DEMOTE_TIMEOUT=12
50dc83
+PROMOTE_TIMEOUT=12
50dc83
+MIGRATION_TIMEOUT=10
50dc83
+DEMOTE_FREQ=60
50dc83
+PROMOTE_FREQ=10
50dc83
+TEST_DIR="test_files"
50dc83
+NUM_FILES=15
50dc83
+
50dc83
+function read_all {
50dc83
+    for file in *
50dc83
+    do
50dc83
+        cat $file
50dc83
+    done
50dc83
+}
50dc83
+
50dc83
+function tier_status () {
50dc83
+        $CLI volume tier $V0 status | grep "success" | wc -l
50dc83
+}
50dc83
+
50dc83
+cleanup
50dc83
+
50dc83
+TEST glusterd
50dc83
+TEST pidof glusterd
50dc83
+
50dc83
+# Create distributed replica volume
50dc83
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0..$LAST_BRICK}
50dc83
+TEST $CLI volume start $V0
50dc83
+
50dc83
+TEST $CLI volume set $V0 performance.quick-read off
50dc83
+TEST $CLI volume set $V0 performance.io-cache off
50dc83
+TEST $CLI volume set $V0 features.ctr-enabled on
50dc83
+
50dc83
+
50dc83
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0;
50dc83
+
50dc83
+# Create a number of "legacy" files before attaching tier
50dc83
+mkdir $M0/${TEST_DIR}
50dc83
+cd $M0/${TEST_DIR}
50dc83
+TEST create_many_files file $NUM_FILES
50dc83
+wait
50dc83
+
50dc83
+# Attach tier
50dc83
+TEST $CLI volume tier $V0 attach replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
50dc83
+
50dc83
+TEST $CLI volume set $V0 cluster.tier-mode test
50dc83
+TEST $CLI volume set $V0 cluster.tier-demote-frequency $DEMOTE_FREQ
50dc83
+TEST $CLI volume set $V0 cluster.tier-promote-frequency $PROMOTE_FREQ
50dc83
+TEST $CLI volume set $V0 cluster.read-freq-threshold 0
50dc83
+TEST $CLI volume set $V0 cluster.write-freq-threshold 0
50dc83
+
50dc83
+# wait a little for lookup heal to finish
50dc83
+wait_for_tier_start
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" tier_status
50dc83
+
50dc83
+# make sure fix layout completed
50dc83
+CPATH=$B0/${V0}0
50dc83
+echo $CPATH > /tmp/out
50dc83
+TEST getfattr -n "trusted.tier.fix.layout.complete" $CPATH
50dc83
+
50dc83
+# Read "legacy" files
50dc83
+drop_cache $M0
50dc83
+
50dc83
+sleep_until_mid_cycle $DEMOTE_FREQ
50dc83
+
50dc83
+TEST read_all
50dc83
+
50dc83
+# Test to make sure files were promoted as expected
50dc83
+sleep $PROMOTE_TIMEOUT
50dc83
+EXPECT_WITHIN $PROMOTE_TIMEOUT "0" check_counters $NUM_FILES 0
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" detach_start $V0
50dc83
+EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" remove_brick_status_completed_field "$V0 $H0:$B0/${V0}${CACHE_BRICK_FIRST}"
50dc83
+
50dc83
+TEST $CLI volume tier $V0 detach commit
50dc83
+
50dc83
+# fix layout flag should be cleared
50dc83
+TEST ! getfattr -n "trusted.tier.fix.layout.complete" $CPATH
50dc83
+
50dc83
+cd;
50dc83
+cleanup
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=KNOWN_ISSUE,BUG=000000
50dc83
diff --git a/tests/basic/tier/locked_file_migration.t b/tests/basic/tier/locked_file_migration.t
50dc83
new file mode 100755
50dc83
index 0000000..7fb1717
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/locked_file_migration.t
50dc83
@@ -0,0 +1,80 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+
50dc83
+
50dc83
+NUM_BRICKS=3
50dc83
+DEMOTE_FREQ=7
50dc83
+PROMOTE_FREQ=30
50dc83
+DEMOTE_TIMEOUT=15
50dc83
+
50dc83
+TEST_STR="Testing write and truncate fops on tier migration"
50dc83
+
50dc83
+
50dc83
+# Creates a tiered volume with pure distribute hot and cold tiers
50dc83
+# Both hot and cold tiers will have an equal number of bricks.
50dc83
+
50dc83
+function create_dist_tier_vol () {
50dc83
+        mkdir $B0/cold
50dc83
+        mkdir $B0/hot
50dc83
+        TEST $CLI volume create $V0 $H0:$B0/cold/${V0}{0..$1}
50dc83
+        TEST $CLI volume set $V0 performance.quick-read off
50dc83
+        TEST $CLI volume set $V0 performance.io-cache off
50dc83
+        TEST $CLI volume set $V0 features.ctr-enabled on
50dc83
+        TEST $CLI volume start $V0
50dc83
+        TEST $CLI volume tier $V0 attach $H0:$B0/hot/${V0}{0..$1}
50dc83
+        TEST $CLI volume set $V0 cluster.tier-demote-frequency $DEMOTE_FREQ
50dc83
+        TEST $CLI volume set $V0 cluster.tier-promote-frequency $PROMOTE_FREQ
50dc83
+
50dc83
+#We don't want promotes to happen in this test
50dc83
+        TEST $CLI volume set $V0 cluster.read-freq-threshold 10
50dc83
+        TEST $CLI volume set $V0 cluster.write-freq-threshold 10
50dc83
+        TEST $CLI volume set $V0 cluster.tier-mode test
50dc83
+}
50dc83
+
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#Basic checks
50dc83
+TEST glusterd
50dc83
+TEST pidof glusterd
50dc83
+TEST $CLI volume info
50dc83
+
50dc83
+
50dc83
+# Create and start a tiered volume
50dc83
+create_dist_tier_vol $NUM_BRICKS
50dc83
+
50dc83
+# Mount FUSE
50dc83
+TEST glusterfs -s $H0 --volfile-id $V0 $M0
50dc83
+
50dc83
+TEST mkdir $M0/dir1
50dc83
+build_tester $(dirname $0)/file_lock.c -o file_lock
50dc83
+cp $(dirname $0)/file_lock $M0/file_lock
50dc83
+
50dc83
+# The files will be created on the hot tier
50dc83
+touch $M0/dir1/FILE1
50dc83
+touch $M0/dir1/FILE2
50dc83
+
50dc83
+# For FILE1, take a POSIX write lock on the entire file.
50dc83
+# Don't take a lock on FILE2
50dc83
+
50dc83
+./file_lock $M0/dir1/FILE1 W &
50dc83
+
50dc83
+sleep $DEMOTE_FREQ
50dc83
+
50dc83
+# Wait for the tier process to demote the file
50dc83
+# Only FILE2 and file_lock should be demoted
50dc83
+# FILE1 should be skipped because of the lock held
50dc83
+# on it
50dc83
+
50dc83
+EXPECT_WITHIN $DEMOTE_TIMEOUT "0" check_counters 0 2
50dc83
+
50dc83
+sleep 10
50dc83
+
50dc83
+rm $(dirname $0)/file_lock
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=KNOWN_ISSUE,BUG=000000
50dc83
diff --git a/tests/basic/tier/new-tier-cmds.t b/tests/basic/tier/new-tier-cmds.t
50dc83
new file mode 100644
50dc83
index 0000000..b9c9390
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/new-tier-cmds.t
50dc83
@@ -0,0 +1,129 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+. $(dirname $0)/../../cluster.rc
50dc83
+
50dc83
+
50dc83
+# Creates a tiered volume with pure distribute hot and cold tiers
50dc83
+# Both hot and cold tiers will have an equal number of bricks.
50dc83
+
50dc83
+function check_peers {
50dc83
+    $CLI_1 peer status | grep 'Peer in Cluster (Connected)' | wc -l
50dc83
+}
50dc83
+
50dc83
+function create_dist_tier_vol () {
50dc83
+        TEST $CLI_1 volume create $V0 disperse 6 redundancy 2 $H1:$B1/${V0}_b1 $H2:$B2/${V0}_b2 $H3:$B3/${V0}_b3 $H1:$B1/${V0}_b4 $H2:$B2/${V0}_b5 $H3:$B3/${V0}_b6
50dc83
+        TEST $CLI_1 volume start $V0
50dc83
+        TEST $CLI_1 volume tier $V0 attach replica 2 $H1:$B1/${V0}_h1 $H2:$B2/${V0}_h2 $H3:$B3/${V0}_h3 $H1:$B1/${V0}_h4 $H2:$B2/${V0}_h5 $H3:$B3/${V0}_h6
50dc83
+}
50dc83
+
50dc83
+function tier_daemon_status {
50dc83
+        local _VAR=CLI_$1
50dc83
+        local xpath_sel='//node[hostname="Tier Daemon"][path="localhost"]/status'
50dc83
+        ${!_VAR} --xml volume status $V0 \
50dc83
+                | xmllint --xpath "$xpath_sel" - \
50dc83
+                | sed -n '/.*<status>\([0-9]*\).*/s//\1/p'
50dc83
+}
50dc83
+
50dc83
+function detach_xml_status {
50dc83
+        $CLI_1 volume tier $V0 detach status --xml | sed -n \
50dc83
+        '/.*<opErrstr>Detach tier status successful/p' | wc -l
50dc83
+}
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#setup cluster and test volume
50dc83
+TEST launch_cluster 3; # start 3-node virtual cluster
50dc83
+TEST $CLI_1 peer probe $H2; # peer probe server 2 from server 1 cli
50dc83
+TEST $CLI_1 peer probe $H3; # peer probe server 3 from server 1 cli
50dc83
+
50dc83
+EXPECT_WITHIN $PROBE_TIMEOUT 2 check_peers;
50dc83
+
50dc83
+#Create and start a tiered volume
50dc83
+create_dist_tier_vol
50dc83
+
50dc83
+########### check failure for older commands #############
50dc83
+
50dc83
+TEST ! $CLI_1 volume rebalance $V0 tier status
50dc83
+
50dc83
+# failure for older command can be removed in 3.11
50dc83
+
50dc83
+##########################################################
50dc83
+
50dc83
+#Issue detach tier on the tiered volume
50dc83
+#Will throw error saying detach tier not started
50dc83
+
50dc83
+EXPECT "Tier command failed" $CLI_1 volume tier $V0 detach status
50dc83
+
50dc83
+EXPECT "0" detach_xml_status
50dc83
+
50dc83
+#kill a node
50dc83
+TEST kill_node 2
50dc83
+
50dc83
+#check if we have the rest of the node available printed in the output of detach status
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" tier_status_node_down
50dc83
+
50dc83
+TEST $glusterd_2;
50dc83
+
50dc83
+EXPECT_WITHIN $PROBE_TIMEOUT 2 check_peers;
50dc83
+
50dc83
+#after starting detach tier the detach tier status should display the status
50dc83
+sleep 2
50dc83
+$CLI_1 volume status
50dc83
+TEST $CLI_1 volume tier $V0 detach start
50dc83
+
50dc83
+EXPECT "1" detach_xml_status
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" tier_detach_status
50dc83
+
50dc83
+#kill a node
50dc83
+TEST kill_node 2
50dc83
+
50dc83
+#check if we have the rest of the node available printed in the output of detach status
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" tier_detach_status_node_down
50dc83
+
50dc83
+TEST $glusterd_2;
50dc83
+
50dc83
+EXPECT_WITHIN $PROBE_TIMEOUT 2 check_peers;
50dc83
+# Make sure we check that the *bricks* are up and not just the node.  >:-(
50dc83
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 1 $V0 $H2 $B2/${V0}_b2
50dc83
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 1 $V0 $H2 $B2/${V0}_h2
50dc83
+
50dc83
+# Parsing normal output doesn't work because of line-wrap issues on our
50dc83
+# regression machines, and the version of xmllint there doesn't support --xpath
50dc83
+# so we can't do it that way either.  In short, there's no way for us to detect
50dc83
+# when we can stop waiting, so we just have to wait the maximum time every time
50dc83
+# and hope any failures will show up later in the script.
50dc83
+sleep $PROCESS_UP_TIMEOUT
50dc83
+#XPECT_WITHIN $PROCESS_UP_TIMEOUT 1 tier_daemon_status 2
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" tier_detach_status
50dc83
+
50dc83
+TEST $CLI_1 volume tier $V0 detach stop
50dc83
+
50dc83
+#If detach tier is stopped the detach tier command will fail
50dc83
+
50dc83
+EXPECT "Tier command failed" $CLI_1 volume tier $V0 detach status
50dc83
+
50dc83
+TEST $CLI_1 volume tier $V0 detach start
50dc83
+
50dc83
+#wait for the detach to complete
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" tier_detach_commit
50dc83
+
50dc83
+#If detach tier is committed then the detach status should fail throwing an error
50dc83
+#saying its not a tiered volume
50dc83
+
50dc83
+EXPECT "Tier command failed" $CLI_1 volume tier $V0 detach status
50dc83
+
50dc83
+########### check failure for older commands #############
50dc83
+
50dc83
+TEST ! $CLI_1 volume rebalance $V0 tier start
50dc83
+
50dc83
+# failure for older command can be removed in 3.11
50dc83
+
50dc83
+##########################################################
50dc83
+cleanup;
50dc83
+
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=KNOWN_ISSUE,BUG=000000
50dc83
diff --git a/tests/basic/tier/readdir-during-migration.t b/tests/basic/tier/readdir-during-migration.t
50dc83
new file mode 100644
50dc83
index 0000000..292ca88
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/readdir-during-migration.t
50dc83
@@ -0,0 +1,65 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+
50dc83
+
50dc83
+NUM_BRICKS=3
50dc83
+DEMOTE_FREQ=5
50dc83
+PROMOTE_FREQ=5
50dc83
+NUM_FILES=30
50dc83
+TEST_DIR=test
50dc83
+# Creates a tiered volume with pure distribute hot and cold tiers
50dc83
+# Both hot and cold tiers will have an equal number of bricks.
50dc83
+
50dc83
+function create_dist_tier_vol () {
50dc83
+        mkdir $B0/cold
50dc83
+        mkdir $B0/hot
50dc83
+        TEST $CLI volume create $V0 $H0:$B0/cold/${V0}{0..$1}
50dc83
+        TEST $CLI volume set $V0 performance.quick-read off
50dc83
+        TEST $CLI volume set $V0 performance.io-cache off
50dc83
+        TEST $CLI volume start $V0
50dc83
+        TEST $CLI volume tier $V0 attach $H0:$B0/hot/${V0}{0..$1}
50dc83
+        TEST $CLI volume set $V0 cluster.tier-mode test
50dc83
+        TEST $CLI volume set $V0 cluster.tier-demote-frequency $DEMOTE_FREQ
50dc83
+        TEST $CLI volume set $V0 cluster.tier-promote-frequency $PROMOTE_FREQ
50dc83
+        TEST $CLI volume set $V0 cluster.read-freq-threshold 0
50dc83
+        TEST $CLI volume set $V0 cluster.write-freq-threshold 0
50dc83
+}
50dc83
+
50dc83
+function check_file_count() {
50dc83
+    if [ $(ls -1 | wc -l) == $1 ]; then
50dc83
+        echo "1"
50dc83
+    else
50dc83
+        echo "0"
50dc83
+    fi
50dc83
+}
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+
50dc83
+TEST glusterd
50dc83
+
50dc83
+#Create and start a tiered volume
50dc83
+create_dist_tier_vol $NUM_BRICKS
50dc83
+
50dc83
+# Mount FUSE
50dc83
+TEST glusterfs -s $H0 --volfile-id $V0 $M0
50dc83
+
50dc83
+# Create a number of "legacy" files before attaching tier
50dc83
+mkdir $M0/${TEST_DIR}
50dc83
+cd $M0/${TEST_DIR}
50dc83
+TEST create_many_files tfile $NUM_FILES
50dc83
+
50dc83
+EXPECT "1" check_file_count $NUM_FILES
50dc83
+
50dc83
+sleep $DEMOTE_FREQ
50dc83
+
50dc83
+EXPECT "1" check_file_count $NUM_FILES
50dc83
+
50dc83
+cd /
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=KNOWN_ISSUE,BUG=000000
50dc83
diff --git a/tests/basic/tier/record-metadata-heat.t b/tests/basic/tier/record-metadata-heat.t
50dc83
new file mode 100755
50dc83
index 0000000..f6f35a8
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/record-metadata-heat.t
50dc83
@@ -0,0 +1,106 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+
50dc83
+NUM_BRICKS=3
50dc83
+DEMOTE_FREQ=5
50dc83
+DEMOTE_TIMEOUT=10
50dc83
+PROMOTE_FREQ=5
50dc83
+
50dc83
+FILE="file1.txt"
50dc83
+FILE_LINK="file2.txt"
50dc83
+
50dc83
+# Creates a tiered volume with pure distribute hot and cold tiers
50dc83
+# Both hot and cold tiers will have an equal number of bricks.
50dc83
+
50dc83
+function create_dist_tier_vol () {
50dc83
+        mkdir $B0/cold
50dc83
+        mkdir $B0/hot
50dc83
+        TEST $CLI volume create $V0 $H0:$B0/cold/${V0}{0..$1}
50dc83
+        TEST $CLI volume set $V0 performance.quick-read off
50dc83
+        TEST $CLI volume set $V0 performance.io-cache off
50dc83
+        TEST $CLI volume set $V0 features.ctr-enabled on
50dc83
+        TEST $CLI volume start $V0
50dc83
+        TEST $CLI volume tier $V0 attach $H0:$B0/hot/${V0}{0..$1}
50dc83
+        TEST $CLI volume set $V0 cluster.tier-mode test
50dc83
+        TEST $CLI volume set $V0 cluster.tier-demote-frequency $DEMOTE_FREQ
50dc83
+        TEST $CLI volume set $V0 cluster.tier-promote-frequency $PROMOTE_FREQ
50dc83
+        TEST $CLI volume set $V0 cluster.read-freq-threshold 4
50dc83
+        TEST $CLI volume set $V0 cluster.write-freq-threshold 4
50dc83
+}
50dc83
+
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#Basic checks
50dc83
+TEST glusterd
50dc83
+
50dc83
+#Create and start a tiered volume
50dc83
+create_dist_tier_vol $NUM_BRICKS
50dc83
+
50dc83
+# Mount FUSE
50dc83
+TEST glusterfs -s $H0 --volfile-id $V0 $M0
50dc83
+
50dc83
+
50dc83
+# The file will be created on the hot tier
50dc83
+touch "$M0/$FILE"
50dc83
+
50dc83
+# Get the path of the file on the hot tier
50dc83
+HPATH=`find $B0/hot/ -name  "$FILE"`
50dc83
+echo "File path on hot tier: "$HPATH
50dc83
+
50dc83
+############################################
50dc83
+# as per the changes on b8b050c3
50dc83
+# To test the xttr set by EC
50dc83
+TEST ! getfattr -n "trusted.ec.size" $HPATH
50dc83
+############################################
50dc83
+
50dc83
+# Expecting the file to be on the hot tier
50dc83
+EXPECT "yes" exists_and_regular_file $HPATH
50dc83
+
50dc83
+sleep_until_mid_cycle $DEMOTE_FREQ
50dc83
+
50dc83
+# Try to heat the file using 5 metadata operations
50dc83
+# WITHOUT setting ctr-record-metadata-heat on
50dc83
+touch "$M0/$FILE"
50dc83
+chmod +x "$M0/$FILE"
50dc83
+chown root "$M0/$FILE"
50dc83
+ln "$M0/$FILE" "$M0/$FILE_LINK"
50dc83
+rm -rf "$M0/$FILE_LINK"
50dc83
+
50dc83
+# Wait for the tier process to demote the file
50dc83
+sleep $DEMOTE_TIMEOUT
50dc83
+
50dc83
+# Get the path of the file on the cold tier
50dc83
+CPATH=`find $B0/cold/ -name  "$FILE"`
50dc83
+echo "File path on cold tier: "$CPATH
50dc83
+
50dc83
+# Expecting the file to be on cold tier
50dc83
+EXPECT "yes" exists_and_regular_file $CPATH
50dc83
+
50dc83
+#Set ctr-record-metadata-heat on
50dc83
+TEST $CLI volume set $V0 ctr-record-metadata-heat on
50dc83
+
50dc83
+sleep_until_mid_cycle $DEMOTE_FREQ
50dc83
+
50dc83
+# Heating the file using 5 metadata operations
50dc83
+touch "$M0/$FILE"
50dc83
+chmod +x "$M0/$FILE"
50dc83
+chown root "$M0/$FILE"
50dc83
+ln "$M0/$FILE" "$M0/$FILE_LINK"
50dc83
+rm -rf "$M0/$FILE_LINK"
50dc83
+
50dc83
+# Wait for the tier process to demote the file
50dc83
+sleep $DEMOTE_TIMEOUT
50dc83
+
50dc83
+# Get the path of the file on the hot tier
50dc83
+echo "File path on hot tier: "$HPATH
50dc83
+
50dc83
+# Expecting the file to be on the hot tier
50dc83
+EXPECT "yes" exists_and_regular_file $HPATH
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=BAD_TEST,BUG=000000
50dc83
diff --git a/tests/basic/tier/tier-heald.t b/tests/basic/tier/tier-heald.t
50dc83
new file mode 100644
50dc83
index 0000000..a8e634f
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/tier-heald.t
50dc83
@@ -0,0 +1,98 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+
50dc83
+# This test contains volume heal commands handled by glusterd.
50dc83
+# Covers enable/disable at the moment. Will be enhanced later to include
50dc83
+# the other commands as well.
50dc83
+
50dc83
+cleanup;
50dc83
+TEST glusterd
50dc83
+TEST pidof glusterd
50dc83
+
50dc83
+volfile=$(gluster system:: getwd)"/glustershd/glustershd-server.vol"
50dc83
+
50dc83
+# Commands should fail when both tiers are not of distribute type.
50dc83
+# Glustershd shouldn't be running as long as there are no replicate/disperse
50dc83
+# volumes
50dc83
+TEST $CLI volume create dist_tier $H0:$B0/cold
50dc83
+TEST $CLI volume start dist_tier
50dc83
+TEST $CLI volume tier dist_tier attach $H0:$B0/hot
50dc83
+
50dc83
+TEST "[ -z $(get_shd_process_pid)]"
50dc83
+TEST ! $CLI volume heal dist_tier enable
50dc83
+TEST ! $CLI volume heal dist_tier disable
50dc83
+
50dc83
+# Commands should work on replicate/disperse volume.
50dc83
+TEST $CLI volume create r2 replica 2 $H0:$B0/r2_0 $H0:$B0/r2_1
50dc83
+TEST "[ -z $(get_shd_process_pid)]"
50dc83
+TEST $CLI volume start r2
50dc83
+
50dc83
+TEST $CLI volume tier r2 attach $H0:$B0/r2_hot
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid
50dc83
+TEST $CLI volume heal r2 enable
50dc83
+EXPECT "enable" volume_option r2 "cluster.self-heal-daemon"
50dc83
+EXPECT "enable" volgen_volume_option $volfile r2-replicate-0 cluster replicate self-heal-daemon
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid
50dc83
+TEST $CLI volume heal r2 disable
50dc83
+EXPECT "disable" volume_option r2 "cluster.self-heal-daemon"
50dc83
+EXPECT "disable" volgen_volume_option $volfile r2-replicate-0 cluster replicate self-heal-daemon
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid
50dc83
+# Commands should work on disperse volume.
50dc83
+TEST $CLI volume create ec2 disperse 3 redundancy 1 $H0:$B0/ec2_0 $H0:$B0/ec2_1 $H0:$B0/ec2_2
50dc83
+TEST $CLI volume start ec2
50dc83
+
50dc83
+TEST $CLI volume tier ec2 attach replica 2 $H0:$B0/ec2_hot{1..4}
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid
50dc83
+TEST $CLI volume heal ec2 enable
50dc83
+EXPECT "enable" volume_option ec2 "cluster.disperse-self-heal-daemon"
50dc83
+EXPECT "enable" volgen_volume_option $volfile ec2-disperse-0 cluster disperse self-heal-daemon
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid
50dc83
+TEST $CLI volume heal ec2 disable
50dc83
+EXPECT "disable" volume_option ec2 "cluster.disperse-self-heal-daemon"
50dc83
+EXPECT "disable" volgen_volume_option $volfile ec2-disperse-0 cluster disperse self-heal-daemon
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "[0-9][0-9]*" get_shd_process_pid
50dc83
+
50dc83
+#Check that shd graph is rewritten correctly on volume stop/start
50dc83
+EXPECT "Y" volgen_volume_exists $volfile ec2-disperse-0 cluster disperse
50dc83
+EXPECT "Y" volgen_volume_exists $volfile r2-replicate-0 cluster replicate
50dc83
+TEST $CLI volume stop r2
50dc83
+EXPECT "Y" volgen_volume_exists $volfile ec2-disperse-0 cluster disperse
50dc83
+EXPECT "N" volgen_volume_exists $volfile r2-replicate-0 cluster replicate
50dc83
+TEST $CLI volume stop ec2
50dc83
+# When both the volumes are stopped glustershd volfile is not modified just the
50dc83
+# process is stopped
50dc83
+TEST "[ -z $(get_shd_process_pid) ]"
50dc83
+
50dc83
+TEST $CLI volume start r2
50dc83
+EXPECT "N" volgen_volume_exists $volfile ec2-disperse-0 cluster disperse
50dc83
+EXPECT "Y" volgen_volume_exists $volfile r2-replicate-0 cluster replicate
50dc83
+
50dc83
+TEST $CLI volume start ec2
50dc83
+
50dc83
+EXPECT "Y" volgen_volume_exists $volfile ec2-disperse-0 cluster disperse
50dc83
+EXPECT "Y" volgen_volume_exists $volfile ec2-replicate-0 cluster replicate
50dc83
+
50dc83
+TEST $CLI volume tier ec2 detach force
50dc83
+
50dc83
+EXPECT "Y" volgen_volume_exists $volfile ec2-disperse-0 cluster disperse
50dc83
+EXPECT "N" volgen_volume_exists $volfile ec2-replicate-0 cluster replicate
50dc83
+
50dc83
+TEST $CLI volume set r2 self-heal-daemon on
50dc83
+TEST $CLI volume set r2 cluster.self-heal-daemon off
50dc83
+TEST ! $CLI volume set ec2 self-heal-daemon off
50dc83
+TEST ! $CLI volume set ec2 cluster.self-heal-daemon on
50dc83
+TEST ! $CLI volume set dist self-heal-daemon off
50dc83
+TEST ! $CLI volume set dist cluster.self-heal-daemon on
50dc83
+
50dc83
+TEST $CLI volume set ec2 disperse-self-heal-daemon off
50dc83
+TEST $CLI volume set ec2 cluster.disperse-self-heal-daemon on
50dc83
+TEST ! $CLI volume set r2 disperse-self-heal-daemon on
50dc83
+TEST ! $CLI volume set r2 cluster.disperse-self-heal-daemon off
50dc83
+TEST ! $CLI volume set dist disperse-self-heal-daemon off
50dc83
+TEST ! $CLI volume set dist cluster.disperse-self-heal-daemon on
50dc83
+
50dc83
+cleanup
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=KNOWN_ISSUE,BUG=000000
50dc83
diff --git a/tests/basic/tier/tier-snapshot.t b/tests/basic/tier/tier-snapshot.t
50dc83
new file mode 100644
50dc83
index 0000000..8747c5d
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/tier-snapshot.t
50dc83
@@ -0,0 +1,47 @@
50dc83
+#!/bin/bash
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../snapshot.rc
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+TEST init_n_bricks 4;
50dc83
+TEST setup_lvm 4;
50dc83
+
50dc83
+TEST glusterd;
50dc83
+
50dc83
+TEST $CLI volume create $V0 replica 2 $H0:$L1 $H0:$L2 ;
50dc83
+
50dc83
+TEST $CLI volume start $V0;
50dc83
+
50dc83
+TEST $CLI volume tier $V0 attach replica 2 $H0:$L3 $H0:$L4 ;
50dc83
+
50dc83
+TEST $GFS --volfile-server=$H0 --volfile-id=$V0 $M0;
50dc83
+
50dc83
+for i in {1..10} ; do echo "file" > $M0/file$i ; done
50dc83
+
50dc83
+TEST $CLI snapshot config activate-on-create enable
50dc83
+
50dc83
+TEST $CLI snapshot create snap1 $V0 no-timestamp;
50dc83
+
50dc83
+for i in {11..20} ; do echo "file" > $M0/file$i ; done
50dc83
+
50dc83
+TEST $CLI snapshot create snap2 $V0 no-timestamp;
50dc83
+
50dc83
+mkdir $M0/dir1;
50dc83
+mkdir $M0/dir2;
50dc83
+
50dc83
+for i in {1..10} ; do echo "foo" > $M0/dir1/foo$i ; done
50dc83
+for i in {1..10} ; do echo "foo" > $M0/dir2/foo$i ; done
50dc83
+
50dc83
+TEST $CLI snapshot create snap3 $V0 no-timestamp;
50dc83
+
50dc83
+for i in {11..20} ; do echo "foo" > $M0/dir1/foo$i ; done
50dc83
+for i in {11..20} ; do echo "foo" > $M0/dir2/foo$i ; done
50dc83
+
50dc83
+TEST $CLI snapshot create snap4 $V0 no-timestamp;
50dc83
+
50dc83
+TEST $CLI snapshot delete all;
50dc83
+
50dc83
+cleanup;
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=BAD_TEST,BUG=000000
50dc83
diff --git a/tests/basic/tier/tier.t b/tests/basic/tier/tier.t
50dc83
new file mode 100755
50dc83
index 0000000..1798541
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/tier.t
50dc83
@@ -0,0 +1,219 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+
50dc83
+LAST_BRICK=3
50dc83
+CACHE_BRICK_FIRST=4
50dc83
+CACHE_BRICK_LAST=5
50dc83
+DEMOTE_TIMEOUT=12
50dc83
+PROMOTE_TIMEOUT=5
50dc83
+MIGRATION_TIMEOUT=10
50dc83
+DEMOTE_FREQ=4
50dc83
+PROMOTE_FREQ=12
50dc83
+
50dc83
+function file_on_slow_tier {
50dc83
+    found=0
50dc83
+
50dc83
+    for i in `seq 0 $LAST_BRICK`; do
50dc83
+        test -e "$B0/${V0}${i}/$1" && found=1 && break;
50dc83
+    done
50dc83
+
50dc83
+    if [ "$found" == "1" ]
50dc83
+    then
50dc83
+        slow_hash1=$2
50dc83
+        slow_hash2=$(fingerprint "$B0/${V0}${i}/$1")
50dc83
+
50dc83
+        if [ "$slow_hash1" == "$slow_hash2" ]
50dc83
+            then
50dc83
+                echo "0"
50dc83
+            else
50dc83
+                echo "2"
50dc83
+        fi
50dc83
+    else
50dc83
+        echo "1"
50dc83
+    fi
50dc83
+
50dc83
+    # temporarily disable non-Linux tests.
50dc83
+    case $OSTYPE in
50dc83
+        NetBSD | FreeBSD | Darwin)
50dc83
+            echo "0"
50dc83
+            ;;
50dc83
+    esac
50dc83
+}
50dc83
+
50dc83
+function file_on_fast_tier {
50dc83
+    found=0
50dc83
+
50dc83
+    for j in `seq $CACHE_BRICK_FIRST $CACHE_BRICK_LAST`; do
50dc83
+        test -e "$B0/${V0}${j}/$1" && found=1 && break;
50dc83
+    done
50dc83
+
50dc83
+
50dc83
+    if [ "$found" == "1" ]
50dc83
+    then
50dc83
+        fast_hash1=$2
50dc83
+        fast_hash2=$(fingerprint "$B0/${V0}${j}/$1")
50dc83
+
50dc83
+        if [ "$fast_hash1" == "$fast_hash2" ]
50dc83
+            then
50dc83
+                echo "0"
50dc83
+            else
50dc83
+                echo "2"
50dc83
+        fi
50dc83
+    else
50dc83
+        echo "1"
50dc83
+    fi
50dc83
+}
50dc83
+
50dc83
+
50dc83
+cleanup
50dc83
+
50dc83
+TEST glusterd
50dc83
+TEST pidof glusterd
50dc83
+
50dc83
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0..$LAST_BRICK}
50dc83
+# testing bug 1215122, ie should fail if replica count and bricks are not compatible.
50dc83
+
50dc83
+TEST ! $CLI volume tier $V0 attach replica 5 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
50dc83
+
50dc83
+TEST $CLI volume start $V0
50dc83
+
50dc83
+# The following two commands instigate a graph switch. Do them
50dc83
+# before attaching the tier. If done on a tiered volume the rebalance
50dc83
+# daemon will terminate and must be restarted manually.
50dc83
+TEST $CLI volume set $V0 performance.quick-read off
50dc83
+TEST $CLI volume set $V0 performance.io-cache off
50dc83
+
50dc83
+#Not a tier volume
50dc83
+TEST ! $CLI volume set $V0 cluster.tier-demote-frequency 4
50dc83
+
50dc83
+#testing bug #1228112, glusterd crashed when trying to detach-tier commit force on a non-tiered volume.
50dc83
+TEST ! $CLI volume tier $V0 detach commit force
50dc83
+
50dc83
+TEST $CLI volume tier $V0 attach replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
50dc83
+
50dc83
+TEST $CLI volume set $V0 cluster.tier-mode test
50dc83
+
50dc83
+# create a file, make sure it can be deleted after attach tier.
50dc83
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0;
50dc83
+cd $M0
50dc83
+TEST touch delete_me.txt
50dc83
+TEST rm -f delete_me.txt
50dc83
+
50dc83
+# confirm watermark CLI works
50dc83
+TEST $CLI volume set $V0 cluster.watermark-hi 85
50dc83
+TEST $CLI volume set $V0 cluster.watermark-low 75
50dc83
+TEST $CLI volume set $V0 cluster.tier-max-mb 1000
50dc83
+TEST $CLI volume set $V0 cluster.tier-max-files 1000
50dc83
+TEST $CLI volume set $V0 cluster.tier-max-promote-file-size 1000
50dc83
+TEST ! $CLI volume set $V0 cluster.tier-max-files -3
50dc83
+TEST ! $CLI volume set $V0 cluster.watermark-low 90
50dc83
+TEST ! $CLI volume set $V0 cluster.watermark-hi 75
50dc83
+TEST ! $CLI volume set $V0 cluster.read-freq-threshold -12
50dc83
+TEST ! $CLI volume set $V0 cluster.write-freq-threshold -12
50dc83
+
50dc83
+#check for watermark reset
50dc83
+TEST $CLI volume set $V0 cluster.watermark-low 10
50dc83
+TEST $CLI volume set $V0 cluster.watermark-hi 30
50dc83
+TEST ! $CLI volume reset $V0 cluster.watermark-low
50dc83
+TEST $CLI volume reset $V0 cluster.watermark-hi
50dc83
+TEST $CLI volume reset $V0 cluster.watermark-low
50dc83
+
50dc83
+# stop the volume and restart it. The rebalance daemon should restart.
50dc83
+cd /tmp
50dc83
+umount $M0
50dc83
+TEST $CLI volume stop $V0
50dc83
+TEST $CLI volume start $V0
50dc83
+
50dc83
+wait_for_tier_start
50dc83
+
50dc83
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0;
50dc83
+cd $M0
50dc83
+
50dc83
+sleep_first_cycle $DEMOTE_FREQ
50dc83
+$CLI volume tier $V0 status
50dc83
+
50dc83
+#Tier options expect non-negative value
50dc83
+TEST ! $CLI volume set $V0 cluster.tier-promote-frequency -1
50dc83
+
50dc83
+#Tier options expect non-negative value
50dc83
+TEST ! $CLI volume set $V0 cluster.read-freq-threshold qwerty
50dc83
+
50dc83
+
50dc83
+TEST $CLI volume set $V0 cluster.tier-demote-frequency $DEMOTE_FREQ
50dc83
+TEST $CLI volume set $V0 cluster.tier-promote-frequency $PROMOTE_FREQ
50dc83
+TEST $CLI volume set $V0 cluster.read-freq-threshold 0
50dc83
+TEST $CLI volume set $V0 cluster.write-freq-threshold 0
50dc83
+
50dc83
+# Basic operations.
50dc83
+TEST stat .
50dc83
+TEST mkdir d1
50dc83
+TEST [ -d d1 ]
50dc83
+TEST touch d1/file1
50dc83
+TEST mkdir d1/d2
50dc83
+TEST [ -d d1/d2 ]
50dc83
+TEST find d1
50dc83
+mkdir /tmp/d1
50dc83
+
50dc83
+# Create a file. It should be on the fast tier.
50dc83
+uuidgen > /tmp/d1/data.txt
50dc83
+md5data=$(fingerprint /tmp/d1/data.txt)
50dc83
+mv /tmp/d1/data.txt ./d1/data.txt
50dc83
+
50dc83
+TEST file_on_fast_tier d1/data.txt $md5data
50dc83
+
50dc83
+uuidgen > /tmp/d1/data2.txt
50dc83
+md5data2=$(fingerprint /tmp/d1/data2.txt)
50dc83
+cp /tmp/d1/data2.txt ./d1/data2.txt
50dc83
+
50dc83
+#File with spaces and special characters.
50dc83
+SPACE_FILE="file with spaces & $peci@l ch@r@cter$ @!@$%^$#@^^*&%$#$%.txt"
50dc83
+
50dc83
+uuidgen > "/tmp/d1/$SPACE_FILE"
50dc83
+md5space=$(fingerprint "/tmp/d1/$SPACE_FILE")
50dc83
+mv "/tmp/d1/$SPACE_FILE" "./d1/$SPACE_FILE"
50dc83
+
50dc83
+# Check auto-demotion on write new.
50dc83
+sleep $DEMOTE_TIMEOUT
50dc83
+
50dc83
+# Check auto-promotion on write append.
50dc83
+UUID=$(uuidgen)
50dc83
+echo $UUID >> /tmp/d1/data2.txt
50dc83
+md5data2=$(fingerprint /tmp/d1/data2.txt)
50dc83
+
50dc83
+sleep_until_mid_cycle $DEMOTE_FREQ
50dc83
+drop_cache $M0
50dc83
+
50dc83
+echo $UUID >> ./d1/data2.txt
50dc83
+cat "./d1/$SPACE_FILE"
50dc83
+
50dc83
+sleep $PROMOTE_TIMEOUT
50dc83
+sleep $DEMOTE_FREQ
50dc83
+EXPECT_WITHIN $DEMOTE_TIMEOUT "0" check_counters 2 6
50dc83
+
50dc83
+# stop gluster, when it comes back info file should have tiered volume
50dc83
+killall glusterd
50dc83
+TEST glusterd
50dc83
+
50dc83
+EXPECT "0" file_on_slow_tier d1/data.txt $md5data
50dc83
+EXPECT "0" file_on_slow_tier d1/data2.txt $md5data2
50dc83
+EXPECT "0" file_on_slow_tier "./d1/$SPACE_FILE" $md5space
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" detach_start $V0
50dc83
+EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" remove_brick_status_completed_field "$V0 $H0:$B0/${V0}${CACHE_BRICK_FIRST}"
50dc83
+
50dc83
+TEST $CLI volume tier $V0 detach commit
50dc83
+
50dc83
+EXPECT "0" confirm_tier_removed ${V0}${CACHE_BRICK_FIRST}
50dc83
+
50dc83
+confirm_vol_stopped $V0
50dc83
+
50dc83
+cd;
50dc83
+
50dc83
+cleanup
50dc83
+rm -rf /tmp/d1
50dc83
+
50dc83
+
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=KNOWN_ISSUE,BUG=000000
50dc83
diff --git a/tests/basic/tier/tier_lookup_heal.t b/tests/basic/tier/tier_lookup_heal.t
50dc83
new file mode 100755
50dc83
index 0000000..c7c7f27
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/tier_lookup_heal.t
50dc83
@@ -0,0 +1,69 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+
50dc83
+LAST_BRICK=1
50dc83
+CACHE_BRICK_FIRST=2
50dc83
+CACHE_BRICK_LAST=3
50dc83
+PROMOTE_TIMEOUT=5
50dc83
+
50dc83
+function file_on_fast_tier {
50dc83
+    local ret="1"
50dc83
+
50dc83
+    s1=$(md5sum $1)
50dc83
+    s2=$(md5sum $B0/${V0}${CACHE_BRICK_FIRST}/$1)
50dc83
+
50dc83
+    if [ -e $B0/${V0}${CACHE_BRICK_FIRST}/$1 ] && ! [ "$s1" == "$s2" ]; then
50dc83
+        echo "0"
50dc83
+    else
50dc83
+        echo "1"
50dc83
+    fi
50dc83
+}
50dc83
+
50dc83
+cleanup
50dc83
+
50dc83
+
50dc83
+TEST glusterd
50dc83
+
50dc83
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0..$LAST_BRICK}
50dc83
+TEST $CLI volume start $V0
50dc83
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0;
50dc83
+
50dc83
+# Create files before CTR xlator is on.
50dc83
+cd $M0
50dc83
+TEST stat .
50dc83
+TEST touch file1
50dc83
+TEST stat file1
50dc83
+
50dc83
+#Attach tier and switch ON CTR Xlator.
50dc83
+TEST $CLI volume tier $V0 attach replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
50dc83
+TEST $CLI volume set $V0 features.ctr-enabled on
50dc83
+TEST $CLI volume set $V0 cluster.tier-demote-frequency 4
50dc83
+TEST $CLI volume set $V0 cluster.tier-promote-frequency 4
50dc83
+TEST $CLI volume set $V0 cluster.read-freq-threshold 0
50dc83
+TEST $CLI volume set $V0 cluster.write-freq-threshold 0
50dc83
+TEST $CLI volume set $V0 performance.quick-read off
50dc83
+TEST $CLI volume set $V0 performance.io-cache off
50dc83
+TEST $CLI volume set $V0 cluster.tier-mode test
50dc83
+
50dc83
+#The lookup should heal the database.
50dc83
+TEST ls file1
50dc83
+
50dc83
+# gf_file_tb and gf_flink_tb should NOT be empty
50dc83
+ENTRY_COUNT=$(echo "select * from gf_file_tb; select * from gf_flink_tb;" | \
50dc83
+        sqlite3 $B0/${V0}$LAST_BRICK/.glusterfs/${V0}$LAST_BRICK.db | wc -l )
50dc83
+TEST [ $ENTRY_COUNT -eq 2 ]
50dc83
+
50dc83
+# Heat-up the file
50dc83
+uuidgen > file1
50dc83
+sleep 5
50dc83
+
50dc83
+#Check if the file is promoted
50dc83
+EXPECT_WITHIN $PROMOTE_TIMEOUT "0" file_on_fast_tier file1
50dc83
+
50dc83
+cd;
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=BAD_TEST,BUG=000000
50dc83
diff --git a/tests/basic/tier/tierd_check.t b/tests/basic/tier/tierd_check.t
50dc83
new file mode 100644
50dc83
index 0000000..5701fa9
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/tierd_check.t
50dc83
@@ -0,0 +1,128 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+. $(dirname $0)/../../cluster.rc
50dc83
+
50dc83
+
50dc83
+# Creates a tiered volume with pure distribute hot and cold tiers
50dc83
+# Both hot and cold tiers will have an equal number of bricks.
50dc83
+
50dc83
+function check_peers {
50dc83
+    $CLI_1 peer status | grep 'Peer in Cluster (Connected)' | wc -l
50dc83
+}
50dc83
+
50dc83
+function create_dist_tier_vol () {
50dc83
+        TEST $CLI_1 volume create $V0 $H1:$B1/${V0} $H2:$B2/${V0}
50dc83
+        TEST $CLI_1 volume start $V0
50dc83
+        TEST $CLI_1 volume tier $V0 attach $H1:$B1/${V0}_h1 $H2:$B2/${V0}_h2
50dc83
+}
50dc83
+
50dc83
+function tier_status () {
50dc83
+	#$CLI_1 volume tier $V0 status | grep progress | wc -l
50dc83
+	# I don't want to disable the entire test, but this part of it seems
50dc83
+	# highly suspect.  *Why* do we always expect the number of lines to be
50dc83
+	# exactly two?  What would it mean for it to be otherwise?  Are we
50dc83
+	# checking *correctness* of the result, or merely its *consistency*
50dc83
+	# with what was observed at some unspecified time in the past?  Does
50dc83
+	# this check only serve to inhibit actual improvements?  Until someone
50dc83
+	# can answer these questions and explain why a hard-coded "2" is less
50dc83
+	# arbitrary than what was here before, we might as well disable this
50dc83
+	# part of the test.
50dc83
+	echo "2"
50dc83
+}
50dc83
+
50dc83
+function tier_daemon_kill () {
50dc83
+pkill -f "tierd/$V0"
50dc83
+echo "$?"
50dc83
+}
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#setup cluster and test volume
50dc83
+TEST launch_cluster 3; # start 3-node virtual cluster
50dc83
+TEST $CLI_1 peer probe $H2; # peer probe server 2 from server 1 cli
50dc83
+TEST $CLI_1 peer probe $H3; # peer probe server 3 from server 1 cli
50dc83
+
50dc83
+EXPECT_WITHIN $PROBE_TIMEOUT 2 check_peers;
50dc83
+
50dc83
+#Create and start a tiered volume
50dc83
+create_dist_tier_vol
50dc83
+
50dc83
+wait_for_tier_start
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT 0 tier_daemon_check
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "2" tier_status
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT 0 tier_daemon_kill
50dc83
+
50dc83
+TEST $CLI_1 volume tier $V0 start
50dc83
+
50dc83
+wait_for_tier_start
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" tier_daemon_check
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "2" tier_status
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" tier_daemon_kill
50dc83
+
50dc83
+TEST $CLI_3 volume tier $V0 start force
50dc83
+
50dc83
+wait_for_tier_start
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" tier_daemon_check
50dc83
+
50dc83
+#The pattern progress should occur twice only.
50dc83
+#it shouldn't come up on the third node without tierd even
50dc83
+#after the tier start force is issued on the node without
50dc83
+#tierd
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "2" tier_status
50dc83
+
50dc83
+#kill the node on which tier is not supposed to run
50dc83
+TEST kill_node 3
50dc83
+
50dc83
+#bring the node back, it should not have tierd running on it
50dc83
+TEST $glusterd_3;
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "2" tier_status
50dc83
+
50dc83
+#after volume restart, check for tierd
50dc83
+
50dc83
+TEST $CLI_3 volume stop $V0
50dc83
+
50dc83
+TEST $CLI_3 volume start $V0
50dc83
+
50dc83
+wait_for_tier_start
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "2" tier_status
50dc83
+
50dc83
+#check for detach start and stop
50dc83
+
50dc83
+TEST $CLI_3 volume tier $V0 detach start
50dc83
+
50dc83
+TEST $CLI_3 volume tier $V0 detach stop
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "2" tier_status
50dc83
+
50dc83
+TEST $CLI_1 volume tier $V0 start force
50dc83
+
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" tier_daemon_check
50dc83
+
50dc83
+# To test for detach start fail while the brick is down
50dc83
+
50dc83
+TEST pkill -f "$B1/$V0"
50dc83
+
50dc83
+TEST ! $CLI_1 volume tier $V0 detach start
50dc83
+
50dc83
+cleanup
50dc83
+# This test isn't worth keeping.  Besides the totally arbitrary tier_status
50dc83
+# checks mentioned above, someone direct-coded pkill to kill bricks instead of
50dc83
+# using the volume.rc function we already had.  I can't be bothered fixing that,
50dc83
+# and the next thing, and the next thing, unless there's a clear benefit to
50dc83
+# doing so, and AFAICT the success or failure of this test tells us nothing
50dc83
+# useful.  Therefore, it's disabled until further notice.
50dc83
+#G_TESTDEF_TEST_STATUS_CENTOS6=KNOWN_ISSUE,BUG=000000
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=KNOWN_ISSUE,BUG=000000
50dc83
diff --git a/tests/basic/tier/unlink-during-migration.t b/tests/basic/tier/unlink-during-migration.t
50dc83
new file mode 100755
50dc83
index 0000000..1330092
50dc83
--- /dev/null
50dc83
+++ b/tests/basic/tier/unlink-during-migration.t
50dc83
@@ -0,0 +1,92 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+
50dc83
+
50dc83
+DEMOTE_FREQ=5
50dc83
+PROMOTE_FREQ=5
50dc83
+
50dc83
+function create_dist_rep_vol () {
50dc83
+        mkdir $B0/cold
50dc83
+        mkdir $B0/hot
50dc83
+        TEST $CLI volume create $V0 replica 2 $H0:$B0/cold/${V0}{0..3}
50dc83
+        TEST $CLI volume set $V0 performance.quick-read off
50dc83
+        TEST $CLI volume set $V0 performance.io-cache off
50dc83
+        TEST $CLI volume set $V0 features.ctr-enabled on
50dc83
+        TEST $CLI volume start $V0
50dc83
+}
50dc83
+
50dc83
+function attach_dist_rep_tier () {
50dc83
+        TEST $CLI volume tier $V0 attach replica 2 $H0:$B0/hot/${V0}{0..3}
50dc83
+        TEST $CLI volume set $V0 cluster.tier-demote-frequency $DEMOTE_FREQ
50dc83
+        TEST $CLI volume set $V0 cluster.tier-promote-frequency $PROMOTE_FREQ
50dc83
+        TEST $CLI volume set $V0 cluster.read-freq-threshold 0
50dc83
+        TEST $CLI volume set $V0 cluster.write-freq-threshold 0
50dc83
+        TEST $CLI volume set $V0 cluster.tier-mode test
50dc83
+}
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#Basic checks
50dc83
+TEST glusterd
50dc83
+TEST pidof glusterd
50dc83
+TEST $CLI volume info
50dc83
+
50dc83
+
50dc83
+#Create and start a volume
50dc83
+create_dist_rep_vol
50dc83
+
50dc83
+# Mount FUSE
50dc83
+TEST glusterfs -s $H0 --volfile-id $V0 $M0
50dc83
+
50dc83
+# Create a large file (320MB), so that rebalance takes time
50dc83
+TEST dd if=/dev/zero of=$M0/foo bs=64k count=5120
50dc83
+
50dc83
+# Get the path of the file on the cold tier
50dc83
+CPATH=`find $B0/cold/ -name  foo`
50dc83
+echo "File path on cold tier: "$CPATH
50dc83
+
50dc83
+#Now attach the tier
50dc83
+attach_dist_rep_tier
50dc83
+
50dc83
+#Write into the file to promote it
50dc83
+echo "good morning">>$M0/foo
50dc83
+
50dc83
+# Wait for the tier process to promote the file
50dc83
+EXPECT_WITHIN $REBALANCE_TIMEOUT "yes" is_sticky_set $CPATH
50dc83
+
50dc83
+# Get the path of the file on the hot tier
50dc83
+HPATH=`find $B0/hot/ -name  foo`
50dc83
+
50dc83
+echo "File path on hot tier: "$HPATH
50dc83
+TEST rm -rf $M0/foo
50dc83
+TEST ! stat $HPATH
50dc83
+TEST ! stat $CPATH
50dc83
+
50dc83
+#unlink during demotion
50dc83
+HPATH="";
50dc83
+CPATH="";
50dc83
+
50dc83
+# Create a large file (320MB), so that rebalance takes time
50dc83
+TEST dd if=/dev/zero of=$M0/foo1 bs=64k count=5120
50dc83
+
50dc83
+# Get the path of the file on the hot tier
50dc83
+HPATH=`find $B0/hot/ -name  foo1`
50dc83
+echo "File path on hot tier : "$HPATH
50dc83
+
50dc83
+EXPECT_WITHIN $REBALANCE_TIMEOUT "yes" is_sticky_set $HPATH
50dc83
+
50dc83
+# Get the path of the file on the cold tier
50dc83
+CPATH=`find $B0/cold/ -name  foo1`
50dc83
+echo "File path on cold tier : "$CPATH
50dc83
+
50dc83
+TEST rm -rf $M0/foo1
50dc83
+
50dc83
+TEST ! stat $HPATH
50dc83
+TEST ! stat $CPATH
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=KNOWN_ISSUE,BUG=000000
50dc83
diff --git a/tests/bugs/glusterd/bug-1303028-Rebalance-glusterd-rpc-connection-issue.t b/tests/bugs/glusterd/bug-1303028-Rebalance-glusterd-rpc-connection-issue.t
50dc83
new file mode 100644
50dc83
index 0000000..3b62a45
50dc83
--- /dev/null
50dc83
+++ b/tests/bugs/glusterd/bug-1303028-Rebalance-glusterd-rpc-connection-issue.t
50dc83
@@ -0,0 +1,78 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+
50dc83
+
50dc83
+# Creates a tiered volume with pure distribute hot and cold tiers
50dc83
+# Both hot and cold tiers will have an equal number of bricks.
50dc83
+
50dc83
+function create_dist_tier_vol () {
50dc83
+        mkdir $B0/cold
50dc83
+        mkdir $B0/hot
50dc83
+        TEST $CLI volume create $V0 $H0:$B0/cold/${V0}{1..3}
50dc83
+        TEST $CLI volume set $V0 performance.quick-read off
50dc83
+        TEST $CLI volume set $V0 performance.io-cache off
50dc83
+        TEST $CLI volume start $V0
50dc83
+        TEST $CLI volume tier $V0 attach $H0:$B0/hot/${V0}{1..2}
50dc83
+        TEST $CLI volume set $V0 cluster.tier-mode test
50dc83
+}
50dc83
+
50dc83
+function non_zero_check () {
50dc83
+        if [ "$1" -ne 0 ]
50dc83
+        then
50dc83
+                echo "0"
50dc83
+        else
50dc83
+                echo "1"
50dc83
+        fi
50dc83
+}
50dc83
+
50dc83
+function num_bricks_up {
50dc83
+        local b
50dc83
+        local n_up=0
50dc83
+
50dc83
+        for b in $B0/hot/${V0}{1..2} $B0/cold/${V0}{1..3}; do
50dc83
+                if [ x"$(brick_up_status $V0 $H0 $b)" = x"1" ]; then
50dc83
+                        n_up=$((n_up+1))
50dc83
+                fi
50dc83
+        done
50dc83
+
50dc83
+        echo $n_up
50dc83
+}
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#Basic checks
50dc83
+TEST glusterd
50dc83
+TEST pidof glusterd
50dc83
+TEST $CLI volume status
50dc83
+
50dc83
+
50dc83
+#Create and start a tiered volume
50dc83
+create_dist_tier_vol
50dc83
+# Wait for the bricks to come up, *then* the tier daemon.
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT 5 num_bricks_up
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT 0 tier_daemon_check
50dc83
+sleep 5   #wait for some time to run tier daemon
50dc83
+time_before_restarting=$(rebalance_run_time $V0);
50dc83
+
50dc83
+#checking for elapsed time after sleeping for two seconds.
50dc83
+EXPECT "0" non_zero_check $time_before_restarting;
50dc83
+
50dc83
+#Difference of elapsed time should be positive
50dc83
+
50dc83
+kill -9 $(pidof glusterd);
50dc83
+TEST glusterd;
50dc83
+sleep 2;
50dc83
+# Wait for the bricks to come up, *then* the tier daemon.
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT 5 num_bricks_up
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" tier_daemon_check;
50dc83
+sleep 1;
50dc83
+time1=$(rebalance_run_time $V0);
50dc83
+EXPECT "0" non_zero_check $time1;
50dc83
+sleep 2;
50dc83
+time2=$(rebalance_run_time $V0);
50dc83
+EXPECT "0" non_zero_check $time2;
50dc83
+diff=`expr $time2 - $time1`
50dc83
+EXPECT "0" non_zero_check $diff;
50dc83
diff --git a/tests/bugs/quota/bug-1288474.t b/tests/bugs/quota/bug-1288474.t
50dc83
new file mode 100755
50dc83
index 0000000..b8f4ba3
50dc83
--- /dev/null
50dc83
+++ b/tests/bugs/quota/bug-1288474.t
50dc83
@@ -0,0 +1,51 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+
50dc83
+NUM_BRICKS=2
50dc83
+
50dc83
+function create_dist_tier_vol () {
50dc83
+        mkdir -p $B0/cold/${V0}{0..$1}
50dc83
+        mkdir -p $B0/hot/${V0}{0..$1}
50dc83
+        TEST $CLI volume create $V0 $H0:$B0/cold/${V0}{0..$1}
50dc83
+	TEST $CLI volume set $V0 nfs.disable false
50dc83
+        TEST $CLI volume start $V0
50dc83
+        TEST $CLI volume tier $V0 attach $H0:$B0/hot/${V0}{0..$1}
50dc83
+}
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#Basic checks
50dc83
+TEST glusterd
50dc83
+
50dc83
+#Create and start a tiered volume
50dc83
+create_dist_tier_vol $NUM_BRICKS
50dc83
+
50dc83
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0
50dc83
+touch $M0/foobar
50dc83
+
50dc83
+TEST $CLI volume quota $V0 enable
50dc83
+TEST $CLI volume quota $V0 limit-usage / 10MB
50dc83
+
50dc83
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "10.0MB" quota_list_field "/" 5
50dc83
+
50dc83
+#check quota list after detach tier
50dc83
+TEST $CLI volume tier $V0 detach start
50dc83
+sleep 1
50dc83
+TEST $CLI volume tier $V0 detach force
50dc83
+
50dc83
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "10.0MB" quota_list_field "/" 5
50dc83
+
50dc83
+#check quota list after attach tier
50dc83
+rm -rf $B0/hot
50dc83
+mkdir $B0/hot
50dc83
+TEST $CLI volume tier $V0 attach $H0:$B0/hot/${V0}{0..$1}
50dc83
+
50dc83
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "10.0MB" quota_list_field "/" 5
50dc83
+
50dc83
+TEST umount $M0
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
diff --git a/tests/bugs/replicate/bug-1290965-detect-bitrotten-objects.t b/tests/bugs/replicate/bug-1290965-detect-bitrotten-objects.t
50dc83
new file mode 100644
50dc83
index 0000000..9863834
50dc83
--- /dev/null
50dc83
+++ b/tests/bugs/replicate/bug-1290965-detect-bitrotten-objects.t
50dc83
@@ -0,0 +1,53 @@
50dc83
+#!/bin/bash
50dc83
+#Self-heal tests
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+cleanup;
50dc83
+
50dc83
+TEST glusterd
50dc83
+TEST pidof glusterd
50dc83
+TEST $CLI volume create $V0 replica 2 $H0:$B0/brick{0,1}
50dc83
+TEST $CLI volume set $V0 self-heal-daemon off
50dc83
+TEST $CLI volume set $V0 entry-self-heal off
50dc83
+TEST $CLI volume set $V0 metadata-self-heal off
50dc83
+TEST $CLI volume set $V0 data-self-heal off
50dc83
+TEST $CLI volume set $V0 performance.stat-prefetch off
50dc83
+TEST $CLI volume start $V0
50dc83
+TEST $CLI volume tier $V0 attach replica 2 $H0:$B0/brick{2,3}
50dc83
+TEST $CLI volume bitrot $V0 enable
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count
50dc83
+TEST $CLI volume bitrot $V0 scrub-frequency hourly
50dc83
+TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0
50dc83
+TEST dd if=/dev/urandom of=$M0/FILE bs=1024 count=1
50dc83
+
50dc83
+#Corrupt file from back-end
50dc83
+TEST stat $B0/brick3/FILE
50dc83
+echo "Corrupted data" >> $B0/brick3/FILE
50dc83
+#Manually set bad-file xattr since we can't wait for an hour.
50dc83
+TEST setfattr -n trusted.bit-rot.bad-file -v 0x3100 $B0/brick3/FILE
50dc83
+
50dc83
+TEST $CLI volume stop $V0
50dc83
+TEST $CLI volume start $V0
50dc83
+EXPECT 'Started' volinfo_field $V0 'Status';
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status $V0 $H0 $B0/brick0
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status $V0 $H0 $B0/brick1
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status $V0 $H0 $B0/brick2
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" brick_up_status $V0 $H0 $B0/brick3
50dc83
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 0
50dc83
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 1
50dc83
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 2
50dc83
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 3
50dc83
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" get_bitd_count
50dc83
+#Trigger lookup so that bitrot xlator marks file as bad in its inode context.
50dc83
+stat $M0/FILE
50dc83
+# Remove hot-tier
50dc83
+TEST $CLI volume tier $V0  detach start
50dc83
+sleep 1
50dc83
+EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" detach_tier_status_field_complete $V0
50dc83
+TEST $CLI volume tier $V0  detach commit
50dc83
+#Test that file has migrated to cold tier.
50dc83
+EXPECT "1024" stat -c "%s" $B0/brick0/FILE
50dc83
+EXPECT "1024" stat -c "%s" $B0/brick1/FILE
50dc83
+TEST umount $M0
50dc83
+cleanup
50dc83
diff --git a/tests/bugs/tier/bug-1205545-CTR-and-trash-integration.t b/tests/bugs/tier/bug-1205545-CTR-and-trash-integration.t
50dc83
new file mode 100644
50dc83
index 0000000..b2d382a
50dc83
--- /dev/null
50dc83
+++ b/tests/bugs/tier/bug-1205545-CTR-and-trash-integration.t
50dc83
@@ -0,0 +1,72 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+
50dc83
+LAST_BRICK=3
50dc83
+CACHE_BRICK_FIRST=4
50dc83
+CACHE_BRICK_LAST=5
50dc83
+
50dc83
+cleanup
50dc83
+
50dc83
+# Start glusterd [1-2]
50dc83
+TEST glusterd
50dc83
+TEST pidof glusterd
50dc83
+
50dc83
+# Set-up tier cluster [3-4]
50dc83
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0..$LAST_BRICK}
50dc83
+TEST $CLI volume start $V0
50dc83
+TEST $CLI volume tier $V0 attach replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST
50dc83
+
50dc83
+# Start and mount the volume after enabling CTR and trash [5-8]
50dc83
+TEST $CLI volume set $V0 features.ctr-enabled on
50dc83
+TEST $CLI volume set $V0 features.trash on
50dc83
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0;
50dc83
+
50dc83
+# Create an empty file
50dc83
+touch $M0/foo
50dc83
+
50dc83
+# gf_file_tb and gf_flink_tb should contain one entry each [9]
50dc83
+ENTRY_COUNT=$(echo "select * from gf_file_tb; select * from gf_flink_tb;" | \
50dc83
+        sqlite3 $B0/${V0}5/.glusterfs/${V0}5.db | wc -l )
50dc83
+TEST [ $ENTRY_COUNT -eq 2 ]
50dc83
+
50dc83
+# Create two hard links
50dc83
+ln $M0/foo $M0/lnk1
50dc83
+ln $M0/foo $M0/lnk2
50dc83
+
50dc83
+# Now gf_flink_tb should contain 3 entries [10]
50dc83
+ENTRY_COUNT=$(echo "select * from gf_flink_tb;" | \
50dc83
+        sqlite3 $B0/${V0}5/.glusterfs/${V0}5.db | wc -l )
50dc83
+TEST [ $ENTRY_COUNT -eq 3 ]
50dc83
+
50dc83
+# Delete the hard link
50dc83
+rm -rf $M0/lnk1
50dc83
+
50dc83
+# Corresponding hard link entry must be removed from gf_flink_tb
50dc83
+# but gf_file_tb should still contain the file entry [11]
50dc83
+ENTRY_COUNT=$(echo "select * from gf_file_tb; select * from gf_flink_tb;" | \
50dc83
+        sqlite3 $B0/${V0}5/.glusterfs/${V0}5.db | wc -l )
50dc83
+TEST [ $ENTRY_COUNT -eq 3 ]
50dc83
+
50dc83
+# Remove the file
50dc83
+rm -rf $M0/foo
50dc83
+
50dc83
+# Another hardlink removed [12]
50dc83
+ENTRY_COUNT=$(echo "select * from gf_file_tb; select * from gf_flink_tb;" | \
50dc83
+        sqlite3 $B0/${V0}5/.glusterfs/${V0}5.db | wc -l )
50dc83
+TEST [ $ENTRY_COUNT -eq 2 ]
50dc83
+
50dc83
+# Remove the last hardlink
50dc83
+rm -rf $M0/lnk2
50dc83
+
50dc83
+# All entried must be removed from gf_flink_tb and gf_file_tb [13]
50dc83
+ENTRY_COUNT=$(echo "select * from gf_file_tb; select * from gf_flink_tb;" | \
50dc83
+        sqlite3 $B0/${V0}5/.glusterfs/${V0}5.db | wc -l )
50dc83
+TEST [ $ENTRY_COUNT -eq 0 ]
50dc83
+
50dc83
+cleanup
50dc83
+
50dc83
+
50dc83
+
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=KNOWN_ISSUE,BUG=000000
50dc83
diff --git a/tests/bugs/tier/bug-1279376-rename-demoted-file.t b/tests/bugs/tier/bug-1279376-rename-demoted-file.t
50dc83
new file mode 100755
50dc83
index 0000000..c4a50d9
50dc83
--- /dev/null
50dc83
+++ b/tests/bugs/tier/bug-1279376-rename-demoted-file.t
50dc83
@@ -0,0 +1,93 @@
50dc83
+#!/bin/bash
50dc83
+
50dc83
+. $(dirname $0)/../../include.rc
50dc83
+. $(dirname $0)/../../volume.rc
50dc83
+. $(dirname $0)/../../tier.rc
50dc83
+
50dc83
+
50dc83
+NUM_BRICKS=2
50dc83
+DEMOTE_FREQ=15
50dc83
+DEMOTE_TIMEOUT=10
50dc83
+PROMOTE_FREQ=500
50dc83
+
50dc83
+
50dc83
+#Both src and dst files must hash to the same hot tier subvol
50dc83
+SRC_FILE="file1.txt"
50dc83
+DST_FILE="newfile1.txt"
50dc83
+
50dc83
+
50dc83
+# Creates a tiered volume with pure distribute hot and cold tiers
50dc83
+# Both hot and cold tiers will have an equal number of bricks.
50dc83
+
50dc83
+function create_dist_tier_vol () {
50dc83
+        mkdir $B0/cold
50dc83
+        mkdir $B0/hot
50dc83
+        TEST $CLI volume create $V0 $H0:$B0/cold/${V0}{0..$1}
50dc83
+        TEST $CLI volume set $V0 performance.quick-read off
50dc83
+        TEST $CLI volume set $V0 performance.io-cache off
50dc83
+        TEST $CLI volume start $V0
50dc83
+        TEST $CLI volume tier $V0 attach $H0:$B0/hot/${V0}{0..$1}
50dc83
+        TEST $CLI volume set $V0 cluster.tier-demote-frequency $DEMOTE_FREQ
50dc83
+        TEST $CLI volume set $V0 cluster.tier-promote-frequency $PROMOTE_FREQ
50dc83
+        TEST $CLI volume set $V0 cluster.tier-mode test
50dc83
+
50dc83
+#We do not want any files to be promoted during this test
50dc83
+        TEST $CLI volume set $V0 features.record-counters on
50dc83
+        TEST $CLI volume set $V0 cluster.read-freq-threshold 50
50dc83
+        TEST $CLI volume set $V0 cluster.write-freq-threshold 50
50dc83
+}
50dc83
+
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#Basic checks
50dc83
+TEST glusterd
50dc83
+TEST pidof glusterd
50dc83
+TEST $CLI volume info
50dc83
+
50dc83
+
50dc83
+#Create and start a tiered volume
50dc83
+create_dist_tier_vol $NUM_BRICKS
50dc83
+
50dc83
+# Mount FUSE
50dc83
+TEST glusterfs -s $H0 --volfile-id $V0 $M0
50dc83
+
50dc83
+
50dc83
+# The file will be created on the hot tier
50dc83
+
50dc83
+TEST touch "$M0/$SRC_FILE"
50dc83
+
50dc83
+# Get the path of the file on the hot tier
50dc83
+HPATH=`find $B0/hot/ -name  "$SRC_FILE"`
50dc83
+echo "File path on hot tier: "$HPATH
50dc83
+
50dc83
+
50dc83
+EXPECT "yes" exists_and_regular_file $HPATH
50dc83
+
50dc83
+# Wait for the tier process to demote the file
50dc83
+sleep $DEMOTE_FREQ
50dc83
+
50dc83
+# Get the path of the file on the cold tier
50dc83
+CPATH=`find $B0/cold/ -name  "$SRC_FILE"`
50dc83
+echo "File path on cold tier: "$CPATH
50dc83
+
50dc83
+EXPECT_WITHIN $DEMOTE_TIMEOUT "yes" exists_and_regular_file $CPATH
50dc83
+
50dc83
+#We don't want $DST_FILE to get demoted
50dc83
+TEST $CLI volume set $V0 cluster.tier-demote-frequency $PROMOTE_FREQ
50dc83
+
50dc83
+#This will be created on the hot tier
50dc83
+
50dc83
+touch "$M0/$DST_FILE"
50dc83
+HPATH=`find $B0/hot/ -name "$DST_FILE"`
50dc83
+echo "File path on hot tier: "$HPATH
50dc83
+
50dc83
+TEST mv $M0/$SRC_FILE $M0/$DST_FILE
50dc83
+
50dc83
+# We expect a single file to exist at this point
50dc83
+# when viewed on the mountpoint
50dc83
+EXPECT 1 echo $(ls -l $M0 | grep $DST_FILE | wc -l)
50dc83
+
50dc83
+cleanup;
50dc83
+
50dc83
+#G_TESTDEF_TEST_STATUS_NETBSD7=KNOWN_ISSUE,BUG=000000
50dc83
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
50dc83
index b7c7bd9..ed24858 100644
50dc83
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
50dc83
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
50dc83
@@ -1859,6 +1859,78 @@ out:
50dc83
     return ret;
50dc83
 }
50dc83
 
50dc83
+#if USE_GFDB /* only add changetimerecorder when GFDB is enabled */
50dc83
+static int
50dc83
+brick_graph_add_changetimerecorder(volgen_graph_t *graph,
50dc83
+                                   glusterd_volinfo_t *volinfo,
50dc83
+                                   dict_t *set_dict,
50dc83
+                                   glusterd_brickinfo_t *brickinfo)
50dc83
+{
50dc83
+    xlator_t *xl = NULL;
50dc83
+    int ret = -1;
50dc83
+    char *brickname = NULL;
50dc83
+    char *path = NULL;
50dc83
+    char index_basepath[PATH_MAX] = {0};
50dc83
+    char *hotbrick = NULL;
50dc83
+
50dc83
+    if (!graph || !volinfo || !set_dict || !brickinfo)
50dc83
+        goto out;
50dc83
+
50dc83
+    path = brickinfo->path;
50dc83
+
50dc83
+    xl = volgen_graph_add(graph, "features/changetimerecorder",
50dc83
+                          volinfo->volname);
50dc83
+    if (!xl)
50dc83
+        goto out;
50dc83
+
50dc83
+    ret = xlator_set_fixed_option(xl, "db-type", "sqlite3");
50dc83
+    if (ret)
50dc83
+        goto out;
50dc83
+
50dc83
+    if (!set_dict || dict_get_str(set_dict, "hot-brick", &hotbrick))
50dc83
+        hotbrick = "off";
50dc83
+
50dc83
+    ret = xlator_set_fixed_option(xl, "hot-brick", hotbrick);
50dc83
+    if (ret)
50dc83
+        goto out;
50dc83
+
50dc83
+    brickname = strrchr(path, '/') + 1;
50dc83
+    snprintf(index_basepath, sizeof(index_basepath), "%s.db", brickname);
50dc83
+    ret = xlator_set_fixed_option(xl, "db-name", index_basepath);
50dc83
+    if (ret)
50dc83
+        goto out;
50dc83
+
50dc83
+    snprintf(index_basepath, sizeof(index_basepath), "%s/%s", path,
50dc83
+             ".glusterfs/");
50dc83
+    ret = xlator_set_fixed_option(xl, "db-path", index_basepath);
50dc83
+    if (ret)
50dc83
+        goto out;
50dc83
+
50dc83
+    ret = xlator_set_fixed_option(xl, "record-exit", "off");
50dc83
+    if (ret)
50dc83
+        goto out;
50dc83
+
50dc83
+    ret = xlator_set_fixed_option(xl, "ctr_link_consistency", "off");
50dc83
+    if (ret)
50dc83
+        goto out;
50dc83
+
50dc83
+    ret = xlator_set_fixed_option(xl, "ctr_lookupheal_link_timeout", "300");
50dc83
+    if (ret)
50dc83
+        goto out;
50dc83
+
50dc83
+    ret = xlator_set_fixed_option(xl, "ctr_lookupheal_inode_timeout", "300");
50dc83
+    if (ret)
50dc83
+        goto out;
50dc83
+
50dc83
+    ret = xlator_set_fixed_option(xl, "record-entry", "on");
50dc83
+    if (ret)
50dc83
+        goto out;
50dc83
+
50dc83
+out:
50dc83
+    return ret;
50dc83
+}
50dc83
+#endif /* USE_GFDB */
50dc83
+
50dc83
 static int
50dc83
 brick_graph_add_acl(volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
50dc83
                     dict_t *set_dict, glusterd_brickinfo_t *brickinfo)
50dc83
@@ -2615,6 +2687,9 @@ static volgen_brick_xlator_t server_graph_table[] = {
50dc83
     {brick_graph_add_acl, "acl"},
50dc83
     {brick_graph_add_bitrot_stub, "bitrot-stub"},
50dc83
     {brick_graph_add_changelog, "changelog"},
50dc83
+#if USE_GFDB /* changetimerecorder depends on gfdb */
50dc83
+    {brick_graph_add_changetimerecorder, "changetimerecorder"},
50dc83
+#endif
50dc83
     {brick_graph_add_bd, "bd"},
50dc83
     {brick_graph_add_trash, "trash"},
50dc83
     {brick_graph_add_arbiter, "arbiter"},
50dc83
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
50dc83
index c8f6e67..a877805 100644
50dc83
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
50dc83
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
50dc83
@@ -11,6 +11,474 @@ cases as published by the Free Software Foundation.
50dc83
 #include "glusterd-volgen.h"
50dc83
 #include "glusterd-utils.h"
50dc83
 
50dc83
+#if USE_GFDB /* no GFDB means tiering is disabled */
50dc83
+
50dc83
+static int
50dc83
+get_tier_freq_threshold(glusterd_volinfo_t *volinfo, char *threshold_key)
50dc83
+{
50dc83
+    int threshold = 0;
50dc83
+    char *str_thresold = NULL;
50dc83
+    int ret = -1;
50dc83
+    xlator_t *this = NULL;
50dc83
+
50dc83
+    this = THIS;
50dc83
+    GF_ASSERT(this);
50dc83
+
50dc83
+    glusterd_volinfo_get(volinfo, threshold_key, &str_thresold);
50dc83
+    if (str_thresold) {
50dc83
+        ret = gf_string2int(str_thresold, &threshold);
50dc83
+        if (ret == -1) {
50dc83
+            threshold = ret;
50dc83
+            gf_msg(this->name, GF_LOG_ERROR, EINVAL, GD_MSG_INCOMPATIBLE_VALUE,
50dc83
+                   "Failed to convert "
50dc83
+                   "string to integer");
50dc83
+        }
50dc83
+    }
50dc83
+
50dc83
+    return threshold;
50dc83
+}
50dc83
+
50dc83
+/*
50dc83
+ * Validation function for record-counters
50dc83
+ * if write-freq-threshold and read-freq-threshold both have non-zero values
50dc83
+ * record-counters cannot be set to off
50dc83
+ * if record-counters is set to on
50dc83
+ * check if both the frequency thresholds are zero, then pop
50dc83
+ * a note, but volume set is not failed.
50dc83
+ * */
50dc83
+static int
50dc83
+validate_tier_counters(glusterd_volinfo_t *volinfo, dict_t *dict, char *key,
50dc83
+                       char *value, char **op_errstr)
50dc83
+{
50dc83
+    char errstr[2048] = "";
50dc83
+    int ret = -1;
50dc83
+    xlator_t *this = NULL;
50dc83
+    gf_boolean_t origin_val = -1;
50dc83
+    int current_wt = 0;
50dc83
+    int current_rt = 0;
50dc83
+
50dc83
+    this = THIS;
50dc83
+    GF_ASSERT(this);
50dc83
+
50dc83
+    if (volinfo->type != GF_CLUSTER_TYPE_TIER) {
50dc83
+        snprintf(errstr, sizeof(errstr),
50dc83
+                 "Volume %s is not a tier "
50dc83
+                 "volume. Option %s is only valid for tier volume.",
50dc83
+                 volinfo->volname, key);
50dc83
+        goto out;
50dc83
+    }
50dc83
+
50dc83
+    ret = gf_string2boolean(value, &origin_val);
50dc83
+    if (ret) {
50dc83
+        snprintf(errstr, sizeof(errstr),
50dc83
+                 "%s is not a compatible "
50dc83
+                 "value. %s expects an boolean value",
50dc83
+                 value, key);
50dc83
+        goto out;
50dc83
+    }
50dc83
+
50dc83
+    current_rt = get_tier_freq_threshold(volinfo,
50dc83
+                                         "cluster.read-freq-threshold");
50dc83
+    if (current_rt == -1) {
50dc83
+        snprintf(errstr, sizeof(errstr),
50dc83
+                 " Failed to retrieve value"
50dc83
+                 " of cluster.read-freq-threshold");
50dc83
+        goto out;
50dc83
+    }
50dc83
+    current_wt = get_tier_freq_threshold(volinfo,
50dc83
+                                         "cluster.write-freq-threshold");
50dc83
+    if (current_wt == -1) {
50dc83
+        snprintf(errstr, sizeof(errstr),
50dc83
+                 " Failed to retrieve value "
50dc83
+                 "of cluster.write-freq-threshold");
50dc83
+        goto out;
50dc83
+    }
50dc83
+    /* If record-counters is set to off */
50dc83
+    if (!origin_val) {
50dc83
+        /* Both the thresholds should be zero to set
50dc83
+         * record-counters to off*/
50dc83
+        if (current_rt || current_wt) {
50dc83
+            snprintf(errstr, sizeof(errstr),
50dc83
+                     "Cannot set features.record-counters to \"%s\""
50dc83
+                     " as cluster.write-freq-threshold is %d"
50dc83
+                     " and cluster.read-freq-threshold is %d. Please"
50dc83
+                     " set both cluster.write-freq-threshold and "
50dc83
+                     " cluster.read-freq-threshold to 0, to set "
50dc83
+                     " features.record-counters to \"%s\".",
50dc83
+                     value, current_wt, current_rt, value);
50dc83
+            ret = -1;
50dc83
+            goto out;
50dc83
+        }
50dc83
+    }
50dc83
+    /* TODO give a warning message to the user. errstr without re = -1 will
50dc83
+     * not result in a warning on cli for now.
50dc83
+    else {
50dc83
+            if (!current_rt && !current_wt) {
50dc83
+                    snprintf (errstr, sizeof (errstr),
50dc83
+                            " Note : cluster.write-freq-threshold is %d"
50dc83
+                            " and cluster.read-freq-threshold is %d. Please"
50dc83
+                            " set both cluster.write-freq-threshold and "
50dc83
+                            " cluster.read-freq-threshold to"
50dc83
+                            " appropriate positive values.",
50dc83
+                            current_wt, current_rt);
50dc83
+            }
50dc83
+    }*/
50dc83
+
50dc83
+    ret = 0;
50dc83
+out:
50dc83
+
50dc83
+    if (ret) {
50dc83
+        gf_msg(this->name, GF_LOG_ERROR, EINVAL, GD_MSG_INCOMPATIBLE_VALUE,
50dc83
+               "%s", errstr);
50dc83
+        *op_errstr = gf_strdup(errstr);
50dc83
+    }
50dc83
+
50dc83
+    return ret;
50dc83
+}
50dc83
+
50dc83
+/*
50dc83
+ * Validation function for ctr sql params
50dc83
+ *      features.ctr-sql-db-cachesize           (Range: 1000 to 262144 pages)
50dc83
+ *      features.ctr-sql-db-wal-autocheckpoint  (Range: 1000 to 262144 pages)
50dc83
+ * */
50dc83
+static int
50dc83
+validate_ctr_sql_params(glusterd_volinfo_t *volinfo, dict_t *dict, char *key,
50dc83
+                        char *value, char **op_errstr)
50dc83
+{
50dc83
+    int ret = -1;
50dc83
+    xlator_t *this = NULL;
50dc83
+    char errstr[2048] = "";
50dc83
+    int origin_val = -1;
50dc83
+
50dc83
+    this = THIS;
50dc83
+    GF_ASSERT(this);
50dc83
+
50dc83
+    ret = gf_string2int(value, &origin_val);
50dc83
+    if (ret) {
50dc83
+        snprintf(errstr, sizeof(errstr),
50dc83
+                 "%s is not a compatible "
50dc83
+                 "value. %s expects an integer value.",
50dc83
+                 value, key);
50dc83
+        ret = -1;
50dc83
+        goto out;
50dc83
+    }
50dc83
+
50dc83
+    if (origin_val < 0) {
50dc83
+        snprintf(errstr, sizeof(errstr),
50dc83
+                 "%s is not a "
50dc83
+                 "compatible value. %s expects a positive"
50dc83
+                 "integer value.",
50dc83
+                 value, key);
50dc83
+        ret = -1;
50dc83
+        goto out;
50dc83
+    }
50dc83
+
50dc83
+    if (strstr(key, "sql-db-cachesize") ||
50dc83
+        strstr(key, "sql-db-wal-autocheckpoint")) {
50dc83
+        if ((origin_val < 1000) || (origin_val > 262144)) {
50dc83
+            snprintf(errstr, sizeof(errstr),
50dc83
+                     "%s is not a "
50dc83
+                     "compatible value. %s "
50dc83
+                     "expects a value between : "
50dc83
+                     "1000 to 262144.",
50dc83
+                     value, key);
50dc83
+            ret = -1;
50dc83
+            goto out;
50dc83
+        }
50dc83
+    }
50dc83
+
50dc83
+    ret = 0;
50dc83
+out:
50dc83
+    if (ret) {
50dc83
+        gf_msg(this->name, GF_LOG_ERROR, EINVAL, GD_MSG_INCOMPATIBLE_VALUE,
50dc83
+               "%s", errstr);
50dc83
+        *op_errstr = gf_strdup(errstr);
50dc83
+    }
50dc83
+    return ret;
50dc83
+}
50dc83
+
50dc83
+/* Validation for tiering frequency thresholds
50dc83
+ * If any of the frequency thresholds are set to a non-zero value,
50dc83
+ * switch record-counters on, if not already on
50dc83
+ * If both the frequency thresholds are set to zero,
50dc83
+ * switch record-counters off, if not already off
50dc83
+ * */
50dc83
+static int
50dc83
+validate_tier_thresholds(glusterd_volinfo_t *volinfo, dict_t *dict, char *key,
50dc83
+                         char *value, char **op_errstr)
50dc83
+{
50dc83
+    char errstr[2048] = "";
50dc83
+    int ret = -1;
50dc83
+    xlator_t *this = NULL;
50dc83
+    int origin_val = -1;
50dc83
+    gf_boolean_t current_rc = _gf_false;
50dc83
+    int current_wt = 0;
50dc83
+    int current_rt = 0;
50dc83
+    gf_boolean_t is_set_rc = _gf_false;
50dc83
+    char *proposed_rc = NULL;
50dc83
+
50dc83
+    this = THIS;
50dc83
+    GF_ASSERT(this);
50dc83
+
50dc83
+    if (volinfo->type != GF_CLUSTER_TYPE_TIER) {
50dc83
+        snprintf(errstr, sizeof(errstr),
50dc83
+                 "Volume %s is not a tier "
50dc83
+                 "volume. Option %s is only valid for tier volume.",
50dc83
+                 volinfo->volname, key);
50dc83
+        goto out;
50dc83
+    }
50dc83
+
50dc83
+    ret = gf_string2int(value, &origin_val);
50dc83
+    if (ret) {
50dc83
+        snprintf(errstr, sizeof(errstr),
50dc83
+                 "%s is not a compatible "
50dc83
+                 "value. %s expects an integer value.",
50dc83
+                 value, key);
50dc83
+        ret = -1;
50dc83
+        goto out;
50dc83
+    }
50dc83
+
50dc83
+    if (origin_val < 0) {
50dc83
+        snprintf(errstr, sizeof(errstr),
50dc83
+                 "%s is not a "
50dc83
+                 "compatible value. %s expects a positive"
50dc83
+                 "integer value.",
50dc83
+                 value, key);
50dc83
+        ret = -1;
50dc83
+        goto out;
50dc83
+    }
50dc83
+
50dc83
+    /* Get the record-counters value */
50dc83
+    ret = glusterd_volinfo_get_boolean(volinfo, "features.record-counters");
50dc83
+    if (ret == -1) {
50dc83
+        snprintf(errstr, sizeof(errstr),
50dc83
+                 "Failed to retrieve value of"
50dc83
+                 "features.record-counters from volume info");
50dc83
+        goto out;
50dc83
+    }
50dc83
+    current_rc = ret;
50dc83
+
50dc83
+    /* if any of the thresholds are set to a non-zero value
50dc83
+     * switch record-counters on, if not already on*/
50dc83
+    if (origin_val > 0) {
50dc83
+        if (!current_rc) {
50dc83
+            is_set_rc = _gf_true;
50dc83
+            current_rc = _gf_true;
50dc83
+        }
50dc83
+    } else {
50dc83
+        /* if the set is for write-freq-threshold */
50dc83
+        if (strstr(key, "write-freq-threshold")) {
50dc83
+            current_rt = get_tier_freq_threshold(volinfo,
50dc83
+                                                 "cluster.read-freq-threshold");
50dc83
+            if (current_rt == -1) {
50dc83
+                snprintf(errstr, sizeof(errstr),
50dc83
+                         " Failed to retrieve value of"
50dc83
+                         "cluster.read-freq-threshold");
50dc83
+                goto out;
50dc83
+            }
50dc83
+            current_wt = origin_val;
50dc83
+        }
50dc83
+        /* else it should be read-freq-threshold */
50dc83
+        else {
50dc83
+            current_wt = get_tier_freq_threshold(
50dc83
+                volinfo, "cluster.write-freq-threshold");
50dc83
+            if (current_wt == -1) {
50dc83
+                snprintf(errstr, sizeof(errstr),
50dc83
+                         " Failed to retrieve value of"
50dc83
+                         "cluster.write-freq-threshold");
50dc83
+                goto out;
50dc83
+            }
50dc83
+            current_rt = origin_val;
50dc83
+        }
50dc83
+
50dc83
+        /* Since both the thresholds are zero, set record-counters
50dc83
+         * to off, if not already off */
50dc83
+        if (current_rt == 0 && current_wt == 0) {
50dc83
+            if (current_rc) {
50dc83
+                is_set_rc = _gf_true;
50dc83
+                current_rc = _gf_false;
50dc83
+            }
50dc83
+        }
50dc83
+    }
50dc83
+
50dc83
+    /* if record-counter has to be set to proposed value */
50dc83
+    if (is_set_rc) {
50dc83
+        if (current_rc) {
50dc83
+            ret = gf_asprintf(&proposed_rc, "on");
50dc83
+        } else {
50dc83
+            ret = gf_asprintf(&proposed_rc, "off");
50dc83
+        }
50dc83
+        if (ret < 0) {
50dc83
+            gf_msg(this->name, GF_LOG_ERROR, EINVAL, GD_MSG_INCOMPATIBLE_VALUE,
50dc83
+                   "Failed to allocate memory to dict_value");
50dc83
+            goto error;
50dc83
+        }
50dc83
+        ret = dict_set_str(volinfo->dict, "features.record-counters",
50dc83
+                           proposed_rc);
50dc83
+    error:
50dc83
+        if (ret) {
50dc83
+            snprintf(errstr, sizeof(errstr),
50dc83
+                     "Failed to set features.record-counters"
50dc83
+                     "to \"%s\" automatically."
50dc83
+                     "Please try to set features.record-counters "
50dc83
+                     "\"%s\" manually. The options "
50dc83
+                     "cluster.write-freq-threshold and "
50dc83
+                     "cluster.read-freq-threshold can only "
50dc83
+                     "be set to a non zero value, if "
50dc83
+                     "features.record-counters is "
50dc83
+                     "set to \"on\".",
50dc83
+                     proposed_rc, proposed_rc);
50dc83
+            goto out;
50dc83
+        }
50dc83
+    }
50dc83
+    ret = 0;
50dc83
+out:
50dc83
+    if (ret) {
50dc83
+        gf_msg(this->name, GF_LOG_ERROR, EINVAL, GD_MSG_INCOMPATIBLE_VALUE,
50dc83
+               "%s", errstr);
50dc83
+        *op_errstr = gf_strdup(errstr);
50dc83
+        if (proposed_rc)
50dc83
+            GF_FREE(proposed_rc);
50dc83
+    }
50dc83
+    return ret;
50dc83
+}
50dc83
+
50dc83
+static int
50dc83
+validate_tier(glusterd_volinfo_t *volinfo, dict_t *dict, char *key, char *value,
50dc83
+              char **op_errstr)
50dc83
+{
50dc83
+    char errstr[2048] = "";
50dc83
+    int ret = 0;
50dc83
+    xlator_t *this = NULL;
50dc83
+    int origin_val = -1;
50dc83
+    char *current_wm_hi = NULL;
50dc83
+    char *current_wm_low = NULL;
50dc83
+    uint64_t wm_hi = 0;
50dc83
+    uint64_t wm_low = 0;
50dc83
+
50dc83
+    this = THIS;
50dc83
+    GF_ASSERT(this);
50dc83
+
50dc83
+    if (volinfo->type != GF_CLUSTER_TYPE_TIER) {
50dc83
+        snprintf(errstr, sizeof(errstr),
50dc83
+                 "Volume %s is not a tier "
50dc83
+                 "volume. Option %s is only valid for tier volume.",
50dc83
+                 volinfo->volname, key);
50dc83
+        gf_msg(this->name, GF_LOG_ERROR, EINVAL, GD_MSG_INCOMPATIBLE_VALUE,
50dc83
+               "%s", errstr);
50dc83
+        *op_errstr = gf_strdup(errstr);
50dc83
+        ret = -1;
50dc83
+        goto out;
50dc83
+    }
50dc83
+
50dc83
+    if (strstr(key, "cluster.tier-mode")) {
50dc83
+        if (strcmp(value, "test") && strcmp(value, "cache")) {
50dc83
+            ret = -1;
50dc83
+            goto out;
50dc83
+        }
50dc83
+        goto out;
50dc83
+    } else if (strstr(key, "tier-pause")) {
50dc83
+        if (strcmp(value, "off") && strcmp(value, "on")) {
50dc83
+            ret = -1;
50dc83
+            goto out;
50dc83
+        }
50dc83
+        goto out;
50dc83
+    } else if (strstr(key, "tier-compact")) {
50dc83
+        if (strcmp(value, "on") && strcmp(value, "off")) {
50dc83
+            ret = -1;
50dc83
+            goto out;
50dc83
+        }
50dc83
+
50dc83
+        goto out;
50dc83
+    }
50dc83
+
50dc83
+    /*
50dc83
+     * Rest of the volume set options for tier are expecting a positive
50dc83
+     * Integer. Change the function accordingly if this constraint is
50dc83
+     * changed.
50dc83
+     */
50dc83
+    ret = gf_string2int(value, &origin_val);
50dc83
+    if (ret) {
50dc83
+        snprintf(errstr, sizeof(errstr),
50dc83
+                 "%s is not a compatible "
50dc83
+                 "value. %s expects an integer value.",
50dc83
+                 value, key);
50dc83
+        gf_msg(this->name, GF_LOG_ERROR, EINVAL, GD_MSG_INCOMPATIBLE_VALUE,
50dc83
+               "%s", errstr);
50dc83
+        *op_errstr = gf_strdup(errstr);
50dc83
+        ret = -1;
50dc83
+        goto out;
50dc83
+    }
50dc83
+
50dc83
+    if (strstr(key, "watermark-hi") || strstr(key, "watermark-low")) {
50dc83
+        if ((origin_val < 1) || (origin_val > 99)) {
50dc83
+            snprintf(errstr, sizeof(errstr),
50dc83
+                     "%s is not a "
50dc83
+                     "compatible value. %s expects a "
50dc83
+                     "percentage from 1-99.",
50dc83
+                     value, key);
50dc83
+            gf_msg(this->name, GF_LOG_ERROR, EINVAL, GD_MSG_INCOMPATIBLE_VALUE,
50dc83
+                   "%s", errstr);
50dc83
+            *op_errstr = gf_strdup(errstr);
50dc83
+            ret = -1;
50dc83
+            goto out;
50dc83
+        }
50dc83
+
50dc83
+        if (strstr(key, "watermark-hi")) {
50dc83
+            wm_hi = origin_val;
50dc83
+        } else {
50dc83
+            glusterd_volinfo_get(volinfo, "cluster.watermark-hi",
50dc83
+                                 &current_wm_hi);
50dc83
+            gf_string2bytesize_uint64(current_wm_hi, &wm_hi);
50dc83
+        }
50dc83
+
50dc83
+        if (strstr(key, "watermark-low")) {
50dc83
+            wm_low = origin_val;
50dc83
+        } else {
50dc83
+            glusterd_volinfo_get(volinfo, "cluster.watermark-low",
50dc83
+                                 &current_wm_low);
50dc83
+            gf_string2bytesize_uint64(current_wm_low, &wm_low);
50dc83
+        }
50dc83
+        if (wm_low >= wm_hi) {
50dc83
+            snprintf(errstr, sizeof(errstr),
50dc83
+                     "lower watermark"
50dc83
+                     " cannot be equal or exceed upper "
50dc83
+                     "watermark.");
50dc83
+            gf_msg(this->name, GF_LOG_ERROR, EINVAL, GD_MSG_INCOMPATIBLE_VALUE,
50dc83
+                   "%s", errstr);
50dc83
+            *op_errstr = gf_strdup(errstr);
50dc83
+            ret = -1;
50dc83
+            goto out;
50dc83
+        }
50dc83
+    } else if (strstr(key, "tier-promote-frequency") ||
50dc83
+               strstr(key, "tier-max-mb") ||
50dc83
+               strstr(key, "tier-max-promote-file-size") ||
50dc83
+               strstr(key, "tier-max-files") ||
50dc83
+               strstr(key, "tier-demote-frequency") ||
50dc83
+               strstr(key, "tier-hot-compact-frequency") ||
50dc83
+               strstr(key, "tier-cold-compact-frequency") ||
50dc83
+               strstr(key, "tier-query-limit")) {
50dc83
+        if (origin_val < 1) {
50dc83
+            snprintf(errstr, sizeof(errstr),
50dc83
+                     "%s is not a "
50dc83
+                     " compatible value. %s expects a positive "
50dc83
+                     "integer value greater than 0.",
50dc83
+                     value, key);
50dc83
+            gf_msg(this->name, GF_LOG_ERROR, EINVAL, GD_MSG_INCOMPATIBLE_VALUE,
50dc83
+                   "%s", errstr);
50dc83
+            *op_errstr = gf_strdup(errstr);
50dc83
+            ret = -1;
50dc83
+            goto out;
50dc83
+        }
50dc83
+    }
50dc83
+out:
50dc83
+    gf_msg_debug(this->name, 0, "Returning %d", ret);
50dc83
+
50dc83
+    return ret;
50dc83
+}
50dc83
+
50dc83
+#endif /* End for USE_GFDB */
50dc83
+
50dc83
 static int
50dc83
 validate_cache_max_min_size(glusterd_volinfo_t *volinfo, dict_t *dict,
50dc83
                             char *key, char *value, char **op_errstr)
50dc83
@@ -2485,6 +2953,261 @@ struct volopt_map_entry glusterd_volopt_map[] = {
50dc83
                     "/var/run/gluster/shared_storage on enabling this "
50dc83
                     "option. Unmount and delete the shared storage volume "
50dc83
                     " on disabling this option."},
50dc83
+#if USE_GFDB /* no GFDB means tiering is disabled */
50dc83
+    /* tier translator - global tunables */
50dc83
+    {.key = "cluster.write-freq-threshold",
50dc83
+     .voltype = "cluster/tier",
50dc83
+     .value = "0",
50dc83
+     .option = "write-freq-threshold",
50dc83
+     .op_version = GD_OP_VERSION_3_7_0,
50dc83
+     .flags = VOLOPT_FLAG_CLIENT_OPT,
50dc83
+     .validate_fn = validate_tier_thresholds,
50dc83
+     .description = "Defines the number of writes, in a promotion/demotion"
50dc83
+                    " cycle, that would mark a file HOT for promotion. Any"
50dc83
+                    " file that has write hits less than this value will "
50dc83
+                    "be considered as COLD and will be demoted."},
50dc83
+    {.key = "cluster.read-freq-threshold",
50dc83
+     .voltype = "cluster/tier",
50dc83
+     .value = "0",
50dc83
+     .option = "read-freq-threshold",
50dc83
+     .op_version = GD_OP_VERSION_3_7_0,
50dc83
+     .flags = VOLOPT_FLAG_CLIENT_OPT,
50dc83
+     .validate_fn = validate_tier_thresholds,
50dc83
+     .description = "Defines the number of reads, in a promotion/demotion "
50dc83
+                    "cycle, that would mark a file HOT for promotion. Any "
50dc83
+                    "file that has read hits less than this value will be "
50dc83
+                    "considered as COLD and will be demoted."},
50dc83
+    {
50dc83
+        .key = "cluster.tier-pause",
50dc83
+        .voltype = "cluster/tier",
50dc83
+        .option = "tier-pause",
50dc83
+        .op_version = GD_OP_VERSION_3_7_6,
50dc83
+        .flags = VOLOPT_FLAG_CLIENT_OPT,
50dc83
+        .validate_fn = validate_tier,
50dc83
+    },
50dc83
+    {
50dc83
+        .key = "cluster.tier-promote-frequency",
50dc83
+        .voltype = "cluster/tier",
50dc83
+        .value = "120",
50dc83
+        .option = "tier-promote-frequency",
50dc83
+        .op_version = GD_OP_VERSION_3_7_0,
50dc83
+        .flags = VOLOPT_FLAG_CLIENT_OPT,
50dc83
+        .validate_fn = validate_tier,
50dc83
+    },
50dc83
+    {
50dc83
+        .key = "cluster.tier-demote-frequency",
50dc83
+        .voltype = "cluster/tier",
50dc83
+        .value = "3600",
50dc83
+        .option = "tier-demote-frequency",
50dc83
+        .op_version = GD_OP_VERSION_3_7_0,
50dc83
+        .flags = VOLOPT_FLAG_CLIENT_OPT,
50dc83
+        .validate_fn = validate_tier,
50dc83
+    },
50dc83
+    {.key = "cluster.watermark-hi",
50dc83
+     .voltype = "cluster/tier",
50dc83
+     .value = "90",
50dc83
+     .option = "watermark-hi",
50dc83
+     .op_version = GD_OP_VERSION_3_7_6,
50dc83
+     .flags = VOLOPT_FLAG_CLIENT_OPT,
50dc83
+     .validate_fn = validate_tier,
50dc83
+     .description =
50dc83
+         "Upper % watermark for promotion. If hot tier fills"
50dc83
+         " above this percentage, no promotion will happen and demotion will "
50dc83
+         "happen with high probability."},
50dc83
+    {.key = "cluster.watermark-low",
50dc83
+     .voltype = "cluster/tier",
50dc83
+     .value = "75",
50dc83
+     .option = "watermark-low",
50dc83
+     .op_version = GD_OP_VERSION_3_7_6,
50dc83
+     .flags = VOLOPT_FLAG_CLIENT_OPT,
50dc83
+     .validate_fn = validate_tier,
50dc83
+     .description =
50dc83
+         "Lower % watermark. If hot tier is less "
50dc83
+         "full than this, promotion will happen and demotion will not happen. "
50dc83
+         "If greater than this, promotion/demotion will happen at a "
50dc83
+         "probability "
50dc83
+         "relative to how full the hot tier is."},
50dc83
+    {.key = "cluster.tier-mode",
50dc83
+     .voltype = "cluster/tier",
50dc83
+     .option = "tier-mode",
50dc83
+     .value = "cache",
50dc83
+     .op_version = GD_OP_VERSION_3_7_6,
50dc83
+     .flags = VOLOPT_FLAG_CLIENT_OPT,
50dc83
+     .validate_fn = validate_tier,
50dc83
+     .description =
50dc83
+         "Either 'test' or 'cache'. Test mode periodically"
50dc83
+         " demotes or promotes files automatically based on access."
50dc83
+         " Cache mode does so based on whether the cache is full or not,"
50dc83
+         " as specified with watermarks."},
50dc83
+    {.key = "cluster.tier-max-promote-file-size",
50dc83
+     .voltype = "cluster/tier",
50dc83
+     .option = "tier-max-promote-file-size",
50dc83
+     .value = "0",
50dc83
+     .op_version = GD_OP_VERSION_3_7_10,
50dc83
+     .flags = VOLOPT_FLAG_CLIENT_OPT,
50dc83
+     .validate_fn = validate_tier,
50dc83
+     .description =
50dc83
+         "The maximum file size in bytes that is promoted. If 0, there"
50dc83
+         " is no maximum size (default)."},
50dc83
+    {.key = "cluster.tier-max-mb",
50dc83
+     .voltype = "cluster/tier",
50dc83
+     .option = "tier-max-mb",
50dc83
+     .value = "4000",
50dc83
+     .op_version = GD_OP_VERSION_3_7_6,
50dc83
+     .flags = VOLOPT_FLAG_CLIENT_OPT,
50dc83
+     .validate_fn = validate_tier,
50dc83
+     .description = "The maximum number of MB that may be migrated"
50dc83
+                    " in any direction in a given cycle by a single node."},
50dc83
+    {.key = "cluster.tier-max-files",
50dc83
+     .voltype = "cluster/tier",
50dc83
+     .option = "tier-max-files",
50dc83
+     .value = "10000",
50dc83
+     .op_version = GD_OP_VERSION_3_7_6,
50dc83
+     .flags = VOLOPT_FLAG_CLIENT_OPT,
50dc83
+     .validate_fn = validate_tier,
50dc83
+     .description = "The maximum number of files that may be migrated"
50dc83
+                    " in any direction in a given cycle by a single node."},
50dc83
+    {.key = "cluster.tier-query-limit",
50dc83
+     .voltype = "cluster/tier",
50dc83
+     .option = "tier-query-limit",
50dc83
+     .value = "100",
50dc83
+     .op_version = GD_OP_VERSION_3_9_1,
50dc83
+     .flags = VOLOPT_FLAG_CLIENT_OPT,
50dc83
+     .validate_fn = validate_tier,
50dc83
+     .type = NO_DOC,
50dc83
+     .description = "The maximum number of files that may be migrated "
50dc83
+                    "during an emergency demote. An emergency condition "
50dc83
+                    "is flagged when writes breach the hi-watermark."},
50dc83
+    {.key = "cluster.tier-compact",
50dc83
+     .voltype = "cluster/tier",
50dc83
+     .option = "tier-compact",
50dc83
+     .value = "on",
50dc83
+     .op_version = GD_OP_VERSION_3_9_0,
50dc83
+     .flags = VOLOPT_FLAG_CLIENT_OPT,
50dc83
+     .validate_fn = validate_tier,
50dc83
+     .description = "Activate or deactivate the compaction of the DB"
50dc83
+                    " for the volume's metadata."},
50dc83
+    {
50dc83
+        .key = "cluster.tier-hot-compact-frequency",
50dc83
+        .voltype = "cluster/tier",
50dc83
+        .value = "604800",
50dc83
+        .option = "tier-hot-compact-frequency",
50dc83
+        .op_version = GD_OP_VERSION_3_9_0,
50dc83
+        .flags = VOLOPT_FLAG_CLIENT_OPT,
50dc83
+        .validate_fn = validate_tier,
50dc83
+    },
50dc83
+    {
50dc83
+        .key = "cluster.tier-cold-compact-frequency",
50dc83
+        .voltype = "cluster/tier",
50dc83
+        .value = "604800",
50dc83
+        .option = "tier-cold-compact-frequency",
50dc83
+        .op_version = GD_OP_VERSION_3_9_0,
50dc83
+        .flags = VOLOPT_FLAG_CLIENT_OPT,
50dc83
+        .validate_fn = validate_tier,
50dc83
+    },
50dc83
+    {.key = "features.ctr-enabled",
50dc83
+     .voltype = "features/changetimerecorder",
50dc83
+     .value = "off",
50dc83
+     .option = "ctr-enabled",
50dc83
+     .op_version = GD_OP_VERSION_3_7_0,
50dc83
+     .description = "Enable CTR xlator"},
50dc83
+    {.key = "features.record-counters",
50dc83
+     .voltype = "features/changetimerecorder",
50dc83
+     .value = "off",
50dc83
+     .option = "record-counters",
50dc83
+     .op_version = GD_OP_VERSION_3_7_0,
50dc83
+     .validate_fn = validate_tier_counters,
50dc83
+     .description = "Its a Change Time Recorder Xlator option to "
50dc83
+                    "enable recording write "
50dc83
+                    "and read heat counters. The default is disabled. "
50dc83
+                    "If enabled, \"cluster.write-freq-threshold\" and "
50dc83
+                    "\"cluster.read-freq-threshold\" defined the number "
50dc83
+                    "of writes (or reads) to a given file are needed "
50dc83
+                    "before triggering migration."},
50dc83
+    {.key = "features.ctr-record-metadata-heat",
50dc83
+     .voltype = "features/changetimerecorder",
50dc83
+     .value = "off",
50dc83
+     .option = "ctr-record-metadata-heat",
50dc83
+     .op_version = GD_OP_VERSION_3_7_0,
50dc83
+     .type = NO_DOC,
50dc83
+     .description = "Its a Change Time Recorder Xlator option to "
50dc83
+                    "enable recording write heat on metadata of the file. "
50dc83
+                    "The default is disabled. "
50dc83
+                    "Metadata is inode attributes like atime, mtime,"
50dc83
+                    " permissions etc and "
50dc83
+                    "extended attributes of a file ."},
50dc83
+    {.key = "features.ctr_link_consistency",
50dc83
+     .voltype = "features/changetimerecorder",
50dc83
+     .value = "off",
50dc83
+     .option = "ctr_link_consistency",
50dc83
+     .op_version = GD_OP_VERSION_3_7_0,
50dc83
+     .type = NO_DOC,
50dc83
+     .description = "Enable a crash consistent way of recording hardlink "
50dc83
+                    "updates by Change Time Recorder Xlator. "
50dc83
+                    "When recording in a crash "
50dc83
+                    "consistent way the data operations will "
50dc83
+                    "experience more latency."},
50dc83
+    {.key = "features.ctr_lookupheal_link_timeout",
50dc83
+     .voltype = "features/changetimerecorder",
50dc83
+     .value = "300",
50dc83
+     .option = "ctr_lookupheal_link_timeout",
50dc83
+     .op_version = GD_OP_VERSION_3_7_2,
50dc83
+     .type = NO_DOC,
50dc83
+     .description = "Defines the expiry period of in-memory "
50dc83
+                    "hardlink of an inode,"
50dc83
+                    "used by lookup heal in Change Time Recorder."
50dc83
+                    "Once the expiry period"
50dc83
+                    "hits an attempt to heal the database per "
50dc83
+                    "hardlink is done and the "
50dc83
+                    "in-memory hardlink period is reset"},
50dc83
+    {.key = "features.ctr_lookupheal_inode_timeout",
50dc83
+     .voltype = "features/changetimerecorder",
50dc83
+     .value = "300",
50dc83
+     .option = "ctr_lookupheal_inode_timeout",
50dc83
+     .op_version = GD_OP_VERSION_3_7_2,
50dc83
+     .type = NO_DOC,
50dc83
+     .description = "Defines the expiry period of in-memory inode,"
50dc83
+                    "used by lookup heal in Change Time Recorder. "
50dc83
+                    "Once the expiry period"
50dc83
+                    "hits an attempt to heal the database per "
50dc83
+                    "inode is done"},
50dc83
+    {.key = "features.ctr-sql-db-cachesize",
50dc83
+     .voltype = "features/changetimerecorder",
50dc83
+     .value = "12500",
50dc83
+     .option = "sql-db-cachesize",
50dc83
+     .validate_fn = validate_ctr_sql_params,
50dc83
+     .op_version = GD_OP_VERSION_3_7_7,
50dc83
+     .description = "Defines the cache size of the sqlite database of "
50dc83
+                    "changetimerecorder xlator."
50dc83
+                    "The input to this option is in pages."
50dc83
+                    "Each page is 4096 bytes. Default value is 12500 "
50dc83
+                    "pages."
50dc83
+                    "The max value is 262144 pages i.e 1 GB and "
50dc83
+                    "the min value is 1000 pages i.e ~ 4 MB. "},
50dc83
+    {.key = "features.ctr-sql-db-wal-autocheckpoint",
50dc83
+     .voltype = "features/changetimerecorder",
50dc83
+     .value = "25000",
50dc83
+     .option = "sql-db-wal-autocheckpoint",
50dc83
+     .validate_fn = validate_ctr_sql_params,
50dc83
+     .op_version = GD_OP_VERSION_3_7_7,
50dc83
+     .description = "Defines the autocheckpoint of the sqlite database of "
50dc83
+                    " changetimerecorder. "
50dc83
+                    "The input to this option is in pages. "
50dc83
+                    "Each page is 4096 bytes. Default value is 25000 "
50dc83
+                    "pages."
50dc83
+                    "The max value is 262144 pages i.e 1 GB and "
50dc83
+                    "the min value is 1000 pages i.e ~4 MB."},
50dc83
+    {.key = VKEY_FEATURES_SELINUX,
50dc83
+     .voltype = "features/selinux",
50dc83
+     .type = NO_DOC,
50dc83
+     .value = "on",
50dc83
+     .op_version = GD_OP_VERSION_3_11_0,
50dc83
+     .description = "Convert security.selinux xattrs to "
50dc83
+                    "trusted.gluster.selinux on the bricks. Recommended "
50dc83
+                    "to have enabled when clients and/or bricks support "
50dc83
+                    "SELinux."},
50dc83
+
50dc83
+#endif /* USE_GFDB */
50dc83
     {
50dc83
         .key = "locks.trace",
50dc83
         .voltype = "features/locks",
50dc83
-- 
50dc83
1.8.3.1
50dc83