summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSoumya Koduri <skoduri@redhat.com>2015-11-27 12:09:22 +0530
committerNiels de Vos <ndevos@redhat.com>2015-12-01 02:32:50 -0800
commitffe80877a0eb0eaf2540be95b401623c6d7c722f (patch)
tree706b3d81a1a0b63a11da2b8f1b0d44c0e9223911 /tests
parentf2c52ae206f309ec636a299a76849c843c8ab83d (diff)
Upcall: Read gfid from iatt in case of invalid inode
When any file/dir is looked upon for the first time, inode created shall be invalid till it gets linked to the inode table. In such cases, read the gfid from the iatt structure returned as part of such fops for UPCALL processing. Change-Id: Ie5eb2f3be18c34cf7ef172e126c9db5ef7a8512b BUG: 1283983 Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/12773 Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/basic/gfapi/bug1283983.c123
-rwxr-xr-xtests/basic/gfapi/bug1283983.sh33
2 files changed, 156 insertions, 0 deletions
diff --git a/tests/basic/gfapi/bug1283983.c b/tests/basic/gfapi/bug1283983.c
new file mode 100644
index 00000000000..76db8d5ca09
--- /dev/null
+++ b/tests/basic/gfapi/bug1283983.c
@@ -0,0 +1,123 @@
+#include <fcntl.h>
+#include <unistd.h>
+#include <time.h>
+#include <limits.h>
+#include <alloca.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <glusterfs/api/glfs.h>
+#include <glusterfs/api/glfs-handles.h>
+int gfapi = 1;
+
+#define LOG_ERR(func, ret) do { \
+ if (ret != 0) { \
+ fprintf (stderr, "%s : returned error ret(%d), errno(%d)\n", \
+ func, ret, errno); \
+ exit(1); \
+ } else { \
+ fprintf (stderr, "%s : returned %d\n", func, ret); \
+ } \
+ } while (0)
+#define LOG_IF_NO_ERR(func, ret) do { \
+ if (ret == 0) { \
+ fprintf (stderr, "%s : hasn't returned error %d\n", \
+ func, ret); \
+ exit(1); \
+ } else { \
+ fprintf (stderr, "%s : returned %d\n", func, ret); \
+ } \
+ } while (0)
+int
+main (int argc, char *argv[])
+{
+ glfs_t *fs = NULL;
+ int ret = 0, i;
+ glfs_fd_t *fd = NULL;
+ char *filename = "/a1";
+ char *filename2 = "/a2";
+ struct stat sb = {0, };
+ struct callback_arg cbk;
+ char *logfile = NULL;
+ char *volname = NULL;
+ int cnt = 1;
+ struct callback_inode_arg *in_arg = NULL;
+ struct glfs_object *root = NULL, *leaf = NULL;
+
+ cbk.reason = 0;
+
+ fprintf (stderr, "Starting libgfapi_fini\n");
+ if (argc != 3) {
+ fprintf (stderr, "Invalid argument\n");
+ exit(1);
+ }
+
+ volname = argv[1];
+ logfile = argv[2];
+
+
+ fs = glfs_new (volname);
+ if (!fs) {
+ fprintf (stderr, "glfs_new: returned NULL\n");
+ return 1;
+ }
+
+ ret = glfs_set_volfile_server (fs, "tcp", "localhost", 24007);
+ LOG_ERR("glfs_set_volfile_server", ret);
+
+ ret = glfs_set_logging (fs, logfile, 7);
+ LOG_ERR("glfs_set_logging", ret);
+
+ ret = glfs_init (fs);
+ LOG_ERR("glfs_init", ret);
+
+ sleep (2);
+ root = glfs_h_lookupat (fs, NULL, "/", &sb, 0);
+ if (!root) {
+ ret = -1;
+ LOG_ERR ("glfs_h_lookupat root", ret);
+ }
+ leaf = glfs_h_lookupat (fs, root, filename, &sb, 0);
+ if (!leaf) {
+ ret = -1;
+ LOG_IF_NO_ERR ("glfs_h_lookupat leaf", ret);
+ }
+
+ leaf = glfs_h_creat (fs, root, filename, O_RDWR, 0644, &sb);
+ if (!leaf) {
+ ret = -1;
+ LOG_ERR ("glfs_h_lookupat leaf", ret);
+ }
+ fprintf (stderr, "glfs_h_create leaf - %p\n", leaf);
+
+ leaf = glfs_h_lookupat (fs, root, filename2, &sb, 0);
+ if (!leaf) {
+ ret = -1;
+ LOG_IF_NO_ERR ("glfs_h_lookupat leaf", ret);
+ }
+
+ ret = glfs_h_rename (fs, root, filename, root, filename2);
+ LOG_ERR("glfs_rename", ret);
+
+ while (cnt++ < 5) {
+ ret = glfs_h_poll_upcall(fs, &cbk);
+ LOG_ERR ("glfs_h_poll_upcall", ret);
+
+ /* There should not be any upcalls sent */
+ if (cbk.reason != GFAPI_CBK_EVENT_NULL) {
+ fprintf (stderr, "Error: Upcall received(%d)\n",
+ cbk.reason);
+ exit (1);
+ }
+ }
+
+ ret = glfs_fini(fs);
+ LOG_ERR("glfs_fini", ret);
+
+ fprintf (stderr, "End of libgfapi_fini\n");
+
+ exit(0);
+}
+
+
diff --git a/tests/basic/gfapi/bug1283983.sh b/tests/basic/gfapi/bug1283983.sh
new file mode 100755
index 00000000000..97f1b01150c
--- /dev/null
+++ b/tests/basic/gfapi/bug1283983.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../volume.rc
+
+cleanup;
+
+TEST glusterd
+
+TEST $CLI volume create $V0 localhost:$B0/brick1;
+EXPECT 'Created' volinfo_field $V0 'Status';
+
+TEST $CLI volume start $V0;
+EXPECT 'Started' volinfo_field $V0 'Status';
+
+logdir=`gluster --print-logdir`
+
+## Enable Upcall cache-invalidation feature
+TEST $CLI volume set $V0 features.cache-invalidation on;
+
+build_tester $(dirname $0)/bug1283983.c -lgfapi -o $(dirname $0)/bug1283983
+
+TEST ./$(dirname $0)/bug1283983 $V0 $logdir/bug1283983.log
+
+## There shouldn't be any NULL gfid messages logged
+TEST ! cat $logdir/bug1283983.log | grep "upcall" | grep "00000000-0000-0000-0000-000000000000"
+
+cleanup_tester $(dirname $0)/bug1283983
+
+TEST $CLI volume stop $V0
+TEST $CLI volume delete $V0
+
+cleanup;