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>
This commit is contained in:
Avra Sengupta 2013-01-24 11:39:48 +05:30 committed by Anand Avati
parent 326a47939d
commit b8d5fd2b88
16 changed files with 58 additions and 38 deletions

View File

@ -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;

View File

@ -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

View File

@ -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 () {

View File

@ -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

View File

@ -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\" \

View File

@ -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

View File

@ -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);

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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";

View File

@ -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 {

View File

@ -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);

View File

@ -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 "

View File

@ -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 = *~

View File

@ -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"
},