summaryrefslogtreecommitdiffstats
path: root/tests/basic/ctime/ctime-glfs-init.c
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2018-05-25 08:55:11 -0400
committerAmar Tumballi <amarts@redhat.com>2018-05-28 04:57:22 +0000
commit3d38e4e47f129bdb36c3fbbd481dabe4ba4413d6 (patch)
tree984b6d3bf3a1554b9e47d964c9f7d89c251f6e34 /tests/basic/ctime/ctime-glfs-init.c
parent7d92af4eac386001b46b8f1a98e8ccb95ca1a225 (diff)
libgfapi: Fix lookup on root
Lookup on root was sending "/" as the path. This will break the basename calculation in loc_copy and hence lookup on root was failing if the loc_copy was involved in the stack. With ctime, a first lookup on root initiates a metadata self heal because of ctime xattr not being same on all afr subvolumes. This results in loc_copy and hence the failure of lookup. Fix would be to send path with "." for the root. fixes: bz#1582516 Change-Id: Iafe4b99f249a4f5034ad34c1d30590de0e35aa0d Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'tests/basic/ctime/ctime-glfs-init.c')
-rw-r--r--tests/basic/ctime/ctime-glfs-init.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/basic/ctime/ctime-glfs-init.c b/tests/basic/ctime/ctime-glfs-init.c
new file mode 100644
index 00000000000..57a3dc7820e
--- /dev/null
+++ b/tests/basic/ctime/ctime-glfs-init.c
@@ -0,0 +1,67 @@
+#include <fcntl.h>
+#include <unistd.h>
+#include <time.h>
+#include <limits.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <glusterfs/api/glfs.h>
+#include <glusterfs/api/glfs-handles.h>
+
+#define LOG_ERR(msg) do { \
+ fprintf (stderr, "%s : Error (%s)\n", msg, strerror (errno)); \
+ } while (0)
+
+int
+main (int argc, char *argv[])
+{
+ int ret = 0;
+ char *hostname = NULL;
+ char *volname = NULL;
+ char *logfile = NULL;
+ glfs_t *fs = NULL;
+
+ if (argc != 4) {
+ fprintf (stderr, "Invalid argument\n");
+ exit(1);
+ }
+
+ hostname = argv[1];
+ volname = argv[2];
+ logfile = argv[3];
+
+ fs = glfs_new (volname);
+ if (!fs) {
+ LOG_ERR ("glfs_new failed");
+ return -1;
+ }
+
+ ret = glfs_set_volfile_server (fs, "tcp", hostname, 24007);
+ if (ret < 0) {
+ LOG_ERR ("glfs_set_volfile_server failed");
+ goto err;
+ }
+
+ ret = glfs_set_logging (fs, logfile, 7);
+ if (ret < 0) {
+ LOG_ERR ("glfs_set_logging failed");
+ goto err;
+ }
+
+ ret = glfs_init (fs);
+ if (ret < 0) {
+ LOG_ERR ("glfs_init failed");
+ goto err;
+ }
+
+ glfs_fini (fs);
+ fs = NULL;
+ return 0;
+err:
+ glfs_fini (fs);
+ fs = NULL;
+
+ return -1;
+}