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__
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:
21 ZAM-FIXME-HANS: wrong return code name. Change them all.
22 -ENOENT - neighbor is not in cache, what is detected by sibling
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 .
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. */
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
45 GN_CAN_USE_UPPER_LEVELS
= 0x1,
46 /* locking left neighbor instead of right one */
48 /* automatically load neighbor node content */
49 GN_LOAD_NEIGHBOR
= 0x4,
50 /* return -E_REPEAT if can't lock */
52 /* used internally in tree_walk.c, causes renew_sibling to not
53 allocate neighbor znode, but only search for it in znode cache */
55 /* do not go across atom boundaries */
57 /* allow to lock not connected nodes */
58 GN_ALLOW_NOT_CONNECTED
= 0x40,
59 /* Avoid synchronous jload, instead, call jstartio() and return -E_REPEAT. */
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
,
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() */
76 reiser4_get_left_neighbor(lock_handle
* result
, znode
* node
, int lock_mode
,
79 return reiser4_get_neighbor(result
, node
, lock_mode
,
84 reiser4_get_right_neighbor(lock_handle
* result
, znode
* node
, int lock_mode
,
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 *);
110 int check_sibling_list(znode
* node
);
112 #define check_sibling_list(n) (1)
115 #endif /* __FS_REISER4_TREE_WALK_H__ */
119 c-indentation-style: "K&R"