diff options
Diffstat (limited to 'tests/bugs/posix')
| -rw-r--r-- | tests/bugs/posix/bug-1034716.t | 60 | ||||
| -rwxr-xr-x | tests/bugs/posix/bug-1040275-brick-uid-reset-on-volume-restart.t | 60 | ||||
| -rwxr-xr-x | tests/bugs/posix/bug-1113960.t | 98 | ||||
| -rwxr-xr-x | tests/bugs/posix/bug-1122028.t | 51 | ||||
| -rw-r--r-- | tests/bugs/posix/bug-1175711.c | 37 | ||||
| -rwxr-xr-x | tests/bugs/posix/bug-1175711.t | 30 | ||||
| -rw-r--r-- | tests/bugs/posix/bug-1360679.t | 36 | ||||
| -rwxr-xr-x | tests/bugs/posix/bug-1619720.t | 58 | ||||
| -rw-r--r-- | tests/bugs/posix/bug-1651445.t | 54 | ||||
| -rw-r--r-- | tests/bugs/posix/bug-765380.t | 39 | ||||
| -rwxr-xr-x | tests/bugs/posix/bug-990028.t | 157 | ||||
| -rw-r--r-- | tests/bugs/posix/bug-gfid-path.t | 70 | ||||
| -rw-r--r-- | tests/bugs/posix/disallow-gfid-volumeid-fremovexattr.c | 104 | ||||
| -rwxr-xr-x | tests/bugs/posix/disallow-gfid-volumeid-fremovexattr.t | 21 | ||||
| -rw-r--r-- | tests/bugs/posix/disallow-gfid-volumeid-removexattr.t | 26 |
15 files changed, 901 insertions, 0 deletions
diff --git a/tests/bugs/posix/bug-1034716.t b/tests/bugs/posix/bug-1034716.t new file mode 100644 index 00000000000..d36f8b598f4 --- /dev/null +++ b/tests/bugs/posix/bug-1034716.t @@ -0,0 +1,60 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +#Basic checks +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info + +#Create a distributed volume +TEST $CLI volume create $V0 $H0:$B0/${V0}{1..2}; +TEST $CLI volume start $V0 + +# Mount FUSE +TEST glusterfs -s $H0 --volfile-id $V0 $M0 + +#Create a file and perform fop on a DIR +TEST touch $M0/foo + +function xattr_query_check() { + local path=$1 + + local ret=`getfattr -m . -d $path 2>&1 | grep -c 'trusted.glusterfs'` + echo $ret +} + +function set_xattr() { + local path=$1 + local xa_name=$2 + local xa_val=$3 + + setfattr -n $xa_name -v $xa_val $path + echo $? +} + +function remove_xattr() { + local path=$1 + local xa_name=$2 + + setfattr -x $xa_name $path + echo $? +} + +EXPECT 0 xattr_query_check $M0/ +EXPECT 0 xattr_query_check $M0/foo + +EXPECT 1 set_xattr $M0/ 'trusted.glusterfs.volume-id' 'foo' +EXPECT 1 remove_xattr $M0/ 'trusted.glusterfs.volume-id' + + +## Finish up +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0; +TEST ! $CLI volume info $V0; + +cleanup; diff --git a/tests/bugs/posix/bug-1040275-brick-uid-reset-on-volume-restart.t b/tests/bugs/posix/bug-1040275-brick-uid-reset-on-volume-restart.t new file mode 100755 index 00000000000..3839c6e3380 --- /dev/null +++ b/tests/bugs/posix/bug-1040275-brick-uid-reset-on-volume-restart.t @@ -0,0 +1,60 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +function get_uid() { + stat -c '%u' $1; +} + +function get_gid() { + stat -c '%g' $1; +} + +function check_stat() { + stat $1 + echo $? +} + +cleanup; + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{1,2,3,4,5,6}; + +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; +EXPECT '6' brick_count $V0 + +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +TEST glusterfs -s $H0 --volfile-id $V0 $M0; + +EXPECT 0 get_uid $M0; +EXPECT 0 get_gid $M0; + +TEST chown 100:101 $M0; + +EXPECT 100 get_uid $M0; +EXPECT 101 get_gid $M0; + +TEST $CLI volume stop $V0; +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" online_brick_count + +TEST $CLI volume start $V0; +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "6" online_brick_count + +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 2 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 3 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 4 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 5 + +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" check_stat $M0 +EXPECT 100 get_uid $M0; +EXPECT 101 get_gid $M0; + +cleanup; diff --git a/tests/bugs/posix/bug-1113960.t b/tests/bugs/posix/bug-1113960.t new file mode 100755 index 00000000000..ee42de2a092 --- /dev/null +++ b/tests/bugs/posix/bug-1113960.t @@ -0,0 +1,98 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../nfs.rc + +NUM_DIRS=50 +NUM_FILES=10 + +create_dirs () { + for (( i=1; i<=$NUM_DIRS; i+=1));do + mkdir $1/olddir$i + for (( j=0; j<$NUM_FILES; j+=1));do + echo "This is file $j in dir $i" > $1/olddir$i/file$j; + done + done + echo "0" > $M0/status +} + +move_dirs () { + old_path="$1" + new_path="$1" + + #Create a deep directory + for (( i=$NUM_DIRS; i>=2; i-=1));do + mv $1/olddir$i $1/olddir`expr $i - 1` > /dev/null 2>&1; + done + + #Start renaming files and dirs so the paths change for the + #posix_handle_path calculations + + for (( i=1; i<=$NUM_DIRS; i+=1));do + old_path="$new_path/olddir$i" + new_path="$new_path/longernamedir$i" + mv $old_path $new_path; + + for (( j=0; j<$NUM_FILES; j+=1));do + mv $new_path/file$j $new_path/newfile$j > /dev/null 2>&1; + done + done + echo "done" > $M0/status +} + +ls_loop () { + #Loop until the move_dirs function is done + for (( i=0; i<=500; i+=1 )); do + ls -lR $1 > /dev/null 2>&1 + done +} + + +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info; + +TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2,3,4}; + +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; +EXPECT '4' brick_count $V0 + +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +## Mount FUSE with caching disabled (read-write) +TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0; + +TEST create_dirs $M0 + +## Mount FUSE with caching disabled (read-write) again +TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M1; + +TEST glusterfs -s $H0 --volfile-id $V0 $M2; + +(ls_loop $M1)& +ls_pid1=$! + +(ls_loop $M2)& +ls_pid2=$! + + +#Start moving/renaming the directories so the paths change +TEST move_dirs $M0 + +EXPECT_WITHIN 180 "done" cat $M0/status + +#Kill the ls processes + +kill -SIGTERM $ls_pid1 +kill -SIGTERM $ls_pid2 + + +#Check if all bricks are still up +EXPECT '4' online_brick_count $V0 + +cleanup; diff --git a/tests/bugs/posix/bug-1122028.t b/tests/bugs/posix/bug-1122028.t new file mode 100755 index 00000000000..492668cf1dc --- /dev/null +++ b/tests/bugs/posix/bug-1122028.t @@ -0,0 +1,51 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info + +# Create a 1x1 distributed volume +TEST $CLI volume create $V0 $H0:$B0/${V0}0 +EXPECT 'Created' volinfo_field $V0 'Status' + +# Start volume +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status' + +# Mount volume over FUSE +TEST glusterfs -s $H0 --volfile-id $V0 $M0 + +TEST mkdir $M0/dir +TEST touch $M0/dir/a +TEST ln $M0/dir/a $M0/dir/b + +# Confirm hardlinks +inum1=$(ls -i $M0/dir/a | cut -d' ' -f1) +inum2=$(ls -i $M0/dir/b | cut -d' ' -f1) +TEST [ "$inum1" = "$inum2" ] + +# Turn on build-pgfid +TEST $CLI volume set $V0 build-pgfid on +EXPECT 'on' volinfo_field $V0 'storage.build-pgfid' + +# Unlink files +TEST unlink $M0/dir/a +TEST unlink $M0/dir/b + +# Unmount +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 + +# Stop the volume +TEST $CLI volume stop $V0; +EXPECT 'Stopped' volinfo_field $V0 'Status'; + +# Delete the volume +TEST $CLI volume delete $V0; +TEST ! $CLI volume info $V0; + +cleanup diff --git a/tests/bugs/posix/bug-1175711.c b/tests/bugs/posix/bug-1175711.c new file mode 100644 index 00000000000..8ab193c4014 --- /dev/null +++ b/tests/bugs/posix/bug-1175711.c @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <dirent.h> +#include <string.h> +#include <assert.h> + +int +main(int argc, char **argv) +{ + DIR *dir = NULL; + struct dirent *entry = NULL; + int ret = 0; + char *path = NULL; + + assert(argc == 2); + path = argv[1]; + + dir = opendir(path); + if (!dir) { + printf("opendir(%s) failed.\n", path); + return -1; + } + +#ifdef _DIRENT_HAVE_D_TYPE + while ((entry = readdir(dir)) != NULL) { + if (entry->d_type == DT_UNKNOWN) { + printf("d_type found to be DT_UNKNOWN\n"); + ret = -1; + break; + } + } +#endif + + if (dir) + closedir(dir); + + return ret; +} diff --git a/tests/bugs/posix/bug-1175711.t b/tests/bugs/posix/bug-1175711.t new file mode 100755 index 00000000000..f4162544d92 --- /dev/null +++ b/tests/bugs/posix/bug-1175711.t @@ -0,0 +1,30 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +# Create, start and mount the volume. +TEST glusterd; +TEST $CLI volume create $V0 $H0:$B0/$V0; +TEST $CLI volume start $V0; +TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0 + +# Compile the test program +TEST $CC -Wall $(dirname $0)/bug-1175711.c -o $(dirname $0)/bug-1175711 + +# Create directory and some entries inside them. +mkdir -p $M0/dir-bug-1175711 +mkdir -p $M0/dir-bug-1175711/DT_DIR +touch $M0/dir-bug-1175711/DT_REG + +# Invoke the test program and pass path of directory to it. +TEST $(dirname $0)/bug-1175711 $M0/dir-bug-1175711 + +# Unmount, stop and delete the volume +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 +TEST $CLI volume stop $V0; +TEST $CLI volume delete $V0; + +cleanup; diff --git a/tests/bugs/posix/bug-1360679.t b/tests/bugs/posix/bug-1360679.t new file mode 100644 index 00000000000..fbb9d027ddb --- /dev/null +++ b/tests/bugs/posix/bug-1360679.t @@ -0,0 +1,36 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../fileio.rc + +cleanup +function num_entries { + ls -l $1 | wc -l +} + +function create_unlink_entry { + for i in {0..1} + do + mkdir -p $B0/${V0}$i/.glusterfs/unlink/{1..3}/{1..10}/1 + dd if=/dev/urandom of=$B0/${V0}$i/.glusterfs/unlink/file-1 bs=1M count=1 + dd if=/dev/urandom of=$B0/${V0}$i/.glusterfs/unlink/file-2 bs=1M count=1 + dd if=/dev/urandom of=$B0/${V0}$i/.glusterfs/unlink/1/file-1 bs=1M count=1 + dd if=/dev/urandom of=$B0/${V0}$i/.glusterfs/unlink/2/file-1 bs=1M count=1 + dd if=/dev/urandom of=$B0/${V0}$i/.glusterfs/unlink/3/file-1 bs=1M count=1 + ln $B0/${V0}$i/.glusterfs/unlink/file-1 $B0/${V0}$i/.glusterfs/unlink/file-link + ln -s $B0/${V0}$i/.glusterfs/unlink/1 $B0/${V0}$i/.glusterfs/unlink/link + ln -s $B0/${V0}$i/.glusterfs/unlink/2 $B0/${V0}$i/.glusterfs/unlink/link-2 + done +} + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 disperse 6 redundancy 2 $H0:$B0/${V0}{0..5} +TEST $CLI volume start $V0 +TEST $CLI volume stop $V0 +create_unlink_entry +TEST $CLI volume start $V0 +EXPECT_WITHIN $UNLINK_TIMEOUT "^1$" num_entries $B0/${V0}0/.glusterfs/unlink/ +EXPECT_WITHIN $UNLINK_TIMEOUT "^1$" num_entries $B0/${V0}1/.glusterfs/unlink/ +cleanup; diff --git a/tests/bugs/posix/bug-1619720.t b/tests/bugs/posix/bug-1619720.t new file mode 100755 index 00000000000..bfd304dc809 --- /dev/null +++ b/tests/bugs/posix/bug-1619720.t @@ -0,0 +1,58 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../dht.rc + +cleanup; + + +# Test steps: +# The test checks to make sure that the trusted.pgfid.xx xattr is set on +# both the linkto and data files post the final rename. +# The test creates files file-1 and file-3 so that src_hashed = dst_hashed, +# src_cached = dst_cached and xxx_hashed != xxx_cached. +# It then renames file-1 to file-3 which triggers the posix_mknod call +# which updates the trusted.pgfid.xx xattr. + + +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 +TEST $CLI volume start $V0 +TEST $CLI volume set $V0 storage.build-pgfid on + +## Mount FUSE +TEST glusterfs -s $H0 --volfile-id $V0 $M0; + +TEST mkdir $M0/tmp + + + +# Not the best way to do this but I need files which hash to the same subvol and +# whose cached subvols are the same. +# In a 2 subvol distributed volume, file-{1,3} hash to the same subvol. +# file-2 will hash to the other subvol + +TEST touch $M0/tmp/file-2 +pgfid_xattr_name=$(getfattr -m "trusted.pgfid.*" $B0/${V0}1/tmp/file-2 | grep "trusted.pgfid") +echo $pgfid_xattr_name + + +TEST mv $M0/tmp/file-2 $M0/tmp/file-1 +TEST touch $M0/tmp/file-2 +TEST mv $M0/tmp/file-2 $M0/tmp/file-3 + +# At this point, both the file-1 and file-3 data files exist on one subvol +# and both linkto files on the other + +TEST mv -f $M0/tmp/file-1 $M0/tmp/file-3 + + +TEST getfattr -n $pgfid_xattr_name $B0/${V0}0/tmp/file-3 +TEST getfattr -n $pgfid_xattr_name $B0/${V0}1/tmp/file-3 + +# Not required for the test but an extra check if required. +# The linkto file was not renamed Without the fix. +#TEST mv $M0/tmp/file-3 $M0/tmp/file-6 +cleanup; diff --git a/tests/bugs/posix/bug-1651445.t b/tests/bugs/posix/bug-1651445.t new file mode 100644 index 00000000000..4d08b69b9b0 --- /dev/null +++ b/tests/bugs/posix/bug-1651445.t @@ -0,0 +1,54 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../snapshot.rc + +cleanup + +TEST verify_lvm_version +TEST glusterd +TEST pidof glusterd +TEST init_n_bricks 3 +TEST setup_lvm 3 + +TEST $CLI volume create $V0 replica 3 $H0:$L{1,2,3} +TEST $CLI volume start $V0 + +TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 + +#Setting the size in bytes +TEST $CLI volume set $V0 storage.reserve 40MB + +#wait 5s to reset disk_space_full flag +sleep 5 + +TEST dd if=/dev/zero of=$M0/a bs=100M count=1 +TEST dd if=/dev/zero of=$M0/b bs=10M count=1 + +# Wait 5s to update disk_space_full flag because thread check disk space +# after every 5s + +sleep 5 +# setup_lvm create lvm partition of 150M and 40M are reserve so after +# consuming more than 110M next dd should fail +TEST ! dd if=/dev/zero of=$M0/c bs=5M count=1 +TEST dd if=/dev/urandom of=$M0/a bs=1022 count=1 oflag=seek_bytes,sync seek=102 conv=notrunc + +rm -rf $M0/* + +#Setting the size in percent and repeating the above steps +TEST $CLI volume set $V0 storage.reserve 40 + +sleep 5 + +TEST dd if=/dev/zero of=$M0/a bs=80M count=1 +TEST dd if=/dev/zero of=$M0/b bs=10M count=1 + +sleep 5 +TEST ! dd if=/dev/zero of=$M0/c bs=5M count=1 + +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0 + +cleanup diff --git a/tests/bugs/posix/bug-765380.t b/tests/bugs/posix/bug-765380.t new file mode 100644 index 00000000000..384b8022a42 --- /dev/null +++ b/tests/bugs/posix/bug-765380.t @@ -0,0 +1,39 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd + +REPLICA=2 + +TEST $CLI volume create $V0 replica $REPLICA $H0:$B0/${V0}00 $H0:$B0/${V0}01 $H0:$B0/${V0}10 $H0:$B0/${V0}11 +TEST $CLI volume start $V0 + +## Mount FUSE with caching disabled +TEST $GFS -s $H0 --volfile-id $V0 $M0; + +function count_hostname_or_uuid_from_pathinfo() +{ + pathinfo=$(getfattr -n trusted.glusterfs.pathinfo $M0/f00f) + echo $pathinfo | grep -o $1 | wc -l +} + +TEST touch $M0/f00f + +EXPECT $REPLICA count_hostname_or_uuid_from_pathinfo $H0 + +# turn on node-uuid-pathinfo option +TEST $CLI volume set $V0 node-uuid-pathinfo on + +# do not expext hostname as part of the pathinfo string +EXPECT 0 count_hostname_or_uuid_from_pathinfo $H0 + +uuid=$(grep UUID $GLUSTERD_WORKDIR/glusterd.info | cut -f2 -d=) + +# ... but expect the uuid $REPLICA times +EXPECT $REPLICA count_hostname_or_uuid_from_pathinfo $uuid + +cleanup; diff --git a/tests/bugs/posix/bug-990028.t b/tests/bugs/posix/bug-990028.t new file mode 100755 index 00000000000..bef36a8897d --- /dev/null +++ b/tests/bugs/posix/bug-990028.t @@ -0,0 +1,157 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../fileio.rc + +cleanup; + +TESTS_EXPECTED_IN_LOOP=153 + +function __init() +{ + TEST glusterd + TEST pidof glusterd + TEST $CLI volume info; + + TEST $CLI volume create $V0 $H0:$B0/brick + + EXPECT 'Created' volinfo_field $V0 'Status'; + + TEST $CLI volume start $V0 + + TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0 + + TEST $CLI volume quota $V0 enable +} + +#CASE-1 +#checking pgfid under same directory +function links_in_same_directory() +{ + # create a file file1 + TEST touch $M0/file1 + + # create 50 hardlinks for file1 + for i in `seq 2 50`; do + TEST_IN_LOOP ln $M0/file1 $M0/file$i + done + + # store the pgfid of file1 in PGFID_FILE1 [should be 50 now (0x000000032)] + PGFID_FILE1=`getfattr -m "trusted.pgfid.*" -de hex $B0/brick/file1 2>&1 | grep "trusted.pgfid" | gawk -F '=' '{print $2}'` + + # compare the pgfid(link value ) of each hard links are equal or not + for i in `seq 2 50`; do + TEMP=`getfattr -m "trusted.pgfid.*" -de hex $B0/brick/file$i 2>&1 | grep "trusted.pgfid" | gawk -F '=' '{print $2}'` + TEST_IN_LOOP [ $PGFID_FILE1 = $TEMP ] + done + + # check if no of links value is 50 or not + TEST [ $PGFID_FILE1 = "0x00000032" ] + + # unlink file 2 to 50 + for i in `seq 2 50`; do + TEST_IN_LOOP unlink $M0/file$i; + done + + # now check if pgfid value is 1 or not + PGFID_FILE1=`getfattr -m "trusted.pgfid.*" -de hex $B0/brick/file1 2>&1 | grep "trusted.pgfid" | gawk -F '=' '{print $2}'`; + + TEST [ $PGFID_FILE1 = "0x00000001" ] + + TEST rm -f $M0/* +} + +##checking pgfid under diff directories +function links_across_directories() +{ + TEST mkdir $M0/dir1 $M0/dir2; + + # create a file in dir1 + TEST touch $M0/dir1/file1; + + # create hard link for file1 in dir2 + TEST ln $M0/dir1/file1 $M0/dir2/file2; + + #first check is to find whether there are two pgfids or not + LINES=`getfattr -m "trusted.pgfid.*" -de hex $B0/brick/dir1/file1 2>&1 | grep "trusted.pgfid" | wc -l` + TEST [ $LINES = 2 ] + + for i in $(seq 1 2); do + HL=`getfattr -m "trusted.pgfid.*" -de hex $B0/brick/dir$i/file$i 2>&1 | grep "trusted.pgfid" | awk -v n=$i 'NR==n' | cut -d'=' -f2` + TEST_IN_LOOP [ $HL = "0x00000001" ] + done + + #now unlink file2 and check the pgfid of file1 + #1. no. of pgfid should be one + #2. no. of hard link should be one + TEST unlink $M0/dir2/file2 + + LINES=`getfattr -m "trusted.pgfid.*" -de hex $B0/brick/dir1/file1 2>&1 | grep "trusted.pgfid" | wc -l` + TEST [ $LINES == 1 ] + + #next to check is to whether they contain hard link value of one or not + HL=`getfattr -m "trusted.pgfid.*" -de hex $B0/brick/dir1/file1 2>&1 | grep "trusted.pgfid" | cut -d'=' -f2` + TEST [ $HL = "0x00000001" ] + + #rename file under same directory + + TEST touch $M0/r_file1 + PGFID_rfile1=`getfattr -m "trusted.pgfid.*" -de hex $B0/brick/r_file1 2>&1 | grep "trusted.pgfid"` + + #cross check whether hard link count is one + HL=`getfattr -m "trusted.pgfid.*" -de hex $B0/brick/r_file1 2>&1 | grep "trusted.pgfid" | cut -d'=' -f2` + + TEST [ $HL = "0x00000001" ] + + #now rename the file to r_file1 + TEST mv $M0/r_file1 $M0/r_file2 + + #now check the pgfid hard link count is still one or not + HL=`getfattr -m "trusted.pgfid.*" -de hex $B0/brick/r_file2 2>&1 | grep "trusted.pgfid" | cut -d'=' -f2` + + TEST [ $HL = "0x00000001" ] + + #now move the file to a different directory where it has no hard link and check + TEST mkdir $M0/dir3; + TEST mv $M0/r_file2 $M0/dir3; + + #now check the pgfid has changed or not and hard limit is one or not + PGFID_newDir=`getfattr -m "trusted.pgfid.*" -de hex $B0/brick/dir3/r_file2 2>&1 | grep "trusted.pgfid"` + + #now the older pgfid and new pgfid shouldn't match + TEST [ $PGFID_rfile1 != $PGFID_newDir ] + + HL=`getfattr -m "trusted.pgfid" -de hex $B0/brick/dir3/r_file2 2>&1 | grep "trusted.pgfid" | cut -d'=' -f2` + TEST [ $HL = "0x00000001" ] + + TEST touch $M0/dir1/rl_file_1 + ln $M0/dir1/rl_file_1 $M0/dir2/rl_file_2 + mv $M0/dir1/rl_file_1 $M0/dir2 + + #now the there should be just one pgfid for both files + for i in $(seq 1 2); do + NL=`getfattr -m "trusted.pgfid" -de hex $B0/brick/dir2/rl_file_$i 2>&1 | grep "trusted.pgfid"|wc -l ` + TEST_IN_LOOP [ $HL = "0x00000001" ] + done + + #now pgfid of both files should match + P_rl_file_1=`getfattr -m "trusted.pgfid" -de hex $B0/brick/dir2/rl_file_1 2>&1 | grep "trusted.pgfid"` + P_rl_file_2=`getfattr -m "trusted.pgfid" -de hex $B0/brick/dir2/rl_file_2 2>&1 | grep "trusted.pgfid"` + TEST [ $P_rl_file_1 = $P_rl_file_2 ] + + #now the no of hard link should be two for both rl_file_1 and rl_file_2 + for i in $(seq 1 2); do + HL=`getfattr -m "trusted.pgfid" -de hex $B0/brick/dir2/rl_file_$i 2>&1 | grep "trusted.pgfid" | cut -d'=' -f2` + TEST_IN_LOOP [ $HL = "0x00000002" ] + done + + TEST rm -rf $M0/* +} + +__init; +links_in_same_directory; +links_across_directories; +TEST $CLI volume stop $V0 + +cleanup diff --git a/tests/bugs/posix/bug-gfid-path.t b/tests/bugs/posix/bug-gfid-path.t new file mode 100644 index 00000000000..1bbbe9f0670 --- /dev/null +++ b/tests/bugs/posix/bug-gfid-path.t @@ -0,0 +1,70 @@ +#!/bin/bash + +# This test case is for the bug where, even though a file is +# created when gfid2path option is turned off (default is ON), +# getfattr of "glusterfs.gfidtopath" was succeeding for that +# file. Ideally the getfattr should fail, as the file does not +# have its path(s) stored as a extended attribute (because it +# was created when gfid2path option was off) + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info; + +TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2,3,4}; + +EXPECT "$V0" volinfo_field $V0 'Volume Name'; +EXPECT 'Created' volinfo_field $V0 'Status'; +EXPECT '4' brick_count $V0 + +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +TEST glusterfs -s $H0 --volfile-id $V0 $M0; + +TEST mkdir $M0/dir +TEST mkdir $M0/new +TEST mkdir $M0/3 + +TEST touch $M0/dir/file + +# except success as by default gfid2path is enabled +# and the glusterfs.gfidtopath xattr should give the +# path of the object as the value + +TEST getfattr -n glusterfs.gfidtopath $M0/dir/file + +# turn off gfid2path feature +TEST $CLI volume set $V0 storage.gfid2path off + +TEST touch $M0/new/foo + +# again enable gfid2path. This has to be enabled before +# trying the getfattr. Because, glusterfs.gfidtopath xattr +# request is handled only if gfid2path is enabled. If not, +# then getxattr on glusterfs.gfid2path fails anyways. In this +# context we want getfattr to fail, because the file was created +# when gfid2path feature was disabled and not because gfid2path +# feature itself is disabled. +TEST $CLI volume set $V0 storage.gfid2path on + +# getfattr should fail as it is attempted on a file +# which does not have its path stored as a xattr +# (because file got created after disabling gfid2path) +TEST ! getfattr -n glusterfs.gfidtopath $M0/new/foo; + + + +TEST touch $M0/3/new + +# should be successful +TEST getfattr -n glusterfs.gfidtopath $M0/3/new + +TEST rm -rf $M0/* + +cleanup; diff --git a/tests/bugs/posix/disallow-gfid-volumeid-fremovexattr.c b/tests/bugs/posix/disallow-gfid-volumeid-fremovexattr.c new file mode 100644 index 00000000000..4ed3181d48f --- /dev/null +++ b/tests/bugs/posix/disallow-gfid-volumeid-fremovexattr.c @@ -0,0 +1,104 @@ +#include <glusterfs/api/glfs.h> +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int +main(int argc, char *argv[]) +{ + glfs_t *fs = NULL; + int ret = 0; + int i = 0; + glfs_fd_t *fd = NULL; + char *logfile = NULL; + char *hostname = NULL; + + if (argc != 4) { + fprintf(stderr, + "Expect following args %s <hostname> <Vol> <log file>\n", + argv[0]); + return -1; + } + + hostname = argv[1]; + logfile = argv[3]; + + fs = glfs_new(argv[2]); + if (!fs) { + fprintf(stderr, "glfs_new: returned NULL (%s)\n", strerror(errno)); + return -1; + } + + ret = glfs_set_volfile_server(fs, "tcp", hostname, 24007); + if (ret < 0) { + fprintf(stderr, "glfs_set_volfile_server failed ret:%d (%s)\n", ret, + strerror(errno)); + return -1; + } + + ret = glfs_set_logging(fs, logfile, 7); + if (ret < 0) { + fprintf(stderr, "glfs_set_logging failed with ret: %d (%s)\n", ret, + strerror(errno)); + return -1; + } + + ret = glfs_init(fs); + if (ret < 0) { + fprintf(stderr, "glfs_init failed with ret: %d (%s)\n", ret, + strerror(errno)); + return -1; + } + + fd = glfs_opendir(fs, "/"); + if (!fd) { + fprintf(stderr, "glfs_opendir failed with (%s)\n", strerror(errno)); + return -1; + } + + ret = glfs_fremovexattr(fd, "trusted.gfid"); + if (ret == 0 || errno != EPERM) { + fprintf(stderr, + "glfs_fremovexattr gfid exited with ret: " + "%d (%s)\n", + ret, strerror(errno)); + return -1; + } + + ret = glfs_fremovexattr(fd, "trusted.glusterfs.volume-id"); + if (ret == 0 || errno != EPERM) { + fprintf(stderr, + "glfs_fremovexattr volume-id exited with ret: " + "%d (%s)\n", + ret, strerror(errno)); + return -1; + } + + ret = glfs_fsetxattr(fd, "trusted.abc", "abc", 3, 0); + if (ret < 0) { + fprintf(stderr, + "glfs_fsetxattr trusted.abc exited with ret: " + "%d (%s)\n", + ret, strerror(errno)); + return -1; + } + + ret = glfs_fremovexattr(fd, "trusted.abc"); + if (ret < 0) { + fprintf(stderr, + "glfs_fremovexattr trusted.abc exited with " + "ret: %d (%s)\n", + ret, strerror(errno)); + return -1; + } + + (void)glfs_closedir(fd); + ret = glfs_fini(fs); + if (ret < 0) { + fprintf(stderr, "glfs_fini failed with ret: %d (%s)\n", ret, + strerror(errno)); + return -1; + } + return 0; +} diff --git a/tests/bugs/posix/disallow-gfid-volumeid-fremovexattr.t b/tests/bugs/posix/disallow-gfid-volumeid-fremovexattr.t new file mode 100755 index 00000000000..b9fd44ae0d7 --- /dev/null +++ b/tests/bugs/posix/disallow-gfid-volumeid-fremovexattr.t @@ -0,0 +1,21 @@ +#!/bin/bash +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +## Start and create a volume +TEST glusterd; +TEST pidof glusterd; +TEST $CLI volume info; + +TEST $CLI volume create $V0 $H0:$B0/${V0}; +TEST $CLI volume start $V0; +logdir=`gluster --print-logdir` + + +TEST build_tester $(dirname $0)/disallow-gfid-volumeid-fremovexattr.c -lgfapi +TEST $(dirname $0)/disallow-gfid-volumeid-fremovexattr $H0 $V0 $logdir/disallow-gfid-volumeid-fremovexattr.log + +cleanup_tester $(dirname $0)/disallow-gfid-volumeid-fremovexattr +cleanup; diff --git a/tests/bugs/posix/disallow-gfid-volumeid-removexattr.t b/tests/bugs/posix/disallow-gfid-volumeid-removexattr.t new file mode 100644 index 00000000000..d26eb21ccc5 --- /dev/null +++ b/tests/bugs/posix/disallow-gfid-volumeid-removexattr.t @@ -0,0 +1,26 @@ +#!/bin/bash + +#This test checks that gfid/volume-id removexattrs are not allowed. +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup; + +#Basic checks +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info + +#Create a distributed volume +TEST $CLI volume create $V0 $H0:$B0/${V0}{1..2}; +TEST $CLI volume start $V0 + +# Mount FUSE +TEST glusterfs -s $H0 --volfile-id $V0 $M0 + +TEST ! setfattr -x trusted.gfid $M0 +TEST ! setfattr -x trusted.glusterfs.volume-id $M0 +TEST setfattr -n trusted.abc -v abc $M0 +TEST setfattr -x trusted.abc $M0 + +cleanup; |
