summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2013-01-24 11:39:48 +0530
committerAnand Avati <avati@redhat.com>2013-01-29 15:27:29 -0800
commitb8d5fd2b88db7e18a10e57a0edf1a41eda4f5314 (patch)
tree7fb29a1060e0fc802f81473114117aabec4db507
parent326a47939dabff218205ca2959b9701e2e0ce47c (diff)
glusterfs : Moved option files, and statedumps from /tmp
Change-Id: Ibdede396c4d6859225937316b7a59a661bcaf9f5 BUG: 764890 Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/4422 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r--cli/src/cli.c5
-rw-r--r--cli/src/cli.h1
-rwxr-xr-xextras/hook-scripts/S30samba-stop.sh2
-rw-r--r--glusterfsd/src/Makefile.am1
-rw-r--r--libglusterfs/src/Makefile.am3
-rw-r--r--libglusterfs/src/glusterfs.h2
-rw-r--r--libglusterfs/src/run.c2
-rw-r--r--libglusterfs/src/statedump.c43
-rwxr-xr-xtests/bugs/bug-797171.t14
-rwxr-xr-xtests/bugs/bug-858215.t4
-rw-r--r--tests/include.rc1
-rw-r--r--tests/volume.rc6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-replace-brick.c3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c4
-rw-r--r--xlators/protocol/server/src/Makefile.am3
-rw-r--r--xlators/protocol/server/src/server.c2
16 files changed, 58 insertions, 38 deletions
diff --git a/cli/src/cli.c b/cli/src/cli.c
index 4ff172805..082ba67c0 100644
--- a/cli/src/cli.c
+++ b/cli/src/cli.c
@@ -307,6 +307,11 @@ cli_opt_parse (char *opt, struct cli_state *state)
exit (0);
}
+ if (strcmp (opt, "print-statedumpdir") == 0) {
+ cli_out ("%s", DEFAULT_VAR_RUN_DIRECTORY);
+ exit (0);
+ }
+
if (strcmp (opt, "xml") == 0) {
#if (HAVE_LIB_XML)
state->mode |= GLUSTER_MODE_XML;
diff --git a/cli/src/cli.h b/cli/src/cli.h
index 62216397f..e0699b429 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -33,6 +33,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/extras/hook-scripts/S30samba-stop.sh b/extras/hook-scripts/S30samba-stop.sh
index f96847309..7e05c2111 100755
--- a/extras/hook-scripts/S30samba-stop.sh
+++ b/extras/hook-scripts/S30samba-stop.sh
@@ -35,7 +35,7 @@ function del_samba_export () {
volname=$1
cp /etc/samba/smb.conf /tmp/smb.conf
sed -i "/gluster-$volname/,/^$/d" /tmp/smb.conf &&\
- mv /tmp/smb.conf /etc/samba/smb.conf
+ cp /tmp/smb.conf /etc/samba/smb.conf
}
function umount_volume () {
diff --git a/glusterfsd/src/Makefile.am b/glusterfsd/src/Makefile.am
index c9e894d87..05a10dee3 100644
--- a/glusterfsd/src/Makefile.am
+++ b/glusterfsd/src/Makefile.am
@@ -26,6 +26,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
$(INSTALL) -d -m 755 $(DESTDIR)$(sbindir)
rm -f $(DESTDIR)$(sbindir)/glusterfs
diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am
index 0503e97f6..d0a617e7b 100644
--- a/libglusterfs/src/Makefile.am
+++ b/libglusterfs/src/Makefile.am
@@ -1,5 +1,6 @@
libglusterfs_la_CFLAGS = -Wall $(GF_CFLAGS) \
- $(GF_DARWIN_LIBGLUSTERFS_CFLAGS)
+ $(GF_DARWIN_LIBGLUSTERFS_CFLAGS) \
+ -DDATADIR=\"$(localstatedir)\"
libglusterfs_la_CPPFLAGS = $(GF_CPPFLAGS) -D__USE_FILE_OFFSET64 \
-DXLATORDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator\" \
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index dae539841..74e6847a0 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -134,6 +134,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 94511b1c3..ebe7f3962 100644
--- a/libglusterfs/src/run.c
+++ b/libglusterfs/src/run.c
@@ -490,7 +490,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 b8ba882f3..8175faba4 100644
--- a/libglusterfs/src/statedump.c
+++ b/libglusterfs/src/statedump.c
@@ -541,7 +541,7 @@ out:
return all_disabled;
}
-/* These options are dumped by default if /tmp/glusterdump.options
+/* These options are dumped by default if glusterdump.options
file exists and it is emtpty
*/
static int
@@ -635,21 +635,22 @@ gf_proc_dump_options_init ()
char *saveptr = NULL;
char dump_option_file[PATH_MAX];
- /* glusterd will create a file /tmp/glusterdump.<pid>.options and
+ /* glusterd will create a file glusterdump.<pid>.options and
sets the statedump options for the process and the file is removed
after the statedump is taken. Direct issue of SIGUSR1 does not have
mechanism for considering the statedump options. So to have a way
of configuring the statedump of all the glusterfs processes through
- both cli command and SIGUSR1, /tmp/glusterdump.options file
- is searched and the options mentioned in it are given the higher
- priority.
+ both cli command and SIGUSR1, glusterdump.options file is searched
+ and the options mentioned in it are given the higher priority.
*/
snprintf (dump_option_file, sizeof (dump_option_file),
- "/tmp/glusterdump.options");
+ DEFAULT_VAR_RUN_DIRECTORY
+ "/glusterdump.options");
fp = fopen (dump_option_file, "r");
if (!fp) {
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");
@@ -696,15 +697,15 @@ gf_proc_dump_options_init ()
void
gf_proc_dump_info (int signum, glusterfs_ctx_t *ctx)
{
- int i = 0;
- int ret = -1;
- glusterfs_graph_t *trav = NULL;
- char brick_name[PATH_MAX] = {0,};
- struct timeval tv = {0,};
- char timestr[256] = {0,};
- char sign_string[512] = {0,};
- char tmp_dump_name[] = "/tmp/dumpXXXXXX";
- char path[PATH_MAX] = {0,};
+ int i = 0;
+ int ret = -1;
+ glusterfs_graph_t *trav = NULL;
+ char brick_name[PATH_MAX] = {0,};
+ char timestr[256] = {0,};
+ char sign_string[512] = {0,};
+ char tmp_dump_name[PATH_MAX] = {0,};
+ char path[PATH_MAX] = {0,};
+ struct timeval tv = {0,};
gf_proc_dump_lock ();
@@ -722,8 +723,14 @@ gf_proc_dump_info (int signum, glusterfs_ctx_t *ctx)
snprintf (path, sizeof (path), "%s/%s.%d.dump.%"PRIu64,
((dump_options.dump_path != NULL)?dump_options.dump_path:
- ((ctx->statedump_path != NULL)?ctx->statedump_path:"/tmp")),
- brick_name, getpid(), (uint64_t) time (NULL));
+ ((ctx->statedump_path != NULL)?ctx->statedump_path:
+ DEFAULT_VAR_RUN_DIRECTORY)), brick_name, getpid(),
+ (uint64_t) time (NULL));
+
+ snprintf (tmp_dump_name, PATH_MAX, "%s/dumpXXXXXX",
+ ((dump_options.dump_path != NULL)?dump_options.dump_path:
+ ((ctx->statedump_path != NULL)?ctx->statedump_path:
+ DEFAULT_VAR_RUN_DIRECTORY)));
ret = gf_proc_dump_open (tmp_dump_name);
if (ret < 0)
diff --git a/tests/bugs/bug-797171.t b/tests/bugs/bug-797171.t
index d5603676b..a1b28d9ff 100755
--- a/tests/bugs/bug-797171.t
+++ b/tests/bugs/bug-797171.t
@@ -26,18 +26,18 @@ rm -f $M0/*;
pid_file=$(ls /var/lib/glusterd/vols/$V0/run);
brick_pid=$(cat /var/lib/glusterd/vols/$V0/run/$pid_file);
-mkdir /tmp/statedump_tmp/;
-echo "path=/tmp/statedump_tmp" > /tmp/glusterdump.options;
-echo "all=yes" >> /tmp/glusterdump.options;
+mkdir $statedumpdir/statedump_tmp/;
+echo "path=$statedumpdir/statedump_tmp" > $statedumpdir/glusterdump.options;
+echo "all=yes" >> $statedumpdir/glusterdump.options;
TEST $CLI volume statedump $V0 history;
-file_name=$(ls /tmp/statedump_tmp);
-TEST grep "xlator.debug.trace.history" /tmp/statedump_tmp/$file_name;
+file_name=$(ls $statedumpdir/statedump_tmp);
+TEST grep "xlator.debug.trace.history" $statedumpdir/statedump_tmp/$file_name;
TEST umount $M0
-rm -rf /tmp/statedump_tmp;
-rm -f /tmp/glusterdump.options;
+rm -rf $statedumpdir/statedump_tmp;
+rm -f $statedumpdir/glusterdump.options;
cleanup;
diff --git a/tests/bugs/bug-858215.t b/tests/bugs/bug-858215.t
index c93ff8b97..aee7d5fcb 100755
--- a/tests/bugs/bug-858215.t
+++ b/tests/bugs/bug-858215.t
@@ -55,7 +55,7 @@ do
done
dump_dir='/tmp/gerrit_glusterfs'
-cat >/tmp/glusterdump.options <<EOF
+cat >$statedumpdir/glusterdump.options <<EOF
all=yes
path=$dump_dir
EOF
@@ -76,6 +76,6 @@ TEST $CLI volume delete $V0;
TEST ! $CLI volume info $V0;
TEST rm -rf $dump_dir;
-TEST rm /tmp/glusterdump.options;
+TEST rm $statedumpdir/glusterdump.options;
cleanup;
diff --git a/tests/include.rc b/tests/include.rc
index 03ffe4a5c..1d1386f98 100644
--- a/tests/include.rc
+++ b/tests/include.rc
@@ -6,6 +6,7 @@ V0=${V0:=patchy}; # volume name to use in tests
B0=${B0:=/d/backends}; # top level of brick directories
H0=${H0:=`hostname --fqdn`}; # hostname
DEBUG=${DEBUG:=0} # turn on debugging?
+statedumpdir=`gluster --print-statedumpdir`; # Default directory for statedump
CLI="gluster --mode=script";
diff --git a/tests/volume.rc b/tests/volume.rc
index 9ecb24d40..e8dd2eeb7 100644
--- a/tests/volume.rc
+++ b/tests/volume.rc
@@ -38,12 +38,12 @@ function generate_client_statedump {
local fpath=""
client_pid=$1
#remove old stale statedumps
- rm -f /tmp/glusterdump.$client_pid.dump.* 2>/dev/null
+ rm -f $statedumpdir/glusterdump.$client_pid.dump.* 2>/dev/null
kill -USR1 $client_pid
#Wait till the statedump is generated
sleep 1
- fname=$(ls /tmp | grep -E "glusterdump.$client_pid.dump.*")
- echo /tmp/$fname
+ fname=$(ls $statedumpdir | grep -E "glusterdump.$client_pid.dump.*")
+ echo $statedumpdir/$fname
}
function generate_mount_statedump {
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
index 8bd9a1529..c4e26c132 100644
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
@@ -27,7 +27,8 @@
#include <signal.h>
#define GLUSTERD_GET_RB_MNTPT(path, len, volinfo) \
- snprintf (path, len, "/tmp/%s-"RB_CLIENT_MOUNTPOINT, \
+ snprintf (path, len, \
+ DEFAULT_VAR_RUN_DIRECTORY"/%s-"RB_CLIENT_MOUNTPOINT, \
volinfo->volname);
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index b68ba252e..b1be28b18 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -5700,7 +5700,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 "
@@ -5773,7 +5773,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 c7ac38172..cdb0f0277 100644
--- a/xlators/protocol/server/src/Makefile.am
+++ b/xlators/protocol/server/src/Makefile.am
@@ -20,6 +20,7 @@ AM_CPPFLAGS = $(GF_CPPFLAGS) \
-I$(top_srcdir)/rpc/rpc-lib/src/ \
-I$(top_srcdir)/rpc/xdr/src/
-AM_CFLAGS = -Wall $(GF_CFLAGS)
+AM_CFLAGS = -Wall $(GF_CFLAGS) \
+ -DDATADIR=\"$(localstatedir)\"
CLEANFILES = *~
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
index 5cc27ce60..9e60febfb 100644
--- a/xlators/protocol/server/src/server.c
+++ b/xlators/protocol/server/src/server.c
@@ -1276,7 +1276,7 @@ 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"
},