diff options
author | Amar Tumballi <amar@gluster.com> | 2011-03-16 09:38:28 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2011-03-17 11:57:17 -0700 |
commit | 924d2ed32d19a2a0014f803edd3d4511a0af99c2 (patch) | |
tree | 56ac7c904ee454bf9e16c4fd173a6e2906375d25 /libglusterfs/src/stack.h | |
parent | ebe47d5dae42da18b289e7be44eb67a8157a56b1 (diff) |
libglusterfs: all header files updated
* whitespace cleanup (M-x whitespace-cleanup)
* indentation fixes (M-x indent-region)
* replaced tab with spaces (M-x untabify)
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 2346 (Log message enhancements in GlusterFS - phase 1)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2346
Diffstat (limited to 'libglusterfs/src/stack.h')
-rw-r--r-- | libglusterfs/src/stack.h | 365 |
1 files changed, 182 insertions, 183 deletions
diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h index 1c3e3430e12..7165faccaa7 100644 --- a/libglusterfs/src/stack.h +++ b/libglusterfs/src/stack.h @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2006-2010 Gluster, Inc. <http://www.gluster.com> This file is part of GlusterFS. @@ -47,78 +47,79 @@ typedef struct _call_pool_t call_pool_t; #define NFS_PID 1 typedef int32_t (*ret_fn_t) (call_frame_t *frame, - call_frame_t *prev_frame, - xlator_t *this, - int32_t op_ret, - int32_t op_errno, - ...); + call_frame_t *prev_frame, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + ...); struct _call_pool_t { - union { - struct list_head all_frames; - struct { - call_stack_t *next_call; - call_stack_t *prev_call; - } all_stacks; - }; - int64_t cnt; - gf_lock_t lock; - struct mem_pool *frame_mem_pool; - struct mem_pool *stack_mem_pool; + union { + struct list_head all_frames; + struct { + call_stack_t *next_call; + call_stack_t *prev_call; + } all_stacks; + }; + int64_t cnt; + gf_lock_t lock; + struct mem_pool *frame_mem_pool; + struct mem_pool *stack_mem_pool; }; struct _call_frame_t { - call_stack_t *root; /* stack root */ - call_frame_t *parent; /* previous BP */ - call_frame_t *next; - call_frame_t *prev; /* maintainence list */ - void *local; /* local variables */ - xlator_t *this; /* implicit object */ - ret_fn_t ret; /* op_return address */ - int32_t ref_count; - gf_lock_t lock; - void *cookie; /* unique cookie */ - gf_boolean_t complete; - - glusterfs_fop_t op; + call_stack_t *root; /* stack root */ + call_frame_t *parent; /* previous BP */ + call_frame_t *next; + call_frame_t *prev; /* maintainence list */ + void *local; /* local variables */ + xlator_t *this; /* implicit object */ + ret_fn_t ret; /* op_return address */ + int32_t ref_count; + gf_lock_t lock; + void *cookie; /* unique cookie */ + gf_boolean_t complete; + + glusterfs_fop_t op; struct timeval begin; /* when this frame was created */ struct timeval end; /* when this frame completed */ }; struct _call_stack_t { - union { - struct list_head all_frames; - struct { - call_stack_t *next_call; - call_stack_t *prev_call; - }; - }; - call_pool_t *pool; - void *trans; - uint64_t unique; - void *state; /* pointer to request state */ - uid_t uid; - gid_t gid; - pid_t pid; + union { + struct list_head all_frames; + struct { + call_stack_t *next_call; + call_stack_t *prev_call; + }; + }; + call_pool_t *pool; + void *trans; + uint64_t unique; + void *state; /* pointer to request state */ + uid_t uid; + gid_t gid; + pid_t pid; uint32_t ngrps; uint32_t groups[GF_REQUEST_MAXGROUPS]; uint64_t lk_owner; - call_frame_t frames; + call_frame_t frames; - int32_t op; - int8_t type; + int32_t op; + int8_t type; }; -#define frame_set_uid_gid(frm, u, g) \ - do { \ - if (frm) { \ - (frm)->root->uid = u; \ - (frm)->root->gid = g; \ - (frm)->root->ngrps = 0; \ - } \ - } while (0); \ +#define frame_set_uid_gid(frm, u, g) \ + do { \ + if (frm) { \ + (frm)->root->uid = u; \ + (frm)->root->gid = g; \ + (frm)->root->ngrps = 0; \ + } \ + } while (0); \ + struct xlator_fops; @@ -132,22 +133,22 @@ gf_update_latency (call_frame_t *frame); static inline void FRAME_DESTROY (call_frame_t *frame) { - void *local = NULL; - if (frame->next) - frame->next->prev = frame->prev; - if (frame->prev) - frame->prev->next = frame->next; - if (frame->local) { - local = frame->local; - frame->local = NULL; - - } - - LOCK_DESTROY (&frame->lock); - mem_put (frame->root->pool->frame_mem_pool, frame); - - if (local) - GF_FREE (local); + void *local = NULL; + if (frame->next) + frame->next->prev = frame->prev; + if (frame->prev) + frame->prev->next = frame->next; + if (frame->local) { + local = frame->local; + frame->local = NULL; + + } + + LOCK_DESTROY (&frame->lock); + mem_put (frame->root->pool->frame_mem_pool, frame); + + if (local) + GF_FREE (local); } @@ -156,27 +157,27 @@ STACK_DESTROY (call_stack_t *stack) { void *local = NULL; - LOCK (&stack->pool->lock); - { - list_del_init (&stack->all_frames); - stack->pool->cnt--; - } - UNLOCK (&stack->pool->lock); + LOCK (&stack->pool->lock); + { + list_del_init (&stack->all_frames); + stack->pool->cnt--; + } + UNLOCK (&stack->pool->lock); - if (stack->frames.local) { - local = stack->frames.local; - stack->frames.local = NULL; - } + if (stack->frames.local) { + local = stack->frames.local; + stack->frames.local = NULL; + } - LOCK_DESTROY (&stack->frames.lock); + LOCK_DESTROY (&stack->frames.lock); - while (stack->frames.next) { - FRAME_DESTROY (stack->frames.next); - } - mem_put (stack->pool->stack_mem_pool, stack); + while (stack->frames.next) { + FRAME_DESTROY (stack->frames.next); + } + mem_put (stack->pool->stack_mem_pool, stack); - if (local) - GF_FREE (local); + if (local) + GF_FREE (local); } @@ -200,73 +201,73 @@ STACK_DESTROY (call_stack_t *stack) /* make a call */ -#define STACK_WIND(frame, rfn, obj, fn, params ...) \ - do { \ - call_frame_t *_new = NULL; \ +#define STACK_WIND(frame, rfn, obj, fn, params ...) \ + do { \ + call_frame_t *_new = NULL; \ xlator_t *old_THIS = NULL; \ \ - _new = mem_get0 (frame->root->pool->frame_mem_pool); \ + _new = mem_get0 (frame->root->pool->frame_mem_pool); \ if (!_new) { \ gf_log ("stack", GF_LOG_ERROR, "alloc failed"); \ break; \ } \ - typeof(fn##_cbk) tmp_cbk = rfn; \ - _new->root = frame->root; \ - _new->next = frame->root->frames.next; \ - _new->prev = &frame->root->frames; \ - if (frame->root->frames.next) \ - frame->root->frames.next->prev = _new; \ - frame->root->frames.next = _new; \ - _new->this = obj; \ - _new->ret = (ret_fn_t) tmp_cbk; \ - _new->parent = frame; \ - _new->cookie = _new; \ - LOCK_INIT (&_new->lock); \ - frame->ref_count++; \ + typeof(fn##_cbk) tmp_cbk = rfn; \ + _new->root = frame->root; \ + _new->next = frame->root->frames.next; \ + _new->prev = &frame->root->frames; \ + if (frame->root->frames.next) \ + frame->root->frames.next->prev = _new; \ + frame->root->frames.next = _new; \ + _new->this = obj; \ + _new->ret = (ret_fn_t) tmp_cbk; \ + _new->parent = frame; \ + _new->cookie = _new; \ + LOCK_INIT (&_new->lock); \ + frame->ref_count++; \ old_THIS = THIS; \ THIS = obj; \ - fn (_new, obj, params); \ + fn (_new, obj, params); \ THIS = old_THIS; \ - } while (0) + } while (0) /* make a call with a cookie */ -#define STACK_WIND_COOKIE(frame, rfn, cky, obj, fn, params ...) \ - do { \ +#define STACK_WIND_COOKIE(frame, rfn, cky, obj, fn, params ...) \ + do { \ call_frame_t *_new = NULL; \ xlator_t *old_THIS = NULL; \ \ - _new = mem_get0 (frame->root->pool->frame_mem_pool); \ + _new = mem_get0 (frame->root->pool->frame_mem_pool); \ if (!_new) { \ gf_log ("stack", GF_LOG_ERROR, "alloc failed"); \ break; \ } \ - typeof(fn##_cbk) tmp_cbk = rfn; \ - _new->root = frame->root; \ - _new->next = frame->root->frames.next; \ - _new->prev = &frame->root->frames; \ - if (frame->root->frames.next) \ - frame->root->frames.next->prev = _new; \ - frame->root->frames.next = _new; \ - _new->this = obj; \ - _new->ret = (ret_fn_t) tmp_cbk; \ - _new->parent = frame; \ - _new->cookie = cky; \ - LOCK_INIT (&_new->lock); \ - frame->ref_count++; \ - fn##_cbk = rfn; \ + typeof(fn##_cbk) tmp_cbk = rfn; \ + _new->root = frame->root; \ + _new->next = frame->root->frames.next; \ + _new->prev = &frame->root->frames; \ + if (frame->root->frames.next) \ + frame->root->frames.next->prev = _new; \ + frame->root->frames.next = _new; \ + _new->this = obj; \ + _new->ret = (ret_fn_t) tmp_cbk; \ + _new->parent = frame; \ + _new->cookie = cky; \ + LOCK_INIT (&_new->lock); \ + frame->ref_count++; \ + fn##_cbk = rfn; \ old_THIS = THIS; \ THIS = obj; \ - fn (_new, obj, params); \ + fn (_new, obj, params); \ THIS = old_THIS; \ - } while (0) + } while (0) /* return from function */ -#define STACK_UNWIND(frame, params ...) \ - do { \ - ret_fn_t fn = NULL; \ - call_frame_t *_parent = NULL; \ +#define STACK_UNWIND(frame, params ...) \ + do { \ + ret_fn_t fn = NULL; \ + call_frame_t *_parent = NULL; \ xlator_t *old_THIS = NULL; \ if (!frame) { \ gf_log ("stack", GF_LOG_CRITICAL, "!frame"); \ @@ -274,20 +275,20 @@ STACK_DESTROY (call_stack_t *stack) } \ fn = frame->ret; \ _parent = frame->parent; \ - _parent->ref_count--; \ + _parent->ref_count--; \ old_THIS = THIS; \ THIS = _parent->this; \ frame->complete = _gf_true; \ - fn (_parent, frame->cookie, _parent->this, params); \ + fn (_parent, frame->cookie, _parent->this, params); \ THIS = old_THIS; \ - } while (0) + } while (0) /* return from function in type-safe way */ #define STACK_UNWIND_STRICT(op, frame, params ...) \ - do { \ - fop_##op##_cbk_t fn = NULL; \ - call_frame_t *_parent = NULL; \ + do { \ + fop_##op##_cbk_t fn = NULL; \ + call_frame_t *_parent = NULL; \ xlator_t *old_THIS = NULL; \ \ if (!frame) { \ @@ -296,90 +297,88 @@ STACK_DESTROY (call_stack_t *stack) } \ fn = (fop_##op##_cbk_t )frame->ret; \ _parent = frame->parent; \ - _parent->ref_count--; \ + _parent->ref_count--; \ old_THIS = THIS; \ THIS = _parent->this; \ frame->complete = _gf_true; \ - fn (_parent, frame->cookie, _parent->this, params); \ + fn (_parent, frame->cookie, _parent->this, params); \ THIS = old_THIS; \ - } while (0) + } while (0) static inline call_frame_t * copy_frame (call_frame_t *frame) { - call_stack_t *newstack = NULL; - call_stack_t *oldstack = NULL; + call_stack_t *newstack = NULL; + call_stack_t *oldstack = NULL; - if (!frame) { - return NULL; - } + if (!frame) { + return NULL; + } - newstack = mem_get0 (frame->root->pool->stack_mem_pool); + newstack = mem_get0 (frame->root->pool->stack_mem_pool); if (newstack == NULL) { return NULL; } - oldstack = frame->root; + oldstack = frame->root; - newstack->uid = oldstack->uid; - newstack->gid = oldstack->gid; - newstack->pid = oldstack->pid; + newstack->uid = oldstack->uid; + newstack->gid = oldstack->gid; + newstack->pid = oldstack->pid; newstack->ngrps = oldstack->ngrps; memcpy (newstack->groups, oldstack->groups, sizeof (uint32_t) * GF_REQUEST_MAXGROUPS); - newstack->unique = oldstack->unique; + newstack->unique = oldstack->unique; - newstack->frames.this = frame->this; - newstack->frames.root = newstack; - newstack->pool = oldstack->pool; + newstack->frames.this = frame->this; + newstack->frames.root = newstack; + newstack->pool = oldstack->pool; newstack->lk_owner = oldstack->lk_owner; - LOCK_INIT (&newstack->frames.lock); + LOCK_INIT (&newstack->frames.lock); - LOCK (&oldstack->pool->lock); - { - list_add (&newstack->all_frames, &oldstack->all_frames); - newstack->pool->cnt++; - } - UNLOCK (&oldstack->pool->lock); + LOCK (&oldstack->pool->lock); + { + list_add (&newstack->all_frames, &oldstack->all_frames); + newstack->pool->cnt++; + } + UNLOCK (&oldstack->pool->lock); - return &newstack->frames; + return &newstack->frames; } static inline call_frame_t * create_frame (xlator_t *xl, call_pool_t *pool) { - call_stack_t *stack = NULL; + call_stack_t *stack = NULL; - if (!xl || !pool) { - return NULL; - } + if (!xl || !pool) { + return NULL; + } - stack = mem_get0 (pool->stack_mem_pool); - if (!stack) - return NULL; + stack = mem_get0 (pool->stack_mem_pool); + if (!stack) + return NULL; - stack->pool = pool; - stack->frames.root = stack; - stack->frames.this = xl; + stack->pool = pool; + stack->frames.root = stack; + stack->frames.this = xl; - LOCK (&pool->lock); - { - list_add (&stack->all_frames, &pool->all_frames); - pool->cnt++; - } - UNLOCK (&pool->lock); + LOCK (&pool->lock); + { + list_add (&stack->all_frames, &pool->all_frames); + pool->cnt++; + } + UNLOCK (&pool->lock); - LOCK_INIT (&stack->frames.lock); + LOCK_INIT (&stack->frames.lock); - return &stack->frames; + return &stack->frames; } -void -gf_proc_dump_pending_frames(call_pool_t *call_pool); +void gf_proc_dump_pending_frames(call_pool_t *call_pool); -gf_boolean_t -__is_fuse_call (call_frame_t *frame); +gf_boolean_t __is_fuse_call (call_frame_t *frame); #endif /* _STACK_H */ |