summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2012-07-25 06:27:57 +0530
committerAnand Avati <avati@redhat.com>2012-07-30 11:17:00 -0700
commit9181871ff49a5b1e5b1acc9c8a96c99d28e80a5e (patch)
tree43b414aeae8d8db76b8f822db00fabcd9b8aa909 /libglusterfs
parent331c8d44d8e2781150c9bea56f36576a9dda0d6f (diff)
libglusterfs/statedump: add start and end markers in the statedump file
Also do not overwrite the statedump file if statedump is taken on the same process again. Instead add the timestamp to the filename Change-Id: I451a0decf2dad5c398631cab1fc2a69811c69af8 BUG: 843408 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com> Reviewed-on: http://review.gluster.com/3738 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/statedump.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c
index 1abd603ad..1158a2d82 100644
--- a/libglusterfs/src/statedump.c
+++ b/libglusterfs/src/statedump.c
@@ -60,8 +60,9 @@ gf_proc_dump_open (char *dump_dir, char *brickname)
char path[PATH_MAX] = {0,};
int dump_fd = -1;
- snprintf (path, sizeof (path), "%s/%s.%d.dump", (dump_dir ?
- dump_dir : "/tmp"), brickname, getpid());
+ snprintf (path, sizeof (path), "%s/%s.%d.dump.%"PRIu64,
+ (dump_dir ? dump_dir : "/tmp"), brickname, getpid(),
+ (uint64_t) time (NULL));
dump_fd = open (path, O_CREAT|O_RDWR|O_TRUNC|O_APPEND, 0600);
if (dump_fd < 0)
@@ -622,6 +623,9 @@ gf_proc_dump_info (int signum, glusterfs_ctx_t *ctx)
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,};
gf_proc_dump_lock ();
@@ -641,6 +645,25 @@ gf_proc_dump_info (int signum, glusterfs_ctx_t *ctx)
if (ret < 0)
goto out;
+ //continue even though gettimeofday() has failed
+ ret = gettimeofday (&tv, NULL);
+ if (0 == ret) {
+ gf_time_fmt (timestr, sizeof timestr, tv.tv_sec, gf_timefmt_FT);
+ snprintf (timestr + strlen (timestr),
+ sizeof timestr - strlen (timestr),
+ ".%"GF_PRI_SUSECONDS, tv.tv_usec);
+ }
+
+ snprintf (sign_string, sizeof (sign_string), "DUMP-START-TIME: %s\n",
+ timestr);
+
+ //swallow the errors of write for start and end marker
+ ret = write (gf_dump_fd, sign_string, strlen (sign_string));
+
+ memset (sign_string, 0, sizeof (sign_string));
+ memset (timestr, 0, sizeof (timestr));
+ memset (&tv, 0, sizeof (tv));
+
if (GF_PROC_DUMP_IS_OPTION_ENABLED (mem)) {
gf_proc_dump_mem_info ();
gf_proc_dump_mempool_info (ctx);
@@ -672,6 +695,18 @@ gf_proc_dump_info (int signum, glusterfs_ctx_t *ctx)
i++;
}
+ ret = gettimeofday (&tv, NULL);
+ if (0 == ret) {
+ gf_time_fmt (timestr, sizeof timestr, tv.tv_sec, gf_timefmt_FT);
+ snprintf (timestr + strlen (timestr),
+ sizeof timestr - strlen (timestr),
+ ".%"GF_PRI_SUSECONDS, tv.tv_usec);
+ }
+
+ snprintf (sign_string, sizeof (sign_string), "\nDUMP-END-TIME: %s",
+ timestr);
+ ret = write (gf_dump_fd, sign_string, strlen (sign_string));
+
out:
if (gf_dump_fd != -1)
gf_proc_dump_close ();