Skip to content

Commit

Permalink
heal: glfs-heal implementation
Browse files Browse the repository at this point in the history
Thanks a lot to Niels for helping me to get build stuff right.

Change-Id: I634f24d90cd856ceab3cc0c6e9a91003f443403e
BUG: 1147462
Signed-off-by: Pranith Kumar K <[email protected]>
Reviewed-on: http://review.gluster.org/6529
Reviewed-by: Krutika Dhananjay <[email protected]>
Tested-by: Gluster Build System <[email protected]>
  • Loading branch information
Pranith Kumar K authored and gluster-ant committed Dec 15, 2013
1 parent 9d82d85 commit 31e7298
Show file tree
Hide file tree
Showing 14 changed files with 870 additions and 62 deletions.
3 changes: 1 addition & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ EXTRA_DIST = autogen.sh \
$(shell find $(top_srcdir)/tests -type f -print)

SUBDIRS = $(ARGP_STANDALONE_DIR) libglusterfs rpc api xlators glusterfsd \
$(FUSERMOUNT_SUBDIR) doc extras cli @SYNCDAEMON_SUBDIR@ \
$(FUSERMOUNT_SUBDIR) doc extras cli heal @SYNCDAEMON_SUBDIR@ \
@UMOUNTD_SUBDIR@


pkgconfigdir = @pkgconfigdir@
pkgconfig_DATA = glusterfs-api.pc libgfchangelog.pc
Expand Down
33 changes: 29 additions & 4 deletions cli/src/cli-cmd-volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <sys/socket.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <netinet/in.h>

#ifndef _CONFIG_H
Expand Down Expand Up @@ -1903,6 +1904,10 @@ cli_cmd_volume_heal_cbk (struct cli_state *state, struct cli_cmd_word *word,
dict_t *options = NULL;
xlator_t *this = NULL;
cli_local_t *local = NULL;
int heal_op = 0;
runner_t runner = {0};
char buff[PATH_MAX] = {0};
char *out = NULL;

this = THIS;
frame = create_frame (this, this->ctx->pool);
Expand All @@ -1921,13 +1926,33 @@ cli_cmd_volume_heal_cbk (struct cli_state *state, struct cli_cmd_word *word,
parse_error = 1;
goto out;
}
ret = dict_get_int32 (options, "heal-op", &heal_op);
if (ret < 0)
goto out;

proc = &cli_rpc_prog->proctable[GLUSTER_CLI_HEAL_VOLUME];
if (heal_op == GF_AFR_OP_INDEX_SUMMARY) {
runinit (&runner);
runner_add_args (&runner, SBIN_DIR"/glfsheal", words[2], NULL);
runner_redir (&runner, STDOUT_FILENO, RUN_PIPE);
ret = runner_start (&runner);
if (ret == -1)
goto out;
while ((out = fgets(buff, sizeof(buff),
runner_chio (&runner, STDOUT_FILENO)))) {
printf ("%s", out);
}

CLI_LOCAL_INIT (local, words, frame, options);
ret = runner_end (&runner);
ret = WEXITSTATUS (ret);
}
else {
proc = &cli_rpc_prog->proctable[GLUSTER_CLI_HEAL_VOLUME];

if (proc->fn) {
ret = proc->fn (frame, THIS, options);
CLI_LOCAL_INIT (local, words, frame, options);

if (proc->fn) {
ret = proc->fn (frame, THIS, options);
}
}

out:
Expand Down
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ AC_CONFIG_FILES([Makefile
geo-replication/Makefile
geo-replication/src/Makefile
geo-replication/syncdaemon/Makefile
heal/Makefile
heal/src/Makefile
glusterfs.spec])

AC_CANONICAL_HOST
Expand Down
1 change: 1 addition & 0 deletions glusterfs.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,7 @@ fi
%endif
# binaries
%{_sbindir}/glusterd
%{_sbindir}/glfsheal
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/storage*
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/posix*
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/protocol/server*
Expand Down
3 changes: 3 additions & 0 deletions heal/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SUBDIRS = src

CLEANFILES =
35 changes: 35 additions & 0 deletions heal/src/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
sbin_PROGRAMS = glfsheal

glfsheal_SOURCES = glfs-heal.c

glfsheal_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la $(GF_LDADD)\
$(RLLIBS) $(top_builddir)/rpc/xdr/src/libgfxdr.la \
$(top_builddir)/rpc/rpc-lib/src/libgfrpc.la \
$(top_builddir)/api/src/libgfapi.la \
$(top_builddir)/xlators/cluster/afr/src/afr.la \
$(GF_GLUSTERFS_LIBS) $(XML_LIBS)

glfsheal_LDFLAGS = $(GF_LDFLAGS)

AM_CPPFLAGS = $(GF_CPPFLAGS) \
-I$(top_srcdir)/xlators/lib/src\
-I$(top_srcdir)/xlators/cluster/afr/src\
-I$(top_srcdir)/libglusterfs/src -I$(top_srcdir)/rpc/rpc-lib/src\
-I$(top_srcdir)/rpc/xdr/src\
-I$(top_srcdir)/api/src\
-I$(top_srcdir)/contrib/argp-standalone\
-DDATADIR=\"$(localstatedir)\" \
-DCONFDIR=\"$(sysconfdir)/glusterfs\" \
-DGSYNCD_PREFIX=\"$(libexecdir)/glusterfs\"\
-DSYNCDAEMON_COMPILE=$(SYNCDAEMON_COMPILE) -DSBIN_DIR=\"$(sbindir)\"\
$(XML_CPPFLAGS)

AM_CFLAGS = -Wall $(GF_GLUSTERFS_CFLAGS)

CLEANFILES =

$(top_builddir)/libglusterfs/src/libglusterfs.la:
$(MAKE) -C $(top_builddir)/libglusterfs/src/ all

$(top_builddir)/xlators/cluster/afr/src/afr.la:
$(MAKE) -C $(top_builddir)/xlators/cluster/afr/src/ all
Loading

0 comments on commit 31e7298

Please sign in to comment.