, 28 Dec 2035 06:54:32 GMT ETag: "6977814ec69b96078a340888794129f741260c6b" /* Copyright (c) 2008-2012 Red Hat, Inc. This file is part of GlusterFS. This file is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. */ #include "statedump.h" #include "stack.h" #include "libglusterfs-messages.h" call_frame_t * create_frame (xlator_t *xl, call_pool_t *pool) { call_stack_t *stack = NULL; call_frame_t *frame = NULL; if (!xl || !pool) { return NULL; } stack = mem_get0 (pool->stack_mem_pool); if (!stack) return NULL; INIT_LIST_HEAD (&stack->myframes); frame = mem_get0 (pool->frame_mem_pool); if (!frame) { mem_put (stack); return NULL; } frame->root = stack; frame->this = xl; LOCK_INIT (&frame->lock); INIT_LIST_HEAD (&frame->frames); list_add (&frame->frames, &stack->myframes); stack->pool = pool; stack->ctx = xl->ctx; if (stack->ctx->measure_latency) { if (gettimeofday (&stack->tv, NULL) == -1) gf_msg ("stack", GF_LOG_ERROR, errno, LG_MSG_GETTIMEOFDAY_FAILED, "gettimeofday () failed"); memcpy (&frame->begin, &stack->tv, sizeof (stack->tv)); } LOCK (&pool->lock); { list_add (&stack->all_frames, &pool->all_frames); pool->cnt++; } UNLOCK (&pool->lock); LOCK_INIT (&stack->stack_lock); return frame; } void gf_proc_dump_call_frame (call_frame_t *call_frame, const char *key_buf,...) { char prefix[GF_DUMP_MAX_BUF_LEN]; va_list ap; call_frame_t my_frame; int ret = -1; char timestr[256] = {0,}; if (!call_frame) return; GF_ASSERT (key_buf); memset(prefix, 0, sizeof(prefix)); memset(&my_frame, 0, sizeof(my_frame)); va_start(ap, key_buf); vsnprintf(prefix, GF_DUMP_MAX_BUF_LEN, key_buf, ap); va_end(ap); ret = TRY_LOCK(&call_frame->lock); if (ret) goto out; memcpy(&my_frame, call_frame, sizeof(my_frame)); UNLOCK(&call_frame->lock); if (my_frame.this->ctx->measure_latency) { gf_time_fmt (timestr, sizeof timestr, my_frame.begin.tv_sec, gf_timefmt_FT); snprintf (timestr + strlen (timestr), sizeof timestr - strlen (timestr), ".%"GF_PRI_SUSECONDS, my_frame.begin.tv_usec); gf_proc_dump_write("frame-creation-time", "%s", timestr); } gf_proc_dump_write("frame", "%p", call_frame); gf_proc_dump_write("ref_count", "%d", my_frame.ref_count); gf_proc_dump_write("translator", "%s", my_frame.this->name); gf_proc_dump_write("complete", "%d", my_frame.complete); if (my_frame.parent) gf_proc_dump_write("parent", "%s", my_frame.parent->this->name); if (my_frame.wind_from) gf_proc_dump_write("wind_from", "%s", my_frame.wind_from); if (my_frame.wind_to) gf_proc_dump_write("wind_to", "%s", my_frame.wind_to); if (my_frame.unwind_from) gf_proc_dump_write("unwind_from", "%s", my_frame.unwind_from); if (my_frame.unwind_to) gf_proc_dum