2 * Copyright 2000 Hans Reiser
3 * See README for licensing and copyright details
5 * Ported to FreeBSD by Jean-Sébastien Pédron <jspedron@club-internet.fr>
10 #ifndef _GNU_REISERFS_REISERFS_FS_H
11 #define _GNU_REISERFS_REISERFS_FS_H
13 #include <sys/cdefs.h>
14 #include <sys/types.h>
15 #include <sys/endian.h>
16 #include <sys/param.h>
17 #include <sys/systm.h>
18 #include <sys/kernel.h>
19 #include <sys/mount.h>
20 #include <sys/namei.h>
23 #include <sys/vnode.h>
24 #include <sys/unistd.h>
29 #include <sys/fcntl.h>
30 #include <sys/syslog.h>
32 #include <sys/malloc.h>
33 #include <sys/dirent.h>
35 //#include <sys/mutex.h>
37 #include <sys/ctype.h>
38 #include <sys/bitstring.h>
40 #include <geom/geom.h>
41 #include <geom/geom_vfs.h>
43 #include <gnu/fs/reiserfs/reiserfs_mount.h>
44 #include <gnu/fs/reiserfs/reiserfs_fs_sb.h>
45 #include <gnu/fs/reiserfs/reiserfs_fs_i.h>
47 /* n must be power of 2 */
48 #define _ROUND_UP(x, n) (((x) + (n) - 1u) & ~((n) - 1u))
50 /* To be ok for alpha and others we have to align structures to 8 byte
52 #define ROUND_UP(x) _ROUND_UP(x, 8LL)
54 /* -------------------------------------------------------------------
56 * -------------------------------------------------------------------*/
58 extern struct vop_vector reiserfs_vnodeops;
59 extern struct vop_vector reiserfs_specops;
61 /* -------------------------------------------------------------------
63 * -------------------------------------------------------------------*/
65 #define REISERFS_BSIZE 1024
67 /* ReiserFS leaves the first 64k unused, so that partition labels have
68 * enough space. If someone wants to write a fancy bootloader that needs
69 * more than 64k, let us know, and this will be increased in size.
70 * This number must be larger than than the largest block size on any
71 * platform, or code will break. -Hans */
72 #define REISERFS_DISK_OFFSET 64
73 #define REISERFS_DISK_OFFSET_IN_BYTES \
74 ((REISERFS_DISK_OFFSET) * (REISERFS_BSIZE))
76 /* The spot for the super in versions 3.5 - 3.5.10 (inclusive) */
77 #define REISERFS_OLD_DISK_OFFSET 8
78 #define REISERFS_OLD_DISK_OFFSET_IN_BYTES \
79 ((REISERFS_OLD_DISK_OFFSET) * (REISERFS_BSIZE))
82 * Structure of a super block on disk, a version of which in RAM is
83 * often accessed as REISERFS_SB(s)->r_rs. The version in RAM is part of
84 * a larger structure containing fields never written to disk.
87 #define UNSET_HASH 0 /* read_super will guess about, what hash names
88 in directories were sorted with */
92 #define DEFAULT_HASH R5_HASH
94 struct journal_params {
95 uint32_t jp_journal_1st_block; /* Where does journal start
97 uint32_t jp_journal_dev; /* Journal device st_rdev */
98 uint32_t jp_journal_size; /* Size of the journal */
99 uint32_t jp_journal_trans_max; /* Max number of blocks in
101 uint32_t jp_journal_magic; /* Random value made on
102 fs creation (this was
103 sb_journal_block_count) */
104 uint32_t jp_journal_max_batch; /* Max number of blocks to
107 uint32_t jp_journal_max_commit_age; /* In seconds, how old can
108 an async commit be */
109 uint32_t jp_journal_max_trans_age; /* In seconds, how old a
113 struct reiserfs_super_block_v1 {
114 uint32_t s_block_count; /* Blocks count */
115 uint32_t s_free_blocks; /* Free blocks count */
116 uint32_t s_root_block; /* Root block number */
118 struct journal_params s_journal;
120 uint16_t s_blocksize;
121 uint16_t s_oid_maxsize;
122 uint16_t s_oid_cursize;
123 uint16_t s_umount_state;
128 uint32_t s_hash_function_code;
129 uint16_t s_tree_height;
132 uint16_t s_reserved_for_journal;
135 #define SB_SIZE_V1 (sizeof(struct reiserfs_super_block_v1))
137 struct reiserfs_super_block {
138 struct reiserfs_super_block_v1 s_v1;
139 uint32_t s_inode_generation;
141 unsigned char s_uuid[16];
142 unsigned char s_label[16];
146 #define SB_SIZE (sizeof(struct reiserfs_super_block))
148 #define REISERFS_VERSION_1 0
149 #define REISERFS_VERSION_2 2
151 #define REISERFS_SB(sbi) (sbi)
152 #define SB_DISK_SUPER_BLOCK(sbi) (REISERFS_SB(sbi)->s_rs)
153 #define SB_V1_DISK_SUPER_BLOCK(sbi) (&(SB_DISK_SUPER_BLOCK(sbi)->s_v1))
155 #define SB_BLOCKSIZE(sbi) \
156 le32toh((SB_V1_DISK_SUPER_BLOCK(sbi)->s_blocksize))
157 #define SB_BLOCK_COUNT(sbi) \
158 le32toh((SB_V1_DISK_SUPER_BLOCK(sbi)->s_block_count))
159 #define SB_FREE_BLOCKS(s) \
160 le32toh((SB_V1_DISK_SUPER_BLOCK(sbi)->s_free_blocks))
162 #define SB_REISERFS_MAGIC(sbi) \
163 (SB_V1_DISK_SUPER_BLOCK(sbi)->s_magic)
165 #define SB_ROOT_BLOCK(sbi) \
166 le32toh((SB_V1_DISK_SUPER_BLOCK(sbi)->s_root_block))
168 #define SB_TREE_HEIGHT(sbi) \
169 le16toh((SB_V1_DISK_SUPER_BLOCK(sbi)->s_tree_height))
171 #define SB_REISERFS_STATE(sbi) \
172 le16toh((SB_V1_DISK_SUPER_BLOCK(sbi)->s_umount_state))
174 #define SB_VERSION(sbi) le16toh((SB_V1_DISK_SUPER_BLOCK(sbi)->s_version))
175 #define SB_BMAP_NR(sbi) le16toh((SB_V1_DISK_SUPER_BLOCK(sbi)->s_bmap_nr))
177 #define REISERFS_SUPER_MAGIC_STRING "ReIsErFs"
178 #define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs"
179 #define REISER2FS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs"
181 extern const char reiserfs_3_5_magic_string[];
182 extern const char reiserfs_3_6_magic_string[];
183 extern const char reiserfs_jr_magic_string[];
185 int is_reiserfs_3_5(struct reiserfs_super_block *rs);
186 int is_reiserfs_3_6(struct reiserfs_super_block *rs);
187 int is_reiserfs_jr(struct reiserfs_super_block *rs);
189 /* ReiserFS internal error code (used by search_by_key and fix_nodes) */
192 typedef uint32_t b_blocknr_t;
193 typedef uint32_t unp_t;
195 struct unfm_nodeinfo {
197 unsigned short unfm_freespace;
200 /* There are two formats of keys: 3.5 and 3.6 */
201 #define KEY_FORMAT_3_5 0
202 #define KEY_FORMAT_3_6 1
204 /* There are two stat datas */
205 #define STAT_DATA_V1 0
206 #define STAT_DATA_V2 1
208 #define REISERFS_I(ip) (ip)
210 #define get_inode_item_key_version(ip) \
211 ((REISERFS_I(ip)->i_flags & i_item_key_version_mask) ? \
212 KEY_FORMAT_3_6 : KEY_FORMAT_3_5)
214 #define set_inode_item_key_version(ip, version) ({ \
215 if ((version) == KEY_FORMAT_3_6) \
216 REISERFS_I(ip)->i_flags |= i_item_key_version_mask; \
218 REISERFS_I(ip)->i_flags &= ~i_item_key_version_mask; \
221 #define get_inode_sd_version(ip) \
222 ((REISERFS_I(ip)->i_flags & i_stat_data_version_mask) ? \
223 STAT_DATA_V2 : STAT_DATA_V1)
225 #define set_inode_sd_version(inode, version) ({ \
226 if((version) == STAT_DATA_V2) \
227 REISERFS_I(ip)->i_flags |= i_stat_data_version_mask; \
229 REISERFS_I(ip)->i_flags &= ~i_stat_data_version_mask; \
232 /* Values for s_umount_state field */
233 #define REISERFS_VALID_FS 1
234 #define REISERFS_ERROR_FS 2
236 /* There are 5 item types currently */
237 #define TYPE_STAT_DATA 0
238 #define TYPE_INDIRECT 1
239 #define TYPE_DIRECT 2
240 #define TYPE_DIRENTRY 3
241 #define TYPE_MAXTYPE 3
244 /* -------------------------------------------------------------------
246 * -------------------------------------------------------------------*/
250 uint32_t k_uniqueness;
254 #if BYTE_ORDER == LITTLE_ENDIAN
255 /* little endian version */
256 uint64_t k_offset:60;
259 /* big endian version */
261 uint64_t k_offset:60;
265 #if (BYTE_ORDER == BIG_ENDIAN)
267 struct offset_v2 offset_v2;
269 } __packed offset_v2_esafe_overlay;
271 static inline uint16_t
272 offset_v2_k_type(const struct offset_v2 *v2)
275 offset_v2_esafe_overlay tmp = *(const offset_v2_esafe_overlay *)v2;
276 tmp.linear = le64toh(tmp.linear);
277 return ((tmp.offset_v2.k_type <= TYPE_MAXTYPE) ?
278 tmp.offset_v2.k_type : TYPE_ANY);
282 set_offset_v2_k_type(struct offset_v2 *v2, int type)
285 offset_v2_esafe_overlay *tmp = (offset_v2_esafe_overlay *)v2;
286 tmp->linear = le64toh(tmp->linear);
287 tmp->offset_v2.k_type = type;
288 tmp->linear = htole64(tmp->linear);
292 offset_v2_k_offset(const struct offset_v2 *v2)
295 offset_v2_esafe_overlay tmp = *(const offset_v2_esafe_overlay *)v2;
296 tmp.linear = le64toh(tmp.linear);
297 return (tmp.offset_v2.k_offset);
301 set_offset_v2_k_offset(struct offset_v2 *v2, off_t offset)
304 offset_v2_esafe_overlay *tmp = (offset_v2_esafe_overlay *)v2;
305 tmp->linear = le64toh(tmp->linear);
306 tmp->offset_v2.k_offset = offset;
307 tmp->linear = htole64(tmp->linear);
309 #else /* BYTE_ORDER != BIG_ENDIAN */
310 #define offset_v2_k_type(v2) ((v2)->k_type)
311 #define set_offset_v2_k_type(v2, val) (offset_v2_k_type(v2) = (val))
312 #define offset_v2_k_offset(v2) ((v2)->k_offset)
313 #define set_offset_v2_k_offset(v2, val) (offset_v2_k_offset(v2) = (val))
314 #endif /* BYTE_ORDER == BIG_ENDIAN */
317 * Key of an item determines its location in the S+tree, and
318 * is composed of 4 components
321 uint32_t k_dir_id; /* Packing locality: by default parent
322 directory object id */
323 uint32_t k_objectid; /* Object identifier */
325 struct offset_v1 k_offset_v1;
326 struct offset_v2 k_offset_v2;
331 struct key on_disk_key;
333 int key_length; /* 3 in all cases but direct2indirect
334 and indirect2direct conversion */
338 * Our function for comparing keys can compare keys of different
339 * lengths. It takes as a parameter the length of the keys it is to
340 * compare. These defines are used in determining what is to be passed
341 * to it as that parameter.
343 #define REISERFS_FULL_KEY_LEN 4
344 #define REISERFS_SHORT_KEY_LEN 2
346 #define KEY_SIZE (sizeof(struct key))
347 #define SHORT_KEY_SIZE (sizeof(uint32_t) + sizeof(uint32_t))
349 /* Return values for search_by_key and clones */
351 #define ITEM_NOT_FOUND 0
352 #define ENTRY_FOUND 1
353 #define ENTRY_NOT_FOUND 0
354 #define DIRECTORY_NOT_FOUND -1
355 #define REGULAR_FILE_FOUND -2
356 #define DIRECTORY_FOUND -3
358 #define BYTE_NOT_FOUND 0
359 #define FILE_NOT_FOUND -1
361 #define POSITION_FOUND 1
362 #define POSITION_NOT_FOUND 0
364 /* Return values for reiserfs_find_entry and search_by_entry_key */
366 #define NAME_NOT_FOUND 0
367 #define GOTO_PREVIOUS_ITEM 2
368 #define NAME_FOUND_INVISIBLE 3
371 * Everything in the filesystem is stored as a set of items. The item
372 * head contains the key of the item, its free space (for indirect
373 * items) and specifies the location of the item itself within the
378 * Everything in the tree is found by searching for it based on
384 * The free space in the last unformatted node of an
385 * indirect item if this is an indirect item. This
386 * equals 0xFFFF iff this is a direct item or stat data
387 * item. Note that the key, not this field, is used to
388 * determine the item type, and thus which field this
391 uint16_t ih_free_space_reserved;
394 * If this is a directory item, this field equals the number of
395 * directory entries in the directory item.
397 uint16_t ih_entry_count;
399 uint16_t ih_item_len; /* Total size of the item body */
400 uint16_t ih_item_location; /* An offset to the item body within
402 uint16_t ih_version; /* 0 for all old items, 2 for new
403 ones. Highest bit is set by fsck
404 temporary, cleaned after all
408 /* Size of item header */
409 #define IH_SIZE (sizeof(struct item_head))
411 #define ih_free_space(ih) le16toh((ih)->u.ih_free_space_reserved)
412 #define ih_version(ih) le16toh((ih)->ih_version)
413 #define ih_entry_count(ih) le16toh((ih)->u.ih_entry_count)
414 #define ih_location(ih) le16toh((ih)->ih_item_location)
415 #define ih_item_len(ih) le16toh((ih)->ih_item_len)
418 * These operate on indirect items, where you've got an array of ints at
419 * a possibly unaligned location. These are a noop on IA32.
421 * p is the array of uint32_t, i is the index into the array, v is the
422 * value to store there.
424 #define get_unaligned(ptr) \
425 ({ __typeof__(*(ptr)) __tmp; \
426 memcpy(&__tmp, (ptr), sizeof(*(ptr))); __tmp; })
428 #define put_unaligned(val, ptr) \
429 ({ __typeof__(*(ptr)) __tmp = (val); \
430 memcpy((ptr), &__tmp, sizeof(*(ptr))); \
433 #define get_block_num(p, i) le32toh(get_unaligned((p) + (i)))
434 #define put_block_num(p, i, v) put_unaligned(htole32(v), (p) + (i))
436 /* In old version uniqueness field shows key type */
437 #define V1_SD_UNIQUENESS 0
438 #define V1_INDIRECT_UNIQUENESS 0xfffffffe
439 #define V1_DIRECT_UNIQUENESS 0xffffffff
440 #define V1_DIRENTRY_UNIQUENESS 500
441 #define V1_ANY_UNIQUENESS 555
443 /* Here are conversion routines */
444 static inline int uniqueness2type(uint32_t uniqueness);
445 static inline uint32_t type2uniqueness(int type);
448 uniqueness2type(uint32_t uniqueness)
451 switch ((int)uniqueness) {
452 case V1_SD_UNIQUENESS:
453 return (TYPE_STAT_DATA);
454 case V1_INDIRECT_UNIQUENESS:
455 return (TYPE_INDIRECT);
456 case V1_DIRECT_UNIQUENESS:
457 return (TYPE_DIRECT);
458 case V1_DIRENTRY_UNIQUENESS:
459 return (TYPE_DIRENTRY);
461 log(LOG_NOTICE, "reiserfs: unknown uniqueness (%u)\n",
463 case V1_ANY_UNIQUENESS:
468 static inline uint32_t
469 type2uniqueness(int type)
474 return (V1_SD_UNIQUENESS);
476 return (V1_INDIRECT_UNIQUENESS);
478 return (V1_DIRECT_UNIQUENESS);
480 return (V1_DIRENTRY_UNIQUENESS);
482 log(LOG_NOTICE, "reiserfs: unknown type (%u)\n", type);
484 return (V1_ANY_UNIQUENESS);
489 * Key is pointer to on disk key which is stored in le, result is cpu,
490 * there is no way to get version of object from key, so, provide
491 * version to these defines.
494 le_key_k_offset(int version, const struct key *key)
497 return ((version == KEY_FORMAT_3_5) ?
498 le32toh(key->u.k_offset_v1.k_offset) :
499 offset_v2_k_offset(&(key->u.k_offset_v2)));
503 le_ih_k_offset(const struct item_head *ih)
506 return (le_key_k_offset(ih_version(ih), &(ih->ih_key)));
510 le_key_k_type(int version, const struct key *key)
513 return ((version == KEY_FORMAT_3_5) ?
514 uniqueness2type(le32toh(key->u.k_offset_v1.k_uniqueness)) :
515 offset_v2_k_type(&(key->u.k_offset_v2)));
519 le_ih_k_type(const struct item_head *ih)
521 return (le_key_k_type(ih_version(ih), &(ih->ih_key)));
525 set_le_key_k_offset(int version, struct key *key, off_t offset)
528 (version == KEY_FORMAT_3_5) ?
529 (key->u.k_offset_v1.k_offset = htole32(offset)) :
530 (set_offset_v2_k_offset(&(key->u.k_offset_v2), offset));
534 set_le_ih_k_offset(struct item_head *ih, off_t offset)
537 set_le_key_k_offset(ih_version(ih), &(ih->ih_key), offset);
541 set_le_key_k_type(int version, struct key *key, int type)
544 (version == KEY_FORMAT_3_5) ?
545 (key->u.k_offset_v1.k_uniqueness =
546 htole32(type2uniqueness(type))) :
547 (set_offset_v2_k_type(&(key->u.k_offset_v2), type));
551 set_le_ih_k_type(struct item_head *ih, int type)
554 set_le_key_k_type(ih_version(ih), &(ih->ih_key), type);
557 #define is_direntry_le_key(version, key) \
558 (le_key_k_type(version, key) == TYPE_DIRENTRY)
559 #define is_direct_le_key(version, key) \
560 (le_key_k_type(version, key) == TYPE_DIRECT)
561 #define is_indirect_le_key(version, key) \
562 (le_key_k_type(version, key) == TYPE_INDIRECT)
563 #define is_statdata_le_key(version, key) \
564 (le_key_k_type(version, key) == TYPE_STAT_DATA)
566 /* Item header has version. */
567 #define is_direntry_le_ih(ih) \
568 is_direntry_le_key(ih_version(ih), &((ih)->ih_key))
569 #define is_direct_le_ih(ih) \
570 is_direct_le_key(ih_version(ih), &((ih)->ih_key))
571 #define is_indirect_le_ih(ih) \
572 is_indirect_le_key(ih_version(ih), &((ih)->ih_key))
573 #define is_statdata_le_ih(ih) \
574 is_statdata_le_key(ih_version(ih), &((ih)->ih_key))
577 set_cpu_key_k_offset(struct cpu_key *key, off_t offset)
580 (key->version == KEY_FORMAT_3_5) ?
581 (key->on_disk_key.u.k_offset_v1.k_offset = offset) :
582 (key->on_disk_key.u.k_offset_v2.k_offset = offset);
586 set_cpu_key_k_type(struct cpu_key *key, int type)
589 (key->version == KEY_FORMAT_3_5) ?
590 (key->on_disk_key.u.k_offset_v1.k_uniqueness =
591 type2uniqueness(type)):
592 (key->on_disk_key.u.k_offset_v2.k_type = type);
595 #define is_direntry_cpu_key(key) (cpu_key_k_type (key) == TYPE_DIRENTRY)
596 #define is_direct_cpu_key(key) (cpu_key_k_type (key) == TYPE_DIRECT)
597 #define is_indirect_cpu_key(key) (cpu_key_k_type (key) == TYPE_INDIRECT)
598 #define is_statdata_cpu_key(key) (cpu_key_k_type (key) == TYPE_STAT_DATA)
600 /* Maximal length of item */
601 #define MAX_ITEM_LEN(block_size) (block_size - BLKH_SIZE - IH_SIZE)
602 #define MIN_ITEM_LEN 1
604 /* Object identifier for root dir */
605 #define REISERFS_ROOT_OBJECTID 2
606 #define REISERFS_ROOT_PARENT_OBJECTID 1
608 /* key is pointer to cpu key, result is cpu */
610 cpu_key_k_offset(const struct cpu_key *key)
613 return ((key->version == KEY_FORMAT_3_5) ?
614 key->on_disk_key.u.k_offset_v1.k_offset :
615 key->on_disk_key.u.k_offset_v2.k_offset);
619 cpu_key_k_type(const struct cpu_key *key)
622 return ((key->version == KEY_FORMAT_3_5) ?
623 uniqueness2type(key->on_disk_key.u.k_offset_v1.k_uniqueness) :
624 key->on_disk_key.u.k_offset_v2.k_type);
628 * Header of a disk block. More precisely, header of a formatted leaf
629 * or internal node, and not the header of an unformatted node.
632 uint16_t blk_level; /* Level of a block in the
634 uint16_t blk_nr_item; /* Number of keys/items in a
636 uint16_t blk_free_space; /* Block free space in bytes. */
637 uint16_t blk_reserved; /* Dump this in v4/planA */
638 struct key blk_right_delim_key; /* Kept only for compatibility */
641 #define BLKH_SIZE (sizeof(struct block_head))
642 #define blkh_level(p_blkh) (le16toh((p_blkh)->blk_level))
643 #define blkh_nr_item(p_blkh) (le16toh((p_blkh)->blk_nr_item))
644 #define blkh_free_space(p_blkh) (le16toh((p_blkh)->blk_free_space))
646 #define FREE_LEVEL 0 /* When node gets removed from the tree its
647 blk_level is set to FREE_LEVEL. It is then
648 used to see whether the node is still in the
651 /* Values for blk_level field of the struct block_head */
652 #define DISK_LEAF_NODE_LEVEL 1 /* Leaf node level.*/
655 * Given the buffer head of a formatted node, resolve to the block head
658 #define B_BLK_HEAD(p_s_bp) ((struct block_head *)((p_s_bp)->b_data))
659 #define B_NR_ITEMS(p_s_bp) (blkh_nr_item(B_BLK_HEAD(p_s_bp)))
660 #define B_LEVEL(p_s_bp) (blkh_level(B_BLK_HEAD(p_s_bp)))
661 #define B_FREE_SPACE(p_s_bp) (blkh_free_space(B_BLK_HEAD(p_s_bp)))
663 /* -------------------------------------------------------------------
665 * -------------------------------------------------------------------*/
668 * Old stat data is 32 bytes long. We are going to distinguish new one
671 struct stat_data_v1 {
672 uint16_t sd_mode; /* File type, permissions */
673 uint16_t sd_nlink; /* Number of hard links */
674 uint16_t sd_uid; /* Owner */
675 uint16_t sd_gid; /* Group */
676 uint32_t sd_size; /* File size */
677 uint32_t sd_atime; /* Time of last access */
678 uint32_t sd_mtime; /* Time file was last modified */
679 uint32_t sd_ctime; /* Time inode (stat data) was last changed
680 (except changes to sd_atime and
684 uint32_t sd_blocks; /* Number of blocks file uses */
686 uint32_t sd_first_direct_byte; /* First byte of file which is
687 stored in a direct item:
688 except that if it equals 1
689 it is a symlink and if it
690 equals ~(uint32_t)0 there
691 is no direct item. The
692 existence of this field
693 really grates on me. Let's
694 replace it with a macro based
695 on sd_size and our tail
696 suppression policy. Someday.
700 #define SD_V1_SIZE (sizeof(struct stat_data_v1))
701 #define stat_data_v1(ih) (ih_version (ih) == KEY_FORMAT_3_5)
702 #define sd_v1_mode(sdp) (le16toh((sdp)->sd_mode))
703 #define set_sd_v1_mode(sdp, v) ((sdp)->sd_mode = htole16(v))
704 #define sd_v1_nlink(sdp) (le16toh((sdp)->sd_nlink))
705 #define set_sd_v1_nlink(sdp, v) ((sdp)->sd_nlink = htole16(v))
706 #define sd_v1_uid(sdp) (le16toh((sdp)->sd_uid))
707 #define set_sd_v1_uid(sdp, v) ((sdp)->sd_uid = htole16(v))
708 #define sd_v1_gid(sdp) (le16toh((sdp)->sd_gid))
709 #define set_sd_v1_gid(sdp, v) ((sdp)->sd_gid = htole16(v))
710 #define sd_v1_size(sdp) (le32toh((sdp)->sd_size))
711 #define set_sd_v1_size(sdp, v) ((sdp)->sd_size = htole32(v))
712 #define sd_v1_atime(sdp) (le32toh((sdp)->sd_atime))
713 #define set_sd_v1_atime(sdp, v) ((sdp)->sd_atime = htole32(v))
714 #define sd_v1_mtime(sdp) (le32toh((sdp)->sd_mtime))
715 #define set_sd_v1_mtime(sdp, v) ((sdp)->sd_mtime = htole32(v))
716 #define sd_v1_ctime(sdp) (le32toh((sdp)->sd_ctime))
717 #define set_sd_v1_ctime(sdp, v) ((sdp)->sd_ctime = htole32(v))
718 #define sd_v1_rdev(sdp) (le32toh((sdp)->u.sd_rdev))
719 #define set_sd_v1_rdev(sdp, v) ((sdp)->u.sd_rdev = htole32(v))
720 #define sd_v1_blocks(sdp) (le32toh((sdp)->u.sd_blocks))
721 #define set_sd_v1_blocks(sdp, v) ((sdp)->u.sd_blocks = htole32(v))
722 #define sd_v1_first_direct_byte(sdp) \
723 (le32toh((sdp)->sd_first_direct_byte))
724 #define set_sd_v1_first_direct_byte(sdp, v) \
725 ((sdp)->sd_first_direct_byte = htole32(v))
728 * We want common flags to have the same values as in ext2,
729 * so chattr(1) will work without problems
731 #include <fs/ext2fs/ext2fs.h>
732 #include <fs/ext2fs/ext2_dinode.h>
733 #define REISERFS_IMMUTABLE_FL EXT2_IMMUTABLE
734 #define REISERFS_APPEND_FL EXT2_APPEND
735 #define REISERFS_SYNC_FL EXT2_SYNC
736 #define REISERFS_NOATIME_FL EXT2_NOATIME
737 #define REISERFS_NODUMP_FL EXT2_NODUMP
738 #define REISERFS_SECRM_FL EXT2_SECRM
739 #define REISERFS_UNRM_FL EXT2_UNRM
740 #define REISERFS_COMPR_FL EXT2_COMPR
741 #define REISERFS_NOTAIL_FL EXT2_NOTAIL_FL
744 * Stat Data on disk (reiserfs version of UFS disk inode minus the
748 uint16_t sd_mode; /* File type, permissions */
749 uint16_t sd_attrs; /* Persistent inode flags */
750 uint32_t sd_nlink; /* Number of hard links */
751 uint64_t sd_size; /* File size */
752 uint32_t sd_uid; /* Owner */
753 uint32_t sd_gid; /* Group */
754 uint32_t sd_atime; /* Time of last access */
755 uint32_t sd_mtime; /* Time file was last modified */
756 uint32_t sd_ctime; /* Time inode (stat data) was last changed
757 (except changes to sd_atime and
762 uint32_t sd_generation;
763 //uint32_t sd_first_direct_byte;
765 * First byte of file which is stored in a
766 * direct item: except that if it equals 1
767 * it is a symlink and if it equals
768 * ~(uint32_t)0 there is no direct item. The
769 * existence of this field really grates
770 * on me. Let's replace it with a macro
771 * based on sd_size and our tail
772 * suppression policy?
777 /* This is 44 bytes long */
778 #define SD_SIZE (sizeof(struct stat_data))
779 #define SD_V2_SIZE SD_SIZE
780 #define stat_data_v2(ih) (ih_version (ih) == KEY_FORMAT_3_6)
781 #define sd_v2_mode(sdp) (le16toh((sdp)->sd_mode))
782 #define set_sd_v2_mode(sdp, v) ((sdp)->sd_mode = htole16(v))
784 /* set_sd_reserved */
785 #define sd_v2_nlink(sdp) (le32toh((sdp)->sd_nlink))
786 #define set_sd_v2_nlink(sdp, v) ((sdp)->sd_nlink = htole32(v))
787 #define sd_v2_size(sdp) (le64toh((sdp)->sd_size))
788 #define set_sd_v2_size(sdp, v) ((sdp)->sd_size = cpu_to_le64(v))
789 #define sd_v2_uid(sdp) (le32toh((sdp)->sd_uid))
790 #define set_sd_v2_uid(sdp, v) ((sdp)->sd_uid = htole32(v))
791 #define sd_v2_gid(sdp) (le32toh((sdp)->sd_gid))
792 #define set_sd_v2_gid(sdp, v) ((sdp)->sd_gid = htole32(v))
793 #define sd_v2_atime(sdp) (le32toh((sdp)->sd_atime))
794 #define set_sd_v2_atime(sdp, v) ((sdp)->sd_atime = htole32(v))
795 #define sd_v2_mtime(sdp) (le32toh((sdp)->sd_mtime))
796 #define set_sd_v2_mtime(sdp, v) ((sdp)->sd_mtime = htole32(v))
797 #define sd_v2_ctime(sdp) (le32toh((sdp)->sd_ctime))
798 #define set_sd_v2_ctime(sdp, v) ((sdp)->sd_ctime = htole32(v))
799 #define sd_v2_blocks(sdp) (le32toh((sdp)->sd_blocks))
800 #define set_sd_v2_blocks(sdp, v) ((sdp)->sd_blocks = htole32(v))
801 #define sd_v2_rdev(sdp) (le32toh((sdp)->u.sd_rdev))
802 #define set_sd_v2_rdev(sdp, v) ((sdp)->u.sd_rdev = htole32(v))
803 #define sd_v2_generation(sdp) (le32toh((sdp)->u.sd_generation))
804 #define set_sd_v2_generation(sdp, v) ((sdp)->u.sd_generation = htole32(v))
805 #define sd_v2_attrs(sdp) (le16toh((sdp)->sd_attrs))
806 #define set_sd_v2_attrs(sdp, v) ((sdp)->sd_attrs = htole16(v))
808 /* -------------------------------------------------------------------
809 * Directory structure
810 * -------------------------------------------------------------------*/
813 #define SD_UNIQUENESS 0
815 #define DOT_DOT_OFFSET 2
816 #define DIRENTRY_UNIQUENESS 500
818 #define FIRST_ITEM_OFFSET 1
820 struct reiserfs_de_head {
821 uint32_t deh_offset; /* Third component of the directory
823 uint32_t deh_dir_id; /* Objectid of the parent directory of
824 the object, that is referenced by
826 uint32_t deh_objectid; /* Objectid of the object, that is
827 referenced by directory entry */
828 uint16_t deh_location; /* Offset of name in the whole item */
829 uint16_t deh_state; /* Whether 1) entry contains stat data
830 (for future), and 2) whether entry
831 is hidden (unlinked) */
834 #define DEH_SIZE sizeof(struct reiserfs_de_head)
835 #define deh_offset(p_deh) (le32toh((p_deh)->deh_offset))
836 #define deh_dir_id(p_deh) (le32toh((p_deh)->deh_dir_id))
837 #define deh_objectid(p_deh) (le32toh((p_deh)->deh_objectid))
838 #define deh_location(p_deh) (le16toh((p_deh)->deh_location))
839 #define deh_state(p_deh) (le16toh((p_deh)->deh_state))
841 #define put_deh_offset(p_deh, v) ((p_deh)->deh_offset = htole32((v)))
842 #define put_deh_dir_id(p_deh, v) ((p_deh)->deh_dir_id = htole32((v)))
843 #define put_deh_objectid(p_deh, v) ((p_deh)->deh_objectid = htole32((v)))
844 #define put_deh_location(p_deh, v) ((p_deh)->deh_location = htole16((v)))
845 #define put_deh_state(p_deh, v) ((p_deh)->deh_state = htole16((v)))
847 /* Empty directory contains two entries "." and ".." and their headers */
848 #define EMPTY_DIR_SIZE \
849 (DEH_SIZE * 2 + ROUND_UP(strlen(".")) + ROUND_UP(strlen("..")))
851 /* Old format directories have this size when empty */
852 #define EMPTY_DIR_SIZE_V1 (DEH_SIZE * 2 + 3)
854 #define DEH_Statdata 0 /* Not used now */
855 #define DEH_Visible 2
857 /* Macro to map Linux' *_bit function to bitstring.h macros */
858 #define set_bit(bit, name) bit_set((bitstr_t *)name, bit)
859 #define clear_bit(bit, name) bit_clear((bitstr_t *)name, bit)
860 #define test_bit(bit, name) bit_test((bitstr_t *)name, bit)
862 #define set_bit_unaligned(bit, name) set_bit(bit, name)
863 #define clear_bit_unaligned(bit, name) clear_bit(bit, name)
864 #define test_bit_unaligned(bit, name) test_bit(bit, name)
866 #define mark_de_with_sd(deh) \
867 set_bit_unaligned(DEH_Statdata, &((deh)->deh_state))
868 #define mark_de_without_sd(deh) \
869 clear_bit_unaligned(DEH_Statdata, &((deh)->deh_state))
870 #define mark_de_visible(deh) \
871 set_bit_unaligned (DEH_Visible, &((deh)->deh_state))
872 #define mark_de_hidden(deh) \
873 clear_bit_unaligned (DEH_Visible, &((deh)->deh_state))
875 #define de_with_sd(deh) \
876 test_bit_unaligned(DEH_Statdata, &((deh)->deh_state))
877 #define de_visible(deh) \
878 test_bit_unaligned(DEH_Visible, &((deh)->deh_state))
879 #define de_hidden(deh) \
880 !test_bit_unaligned(DEH_Visible, &((deh)->deh_state))
882 /* Two entries per block (at least) */
883 #define REISERFS_MAX_NAME(block_size) 255
886 * This structure is used for operations on directory entries. It is not
887 * a disk structure. When reiserfs_find_entry or search_by_entry_key
888 * find directory entry, they return filled reiserfs_dir_entry structure
890 struct reiserfs_dir_entry {
893 struct item_head *de_ih;
895 struct reiserfs_de_head *de_deh;
899 char *de_gen_number_bit_string;
902 uint32_t de_objectid;
904 struct cpu_key de_entry_key;
907 /* Pointer to file name, stored in entry */
908 #define B_I_DEH_ENTRY_FILE_NAME(bp, ih, deh) \
909 (B_I_PITEM(bp, ih) + deh_location(deh))
912 #define I_DEH_N_ENTRY_FILE_NAME_LENGTH(ih, deh, entry_num) \
913 (I_DEH_N_ENTRY_LENGTH(ih, deh, entry_num) - \
914 (de_with_sd(deh) ? SD_SIZE : 0))
916 /* Hash value occupies bits from 7 up to 30 */
917 #define GET_HASH_VALUE(offset) ((offset) & 0x7fffff80LL)
919 /* Generation number occupies 7 bits starting from 0 up to 6 */
920 #define GET_GENERATION_NUMBER(offset) ((offset) & 0x7fLL)
921 #define MAX_GENERATION_NUMBER 127
924 #define B_I_PITEM(bp, ih) ((bp)->b_data + ih_location(ih))
925 #define B_I_DEH(bp, ih) ((struct reiserfs_de_head *)(B_I_PITEM(bp, ih)))
928 * Length of the directory entry in directory item. This define
929 * calculates length of i-th directory entry using directory entry
930 * locations from dir entry head. When it calculates length of 0-th
931 * directory entry, it uses length of whole item in place of entry
932 * location of the non-existent following entry in the calculation. See
936 entry_length (const struct buf *bp, const struct item_head *ih,
939 struct reiserfs_de_head *deh;
941 deh = B_I_DEH(bp, ih) + pos_in_item;
943 return (deh_location(deh - 1) - deh_location(deh));
945 return (ih_item_len(ih) - deh_location(deh));
949 * Number of entries in the directory item, depends on ENTRY_COUNT
950 * being at the start of directory dynamic data.
952 #define I_ENTRY_COUNT(ih) (ih_entry_count((ih)))
954 /* -------------------------------------------------------------------
956 * -------------------------------------------------------------------*/
959 * Disk child pointer: The pointer from an internal node of the tree
960 * to a node that is on disk.
963 uint32_t dc_block_number; /* Disk child's block number. */
964 uint16_t dc_size; /* Disk child's used space. */
965 uint16_t dc_reserved;
968 #define DC_SIZE (sizeof(struct disk_child))
969 #define dc_block_number(dc_p) (le32toh((dc_p)->dc_block_number))
970 #define dc_size(dc_p) (le16toh((dc_p)->dc_size))
971 #define put_dc_block_number(dc_p, val) \
972 do { (dc_p)->dc_block_number = htole32(val); } while (0)
973 #define put_dc_size(dc_p, val) \
974 do { (dc_p)->dc_size = htole16(val); } while (0)
976 /* Get disk child by buffer header and position in the tree node. */
977 #define B_N_CHILD(p_s_bp, n_pos) \
978 ((struct disk_child *)((p_s_bp)->b_data + BLKH_SIZE + \
979 B_NR_ITEMS(p_s_bp) * KEY_SIZE + \
982 /* Get disk child number by buffer header and position in the tree node. */
983 #define B_N_CHILD_NUM(p_s_bp, n_pos) \
984 (dc_block_number(B_N_CHILD(p_s_bp, n_pos)))
985 #define PUT_B_N_CHILD_NUM(p_s_bp, n_pos, val) \
986 (put_dc_block_number(B_N_CHILD(p_s_bp, n_pos), val))
988 /* -------------------------------------------------------------------
989 * Path structures and defines
990 * -------------------------------------------------------------------*/
992 struct path_element {
993 struct buf *pe_buffer; /* Pointer to the buffer at the path in
995 int pe_position; /* Position in the tree node which is
996 placed in the buffer above. */
999 #define MAX_HEIGHT 5 /* Maximal height of a tree. Don't
1000 change this without changing
1001 JOURNAL_PER_BALANCE_CNT */
1002 #define EXTENDED_MAX_HEIGHT 7 /* Must be equals MAX_HEIGHT +
1003 FIRST_PATH_ELEMENT_OFFSET */
1004 #define FIRST_PATH_ELEMENT_OFFSET 2 /* Must be equal to at least 2. */
1005 #define ILLEGAL_PATH_ELEMENT_OFFSET 1 /* Must be equal to
1006 FIRST_PATH_ELEMENT_OFFSET - 1 */
1007 #define MAX_FEB_SIZE 6 /* This MUST be MAX_HEIGHT + 1.
1008 See about FEB below */
1011 /* Length of the array below. */
1013 /* Array of the path element */
1014 struct path_element path_elements[EXTENDED_MAX_HEIGHT];
1018 #define pos_in_item(path) ((path)->pos_in_item)
1021 /* To workaround a bug in gcc. He generates a call to memset() which
1022 * is a inline function; this causes a compile time error. */
1023 #define INITIALIZE_PATH(var) \
1025 bzero(&var, sizeof(var)); \
1026 var.path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
1028 #define INITIALIZE_PATH(var) \
1029 struct path var = { ILLEGAL_PATH_ELEMENT_OFFSET, }
1032 /* Get path element by path and path position. */
1033 #define PATH_OFFSET_PELEMENT(p_s_path, n_offset) \
1034 ((p_s_path)->path_elements + (n_offset))
1036 /* Get buffer header at the path by path and path position. */
1037 #define PATH_OFFSET_PBUFFER(p_s_path, n_offset) \
1038 (PATH_OFFSET_PELEMENT(p_s_path, n_offset)->pe_buffer)
1040 /* Get position in the element at the path by path and path position. */
1041 #define PATH_OFFSET_POSITION(p_s_path, n_offset) \
1042 (PATH_OFFSET_PELEMENT(p_s_path, n_offset)->pe_position)
1044 #define PATH_PLAST_BUFFER(p_s_path) \
1045 (PATH_OFFSET_PBUFFER((p_s_path), (p_s_path)->path_length))
1047 #define PATH_LAST_POSITION(p_s_path) \
1048 (PATH_OFFSET_POSITION((p_s_path), (p_s_path)->path_length))
1050 #define PATH_PITEM_HEAD(p_s_path) \
1051 B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_path), PATH_LAST_POSITION(p_s_path))
1053 #define get_last_bp(path) PATH_PLAST_BUFFER(path)
1054 #define get_ih(path) PATH_PITEM_HEAD(path)
1056 /* -------------------------------------------------------------------
1058 * -------------------------------------------------------------------*/
1060 /* Size of pointer to the unformatted node. */
1061 #define UNFM_P_SIZE (sizeof(unp_t))
1062 #define UNFM_P_SHIFT 2
1064 /* In in-core inode key is stored on le form */
1065 #define INODE_PKEY(ip) ((struct key *)(REISERFS_I(ip)->i_key))
1067 #define MAX_UL_INT 0xffffffff
1068 #define MAX_INT 0x7ffffff
1069 #define MAX_US_INT 0xffff
1071 /* The purpose is to detect overflow of an unsigned short */
1072 #define REISERFS_LINK_MAX (MAX_US_INT - 1000)
1074 #define fs_generation(sbi) (REISERFS_SB(sbi)->s_generation_counter)
1075 #define get_generation(sbi) (fs_generation(sbi))
1077 #define __fs_changed(gen, sbi) (gen != get_generation (sbi))
1078 /*#define fs_changed(gen, sbi) ({ cond_resched(); \
1079 __fs_changed(gen, sbi); })*/
1080 #define fs_changed(gen, sbi) (__fs_changed(gen, sbi))
1082 /* -------------------------------------------------------------------
1084 * -------------------------------------------------------------------*/
1087 * To make any changes in the tree we always first find node, that
1088 * contains item to be changed/deleted or place to insert a new item.
1089 * We call this node S. To do balancing we need to decide what we will
1090 * shift to left/right neighbor, or to a new node, where new item will
1091 * be etc. To make this analysis simpler we build virtual node. Virtual
1092 * node is an array of items, that will replace items of node S. (For
1093 * instance if we are going to delete an item, virtual node does not
1094 * contain it). Virtual node keeps information about item sizes and
1095 * types, mergeability of first and last items, sizes of all entries in
1096 * directory item. We use this array of items when calculating what we
1097 * can shift to neighbors and how many nodes we have to have if we do
1098 * not any shiftings, if we shift to left/right neighbor or to both.
1100 struct virtual_item {
1101 int vi_index; /* Index in the array of item
1103 unsigned short vi_type; /* Left/right mergeability */
1104 unsigned short vi_item_len; /* Length of item that it will
1105 have after balancing */
1106 struct item_head *vi_ih;
1107 const char *vi_item; /* Body of item (old or new) */
1108 const void *vi_new_data; /* 0 always but paste mode */
1109 void *vi_uarea; /* Item specific area */
1112 struct virtual_node {
1113 char *vn_free_ptr; /* This is a pointer to the free space
1115 unsigned short vn_nr_item; /* Number of items in virtual node */
1116 short vn_size; /* Size of node , that node would have
1117 if it has unlimited size and no
1118 balancing is performed */
1119 short vn_mode; /* Mode of balancing (paste, insert,
1121 short vn_affected_item_num;
1122 short vn_pos_in_item;
1123 struct item_head *vn_ins_ih; /* Item header of inserted item, 0 for
1125 const void *vn_data;
1126 struct virtual_item *vn_vi; /* Array of items (including a new one,
1127 excluding item to be deleted) */
1130 /* Used by directory items when creating virtual nodes */
1131 struct direntry_uarea {
1133 uint16_t entry_count;
1134 uint16_t entry_sizes[1];
1137 /* -------------------------------------------------------------------
1139 * -------------------------------------------------------------------*/
1141 struct reiserfs_iget_args {
1146 struct item_operations {
1147 int (*bytes_number)(struct item_head * ih, int block_size);
1148 void (*decrement_key)(struct cpu_key *);
1149 int (*is_left_mergeable)(struct key * ih, unsigned long bsize);
1150 void (*print_item)(struct item_head *, char * item);
1151 void (*check_item)(struct item_head *, char * item);
1153 int (*create_vi)(struct virtual_node * vn,
1154 struct virtual_item * vi, int is_affected, int insert_size);
1155 int (*check_left)(struct virtual_item * vi, int free,
1156 int start_skip, int end_skip);
1157 int (*check_right)(struct virtual_item * vi, int free);
1158 int (*part_size)(struct virtual_item * vi, int from, int to);
1159 int (*unit_num)(struct virtual_item * vi);
1160 void (*print_vi)(struct virtual_item * vi);
1163 extern struct item_operations *item_ops[TYPE_ANY + 1];
1165 #define op_bytes_number(ih, bsize) \
1166 item_ops[le_ih_k_type(ih)]->bytes_number(ih, bsize)
1168 #define COMP_KEYS comp_keys
1169 #define COMP_SHORT_KEYS comp_short_keys
1171 /* Get the item header */
1172 #define B_N_PITEM_HEAD(bp, item_num) \
1173 ((struct item_head *)((bp)->b_data + BLKH_SIZE) + (item_num))
1176 #define B_N_PDELIM_KEY(bp, item_num) \
1177 ((struct key *)((bp)->b_data + BLKH_SIZE) + (item_num))
1179 /* -------------------------------------------------------------------
1180 * Function declarations
1181 * -------------------------------------------------------------------*/
1183 /* reiserfs_stree.c */
1184 int B_IS_IN_TREE(const struct buf *p_s_bp);
1186 extern void copy_item_head(struct item_head * p_v_to,
1187 const struct item_head * p_v_from);
1189 extern int comp_keys(const struct key *le_key,
1190 const struct cpu_key *cpu_key);
1191 extern int comp_short_keys(const struct key *le_key,
1192 const struct cpu_key *cpu_key);
1194 extern int comp_le_keys(const struct key *, const struct key *);
1197 le_key_version(const struct key *key)
1201 type = offset_v2_k_type(&(key->u.k_offset_v2));
1202 if (type != TYPE_DIRECT && type != TYPE_INDIRECT &&
1203 type != TYPE_DIRENTRY)
1204 return (KEY_FORMAT_3_5);
1206 return (KEY_FORMAT_3_6);
1210 copy_key(struct key *to, const struct key *from)
1213 memcpy(to, from, KEY_SIZE);
1216 const struct key *get_lkey(const struct path *p_s_chk_path,
1217 const struct reiserfs_sb_info *p_s_sbi);
1218 const struct key *get_rkey(const struct path *p_s_chk_path,
1219 const struct reiserfs_sb_info *p_s_sbi);
1220 int bin_search(const void * p_v_key, const void * p_v_base,
1221 int p_n_num, int p_n_width, int * p_n_pos);
1223 void pathrelse(struct path *p_s_search_path);
1224 int reiserfs_check_path(struct path *p);
1226 int search_by_key(struct reiserfs_sb_info *p_s_sbi,
1227 const struct cpu_key *p_s_key,
1228 struct path *p_s_search_path,
1230 #define search_item(sbi, key, path) \
1231 search_by_key(sbi, key, path, DISK_LEAF_NODE_LEVEL)
1232 int search_for_position_by_key(struct reiserfs_sb_info *p_s_sbi,
1233 const struct cpu_key *p_s_cpu_key,
1234 struct path *p_s_search_path);
1235 void decrement_counters_in_path(struct path *p_s_search_path);
1237 /* reiserfs_inode.c */
1238 vop_read_t reiserfs_read;
1239 vop_inactive_t reiserfs_inactive;
1240 vop_reclaim_t reiserfs_reclaim;
1242 int reiserfs_get_block(struct reiserfs_node *ip, long block,
1243 off_t offset, struct uio *uio);
1245 void make_cpu_key(struct cpu_key *cpu_key, struct reiserfs_node *ip,
1246 off_t offset, int type, int key_length);
1248 void reiserfs_read_locked_inode(struct reiserfs_node *ip,
1249 struct reiserfs_iget_args *args);
1250 int reiserfs_iget(struct mount *mp, const struct cpu_key *key,
1251 struct vnode **vpp, struct thread *td);
1253 void sd_attrs_to_i_attrs(uint16_t sd_attrs, struct reiserfs_node *ip);
1254 void i_attrs_to_sd_attrs(struct reiserfs_node *ip, uint16_t *sd_attrs);
1256 /* reiserfs_namei.c */
1257 vop_readdir_t reiserfs_readdir;
1258 vop_cachedlookup_t reiserfs_lookup;
1260 void set_de_name_and_namelen(struct reiserfs_dir_entry * de);
1261 int search_by_entry_key(struct reiserfs_sb_info *sbi,
1262 const struct cpu_key *key, struct path *path,
1263 struct reiserfs_dir_entry *de);
1265 /* reiserfs_prints.c */
1266 char *reiserfs_hashname(int code);
1267 void reiserfs_dump_buffer(caddr_t buf, off_t len);
1269 #if defined(REISERFS_DEBUG)
1270 #define reiserfs_log(lvl, fmt, ...) \
1271 log(lvl, "ReiserFS/%s: " fmt, __func__, ## __VA_ARGS__)
1272 #elif defined (REISERFS_DEBUG_CONS)
1273 #define reiserfs_log(lvl, fmt, ...) \
1274 printf("%s:%d: " fmt, __func__, __LINE__, ## __VA_ARGS__)
1276 #define reiserfs_log(lvl, fmt, ...)
1279 #define reiserfs_log_0(lvl, fmt, ...) \
1280 printf("%s:%d: " fmt, __func__, __LINE__, ## __VA_ARGS__)
1282 /* reiserfs_hashes.c */
1283 uint32_t keyed_hash(const signed char *msg, int len);
1284 uint32_t yura_hash(const signed char *msg, int len);
1285 uint32_t r5_hash(const signed char *msg, int len);
1287 #define reiserfs_test_le_bit test_bit
1289 #endif /* !defined _GNU_REISERFS_REISERFS_FS_H */