summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2015-04-09 15:38:47 +0530
committerNiels de Vos <ndevos@redhat.com>2015-05-10 08:14:33 -0700
commitda48a6a596251c19a8ddb1bdfec3da9744a78b8f (patch)
treec2835e85440ca2c17f55641d2312a9dd345dad6a /tests
parentd1d54d027fc616ccae5c329d5b5f02ee9aab1549 (diff)
features/bit-rot-stub: versioning of objects in write/truncate fop instead of open
* This patch brings in the changes where object versioning is done in write and truncate fops instead of tracking them in open and create fops. This model works for both regular and anonymous fds. It also removes the race associated with open calls, create and lookups. This patch follows the below method for object versioning and notifications: Before sending writev on the fd, increase the ongoing version first. This makes anonymous fd write similar to the regular fd write by having the ongoing version increased before doing the write. Do following steps to do versioning: 1) For anonymous fds set the fd context (so that release is invoked) and add the fd context to the list maintained in the inode context. For regular fds the above think would have been done in open itself. 2) Increase the on-disk ongoing version 3) Increase the in memory ongoing version and mark inode as non-dirty 3) Once versioning is successfully done send write operation. If versioning fails, then fail the write fop. 5) In writev_cbk mark inode as modified. > Change-Id: I7104391bbe076d8fc49b68745d2ec29a6e92476c > BUG: 1207979 > Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com> > Reviewed-on: http://review.gluster.org/10233 > Tested-by: Gluster Build System <jenkins@build.gluster.com> > Reviewed-by: Vijay Bellur <vbellur@redhat.com> Change-Id: I4bb86989b5fab02b9ed2950798b1a80e566f1024 BUG: 1220041 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com> Reviewed-on: http://review.gluster.org/10722 Reviewed-by: Gaurav Kumar Garg <ggarg@redhat.com> Tested-by: NetBSD Build System Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/bitrot/br-stub.c47
-rw-r--r--tests/bitrot/br-stub.t21
2 files changed, 54 insertions, 14 deletions
diff --git a/tests/bitrot/br-stub.c b/tests/bitrot/br-stub.c
index 6cb12ed0a8e..e164170bb83 100644
--- a/tests/bitrot/br-stub.c
+++ b/tests/bitrot/br-stub.c
@@ -31,8 +31,10 @@ brstub_validate_version (char *bpath, unsigned long version)
if (ret < 0)
goto err;
- if (xv->ongoingversion != version)
+ if (xv->ongoingversion != version) {
match = -1;
+ fprintf (stderr, "ongoingversion: %lu\n", xv->ongoingversion);
+ }
free (xv);
return match;
@@ -42,11 +44,12 @@ brstub_validate_version (char *bpath, unsigned long version)
}
int
-brstub_open_validation (char *filp, char *bpath, unsigned long startversion)
+brstub_write_validation (char *filp, char *bpath, unsigned long startversion)
{
int fd1 = 0;
int fd2 = 0;
int ret = 0;
+ char *string = "string\n";
/* read only check */
fd1 = open (filp, O_RDONLY);
@@ -55,18 +58,37 @@ brstub_open_validation (char *filp, char *bpath, unsigned long startversion)
close (fd1);
ret = brstub_validate_version (bpath, startversion);
- if (ret < 0)
+ if (ret == 0)
goto err;
-
/* single open (write/) check */
fd1 = open (filp, O_RDWR);
if (fd1 < 0)
goto err;
- close (fd1);
+ ret = write (fd1, string, strlen (string));
+ if (ret <= 0)
+ goto err;
+ /**
+ * Fsync is done so that the write call has properly reached the
+ * disk. For fuse mounts write-behind xlator would have held the
+ * writes with itself and for nfs, client would have held the
+ * write in its cache. So write fop would not have triggered the
+ * versioning as it would have not reached the bit-rot-stub.
+ */
+ fsync (fd1);
startversion++;
ret = brstub_validate_version (bpath, startversion);
+ if (ret < 0)
+ goto err;
+ ret = write (fd1, string, strlen (string));
+ if (ret <= 0)
+ goto err;
+ ret = brstub_validate_version (bpath, startversion);
+ if (ret < 0)
+ goto err;
+
+ close (fd1);
/* multi open (write/) check */
fd1 = open (filp, O_RDWR);
if (fd1 < 0)
@@ -74,13 +96,20 @@ brstub_open_validation (char *filp, char *bpath, unsigned long startversion)
fd2 = open (filp, O_WRONLY);
if (fd1 < 0)
goto err;
+
+ ret = write (fd1, string, strlen (string));
+ if (ret <= 0)
+ goto err;
+
+ ret = write (fd1, string, strlen (string));
+ if (ret <= 0)
+ goto err;
close (fd1);
close (fd2);
/**
- * incremented once per open()/open().../close()/close() sequence
+ * incremented once per write()/write().../close()/close() sequence
*/
- startversion++;
ret = brstub_validate_version (bpath, startversion);
if (ret < 0)
goto err;
@@ -106,11 +135,11 @@ brstub_new_object_validate (char *filp, char *brick)
printf ("Validating initial version..\n");
ret = brstub_validate_version (bpath, 1);
- if (ret < 0)
+ if (ret == 0)
goto err;
printf ("Validating version on modifications..\n");
- ret = brstub_open_validation (filp, bpath, 1);
+ ret = brstub_write_validation (filp, bpath, 1);
if (ret < 0)
goto err;
diff --git a/tests/bitrot/br-stub.t b/tests/bitrot/br-stub.t
index 11d02418785..bab4c7cdbd1 100644
--- a/tests/bitrot/br-stub.t
+++ b/tests/bitrot/br-stub.t
@@ -2,6 +2,7 @@
. $(dirname $0)/../include.rc
. $(dirname $0)/../volume.rc
+. $(dirname $0)/../nfs.rc
STUB_SOURCE=$(dirname $0)/br-stub.c
STUB_EXEC=$(dirname $0)/br-stub
@@ -17,9 +18,9 @@ EXPECT "$V0" volinfo_field $V0 'Volume Name';
EXPECT 'Created' volinfo_field $V0 'Status';
EXPECT '2' brick_count $V0
-## Turn off open-behind (stub does not work with anonfd yet..)
-TEST $CLI volume set $V0 performance.open-behind off
-EXPECT 'off' volinfo_field $V0 'performance.open-behind'
+## Turn off write-behind (write-behind clubs writes together)
+TEST $CLI volume set $V0 performance.write-behind off
+#EXPECT 'off' volinfo_field $V0 'performance.open-behind'
## Start the volume
TEST $CLI volume start $V0;
@@ -27,6 +28,7 @@ EXPECT 'Started' volinfo_field $V0 'Status';
## Mount the volume
TEST $GFS --volfile-server=$H0 --volfile-id=$V0 $M0;
+TEST mount_nfs $H0:/$V0 $N0 nolock;
## Build stub C source
build_tester $STUB_SOURCE -o $STUB_EXEC -I$(dirname $0)/../../xlators/features/bit-rot/src/stub
@@ -34,11 +36,20 @@ TEST [ -e $STUB_EXEC ]
## create & check version
fname="$M0/filezero"
-touch $fname
+touch $fname;
backpath=$(get_backend_paths $fname)
+
+TEST $STUB_EXEC $fname $(dirname $backpath)
+
+rm -f $fname;
+
+## test nfs
+fname="$N0/filezero"
+touch $fname; # backpath remains same..
+
TEST $STUB_EXEC $fname $(dirname $backpath)
-## cleanups..
+##cleanups..
rm -f $STUB_EXEC
cleanup;