diff options
author | Raghavendra Bhat <raghavendra@redhat.com> | 2013-05-14 14:00:08 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2013-05-14 10:47:09 -0700 |
commit | 2ee82710c088461cf4d3769625723346345566f9 (patch) | |
tree | c0d0ae7dec81921a9b2bac047de91219e64800bf | |
parent | c59166c5a3306231864fe7d99e383259a9385233 (diff) |
libglusterfs/statedump: move options file and statedumps from /tmp
Change-Id: I6b107b9a668b0521b955dba8895cbbeaf9e7cb02
BUG: 764890
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-on: http://review.gluster.org/5005
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r-- | cli/src/cli.h | 1 | ||||
-rw-r--r-- | glusterfsd/src/Makefile.am | 1 | ||||
-rw-r--r-- | libglusterfs/src/Makefile.am | 3 | ||||
-rw-r--r-- | libglusterfs/src/glusterfs.h | 2 | ||||
-rw-r--r-- | libglusterfs/src/run.c | 2 | ||||
-rw-r--r-- | libglusterfs/src/statedump.c | 25 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 6 | ||||
-rw-r--r-- | xlators/protocol/server/src/Makefile.am | 1 | ||||
-rw-r--r-- | xlators/protocol/server/src/server.c | 4 |
9 files changed, 30 insertions, 15 deletions
diff --git a/cli/src/cli.h b/cli/src/cli.h index 894b6f934ba..03b51414d77 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -41,6 +41,7 @@ #define CLI_TOP_CMD_TIMEOUT 600 //Longer timeout for volume top #define DEFAULT_CLI_LOG_FILE_DIRECTORY DATADIR "/log/glusterfs" #define DEFAULT_LOG_FILE_DIRECTORY DATADIR "/log/glusterfs" +#define DEFAULT_VAR_RUN_DIRECTORY DATADIR "/run/gluster" #define CLI_VOL_STATUS_BRICK_LEN 55 #define CLI_TAB_LENGTH 8 #define CLI_BRICK_STATUS_LINE_LEN 78 diff --git a/glusterfsd/src/Makefile.am b/glusterfsd/src/Makefile.am index 17d7a4a8139..510b9dc1ffa 100644 --- a/glusterfsd/src/Makefile.am +++ b/glusterfsd/src/Makefile.am @@ -24,6 +24,7 @@ uninstall-local: install-data-local: $(INSTALL) -d -m 755 $(DESTDIR)$(localstatedir)/run + $(INSTALL) -d -m 755 $(DESTDIR)$(localstatedir)/run/gluster $(INSTALL) -d -m 755 $(DESTDIR)$(localstatedir)/log/glusterfs rm -f $(DESTDIR)$(sbindir)/glusterfs rm -f $(DESTDIR)$(sbindir)/glusterd diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am index ac1a9f58e21..aadd97971c2 100644 --- a/libglusterfs/src/Makefile.am +++ b/libglusterfs/src/Makefile.am @@ -1,5 +1,6 @@ libglusterfs_la_CFLAGS = -fPIC -Wall -g -shared -nostartfiles $(GF_CFLAGS) \ - $(GF_DARWIN_LIBGLUSTERFS_CFLAGS) + $(GF_DARWIN_LIBGLUSTERFS_CFLAGS) \ + -DDATADIR=\"$(localstatedir)\" libglusterfs_la_CPPFLAGS = -D_FILE_OFFSET_BITS=64 -D__USE_FILE_OFFSET64 \ -D_GNU_SOURCE -DXLATORDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator\" \ diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index 035bb7c0e7d..4dfb4cfb095 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -129,6 +129,8 @@ #define ZR_FILE_CONTENT_REQUEST(key) (!strncmp(key, ZR_FILE_CONTENT_STR, \ ZR_FILE_CONTENT_STRLEN)) +#define DEFAULT_VAR_RUN_DIRECTORY DATADIR "/run/gluster" + /* GlusterFS's maximum supported Auxilary GIDs */ /* TODO: Keeping it to 200, so that we can fit in 2KB buffer for auth data * in RPC server code, if there is ever need for having more aux-gids, then diff --git a/libglusterfs/src/run.c b/libglusterfs/src/run.c index 34d75df69c2..adc61513a72 100644 --- a/libglusterfs/src/run.c +++ b/libglusterfs/src/run.c @@ -467,7 +467,7 @@ main (int argc, char **argv) printf ("%d %d [%s]\n", ret, errno, strerror (errno)); TBANNER ("output redirection"); - fd = open ("/tmp/foof", O_WRONLY|O_CREAT|O_TRUNC, 0600); + fd = mkstemp ("/tmp/foof"); assert (fd != -1); runinit (&runner); runner_add_args (&runner, "echo", "foo", NULL); diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c index 899d8ef2b1b..90d345dadbe 100644 --- a/libglusterfs/src/statedump.c +++ b/libglusterfs/src/statedump.c @@ -55,15 +55,11 @@ gf_proc_dump_unlock (void) static int -gf_proc_dump_open (char *dump_dir, char *brickname) +gf_proc_dump_open (char path[]) { - char path[PATH_MAX] = {0,}; int dump_fd = -1; - snprintf (path, sizeof (path), "%s/%s.%d.dump", (dump_dir ? - dump_dir : "/tmp"), brickname, getpid()); - - dump_fd = open (path, O_CREAT|O_RDWR|O_TRUNC|O_APPEND, 0600); + dump_fd = mkostemp (path, O_CREAT|O_RDWR|O_TRUNC|O_APPEND); if (dump_fd < 0) return -1; @@ -572,7 +568,8 @@ gf_proc_dump_options_init () char dump_option_file[PATH_MAX]; snprintf (dump_option_file, sizeof (dump_option_file), - "/tmp/glusterdump.%d.options", getpid ()); + DEFAULT_VAR_RUN_DIRECTORY + "glusterdump.%d.options", getpid ()); fp = fopen (dump_option_file, "r"); @@ -619,6 +616,8 @@ gf_proc_dump_info (int signum) glusterfs_ctx_t *ctx = NULL; glusterfs_graph_t *trav = NULL; char brick_name[PATH_MAX] = {0,}; + char tmp_dump_name[PATH_MAX] = {0,}; + char path[PATH_MAX] = {0,}; gf_proc_dump_lock (); @@ -631,7 +630,16 @@ gf_proc_dump_info (int signum) } else strncpy (brick_name, "glusterdump", sizeof (brick_name)); - ret = gf_proc_dump_open (ctx->statedump_path, brick_name); + snprintf (path, sizeof (path), "%s/%s.%d.dump", + ((ctx->statedump_path != NULL)?ctx->statedump_path: + DEFAULT_VAR_RUN_DIRECTORY), + brick_name, getpid()); + + snprintf (tmp_dump_name, PATH_MAX, "%s/dumpXXXXXX", + ((ctx->statedump_path != NULL)?ctx->statedump_path: + DEFAULT_VAR_RUN_DIRECTORY)); + + ret = gf_proc_dump_open (tmp_dump_name); if (ret < 0) goto out; @@ -673,6 +681,7 @@ gf_proc_dump_info (int signum) out: if (gf_dump_fd != -1) gf_proc_dump_close (); + rename (tmp_dump_name, path); gf_proc_dump_unlock (); return; diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 9346e1d9c6f..eada07c924f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -79,7 +79,7 @@ #define NLMV4_VERSION 4 #define NLMV1_VERSION 1 -char *glusterd_sock_dir = "/tmp"; +char *glusterd_sock_dir = "/var/run"; static glusterd_lock_t lock; static void @@ -5179,7 +5179,7 @@ glusterd_brick_statedump (glusterd_volinfo_t *volinfo, } snprintf (dumpoptions_path, sizeof (dumpoptions_path), - "/tmp/glusterdump.%d.options", pid); + DEFAULT_VAR_RUN_DIRECTORY"glusterdump.%d.options", pid); ret = glusterd_set_dump_options (dumpoptions_path, options, option_cnt); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error while parsing the statedump " @@ -5252,7 +5252,7 @@ glusterd_nfs_statedump (char *options, int option_cnt, char **op_errstr) } snprintf (dumpoptions_path, sizeof (dumpoptions_path), - "/tmp/glusterdump.%d.options", pid); + DEFAULT_VAR_RUN_DIRECTORY"glusterdump.%d.options", pid); ret = glusterd_set_dump_options (dumpoptions_path, options, option_cnt); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error while parsing the statedump " diff --git a/xlators/protocol/server/src/Makefile.am b/xlators/protocol/server/src/Makefile.am index 0df5894eceb..11f311fd6a2 100644 --- a/xlators/protocol/server/src/Makefile.am +++ b/xlators/protocol/server/src/Makefile.am @@ -16,6 +16,7 @@ AM_CFLAGS = -fPIC -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -Wall \ -I$(top_srcdir)/libglusterfs/src -shared -nostartfiles \ -DCONFDIR=\"$(sysconfdir)/glusterfs\" -D$(GF_HOST_OS) \ -DLIBDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/auth\" \ + -DDATADIR=\"$(localstatedir)\" \ $(GF_CFLAGS) -I$(top_srcdir)/xlators/protocol/lib/src \ -I$(top_srcdir)/rpc/rpc-lib/src/ \ -I$(top_srcdir)/rpc/xdr/src/ diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index f51dfb9c5ef..ffe938343c8 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -1208,9 +1208,9 @@ struct volume_options options[] = { }, { .key = {"statedump-path"}, .type = GF_OPTION_TYPE_PATH, - .default_value = "/tmp", + .default_value = DEFAULT_VAR_RUN_DIRECTORY, .description = "Specifies directory in which gluster should save its" - " statedumps. By default it is the /tmp directory" + " statedumps." }, { .key = {"lk-heal"}, .type = GF_OPTION_TYPE_BOOL, |