diff options
author | Anand Avati <avati@gluster.com> | 2010-06-07 12:37:34 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-06-07 11:58:50 -0700 |
commit | 79241696fbdebe2583298f12cbaee068ce60c655 (patch) | |
tree | 42e60d351e328fa34f17242c6c3359a8c01e8fa3 /libglusterfs/src/statedump.c | |
parent | c4ebd25a176d6d51d702b1009e261c3c27237a48 (diff) |
dynamic volume changes for graph replacement
Signed-off-by: Anand V. Avati <avati@blackhole.gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 971 (dynamic volume management)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971
Diffstat (limited to 'libglusterfs/src/statedump.c')
-rw-r--r-- | libglusterfs/src/statedump.c | 152 |
1 files changed, 79 insertions, 73 deletions
diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c index 678ed6c8ecd..6f30a30ea78 100644 --- a/libglusterfs/src/statedump.c +++ b/libglusterfs/src/statedump.c @@ -33,17 +33,20 @@ extern xlator_t global_xlator; static pthread_mutex_t gf_proc_dump_mutex; static int gf_dump_fd = -1; -static void + +static void gf_proc_dump_lock (void) { - pthread_mutex_lock(&gf_proc_dump_mutex); + pthread_mutex_lock (&gf_proc_dump_mutex); } -static void + +static void gf_proc_dump_unlock (void) { - pthread_mutex_unlock(&gf_proc_dump_mutex); -} + pthread_mutex_unlock (&gf_proc_dump_mutex); +} + static int gf_proc_dump_open (void) @@ -51,10 +54,10 @@ gf_proc_dump_open (void) char path[256]; int dump_fd = -1; - memset(path, 0, sizeof(path)); - snprintf(path, sizeof(path), "%s.%d",GF_DUMP_LOGFILE_ROOT, getpid()); + memset (path, 0, sizeof (path)); + snprintf (path, sizeof (path), "%s.%d", GF_DUMP_LOGFILE_ROOT, getpid ()); - dump_fd = open(path, O_CREAT|O_RDWR|O_TRUNC|O_APPEND, 0600); + dump_fd = open (path, O_CREAT|O_RDWR|O_TRUNC|O_APPEND, 0600); if (dump_fd < 0) { gf_log("", GF_LOG_ERROR, "Unable to open file: %s" " errno: %d", path, errno); @@ -65,56 +68,59 @@ gf_proc_dump_open (void) return 0; } + static void gf_proc_dump_close (void) { - close(gf_dump_fd); + close (gf_dump_fd); gf_dump_fd = -1; } + void -gf_proc_dump_add_section (char *key, ...) +gf_proc_dump_add_section (char *key, ...) { - + char buf[GF_DUMP_MAX_BUF_LEN]; va_list ap; int ret; assert(key); - - memset(buf, 0, sizeof(buf)); - snprintf(buf, GF_DUMP_MAX_BUF_LEN, "\n["); - va_start(ap, key); - vsnprintf(buf + strlen(buf), - GF_DUMP_MAX_BUF_LEN - strlen(buf), key, ap); - va_end(ap); - snprintf(buf + strlen(buf), - GF_DUMP_MAX_BUF_LEN - strlen(buf), "]\n"); - ret = write(gf_dump_fd, buf, strlen(buf)); + + memset (buf, 0, sizeof(buf)); + snprintf (buf, GF_DUMP_MAX_BUF_LEN, "\n["); + va_start (ap, key); + vsnprintf (buf + strlen(buf), + GF_DUMP_MAX_BUF_LEN - strlen (buf), key, ap); + va_end (ap); + snprintf (buf + strlen(buf), + GF_DUMP_MAX_BUF_LEN - strlen (buf), "]\n"); + ret = write (gf_dump_fd, buf, strlen (buf)); } + void -gf_proc_dump_write (char *key, char *value,...) -{ - - char buf[GF_DUMP_MAX_BUF_LEN]; - int offset = 0; +gf_proc_dump_write (char *key, char *value,...) +{ + + char buf[GF_DUMP_MAX_BUF_LEN]; + int offset = 0; va_list ap; int ret; - - offset = strlen(key); - - memset(buf, 0, GF_DUMP_MAX_BUF_LEN); - snprintf(buf, GF_DUMP_MAX_BUF_LEN, "%s",key); - snprintf(buf + offset, GF_DUMP_MAX_BUF_LEN - offset, "="); + + offset = strlen (key); + + memset (buf, 0, GF_DUMP_MAX_BUF_LEN); + snprintf (buf, GF_DUMP_MAX_BUF_LEN, "%s", key); + snprintf (buf + offset, GF_DUMP_MAX_BUF_LEN - offset, "="); offset += 1; - va_start(ap, value); - vsnprintf(buf + offset, GF_DUMP_MAX_BUF_LEN - offset, value, ap); - va_end(ap); + va_start (ap, value); + vsnprintf (buf + offset, GF_DUMP_MAX_BUF_LEN - offset, value, ap); + va_end (ap); - offset = strlen(buf); - snprintf(buf + offset, GF_DUMP_MAX_BUF_LEN - offset, "\n"); - ret = write(gf_dump_fd, buf, strlen(buf)); + offset = strlen (buf); + snprintf (buf + offset, GF_DUMP_MAX_BUF_LEN - offset, "\n"); + ret = write (gf_dump_fd, buf, strlen (buf)); } static void @@ -165,20 +171,20 @@ gf_proc_dump_mem_info () #ifdef HAVE_MALLOC_STATS struct mallinfo info; - memset(&info, 0, sizeof(struct mallinfo)); - info = mallinfo(); - - gf_proc_dump_add_section("mallinfo"); - gf_proc_dump_write("mallinfo_arena", "%d", info.arena); - gf_proc_dump_write("mallinfo_ordblks", "%d", info.ordblks); - gf_proc_dump_write("mallinfo_smblks","%d", info.smblks); - gf_proc_dump_write("mallinfo_hblks","%d", info.hblks); - gf_proc_dump_write("mallinfo_hblkhd", "%d", info.hblkhd); - gf_proc_dump_write("mallinfo_usmblks","%d", info.usmblks); - gf_proc_dump_write("mallinfo_fsmblks","%d", info.fsmblks); - gf_proc_dump_write("mallinfo_uordblks","%d", info.uordblks); - gf_proc_dump_write("mallinfo_fordblks", "%d", info.fordblks); - gf_proc_dump_write("mallinfo_keepcost", "%d", info.keepcost); + memset (&info, 0, sizeof (struct mallinfo)); + info = mallinfo (); + + gf_proc_dump_add_section ("mallinfo"); + gf_proc_dump_write ("mallinfo_arena", "%d", info.arena); + gf_proc_dump_write ("mallinfo_ordblks", "%d", info.ordblks); + gf_proc_dump_write ("mallinfo_smblks", "%d", info.smblks); + gf_proc_dump_write ("mallinfo_hblks", "%d", info.hblks); + gf_proc_dump_write ("mallinfo_hblkhd", "%d", info.hblkhd); + gf_proc_dump_write ("mallinfo_usmblks", "%d", info.usmblks); + gf_proc_dump_write ("mallinfo_fsmblks", "%d", info.fsmblks); + gf_proc_dump_write ("mallinfo_uordblks", "%d", info.uordblks); + gf_proc_dump_write ("mallinfo_fordblks", "%d", info.fordblks); + gf_proc_dump_write ("mallinfo_keepcost", "%d", info.keepcost); #endif gf_proc_dump_xlator_mem_info(&global_xlator); @@ -203,12 +209,11 @@ gf_proc_dump_xlator_info (xlator_t *this_xl) continue; } if (this_xl->dumpops->priv) - this_xl->dumpops->priv(this_xl); + this_xl->dumpops->priv (this_xl); if (this_xl->dumpops->inode) - this_xl->dumpops->inode(this_xl); + this_xl->dumpops->inode (this_xl); if (this_xl->dumpops->fd) - this_xl->dumpops->fd(this_xl); - + this_xl->dumpops->fd (this_xl); this_xl = this_xl->next; } @@ -221,44 +226,45 @@ gf_proc_dump_info (int signum) { int ret = -1; glusterfs_ctx_t *ctx = NULL; - - gf_proc_dump_lock(); - ret = gf_proc_dump_open(); - if (ret < 0) + + gf_proc_dump_lock (); + ret = gf_proc_dump_open (); + if (ret < 0) goto out; - gf_proc_dump_mem_info(); - ctx = get_global_ctx_ptr(); + gf_proc_dump_mem_info (); + ctx = glusterfs_ctx_get (); if (ctx) { - iobuf_stats_dump(ctx->iobuf_pool); - gf_proc_dump_pending_frames(ctx->pool); - gf_proc_dump_xlator_info(ctx->graph); + iobuf_stats_dump (ctx->iobuf_pool); + gf_proc_dump_pending_frames (ctx->pool); + gf_proc_dump_xlator_info (ctx->active->first); } - - gf_proc_dump_close(); + + gf_proc_dump_close (); out: - gf_proc_dump_unlock(); + gf_proc_dump_unlock (); return; } -void + +void gf_proc_dump_fini (void) { - pthread_mutex_destroy(&gf_proc_dump_mutex); + pthread_mutex_destroy (&gf_proc_dump_mutex); } void gf_proc_dump_init () { - pthread_mutex_init(&gf_proc_dump_mutex, NULL); + pthread_mutex_init (&gf_proc_dump_mutex, NULL); return; } + void gf_proc_dump_cleanup (void) { - pthread_mutex_destroy(&gf_proc_dump_mutex); + pthread_mutex_destroy (&gf_proc_dump_mutex); } - |