1 /* Copyright 2001, 2002, 2003 by Hans Reiser, licensing governed by
4 /* definitions of common constants used by reiser4 */
6 #if !defined(__REISER4_H__)
9 #include <asm/param.h> /* for HZ */
10 #include <linux/errno.h>
11 #include <linux/types.h>
13 #include <linux/hardirq.h>
14 #include <linux/sched.h>
17 * reiser4 compilation options.
20 #if defined(CONFIG_REISER4_DEBUG)
21 /* turn on assertion checks */
22 #define REISER4_DEBUG (1)
24 #define REISER4_DEBUG (0)
27 #if defined(CONFIG_ZLIB_INFLATE)
29 #define REISER4_ZLIB (1)
31 #define REISER4_ZLIB (0)
34 #if defined(CONFIG_CRYPTO_SHA256)
35 #define REISER4_SHA256 (1)
37 #define REISER4_SHA256 (0)
41 * Turn on large keys mode. In his mode (which is default), reiser4 key has 4
42 * 8-byte components. In the old "small key" mode, it's 3 8-byte
43 * components. Additional component, referred to as "ordering" is used to
44 * order items from which given object is composed of. As such, ordering is
45 * placed between locality and objectid. For directory item ordering contains
46 * initial prefix of the file name this item is for. This sorts all directory
47 * items within given directory lexicographically (but see
48 * fibration.[ch]). For file body and stat-data, ordering contains initial
49 * prefix of the name file was initially created with. In the common case
50 * (files with single name) this allows to order file bodies and stat-datas in
51 * the same order as their respective directory entries, thus speeding up
54 * Note, that kernel can only mount file system with the same key size as one
55 * it is compiled for, so flipping this option may render your data
58 #define REISER4_LARGE_KEY (1)
59 /*#define REISER4_LARGE_KEY (0)*/
61 /*#define GUESS_EXISTS 1*/
64 * PLEASE update fs/reiser4/kattr.c:show_options() when adding new compilation
68 extern const char *REISER4_SUPER_MAGIC_STRING
;
69 extern const int REISER4_MAGIC_OFFSET
; /* offset to magic string from the
70 * beginning of device */
72 /* here go tunable parameters that are not worth special entry in kernel
75 /* default number of slots in coord-by-key caches */
76 #define CBK_CACHE_SLOTS (16)
77 /* how many elementary tree operation to carry on the next level */
78 #define CARRIES_POOL_SIZE (5)
79 /* size of pool of preallocated nodes for carry process. */
80 #define NODES_LOCKED_POOL_SIZE (5)
82 #define REISER4_NEW_NODE_FLAGS (COPI_LOAD_LEFT | COPI_LOAD_RIGHT | COPI_GO_LEFT)
83 #define REISER4_NEW_EXTENT_FLAGS (COPI_LOAD_LEFT | COPI_LOAD_RIGHT | COPI_GO_LEFT)
84 #define REISER4_PASTE_FLAGS (COPI_GO_LEFT)
85 #define REISER4_INSERT_FLAGS (COPI_GO_LEFT)
87 /* we are supporting reservation of disk space on uid basis */
88 #define REISER4_SUPPORT_UID_SPACE_RESERVATION (0)
89 /* we are supporting reservation of disk space for groups */
90 #define REISER4_SUPPORT_GID_SPACE_RESERVATION (0)
91 /* we are supporting reservation of disk space for root */
92 #define REISER4_SUPPORT_ROOT_SPACE_RESERVATION (0)
93 /* we use rapid flush mode, see flush.c for comments. */
94 #define REISER4_USE_RAPID_FLUSH (1)
97 * set this to 0 if you don't want to use wait-for-flush in ->writepage().
99 #define REISER4_USE_ENTD (1)
101 /* key allocation is Plan-A */
102 #define REISER4_PLANA_KEY_ALLOCATION (1)
103 /* key allocation follows good old 3.x scheme */
104 #define REISER4_3_5_KEY_ALLOCATION (0)
106 /* size of hash-table for znodes */
107 #define REISER4_ZNODE_HASH_TABLE_SIZE (1 << 13)
109 /* number of buckets in lnode hash-table */
110 #define LNODE_HTABLE_BUCKETS (1024)
112 /* some ridiculously high maximal limit on height of znode tree. This
113 is used in declaration of various per level arrays and
114 to allocate stattistics gathering array for per-level stats. */
115 #define REISER4_MAX_ZTREE_HEIGHT (8)
117 #define REISER4_PANIC_MSG_BUFFER_SIZE (1024)
119 /* If array contains less than REISER4_SEQ_SEARCH_BREAK elements then,
120 sequential search is on average faster than binary. This is because
121 of better optimization and because sequential search is more CPU
122 cache friendly. This number (25) was found by experiments on dual AMD
125 NOTE: testing in kernel has shown that binary search is more effective than
126 implied by results of the user level benchmarking. Probably because in the
127 node keys are separated by other data. So value was adjusted after few
128 tests. More thorough tuning is needed.
130 #define REISER4_SEQ_SEARCH_BREAK (3)
132 /* don't allow tree to be lower than this */
133 #define REISER4_MIN_TREE_HEIGHT (TWIG_LEVEL)
135 /* NOTE NIKITA this is no longer used: maximal atom size is auto-adjusted to
136 * available memory. */
137 /* Default value of maximal atom size. Can be ovewritten by
138 tmgr.atom_max_size mount option. By default infinity. */
139 #define REISER4_ATOM_MAX_SIZE ((unsigned)(~0))
141 /* Default value of maximal atom age (in jiffies). After reaching this age
142 atom will be forced to commit, either synchronously or asynchronously. Can
143 be overwritten by tmgr.atom_max_age mount option. */
144 #define REISER4_ATOM_MAX_AGE (600 * HZ)
146 /* sleeping period for ktxnmrgd */
147 #define REISER4_TXNMGR_TIMEOUT (5 * HZ)
149 /* timeout to wait for ent thread in writepage. Default: 3 milliseconds. */
150 #define REISER4_ENTD_TIMEOUT (3 * HZ / 1000)
152 /* start complaining after that many restarts in coord_by_key().
154 This either means incredibly heavy contention for this part of a tree, or
155 some corruption or bug.
157 #define REISER4_CBK_ITERATIONS_LIMIT (100)
159 /* return -EIO after that many iterations in coord_by_key().
161 I have witnessed more than 800 iterations (in 30 thread test) before cbk
164 #define REISER4_MAX_CBK_ITERATIONS 500000
166 /* put a per-inode limit on maximal number of directory entries with identical
167 keys in hashed directory.
169 Disable this until inheritance interfaces stabilize: we need some way to
170 set per directory limit.
172 #define REISER4_USE_COLLISION_LIMIT (0)
174 /* If flush finds more than FLUSH_RELOCATE_THRESHOLD adjacent dirty leaf-level
175 blocks it will force them to be relocated. */
176 #define FLUSH_RELOCATE_THRESHOLD 64
177 /* If flush finds can find a block allocation closer than at most
178 FLUSH_RELOCATE_DISTANCE from the preceder it will relocate to that position.
180 #define FLUSH_RELOCATE_DISTANCE 64
182 /* If we have written this much or more blocks before encountering busy jnode
183 in flush list - abort flushing hoping that next time we get called
184 this jnode will be clean already, and we will save some seeks. */
185 #define FLUSH_WRITTEN_THRESHOLD 50
187 /* The maximum number of nodes to scan left on a level during flush. */
188 #define FLUSH_SCAN_MAXNODES 10000
190 /* per-atom limit of flushers */
191 #define ATOM_MAX_FLUSHERS (1)
193 /* default tracing buffer size */
194 #define REISER4_TRACE_BUF_SIZE (1 << 15)
196 /* what size units of IO we would like cp, etc., to use, in writing to
199 Can be overwritten by optimal_io_size mount option.
201 #define REISER4_OPTIMAL_IO_SIZE (64 * 1024)
203 /* see comments in inode.c:oid_to_uino() */
204 #define REISER4_UINO_SHIFT (1 << 30)
206 /* Mark function argument as unused to avoid compiler warnings. */
207 #define UNUSED_ARG __attribute__((unused))
209 #if ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)
210 #define NONNULL __attribute__((nonnull))
215 /* master super block offset in bytes.*/
216 #define REISER4_MASTER_OFFSET 65536
218 /* size of VFS block */
219 #define VFS_BLKSIZE 512
220 /* number of bits in size of VFS block (512==2^9) */
221 #define VFS_BLKSIZE_BITS 9
223 #define REISER4_I reiser4_inode_data
226 #define ergo(antecedent, consequent) (!(antecedent) || (consequent))
227 /* logical equivalence */
228 #define equi(p1, p2) (ergo((p1), (p2)) && ergo((p2), (p1)))
230 #define sizeof_array(x) ((int) (sizeof(x) / sizeof(x[0])))
234 /** Reiser4 specific error codes **/
236 #define REISER4_ERROR_CODE_BASE 10000
238 /* Neighbor is not available (side neighbor or parent) */
239 #define E_NO_NEIGHBOR (REISER4_ERROR_CODE_BASE)
241 /* Node was not found in cache */
242 #define E_NOT_IN_CACHE (REISER4_ERROR_CODE_BASE + 1)
244 /* node has no free space enough for completion of balancing operation */
245 #define E_NODE_FULL (REISER4_ERROR_CODE_BASE + 2)
247 /* repeat operation */
248 #define E_REPEAT (REISER4_ERROR_CODE_BASE + 3)
250 /* deadlock happens */
251 #define E_DEADLOCK (REISER4_ERROR_CODE_BASE + 4)
253 /* operation cannot be performed, because it would block and non-blocking mode
255 #define E_BLOCK (REISER4_ERROR_CODE_BASE + 5)
257 /* wait some event (depends on context), then repeat */
258 #define E_WAIT (REISER4_ERROR_CODE_BASE + 6)
260 #endif /* __REISER4_H__ */
264 c-indentation-style: "K&R"