From c85b7c2c0c7b8b9e576ebd20e7446b9051c733e4 Mon Sep 17 00:00:00 2001 From: Jiffin Tony Thottan Date: Wed, 25 Mar 2015 15:04:19 +0530 Subject: features/trash : Notify CTR translator if an unlink happens to a file Backport of http://review.gluster.org/#/c/9989/ This implementation is same as the posix_unlink_cbk() where CTR sends a request during a unlink to send the number of links to the inode and posix obliges sending it using the unwind xdata dict. For Trash xlator a unlink is stat + mkdir(if parent is not present) + rename. And hence this is handled in trash_unlink_rename_cbk(). Change-Id: I402e83567b88e3c9fe171379693c82937af567f9 BUG: 1218032 Signed-off-by: Jiffin Tony Thottan Signed-off-by: Joseph Fernandes Signed-off-by: Anoop C S Reviewed-on: http://review.gluster.org/10513 Reviewed-by: Joseph Fernandes Tested-by: Gluster Build System Reviewed-by: Dan Lambright Reviewed-by: Vijay Bellur --- .../tier/bug-1205545-CTR-and-trash-integration.t | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/bugs/tier/bug-1205545-CTR-and-trash-integration.t (limited to 'tests/bugs/tier') diff --git a/tests/bugs/tier/bug-1205545-CTR-and-trash-integration.t b/tests/bugs/tier/bug-1205545-CTR-and-trash-integration.t new file mode 100644 index 00000000000..979c3e8c83a --- /dev/null +++ b/tests/bugs/tier/bug-1205545-CTR-and-trash-integration.t @@ -0,0 +1,71 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +LAST_BRICK=3 +CACHE_BRICK_FIRST=4 +CACHE_BRICK_LAST=5 + +cleanup + +# Start glusterd [1-2] +TEST glusterd +TEST pidof glusterd + +# Set-up tier cluster [3-4] +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0..$LAST_BRICK} +TEST $CLI volume attach-tier $V0 replica 2 $H0:$B0/${V0}$CACHE_BRICK_FIRST $H0:$B0/${V0}$CACHE_BRICK_LAST + +# Start and mount the volume after enabling CTR and trash [5-8] +TEST $CLI volume set $V0 features.ctr-enabled on +TEST $CLI volume set $V0 features.trash on +TEST $CLI volume start $V0 +TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0; + +# Create an empty file +touch $M0/foo + +# gf_file_tb and gf_flink_tb should contain one entry each [9] +ENTRY_COUNT=$(echo "select * from gf_file_tb; select * from gf_flink_tb;" | \ + sqlite3 $B0/${V0}5/.glusterfs/${V0}5.db | wc -l ) +TEST [ $ENTRY_COUNT -eq 2 ] + +# Create two hard links +ln $M0/foo $M0/lnk1 +ln $M0/foo $M0/lnk2 + +# Now gf_flink_tb should contain 3 entries [10] +ENTRY_COUNT=$(echo "select * from gf_flink_tb;" | \ + sqlite3 $B0/${V0}5/.glusterfs/${V0}5.db | wc -l ) +TEST [ $ENTRY_COUNT -eq 3 ] + +# Delete the hard link +rm -rf $M0/lnk1 + +# Corresponding hard link entry must be removed from gf_flink_tb +# but gf_file_tb should still contain the file entry [11] +ENTRY_COUNT=$(echo "select * from gf_file_tb; select * from gf_flink_tb;" | \ + sqlite3 $B0/${V0}5/.glusterfs/${V0}5.db | wc -l ) +TEST [ $ENTRY_COUNT -eq 3 ] + +# Remove the file +rm -rf $M0/foo + +# Another hardlink removed [12] +ENTRY_COUNT=$(echo "select * from gf_file_tb; select * from gf_flink_tb;" | \ + sqlite3 $B0/${V0}5/.glusterfs/${V0}5.db | wc -l ) +TEST [ $ENTRY_COUNT -eq 2 ] + +# Remove the last hardlink +rm -rf $M0/lnk2 + +# All entried must be removed from gf_flink_tb and gf_file_tb [13] +ENTRY_COUNT=$(echo "select * from gf_file_tb; select * from gf_flink_tb;" | \ + sqlite3 $B0/${V0}5/.glusterfs/${V0}5.db | wc -l ) +TEST [ $ENTRY_COUNT -eq 0 ] + +cleanup + + + -- cgit