summaryrefslogtreecommitdiffstats
path: root/tests/bugs/distribute
diff options
context:
space:
mode:
authorNithya Balachandran <nbalacha@redhat.com>2015-04-13 14:24:44 +0530
committerRaghavendra G <rgowdapp@redhat.com>2015-05-28 03:29:09 -0700
commite878b0bcbaa19e46517e44284685ef99b885117b (patch)
tree50f0abec0ae12f6b49686b972424dd2298fc25fa /tests/bugs/distribute
parenteaf3bfa1886928240eda3a83ab1ece3d61f7fd50 (diff)
cluster/dht: Fix dht_setxattr to follow files under migration
If a file is under migration, any xattrs created on it are lost post migration of the file. This is because the xattrs are set only on the cached subvol of the source and as the source is under migration, it becomes a linkto file post migration. Change-Id: Ib8e233b519cf954e7723c6e26b38fa8f9b8c85c0 BUG: 1193636 Signed-off-by: Nithya Balachandran <nbalacha@redhat.com> Reviewed-on: http://review.gluster.org/10212 Tested-by: NetBSD Build System Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Tested-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'tests/bugs/distribute')
-rw-r--r--tests/bugs/distribute/bug-1193636.c70
-rw-r--r--tests/bugs/distribute/bug-1193636.t72
2 files changed, 142 insertions, 0 deletions
diff --git a/tests/bugs/distribute/bug-1193636.c b/tests/bugs/distribute/bug-1193636.c
new file mode 100644
index 00000000000..eae90783f8e
--- /dev/null
+++ b/tests/bugs/distribute/bug-1193636.c
@@ -0,0 +1,70 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <attr/xattr.h>
+#include <fcntl.h>
+#include <string.h>
+
+
+#define MY_XATTR_NAME "user.ftest"
+#define MY_XATTR_VAL "ftestval"
+
+
+void usage (void)
+{
+ printf ("Usage : bug-1193636 <filename> <xattr_name> <op>\n");
+ printf (" op : 0 - set, 1 - remove\n");
+}
+
+
+int main (int argc, char **argv)
+{
+ int fd;
+ int err = 0;
+ char *xattr_name = NULL;
+ int op = 0;
+
+ if (argc != 4) {
+ usage ();
+ exit (1);
+ }
+
+ op = atoi (argv[3]);
+
+ if ((op != 0) && (op != 1)) {
+ printf ("Invalid operation specified.\n");
+ usage ();
+ exit (1);
+ }
+
+ xattr_name = argv[2];
+
+ fd = open(argv[1], O_RDWR);
+ if (fd == -1) {
+ printf ("Failed to open file %s\n", argv[1]);
+ exit (1);
+ }
+
+ if (!op) {
+ err = fsetxattr (fd, xattr_name, MY_XATTR_VAL,
+ strlen (MY_XATTR_VAL) + 1, XATTR_CREATE);
+
+ if (err) {
+ printf ("Failed to set xattr %s: %m\n", xattr_name);
+ exit (1);
+ }
+
+ } else {
+ err = fremovexattr (fd, xattr_name);
+
+ if (err) {
+ printf ("Failed to remove xattr %s: %m\n", xattr_name);
+ exit (1);
+ }
+ }
+
+ close (fd);
+
+ return 0;
+}
+
diff --git a/tests/bugs/distribute/bug-1193636.t b/tests/bugs/distribute/bug-1193636.t
new file mode 100644
index 00000000000..ccde02edc70
--- /dev/null
+++ b/tests/bugs/distribute/bug-1193636.t
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../volume.rc
+
+
+checksticky () {
+ i=0;
+ while [ ! -k $1 ]; do
+ sleep 1
+ i=$((i+1));
+ if [[ $i == 10 ]]; then
+ return $i
+ fi
+ echo "Waiting... $i"
+ done
+ echo "done ...got out @ $i"
+ return 0
+}
+
+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..3};
+TEST $CLI volume start $V0
+
+# Mount FUSE
+TEST glusterfs -s $H0 --volfile-id $V0 $M0
+
+TEST mkdir $M0/dir1
+
+# Create a large file (1GB), so that rebalance takes time
+dd if=/dev/zero of=$M0/dir1/FILE2 bs=64k count=10240
+
+# Rename the file to create a linkto, for rebalance to
+# act on the file
+TEST mv $M0/dir1/FILE2 $M0/dir1/FILE1
+
+build_tester $(dirname $0)/bug-1193636.c
+
+TEST $CLI volume rebalance $V0 start force
+
+TEST checksticky $B0/${V0}3/dir1/FILE1
+
+TEST setfattr -n "user.test1" -v "test1" $M0/dir1/FILE1
+TEST setfattr -n "user.test2" -v "test1" $M0/dir1/FILE1
+TEST setfattr -n "user.test3" -v "test1" $M0/dir1/FILE1
+
+TEST $(dirname $0)/bug-1193636 $M0/dir1/FILE1 user.fsetx 0
+TEST $(dirname $0)/bug-1193636 $M0/dir1/FILE1 user.fremx 0
+
+TEST getfattr -n "user.fremx" $M0/dir1/FILE1
+TEST setfattr -x "user.test2" $M0/dir1/FILE1
+
+
+TEST $(dirname $0)/bug-1193636 $M0/dir1/FILE1 user.fremx 1
+
+EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" rebalance_status_field $V0
+
+TEST getfattr -n "user.fsetx" $M0/dir1/FILE1
+TEST getfattr -n "user.test1" $M0/dir1/FILE1
+TEST ! getfattr -n "user.test2" $M0/dir1/FILE1
+TEST ! getfattr -n "user.fremx" $M0/dir1/FILE1
+TEST getfattr -n "user.test3" $M0/dir1/FILE1
+
+
+cleanup;