summaryrefslogtreecommitdiffstats
path: root/xlators/experimental/fdl/src/recon.c
diff options
context:
space:
mode:
authorJeff Darcy <jdarcy@redhat.com>2016-02-08 13:30:49 -0500
committerJeff Darcy <jdarcy@redhat.com>2016-02-13 05:13:07 -0800
commitc458433041aafb48ae6d6e5fcf3e1e737dc3fda3 (patch)
tree33a03ca0c1f5faf58419de2c4ff4532752ddfb07 /xlators/experimental/fdl/src/recon.c
parentda33097c3d6492e3b468b4347e47c70828fb4320 (diff)
experimental: add fdl (Full Data Logging) translator
NSR needs logging that is different than our existing changelog in several ways: * Full data, not just metadata * Pre-op, not post-op * High performance * Supports the concept of time-bounded "terms" Others (for example EC) might need the same thing. This patch adds such a translator. It also adds code to dump the resulting journals, and to replay them using syncops, plus (very rudimentary) tests for all of the above. Change-Id: I29680a1b4e0a9e7d5a8497fef302c46434b86636 Signed-off-by: Jeff Darcy <jdarcy@redhat.com> Reviewed-on: http://review.gluster.org/12450 Smoke: Gluster Build System <jenkins@build.gluster.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators/experimental/fdl/src/recon.c')
-rw-r--r--xlators/experimental/fdl/src/recon.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/xlators/experimental/fdl/src/recon.c b/xlators/experimental/fdl/src/recon.c
new file mode 100644
index 00000000000..14168a011e0
--- /dev/null
+++ b/xlators/experimental/fdl/src/recon.c
@@ -0,0 +1,89 @@
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+#include "glusterfs.h"
+#include "fd.h"
+#include "syncop.h"
+#include "glfs-internal.h"
+
+#define GFAPI_SUCCESS 0
+
+extern int recon_execute (glfs_t *, char **, char **);
+
+int
+main (int argc, char **argv)
+{
+ glfs_t *fs;
+ int ret;
+ int meta_fd = (-1);
+ char *meta_buf = NULL;
+ int data_fd = (-1);
+ char *data_buf = NULL;
+
+ fs = glfs_new ("whocares");
+ if (!fs) {
+ fprintf (stderr, "glfs_new failed\n");
+ return EXIT_FAILURE;
+ }
+
+ if (getenv("RECON_DEBUG")) {
+ ret = glfs_set_logging (fs, "/dev/stderr", 7);
+ }
+ else {
+ ret = glfs_set_logging (fs, "/dev/null", 0);
+ }
+
+ if (ret != GFAPI_SUCCESS) {
+ fprintf (stderr, "glfs_set_logging failed (%d)\n", errno);
+ return EXIT_FAILURE;
+ }
+
+ ret = glfs_set_volfile (fs, argv[1]);
+ if (ret != GFAPI_SUCCESS) {
+ fprintf (stderr, "glfs_set_volfile failed (%d)\n", errno);
+ return EXIT_FAILURE;
+ }
+
+ ret = glfs_init (fs);
+ if (ret != GFAPI_SUCCESS) {
+ fprintf (stderr, "glfs_init failed (%d)\n", errno);
+ return EXIT_FAILURE;
+ }
+
+ meta_fd = open (argv[2], O_RDONLY);
+ if (meta_fd < 0) {
+ perror ("open");
+ return EXIT_FAILURE;
+ }
+
+ /* TBD: get proper length */
+ meta_buf = mmap (NULL, 1048576, PROT_READ, MAP_PRIVATE, meta_fd, 0);
+ if (meta_buf == MAP_FAILED) {
+ perror ("mmap");
+ return EXIT_FAILURE;
+ }
+
+ data_fd = open (argv[3], O_RDONLY);
+ if (data_fd < 0) {
+ perror ("open");
+ return EXIT_FAILURE;
+ }
+
+ /* TBD: get proper length */
+ data_buf = mmap (NULL, 1048576, PROT_READ, MAP_PRIVATE, data_fd, 0);
+ if (data_buf == MAP_FAILED) {
+ perror ("mmap");
+ return EXIT_FAILURE;
+ }
+
+ for (;;) {
+ if (!recon_execute(fs,&meta_buf,&data_buf)) {
+ break;
+ }
+ }
+
+ return EXIT_SUCCESS;
+}