fed up with those stupid warnings
[mmotm.git] / fs / reiser4 / tree_walk.h
blob3d5f09f8cb5431713628e2ea7171ffdc438bacb4
1 /* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by reiser4/README */
3 /* definitions of reiser4 tree walk functions */
5 #ifndef __FS_REISER4_TREE_WALK_H__
6 #define __FS_REISER4_TREE_WALK_H__
8 #include "debug.h"
9 #include "forward.h"
11 /* establishes horizontal links between cached znodes */
12 int connect_znode(coord_t * coord, znode * node);
14 /* tree traversal functions (reiser4_get_parent(), reiser4_get_neighbor())
15 have the following common arguments:
17 return codes:
19 @return : 0 - OK,
21 ZAM-FIXME-HANS: wrong return code name. Change them all.
22 -ENOENT - neighbor is not in cache, what is detected by sibling
23 link absence.
25 -E_NO_NEIGHBOR - we are sure that neighbor (or parent) node cannot be
26 found (because we are left-/right- most node of the
27 tree, for example). Also, this return code is for
28 reiser4_get_parent() when we see no parent link -- it
29 means that our node is root node.
31 -E_DEADLOCK - deadlock detected (request from high-priority process
32 received), other error codes are conformed to
33 /usr/include/asm/errno.h .
36 int
37 reiser4_get_parent_flags(lock_handle * result, znode * node,
38 znode_lock_mode mode, int flags);
40 /* bits definition for reiser4_get_neighbor function `flags' arg. */
41 typedef enum {
42 /* If sibling pointer is NULL, this flag allows get_neighbor() to try to
43 * find not allocated not connected neigbor by going though upper
44 * levels */
45 GN_CAN_USE_UPPER_LEVELS = 0x1,
46 /* locking left neighbor instead of right one */
47 GN_GO_LEFT = 0x2,
48 /* automatically load neighbor node content */
49 GN_LOAD_NEIGHBOR = 0x4,
50 /* return -E_REPEAT if can't lock */
51 GN_TRY_LOCK = 0x8,
52 /* used internally in tree_walk.c, causes renew_sibling to not
53 allocate neighbor znode, but only search for it in znode cache */
54 GN_NO_ALLOC = 0x10,
55 /* do not go across atom boundaries */
56 GN_SAME_ATOM = 0x20,
57 /* allow to lock not connected nodes */
58 GN_ALLOW_NOT_CONNECTED = 0x40,
59 /* Avoid synchronous jload, instead, call jstartio() and return -E_REPEAT. */
60 GN_ASYNC = 0x80
61 } znode_get_neigbor_flags;
63 /* A commonly used wrapper for reiser4_get_parent_flags(). */
64 static inline int reiser4_get_parent(lock_handle * result, znode * node,
65 znode_lock_mode mode)
67 return reiser4_get_parent_flags(result, node, mode,
68 GN_ALLOW_NOT_CONNECTED);
71 int reiser4_get_neighbor(lock_handle * neighbor, znode * node,
72 znode_lock_mode lock_mode, int flags);
74 /* there are wrappers for most common usages of reiser4_get_neighbor() */
75 static inline int
76 reiser4_get_left_neighbor(lock_handle * result, znode * node, int lock_mode,
77 int flags)
79 return reiser4_get_neighbor(result, node, lock_mode,
80 flags | GN_GO_LEFT);
83 static inline int
84 reiser4_get_right_neighbor(lock_handle * result, znode * node, int lock_mode,
85 int flags)
87 ON_DEBUG(check_lock_node_data(node));
88 ON_DEBUG(check_lock_data());
89 return reiser4_get_neighbor(result, node, lock_mode,
90 flags & (~GN_GO_LEFT));
93 extern void sibling_list_remove(znode * node);
94 extern void sibling_list_drop(znode * node);
95 extern void sibling_list_insert_nolock(znode * new, znode * before);
96 extern void link_left_and_right(znode * left, znode * right);
98 /* Functions called by tree_walk() when tree_walk() ... */
99 struct tree_walk_actor {
100 /* ... meets a formatted node, */
101 int (*process_znode) (tap_t *, void *);
102 /* ... meets an extent, */
103 int (*process_extent) (tap_t *, void *);
104 /* ... begins tree traversal or repeats it after -E_REPEAT was returned by
105 * node or extent processing functions. */
106 int (*before) (void *);
109 #if REISER4_DEBUG
110 int check_sibling_list(znode * node);
111 #else
112 #define check_sibling_list(n) (1)
113 #endif
115 #endif /* __FS_REISER4_TREE_WALK_H__ */
118 Local variables:
119 c-indentation-style: "K&R"
120 mode-name: "LC"
121 c-basic-offset: 8
122 tab-width: 8
123 fill-column: 120
124 End: