summaryrefslogtreecommitdiffstats
path: root/tests/bugs/replicate/bug-1250170-fsync.c
diff options
context:
space:
mode:
authorRavishankar N <ravishankar@redhat.com>2015-08-04 18:37:47 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2015-08-25 09:27:30 -0700
commitf3c7e6eaa9b14b89c1d58c0edcb5664f28914437 (patch)
tree450350b00bbbee8264fa25fa55495eedfb4578e9 /tests/bugs/replicate/bug-1250170-fsync.c
parent255b4ba477f5163b59efee1c9f62845eb86067a2 (diff)
afr: modify afr_txn_nothing_failed()
In an AFR transaction, we need to consider something as failed only if the failure (either in the pre-op or the FOP phase) occurs on the bricks on which a transaction lock was obtained. Without this, we would end up considering the transaction as failure even on the bricks on which the lock was not obtained, resulting in unnecessary fsyncs during the post-op phase of every write transaction for non-appending writes. Change-Id: Iee79e5d85dc7b4c41459d8bdd04a8454bdaf9a9d BUG: 1250170 Signed-off-by: Ravishankar N <ravishankar@redhat.com> Reviewed-on: http://review.gluster.org/11827 Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'tests/bugs/replicate/bug-1250170-fsync.c')
-rw-r--r--tests/bugs/replicate/bug-1250170-fsync.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/bugs/replicate/bug-1250170-fsync.c b/tests/bugs/replicate/bug-1250170-fsync.c
new file mode 100644
index 00000000000..1d3025bcd9f
--- /dev/null
+++ b/tests/bugs/replicate/bug-1250170-fsync.c
@@ -0,0 +1,56 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+
+int main (int argc, char **argv)
+{
+ char *file = NULL;
+ int fd = -1;
+ char *buffer = NULL;
+ size_t buf_size = 0;
+ size_t written = 0;
+ int ret = 0;
+ off_t offset = 0;
+ int i = 0;
+ int loop_count = 5;
+
+ if (argc < 2) {
+ printf ("Usage:%s <filename>\n", argv[0]);
+ return -1;
+ }
+
+ file = argv[1];
+ buf_size = 1024;
+ buffer = calloc(1, buf_size);
+ if (!buffer) {
+ perror("calloc");
+ return -1;
+ }
+ memset (buffer, 'R', buf_size);
+
+ fd = open(file, O_WRONLY);
+ if (fd == -1) {
+ perror("open");
+ return -1;
+ }
+
+ for (i = 0; i < loop_count; i++) {
+ ret = write (fd, buffer, buf_size);
+ if (ret == -1) {
+ perror("write");
+ return ret;
+ } else {
+ written += ret;
+ }
+ offset = lseek (fd, 0 , SEEK_SET);
+ }
+
+ free(buffer);
+ return 0;
+
+}