aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/reiserfs_fs.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-07-12 23:21:28 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-12 23:21:28 -0400
commitbd4c625c061c2a38568d0add3478f59172455159 (patch)
tree1c44a17c55bce2ee7ad5ea3d15a208ecc0955f74 /include/linux/reiserfs_fs.h
parent7fa94c8868edfef8cb6a201fcc9a5078b7b961da (diff)
reiserfs: run scripts/Lindent on reiserfs code
This was a pure indentation change, using: scripts/Lindent fs/reiserfs/*.c include/linux/reiserfs_*.h to make reiserfs match the regular Linux indentation style. As Jeff Mahoney <jeffm@suse.com> writes: The ReiserFS code is a mix of a number of different coding styles, sometimes different even from line-to-line. Since the code has been relatively stable for quite some time and there are few outstanding patches to be applied, it is time to reformat the code to conform to the Linux style standard outlined in Documentation/CodingStyle. This patch contains the result of running scripts/Lindent against fs/reiserfs/*.c and include/linux/reiserfs_*.h. There are places where the code can be made to look better, but I'd rather keep those patches separate so that there isn't a subtle by-hand hand accident in the middle of a huge patch. To be clear: This patch is reformatting *only*. A number of patches may follow that continue to make the code more consistent with the Linux coding style. Hans wasn't particularly enthusiastic about these patches, but said he wouldn't really oppose them either. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/reiserfs_fs.h')
-rw-r--r--include/linux/reiserfs_fs.h1595
1 files changed, 785 insertions, 810 deletions
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index 4c7c5689ad93..17e458e17e2b 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -3,11 +3,10 @@
3 */ 3 */
4 4
5 /* this file has an amazingly stupid 5 /* this file has an amazingly stupid
6 name, yura please fix it to be 6 name, yura please fix it to be
7 reiserfs.h, and merge all the rest 7 reiserfs.h, and merge all the rest
8 of our .h files that are in this 8 of our .h files that are in this
9 directory into it. */ 9 directory into it. */
10
11 10
12#ifndef _LINUX_REISER_FS_H 11#ifndef _LINUX_REISER_FS_H
13#define _LINUX_REISER_FS_H 12#define _LINUX_REISER_FS_H
@@ -74,9 +73,9 @@
74/* debug levels. Right now, CONFIG_REISERFS_CHECK means print all debug 73/* debug levels. Right now, CONFIG_REISERFS_CHECK means print all debug
75** messages. 74** messages.
76*/ 75*/
77#define REISERFS_DEBUG_CODE 5 /* extra messages to help find/debug errors */ 76#define REISERFS_DEBUG_CODE 5 /* extra messages to help find/debug errors */
78 77
79void reiserfs_warning (struct super_block *s, const char * fmt, ...); 78void reiserfs_warning(struct super_block *s, const char *fmt, ...);
80/* assertions handling */ 79/* assertions handling */
81 80
82/** always check a condition and panic if it's false. */ 81/** always check a condition and panic if it's false. */
@@ -105,82 +104,78 @@ if( !( cond ) ) \
105 * Structure of super block on disk, a version of which in RAM is often accessed as REISERFS_SB(s)->s_rs 104 * Structure of super block on disk, a version of which in RAM is often accessed as REISERFS_SB(s)->s_rs
106 * the version in RAM is part of a larger structure containing fields never written to disk. 105 * the version in RAM is part of a larger structure containing fields never written to disk.
107 */ 106 */
108#define UNSET_HASH 0 // read_super will guess about, what hash names 107#define UNSET_HASH 0 // read_super will guess about, what hash names
109 // in directories were sorted with 108 // in directories were sorted with
110#define TEA_HASH 1 109#define TEA_HASH 1
111#define YURA_HASH 2 110#define YURA_HASH 2
112#define R5_HASH 3 111#define R5_HASH 3
113#define DEFAULT_HASH R5_HASH 112#define DEFAULT_HASH R5_HASH
114 113
115
116struct journal_params { 114struct journal_params {
117 __le32 jp_journal_1st_block; /* where does journal start from on its 115 __le32 jp_journal_1st_block; /* where does journal start from on its
118 * device */ 116 * device */
119 __le32 jp_journal_dev; /* journal device st_rdev */ 117 __le32 jp_journal_dev; /* journal device st_rdev */
120 __le32 jp_journal_size; /* size of the journal */ 118 __le32 jp_journal_size; /* size of the journal */
121 __le32 jp_journal_trans_max; /* max number of blocks in a transaction. */ 119 __le32 jp_journal_trans_max; /* max number of blocks in a transaction. */
122 __le32 jp_journal_magic; /* random value made on fs creation (this 120 __le32 jp_journal_magic; /* random value made on fs creation (this
123 * was sb_journal_block_count) */ 121 * was sb_journal_block_count) */
124 __le32 jp_journal_max_batch; /* max number of blocks to batch into a 122 __le32 jp_journal_max_batch; /* max number of blocks to batch into a
125 * trans */ 123 * trans */
126 __le32 jp_journal_max_commit_age; /* in seconds, how old can an async 124 __le32 jp_journal_max_commit_age; /* in seconds, how old can an async
127 * commit be */ 125 * commit be */
128 __le32 jp_journal_max_trans_age; /* in seconds, how old can a transaction 126 __le32 jp_journal_max_trans_age; /* in seconds, how old can a transaction
129 * be */ 127 * be */
130}; 128};
131 129
132/* this is the super from 3.5.X, where X >= 10 */ 130/* this is the super from 3.5.X, where X >= 10 */
133struct reiserfs_super_block_v1 131struct reiserfs_super_block_v1 {
134{ 132 __le32 s_block_count; /* blocks count */
135 __le32 s_block_count; /* blocks count */ 133 __le32 s_free_blocks; /* free blocks count */
136 __le32 s_free_blocks; /* free blocks count */ 134 __le32 s_root_block; /* root block number */
137 __le32 s_root_block; /* root block number */ 135 struct journal_params s_journal;
138 struct journal_params s_journal; 136 __le16 s_blocksize; /* block size */
139 __le16 s_blocksize; /* block size */ 137 __le16 s_oid_maxsize; /* max size of object id array, see
140 __le16 s_oid_maxsize; /* max size of object id array, see 138 * get_objectid() commentary */
141 * get_objectid() commentary */ 139 __le16 s_oid_cursize; /* current size of object id array */
142 __le16 s_oid_cursize; /* current size of object id array */ 140 __le16 s_umount_state; /* this is set to 1 when filesystem was
143 __le16 s_umount_state; /* this is set to 1 when filesystem was 141 * umounted, to 2 - when not */
144 * umounted, to 2 - when not */ 142 char s_magic[10]; /* reiserfs magic string indicates that
145 char s_magic[10]; /* reiserfs magic string indicates that 143 * file system is reiserfs:
146 * file system is reiserfs: 144 * "ReIsErFs" or "ReIsEr2Fs" or "ReIsEr3Fs" */
147 * "ReIsErFs" or "ReIsEr2Fs" or "ReIsEr3Fs" */ 145 __le16 s_fs_state; /* it is set to used by fsck to mark which
148 __le16 s_fs_state; /* it is set to used by fsck to mark which 146 * phase of rebuilding is done */
149 * phase of rebuilding is done */ 147 __le32 s_hash_function_code; /* indicate, what hash function is being use
150 __le32 s_hash_function_code; /* indicate, what hash function is being use 148 * to sort names in a directory*/
151 * to sort names in a directory*/ 149 __le16 s_tree_height; /* height of disk tree */
152 __le16 s_tree_height; /* height of disk tree */ 150 __le16 s_bmap_nr; /* amount of bitmap blocks needed to address
153 __le16 s_bmap_nr; /* amount of bitmap blocks needed to address 151 * each block of file system */
154 * each block of file system */ 152 __le16 s_version; /* this field is only reliable on filesystem
155 __le16 s_version; /* this field is only reliable on filesystem 153 * with non-standard journal */
156 * with non-standard journal */ 154 __le16 s_reserved_for_journal; /* size in blocks of journal area on main
157 __le16 s_reserved_for_journal; /* size in blocks of journal area on main 155 * device, we need to keep after
158 * device, we need to keep after 156 * making fs with non-standard journal */
159 * making fs with non-standard journal */
160} __attribute__ ((__packed__)); 157} __attribute__ ((__packed__));
161 158
162#define SB_SIZE_V1 (sizeof(struct reiserfs_super_block_v1)) 159#define SB_SIZE_V1 (sizeof(struct reiserfs_super_block_v1))
163 160
164/* this is the on disk super block */ 161/* this is the on disk super block */
165struct reiserfs_super_block 162struct reiserfs_super_block {
166{ 163 struct reiserfs_super_block_v1 s_v1;
167 struct reiserfs_super_block_v1 s_v1; 164 __le32 s_inode_generation;
168 __le32 s_inode_generation; 165 __le32 s_flags; /* Right now used only by inode-attributes, if enabled */
169 __le32 s_flags; /* Right now used only by inode-attributes, if enabled */ 166 unsigned char s_uuid[16]; /* filesystem unique identifier */
170 unsigned char s_uuid[16]; /* filesystem unique identifier */ 167 unsigned char s_label[16]; /* filesystem volume label */
171 unsigned char s_label[16]; /* filesystem volume label */ 168 char s_unused[88]; /* zero filled by mkreiserfs and
172 char s_unused[88] ; /* zero filled by mkreiserfs and 169 * reiserfs_convert_objectid_map_v1()
173 * reiserfs_convert_objectid_map_v1() 170 * so any additions must be updated
174 * so any additions must be updated 171 * there as well. */
175 * there as well. */ 172} __attribute__ ((__packed__));
176} __attribute__ ((__packed__));
177 173
178#define SB_SIZE (sizeof(struct reiserfs_super_block)) 174#define SB_SIZE (sizeof(struct reiserfs_super_block))
179 175
180#define REISERFS_VERSION_1 0 176#define REISERFS_VERSION_1 0
181#define REISERFS_VERSION_2 2 177#define REISERFS_VERSION_2 2
182 178
183
184// on-disk super block fields converted to cpu form 179// on-disk super block fields converted to cpu form
185#define SB_DISK_SUPER_BLOCK(s) (REISERFS_SB(s)->s_rs) 180#define SB_DISK_SUPER_BLOCK(s) (REISERFS_SB(s)->s_rs)
186#define SB_V1_DISK_SUPER_BLOCK(s) (&(SB_DISK_SUPER_BLOCK(s)->s_v1)) 181#define SB_V1_DISK_SUPER_BLOCK(s) (&(SB_DISK_SUPER_BLOCK(s)->s_v1))
@@ -210,13 +205,12 @@ struct reiserfs_super_block
210#define PUT_SB_TREE_HEIGHT(s, val) \ 205#define PUT_SB_TREE_HEIGHT(s, val) \
211 do { SB_V1_DISK_SUPER_BLOCK(s)->s_tree_height = cpu_to_le16(val); } while (0) 206 do { SB_V1_DISK_SUPER_BLOCK(s)->s_tree_height = cpu_to_le16(val); } while (0)
212#define PUT_SB_REISERFS_STATE(s, val) \ 207#define PUT_SB_REISERFS_STATE(s, val) \
213 do { SB_V1_DISK_SUPER_BLOCK(s)->s_umount_state = cpu_to_le16(val); } while (0) 208 do { SB_V1_DISK_SUPER_BLOCK(s)->s_umount_state = cpu_to_le16(val); } while (0)
214#define PUT_SB_VERSION(s, val) \ 209#define PUT_SB_VERSION(s, val) \
215 do { SB_V1_DISK_SUPER_BLOCK(s)->s_version = cpu_to_le16(val); } while (0) 210 do { SB_V1_DISK_SUPER_BLOCK(s)->s_version = cpu_to_le16(val); } while (0)
216#define PUT_SB_BMAP_NR(s, val) \ 211#define PUT_SB_BMAP_NR(s, val) \
217 do { SB_V1_DISK_SUPER_BLOCK(s)->s_bmap_nr = cpu_to_le16 (val); } while (0) 212 do { SB_V1_DISK_SUPER_BLOCK(s)->s_bmap_nr = cpu_to_le16 (val); } while (0)
218 213
219
220#define SB_ONDISK_JP(s) (&SB_V1_DISK_SUPER_BLOCK(s)->s_journal) 214#define SB_ONDISK_JP(s) (&SB_V1_DISK_SUPER_BLOCK(s)->s_journal)
221#define SB_ONDISK_JOURNAL_SIZE(s) \ 215#define SB_ONDISK_JOURNAL_SIZE(s) \
222 le32_to_cpu ((SB_ONDISK_JP(s)->jp_journal_size)) 216 le32_to_cpu ((SB_ONDISK_JP(s)->jp_journal_size))
@@ -231,21 +225,19 @@ struct reiserfs_super_block
231 block >= SB_JOURNAL_1st_RESERVED_BLOCK(s) \ 225 block >= SB_JOURNAL_1st_RESERVED_BLOCK(s) \
232 && block < SB_JOURNAL_1st_RESERVED_BLOCK(s) + \ 226 && block < SB_JOURNAL_1st_RESERVED_BLOCK(s) + \
233 ((!is_reiserfs_jr(SB_DISK_SUPER_BLOCK(s)) ? \ 227 ((!is_reiserfs_jr(SB_DISK_SUPER_BLOCK(s)) ? \
234 SB_ONDISK_JOURNAL_SIZE(s) + 1 : SB_ONDISK_RESERVED_FOR_JOURNAL(s))) 228 SB_ONDISK_JOURNAL_SIZE(s) + 1 : SB_ONDISK_RESERVED_FOR_JOURNAL(s)))
235
236
237 229
238 /* used by gcc */ 230 /* used by gcc */
239#define REISERFS_SUPER_MAGIC 0x52654973 231#define REISERFS_SUPER_MAGIC 0x52654973
240 /* used by file system utilities that 232 /* used by file system utilities that
241 look at the superblock, etc. */ 233 look at the superblock, etc. */
242#define REISERFS_SUPER_MAGIC_STRING "ReIsErFs" 234#define REISERFS_SUPER_MAGIC_STRING "ReIsErFs"
243#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs" 235#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs"
244#define REISER2FS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs" 236#define REISER2FS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs"
245 237
246int is_reiserfs_3_5 (struct reiserfs_super_block * rs); 238int is_reiserfs_3_5(struct reiserfs_super_block *rs);
247int is_reiserfs_3_6 (struct reiserfs_super_block * rs); 239int is_reiserfs_3_6(struct reiserfs_super_block *rs);
248int is_reiserfs_jr (struct reiserfs_super_block * rs); 240int is_reiserfs_jr(struct reiserfs_super_block *rs);
249 241
250/* ReiserFS leaves the first 64k unused, so that partition labels have 242/* ReiserFS leaves the first 64k unused, so that partition labels have
251 enough space. If someone wants to write a fancy bootloader that 243 enough space. If someone wants to write a fancy bootloader that
@@ -272,8 +264,8 @@ typedef __u32 b_blocknr_t;
272typedef __le32 unp_t; 264typedef __le32 unp_t;
273 265
274struct unfm_nodeinfo { 266struct unfm_nodeinfo {
275 unp_t unfm_nodenum; 267 unp_t unfm_nodenum;
276 unsigned short unfm_freespace; 268 unsigned short unfm_freespace;
277}; 269};
278 270
279/* there are two formats of keys: 3.5 and 3.6 271/* there are two formats of keys: 3.5 and 3.6
@@ -285,7 +277,6 @@ struct unfm_nodeinfo {
285#define STAT_DATA_V1 0 277#define STAT_DATA_V1 0
286#define STAT_DATA_V2 1 278#define STAT_DATA_V2 1
287 279
288
289static inline struct reiserfs_inode_info *REISERFS_I(const struct inode *inode) 280static inline struct reiserfs_inode_info *REISERFS_I(const struct inode *inode)
290{ 281{
291 return container_of(inode, struct reiserfs_inode_info, vfs_inode); 282 return container_of(inode, struct reiserfs_inode_info, vfs_inode);
@@ -343,15 +334,13 @@ static inline struct reiserfs_sb_info *REISERFS_SB(const struct super_block *sb)
343 file would fit into one DIRECT item. 334 file would fit into one DIRECT item.
344 Primary intention for this one is to increase performance by decreasing 335 Primary intention for this one is to increase performance by decreasing
345 seeking. 336 seeking.
346*/ 337*/
347#define STORE_TAIL_IN_UNFM_S2(n_file_size,n_tail_size,n_block_size) \ 338#define STORE_TAIL_IN_UNFM_S2(n_file_size,n_tail_size,n_block_size) \
348(\ 339(\
349 (!(n_tail_size)) || \ 340 (!(n_tail_size)) || \
350 (((n_file_size) > MAX_DIRECT_ITEM_LEN(n_block_size)) ) \ 341 (((n_file_size) > MAX_DIRECT_ITEM_LEN(n_block_size)) ) \
351) 342)
352 343
353
354
355/* 344/*
356 * values for s_umount_state field 345 * values for s_umount_state field
357 */ 346 */
@@ -364,9 +353,9 @@ static inline struct reiserfs_sb_info *REISERFS_SB(const struct super_block *sb)
364#define TYPE_STAT_DATA 0 353#define TYPE_STAT_DATA 0
365#define TYPE_INDIRECT 1 354#define TYPE_INDIRECT 1
366#define TYPE_DIRECT 2 355#define TYPE_DIRECT 2
367#define TYPE_DIRENTRY 3 356#define TYPE_DIRENTRY 3
368#define TYPE_MAXTYPE 3 357#define TYPE_MAXTYPE 3
369#define TYPE_ANY 15 // FIXME: comment is required 358#define TYPE_ANY 15 // FIXME: comment is required
370 359
371/***************************************************************************/ 360/***************************************************************************/
372/* KEY & ITEM HEAD */ 361/* KEY & ITEM HEAD */
@@ -376,60 +365,62 @@ static inline struct reiserfs_sb_info *REISERFS_SB(const struct super_block *sb)
376// directories use this key as well as old files 365// directories use this key as well as old files
377// 366//
378struct offset_v1 { 367struct offset_v1 {
379 __le32 k_offset; 368 __le32 k_offset;
380 __le32 k_uniqueness; 369 __le32 k_uniqueness;
381} __attribute__ ((__packed__)); 370} __attribute__ ((__packed__));
382 371
383struct offset_v2 { 372struct offset_v2 {
384 __le64 v; 373 __le64 v;
385} __attribute__ ((__packed__)); 374} __attribute__ ((__packed__));
386 375
387static inline __u16 offset_v2_k_type( const struct offset_v2 *v2 ) 376static inline __u16 offset_v2_k_type(const struct offset_v2 *v2)
388{ 377{
389 __u8 type = le64_to_cpu(v2->v) >> 60; 378 __u8 type = le64_to_cpu(v2->v) >> 60;
390 return (type <= TYPE_MAXTYPE)?type:TYPE_ANY; 379 return (type <= TYPE_MAXTYPE) ? type : TYPE_ANY;
391} 380}
392 381
393static inline void set_offset_v2_k_type( struct offset_v2 *v2, int type ) 382static inline void set_offset_v2_k_type(struct offset_v2 *v2, int type)
394{ 383{
395 v2->v = (v2->v & cpu_to_le64(~0ULL>>4)) | cpu_to_le64((__u64)type<<60); 384 v2->v =
385 (v2->v & cpu_to_le64(~0ULL >> 4)) | cpu_to_le64((__u64) type << 60);
396} 386}
397 387
398static inline loff_t offset_v2_k_offset( const struct offset_v2 *v2 ) 388static inline loff_t offset_v2_k_offset(const struct offset_v2 *v2)
399{ 389{
400 return le64_to_cpu(v2->v) & (~0ULL>>4); 390 return le64_to_cpu(v2->v) & (~0ULL >> 4);
401} 391}
402 392
403static inline void set_offset_v2_k_offset( struct offset_v2 *v2, loff_t offset ){ 393static inline void set_offset_v2_k_offset(struct offset_v2 *v2, loff_t offset)
404 offset &= (~0ULL>>4); 394{
405 v2->v = (v2->v & cpu_to_le64(15ULL<<60)) | cpu_to_le64(offset); 395 offset &= (~0ULL >> 4);
396 v2->v = (v2->v & cpu_to_le64(15ULL << 60)) | cpu_to_le64(offset);
406} 397}
407 398
408/* Key of an item determines its location in the S+tree, and 399/* Key of an item determines its location in the S+tree, and
409 is composed of 4 components */ 400 is composed of 4 components */
410struct reiserfs_key { 401struct reiserfs_key {
411 __le32 k_dir_id; /* packing locality: by default parent 402 __le32 k_dir_id; /* packing locality: by default parent
412 directory object id */ 403 directory object id */
413 __le32 k_objectid; /* object identifier */ 404 __le32 k_objectid; /* object identifier */
414 union { 405 union {
415 struct offset_v1 k_offset_v1; 406 struct offset_v1 k_offset_v1;
416 struct offset_v2 k_offset_v2; 407 struct offset_v2 k_offset_v2;
417 } __attribute__ ((__packed__)) u; 408 } __attribute__ ((__packed__)) u;
418} __attribute__ ((__packed__)); 409} __attribute__ ((__packed__));
419 410
420struct in_core_key { 411struct in_core_key {
421 __u32 k_dir_id; /* packing locality: by default parent 412 __u32 k_dir_id; /* packing locality: by default parent
422 directory object id */ 413 directory object id */
423 __u32 k_objectid; /* object identifier */ 414 __u32 k_objectid; /* object identifier */
424 __u64 k_offset; 415 __u64 k_offset;
425 __u8 k_type; 416 __u8 k_type;
426}; 417};
427 418
428struct cpu_key { 419struct cpu_key {
429 struct in_core_key on_disk_key; 420 struct in_core_key on_disk_key;
430 int version; 421 int version;
431 int key_length; /* 3 in all cases but direct2indirect and 422 int key_length; /* 3 in all cases but direct2indirect and
432 indirect2direct conversion */ 423 indirect2direct conversion */
433}; 424};
434 425
435/* Our function for comparing keys can compare keys of different 426/* Our function for comparing keys can compare keys of different
@@ -475,8 +466,7 @@ struct cpu_key {
475 indirect items) and specifies the location of the item itself 466 indirect items) and specifies the location of the item itself
476 within the block. */ 467 within the block. */
477 468
478struct item_head 469struct item_head {
479{
480 /* Everything in the tree is found by searching for it based on 470 /* Everything in the tree is found by searching for it based on
481 * its key.*/ 471 * its key.*/
482 struct reiserfs_key ih_key; 472 struct reiserfs_key ih_key;
@@ -492,13 +482,13 @@ struct item_head
492 number of directory entries in the directory item. */ 482 number of directory entries in the directory item. */
493 __le16 ih_entry_count; 483 __le16 ih_entry_count;
494 } __attribute__ ((__packed__)) u; 484 } __attribute__ ((__packed__)) u;
495 __le16 ih_item_len; /* total size of the item body */ 485 __le16 ih_item_len; /* total size of the item body */
496 __le16 ih_item_location; /* an offset to the item body 486 __le16 ih_item_location; /* an offset to the item body
497 * within the block */ 487 * within the block */
498 __le16 ih_version; /* 0 for all old items, 2 for new 488 __le16 ih_version; /* 0 for all old items, 2 for new
499 ones. Highest bit is set by fsck 489 ones. Highest bit is set by fsck
500 temporary, cleaned after all 490 temporary, cleaned after all
501 done */ 491 done */
502} __attribute__ ((__packed__)); 492} __attribute__ ((__packed__));
503/* size of item header */ 493/* size of item header */
504#define IH_SIZE (sizeof(struct item_head)) 494#define IH_SIZE (sizeof(struct item_head))
@@ -515,7 +505,6 @@ struct item_head
515#define put_ih_location(ih, val) do { (ih)->ih_item_location = cpu_to_le16(val); } while (0) 505#define put_ih_location(ih, val) do { (ih)->ih_item_location = cpu_to_le16(val); } while (0)
516#define put_ih_item_len(ih, val) do { (ih)->ih_item_len = cpu_to_le16(val); } while (0) 506#define put_ih_item_len(ih, val) do { (ih)->ih_item_len = cpu_to_le16(val); } while (0)
517 507
518
519#define unreachable_item(ih) (ih_version(ih) & (1 << 15)) 508#define unreachable_item(ih) (ih_version(ih) & (1 << 15))
520 509
521#define get_ih_free_space(ih) (ih_version (ih) == KEY_FORMAT_3_6 ? 0 : ih_free_space (ih)) 510#define get_ih_free_space(ih) (ih_version (ih) == KEY_FORMAT_3_6 ? 0 : ih_free_space (ih))
@@ -537,40 +526,48 @@ struct item_head
537#define V1_INDIRECT_UNIQUENESS 0xfffffffe 526#define V1_INDIRECT_UNIQUENESS 0xfffffffe
538#define V1_DIRECT_UNIQUENESS 0xffffffff 527#define V1_DIRECT_UNIQUENESS 0xffffffff
539#define V1_DIRENTRY_UNIQUENESS 500 528#define V1_DIRENTRY_UNIQUENESS 500
540#define V1_ANY_UNIQUENESS 555 // FIXME: comment is required 529#define V1_ANY_UNIQUENESS 555 // FIXME: comment is required
541 530
542// 531//
543// here are conversion routines 532// here are conversion routines
544// 533//
545static inline int uniqueness2type (__u32 uniqueness) CONSTF; 534static inline int uniqueness2type(__u32 uniqueness) CONSTF;
546static inline int uniqueness2type (__u32 uniqueness) 535static inline int uniqueness2type(__u32 uniqueness)
547{ 536{
548 switch ((int)uniqueness) { 537 switch ((int)uniqueness) {
549 case V1_SD_UNIQUENESS: return TYPE_STAT_DATA; 538 case V1_SD_UNIQUENESS:
550 case V1_INDIRECT_UNIQUENESS: return TYPE_INDIRECT; 539 return TYPE_STAT_DATA;
551 case V1_DIRECT_UNIQUENESS: return TYPE_DIRECT; 540 case V1_INDIRECT_UNIQUENESS:
552 case V1_DIRENTRY_UNIQUENESS: return TYPE_DIRENTRY; 541 return TYPE_INDIRECT;
553 default: 542 case V1_DIRECT_UNIQUENESS:
554 reiserfs_warning (NULL, "vs-500: unknown uniqueness %d", 543 return TYPE_DIRECT;
555 uniqueness); 544 case V1_DIRENTRY_UNIQUENESS:
545 return TYPE_DIRENTRY;
546 default:
547 reiserfs_warning(NULL, "vs-500: unknown uniqueness %d",
548 uniqueness);
556 case V1_ANY_UNIQUENESS: 549 case V1_ANY_UNIQUENESS:
557 return TYPE_ANY; 550 return TYPE_ANY;
558 } 551 }
559} 552}
560 553
561static inline __u32 type2uniqueness (int type) CONSTF; 554static inline __u32 type2uniqueness(int type) CONSTF;
562static inline __u32 type2uniqueness (int type) 555static inline __u32 type2uniqueness(int type)
563{ 556{
564 switch (type) { 557 switch (type) {
565 case TYPE_STAT_DATA: return V1_SD_UNIQUENESS; 558 case TYPE_STAT_DATA:
566 case TYPE_INDIRECT: return V1_INDIRECT_UNIQUENESS; 559 return V1_SD_UNIQUENESS;
567 case TYPE_DIRECT: return V1_DIRECT_UNIQUENESS; 560 case TYPE_INDIRECT:
568 case TYPE_DIRENTRY: return V1_DIRENTRY_UNIQUENESS; 561 return V1_INDIRECT_UNIQUENESS;
569 default: 562 case TYPE_DIRECT:
570 reiserfs_warning (NULL, "vs-501: unknown type %d", type); 563 return V1_DIRECT_UNIQUENESS;
564 case TYPE_DIRENTRY:
565 return V1_DIRENTRY_UNIQUENESS;
566 default:
567 reiserfs_warning(NULL, "vs-501: unknown type %d", type);
571 case TYPE_ANY: 568 case TYPE_ANY:
572 return V1_ANY_UNIQUENESS; 569 return V1_ANY_UNIQUENESS;
573 } 570 }
574} 571}
575 572
576// 573//
@@ -578,57 +575,56 @@ static inline __u32 type2uniqueness (int type)
578// there is no way to get version of object from key, so, provide 575// there is no way to get version of object from key, so, provide
579// version to these defines 576// version to these defines
580// 577//
581static inline loff_t le_key_k_offset (int version, const struct reiserfs_key * key) 578static inline loff_t le_key_k_offset(int version,
579 const struct reiserfs_key *key)
582{ 580{
583 return (version == KEY_FORMAT_3_5) ? 581 return (version == KEY_FORMAT_3_5) ?
584 le32_to_cpu( key->u.k_offset_v1.k_offset ) : 582 le32_to_cpu(key->u.k_offset_v1.k_offset) :
585 offset_v2_k_offset( &(key->u.k_offset_v2) ); 583 offset_v2_k_offset(&(key->u.k_offset_v2));
586} 584}
587 585
588static inline loff_t le_ih_k_offset (const struct item_head * ih) 586static inline loff_t le_ih_k_offset(const struct item_head *ih)
589{ 587{
590 return le_key_k_offset (ih_version (ih), &(ih->ih_key)); 588 return le_key_k_offset(ih_version(ih), &(ih->ih_key));
591} 589}
592 590
593static inline loff_t le_key_k_type (int version, const struct reiserfs_key * key) 591static inline loff_t le_key_k_type(int version, const struct reiserfs_key *key)
594{ 592{
595 return (version == KEY_FORMAT_3_5) ? 593 return (version == KEY_FORMAT_3_5) ?
596 uniqueness2type( le32_to_cpu( key->u.k_offset_v1.k_uniqueness)) : 594 uniqueness2type(le32_to_cpu(key->u.k_offset_v1.k_uniqueness)) :
597 offset_v2_k_type( &(key->u.k_offset_v2) ); 595 offset_v2_k_type(&(key->u.k_offset_v2));
598} 596}
599 597
600static inline loff_t le_ih_k_type (const struct item_head * ih) 598static inline loff_t le_ih_k_type(const struct item_head *ih)
601{ 599{
602 return le_key_k_type (ih_version (ih), &(ih->ih_key)); 600 return le_key_k_type(ih_version(ih), &(ih->ih_key));
603} 601}
604 602
605 603static inline void set_le_key_k_offset(int version, struct reiserfs_key *key,
606static inline void set_le_key_k_offset (int version, struct reiserfs_key * key, loff_t offset) 604 loff_t offset)
607{ 605{
608 (version == KEY_FORMAT_3_5) ? 606 (version == KEY_FORMAT_3_5) ? (void)(key->u.k_offset_v1.k_offset = cpu_to_le32(offset)) : /* jdm check */
609 (void)(key->u.k_offset_v1.k_offset = cpu_to_le32 (offset)) : /* jdm check */ 607 (void)(set_offset_v2_k_offset(&(key->u.k_offset_v2), offset));
610 (void)(set_offset_v2_k_offset( &(key->u.k_offset_v2), offset ));
611} 608}
612 609
613 610static inline void set_le_ih_k_offset(struct item_head *ih, loff_t offset)
614static inline void set_le_ih_k_offset (struct item_head * ih, loff_t offset)
615{ 611{
616 set_le_key_k_offset (ih_version (ih), &(ih->ih_key), offset); 612 set_le_key_k_offset(ih_version(ih), &(ih->ih_key), offset);
617} 613}
618 614
619 615static inline void set_le_key_k_type(int version, struct reiserfs_key *key,
620static inline void set_le_key_k_type (int version, struct reiserfs_key * key, int type) 616 int type)
621{ 617{
622 (version == KEY_FORMAT_3_5) ? 618 (version == KEY_FORMAT_3_5) ?
623 (void)(key->u.k_offset_v1.k_uniqueness = cpu_to_le32(type2uniqueness(type))): 619 (void)(key->u.k_offset_v1.k_uniqueness =
624 (void)(set_offset_v2_k_type( &(key->u.k_offset_v2), type )); 620 cpu_to_le32(type2uniqueness(type)))
621 : (void)(set_offset_v2_k_type(&(key->u.k_offset_v2), type));
625} 622}
626static inline void set_le_ih_k_type (struct item_head * ih, int type) 623static inline void set_le_ih_k_type(struct item_head *ih, int type)
627{ 624{
628 set_le_key_k_type (ih_version (ih), &(ih->ih_key), type); 625 set_le_key_k_type(ih_version(ih), &(ih->ih_key), type);
629} 626}
630 627
631
632#define is_direntry_le_key(version,key) (le_key_k_type (version, key) == TYPE_DIRENTRY) 628#define is_direntry_le_key(version,key) (le_key_k_type (version, key) == TYPE_DIRENTRY)
633#define is_direct_le_key(version,key) (le_key_k_type (version, key) == TYPE_DIRECT) 629#define is_direct_le_key(version,key) (le_key_k_type (version, key) == TYPE_DIRECT)
634#define is_indirect_le_key(version,key) (le_key_k_type (version, key) == TYPE_INDIRECT) 630#define is_indirect_le_key(version,key) (le_key_k_type (version, key) == TYPE_INDIRECT)
@@ -642,34 +638,32 @@ static inline void set_le_ih_k_type (struct item_head * ih, int type)
642#define is_indirect_le_ih(ih) is_indirect_le_key (ih_version(ih), &((ih)->ih_key)) 638#define is_indirect_le_ih(ih) is_indirect_le_key (ih_version(ih), &((ih)->ih_key))
643#define is_statdata_le_ih(ih) is_statdata_le_key (ih_version (ih), &((ih)->ih_key)) 639#define is_statdata_le_ih(ih) is_statdata_le_key (ih_version (ih), &((ih)->ih_key))
644 640
645
646
647// 641//
648// key is pointer to cpu key, result is cpu 642// key is pointer to cpu key, result is cpu
649// 643//
650static inline loff_t cpu_key_k_offset (const struct cpu_key * key) 644static inline loff_t cpu_key_k_offset(const struct cpu_key *key)
651{ 645{
652 return key->on_disk_key.k_offset; 646 return key->on_disk_key.k_offset;
653} 647}
654 648
655static inline loff_t cpu_key_k_type (const struct cpu_key * key) 649static inline loff_t cpu_key_k_type(const struct cpu_key *key)
656{ 650{
657 return key->on_disk_key.k_type; 651 return key->on_disk_key.k_type;
658} 652}
659 653
660static inline void set_cpu_key_k_offset (struct cpu_key * key, loff_t offset) 654static inline void set_cpu_key_k_offset(struct cpu_key *key, loff_t offset)
661{ 655{
662 key->on_disk_key.k_offset = offset; 656 key->on_disk_key.k_offset = offset;
663} 657}
664 658
665static inline void set_cpu_key_k_type (struct cpu_key * key, int type) 659static inline void set_cpu_key_k_type(struct cpu_key *key, int type)
666{ 660{
667 key->on_disk_key.k_type = type; 661 key->on_disk_key.k_type = type;
668} 662}
669 663
670static inline void cpu_key_k_offset_dec (struct cpu_key * key) 664static inline void cpu_key_k_offset_dec(struct cpu_key *key)
671{ 665{
672 key->on_disk_key.k_offset --; 666 key->on_disk_key.k_offset--;
673} 667}
674 668
675#define is_direntry_cpu_key(key) (cpu_key_k_type (key) == TYPE_DIRENTRY) 669#define is_direntry_cpu_key(key) (cpu_key_k_type (key) == TYPE_DIRENTRY)
@@ -677,34 +671,25 @@ static inline void cpu_key_k_offset_dec (struct cpu_key * key)
677#define is_indirect_cpu_key(key) (cpu_key_k_type (key) == TYPE_INDIRECT) 671#define is_indirect_cpu_key(key) (cpu_key_k_type (key) == TYPE_INDIRECT)
678#define is_statdata_cpu_key(key) (cpu_key_k_type (key) == TYPE_STAT_DATA) 672#define is_statdata_cpu_key(key) (cpu_key_k_type (key) == TYPE_STAT_DATA)
679 673
680
681/* are these used ? */ 674/* are these used ? */
682#define is_direntry_cpu_ih(ih) (is_direntry_cpu_key (&((ih)->ih_key))) 675#define is_direntry_cpu_ih(ih) (is_direntry_cpu_key (&((ih)->ih_key)))
683#define is_direct_cpu_ih(ih) (is_direct_cpu_key (&((ih)->ih_key))) 676#define is_direct_cpu_ih(ih) (is_direct_cpu_key (&((ih)->ih_key)))
684#define is_indirect_cpu_ih(ih) (is_indirect_cpu_key (&((ih)->ih_key))) 677#define is_indirect_cpu_ih(ih) (is_indirect_cpu_key (&((ih)->ih_key)))
685#define is_statdata_cpu_ih(ih) (is_statdata_cpu_key (&((ih)->ih_key))) 678#define is_statdata_cpu_ih(ih) (is_statdata_cpu_key (&((ih)->ih_key)))
686 679
687
688
689
690
691#define I_K_KEY_IN_ITEM(p_s_ih, p_s_key, n_blocksize) \ 680#define I_K_KEY_IN_ITEM(p_s_ih, p_s_key, n_blocksize) \
692 ( ! COMP_SHORT_KEYS(p_s_ih, p_s_key) && \ 681 ( ! COMP_SHORT_KEYS(p_s_ih, p_s_key) && \
693 I_OFF_BYTE_IN_ITEM(p_s_ih, k_offset (p_s_key), n_blocksize) ) 682 I_OFF_BYTE_IN_ITEM(p_s_ih, k_offset (p_s_key), n_blocksize) )
694 683
695/* maximal length of item */ 684/* maximal length of item */
696#define MAX_ITEM_LEN(block_size) (block_size - BLKH_SIZE - IH_SIZE) 685#define MAX_ITEM_LEN(block_size) (block_size - BLKH_SIZE - IH_SIZE)
697#define MIN_ITEM_LEN 1 686#define MIN_ITEM_LEN 1
698 687
699
700/* object identifier for root dir */ 688/* object identifier for root dir */
701#define REISERFS_ROOT_OBJECTID 2 689#define REISERFS_ROOT_OBJECTID 2
702#define REISERFS_ROOT_PARENT_OBJECTID 1 690#define REISERFS_ROOT_PARENT_OBJECTID 1
703extern struct reiserfs_key root_key; 691extern struct reiserfs_key root_key;
704 692
705
706
707
708/* 693/*
709 * Picture represents a leaf of the S+tree 694 * Picture represents a leaf of the S+tree
710 * ______________________________________________________ 695 * ______________________________________________________
@@ -716,13 +701,13 @@ extern struct reiserfs_key root_key;
716 701
717/* Header of a disk block. More precisely, header of a formatted leaf 702/* Header of a disk block. More precisely, header of a formatted leaf
718 or internal node, and not the header of an unformatted node. */ 703 or internal node, and not the header of an unformatted node. */
719struct block_head { 704struct block_head {
720 __le16 blk_level; /* Level of a block in the tree. */ 705 __le16 blk_level; /* Level of a block in the tree. */
721 __le16 blk_nr_item; /* Number of keys/items in a block. */ 706 __le16 blk_nr_item; /* Number of keys/items in a block. */
722 __le16 blk_free_space; /* Block free space in bytes. */ 707 __le16 blk_free_space; /* Block free space in bytes. */
723 __le16 blk_reserved; 708 __le16 blk_reserved;
724 /* dump this in v4/planA */ 709 /* dump this in v4/planA */
725 struct reiserfs_key blk_right_delim_key; /* kept only for compatibility */ 710 struct reiserfs_key blk_right_delim_key; /* kept only for compatibility */
726}; 711};
727 712
728#define BLKH_SIZE (sizeof(struct block_head)) 713#define BLKH_SIZE (sizeof(struct block_head))
@@ -741,12 +726,12 @@ struct block_head {
741 * values for blk_level field of the struct block_head 726 * values for blk_level field of the struct block_head
742 */ 727 */
743 728
744#define FREE_LEVEL 0 /* when node gets removed from the tree its 729#define FREE_LEVEL 0 /* when node gets removed from the tree its
745 blk_level is set to FREE_LEVEL. It is then 730 blk_level is set to FREE_LEVEL. It is then
746 used to see whether the node is still in the 731 used to see whether the node is still in the
747 tree */ 732 tree */
748 733
749#define DISK_LEAF_NODE_LEVEL 1 /* Leaf node level.*/ 734#define DISK_LEAF_NODE_LEVEL 1 /* Leaf node level. */
750 735
751/* Given the buffer head of a formatted node, resolve to the block head of that node. */ 736/* Given the buffer head of a formatted node, resolve to the block head of that node. */
752#define B_BLK_HEAD(p_s_bh) ((struct block_head *)((p_s_bh)->b_data)) 737#define B_BLK_HEAD(p_s_bh) ((struct block_head *)((p_s_bh)->b_data))
@@ -759,7 +744,6 @@ struct block_head {
759#define PUT_B_LEVEL(p_s_bh,val) do { set_blkh_level(B_BLK_HEAD(p_s_bh),val); } while (0) 744#define PUT_B_LEVEL(p_s_bh,val) do { set_blkh_level(B_BLK_HEAD(p_s_bh),val); } while (0)
760#define PUT_B_FREE_SPACE(p_s_bh,val) do { set_blkh_free_space(B_BLK_HEAD(p_s_bh),val); } while (0) 745#define PUT_B_FREE_SPACE(p_s_bh,val) do { set_blkh_free_space(B_BLK_HEAD(p_s_bh),val); } while (0)
761 746
762
763/* Get right delimiting key. -- little endian */ 747/* Get right delimiting key. -- little endian */
764#define B_PRIGHT_DELIM_KEY(p_s_bh) (&(blk_right_delim_key(B_BLK_HEAD(p_s_bh)) 748#define B_PRIGHT_DELIM_KEY(p_s_bh) (&(blk_right_delim_key(B_BLK_HEAD(p_s_bh))
765 749
@@ -770,41 +754,36 @@ struct block_head {
770#define B_IS_KEYS_LEVEL(p_s_bh) (B_LEVEL(p_s_bh) > DISK_LEAF_NODE_LEVEL \ 754#define B_IS_KEYS_LEVEL(p_s_bh) (B_LEVEL(p_s_bh) > DISK_LEAF_NODE_LEVEL \
771 && B_LEVEL(p_s_bh) <= MAX_HEIGHT) 755 && B_LEVEL(p_s_bh) <= MAX_HEIGHT)
772 756
773
774
775
776/***************************************************************************/ 757/***************************************************************************/
777/* STAT DATA */ 758/* STAT DATA */
778/***************************************************************************/ 759/***************************************************************************/
779 760
780
781// 761//
782// old stat data is 32 bytes long. We are going to distinguish new one by 762// old stat data is 32 bytes long. We are going to distinguish new one by
783// different size 763// different size
784// 764//
785struct stat_data_v1 765struct stat_data_v1 {
786{ 766 __le16 sd_mode; /* file type, permissions */
787 __le16 sd_mode; /* file type, permissions */ 767 __le16 sd_nlink; /* number of hard links */
788 __le16 sd_nlink; /* number of hard links */ 768 __le16 sd_uid; /* owner */
789 __le16 sd_uid; /* owner */ 769 __le16 sd_gid; /* group */
790 __le16 sd_gid; /* group */ 770 __le32 sd_size; /* file size */
791 __le32 sd_size; /* file size */ 771 __le32 sd_atime; /* time of last access */
792 __le32 sd_atime; /* time of last access */ 772 __le32 sd_mtime; /* time file was last modified */
793 __le32 sd_mtime; /* time file was last modified */ 773 __le32 sd_ctime; /* time inode (stat data) was last changed (except changes to sd_atime and sd_mtime) */
794 __le32 sd_ctime; /* time inode (stat data) was last changed (except changes to sd_atime and sd_mtime) */ 774 union {
795 union { 775 __le32 sd_rdev;
796 __le32 sd_rdev; 776 __le32 sd_blocks; /* number of blocks file uses */
797 __le32 sd_blocks; /* number of blocks file uses */ 777 } __attribute__ ((__packed__)) u;
798 } __attribute__ ((__packed__)) u; 778 __le32 sd_first_direct_byte; /* first byte of file which is stored
799 __le32 sd_first_direct_byte; /* first byte of file which is stored 779 in a direct item: except that if it
800 in a direct item: except that if it 780 equals 1 it is a symlink and if it
801 equals 1 it is a symlink and if it 781 equals ~(__u32)0 there is no
802 equals ~(__u32)0 there is no 782 direct item. The existence of this
803 direct item. The existence of this 783 field really grates on me. Let's
804 field really grates on me. Let's 784 replace it with a macro based on
805 replace it with a macro based on 785 sd_size and our tail suppression
806 sd_size and our tail suppression 786 policy. Someday. -Hans */
807 policy. Someday. -Hans */
808} __attribute__ ((__packed__)); 787} __attribute__ ((__packed__));
809 788
810#define SD_V1_SIZE (sizeof(struct stat_data_v1)) 789#define SD_V1_SIZE (sizeof(struct stat_data_v1))
@@ -862,29 +841,29 @@ struct stat_data_v1
862/* Stat Data on disk (reiserfs version of UFS disk inode minus the 841/* Stat Data on disk (reiserfs version of UFS disk inode minus the
863 address blocks) */ 842 address blocks) */
864struct stat_data { 843struct stat_data {
865 __le16 sd_mode; /* file type, permissions */ 844 __le16 sd_mode; /* file type, permissions */
866 __le16 sd_attrs; /* persistent inode flags */ 845 __le16 sd_attrs; /* persistent inode flags */
867 __le32 sd_nlink; /* number of hard links */ 846 __le32 sd_nlink; /* number of hard links */
868 __le64 sd_size; /* file size */ 847 __le64 sd_size; /* file size */
869 __le32 sd_uid; /* owner */ 848 __le32 sd_uid; /* owner */
870 __le32 sd_gid; /* group */ 849 __le32 sd_gid; /* group */
871 __le32 sd_atime; /* time of last access */ 850 __le32 sd_atime; /* time of last access */
872 __le32 sd_mtime; /* time file was last modified */ 851 __le32 sd_mtime; /* time file was last modified */
873 __le32 sd_ctime; /* time inode (stat data) was last changed (except changes to sd_atime and sd_mtime) */ 852 __le32 sd_ctime; /* time inode (stat data) was last changed (except changes to sd_atime and sd_mtime) */
874 __le32 sd_blocks; 853 __le32 sd_blocks;
875 union { 854 union {
876 __le32 sd_rdev; 855 __le32 sd_rdev;
877 __le32 sd_generation; 856 __le32 sd_generation;
878 //__le32 sd_first_direct_byte; 857 //__le32 sd_first_direct_byte;
879 /* first byte of file which is stored in a 858 /* first byte of file which is stored in a
880 direct item: except that if it equals 1 859 direct item: except that if it equals 1
881 it is a symlink and if it equals 860 it is a symlink and if it equals
882 ~(__u32)0 there is no direct item. The 861 ~(__u32)0 there is no direct item. The
883 existence of this field really grates 862 existence of this field really grates
884 on me. Let's replace it with a macro 863 on me. Let's replace it with a macro
885 based on sd_size and our tail 864 based on sd_size and our tail
886 suppression policy? */ 865 suppression policy? */
887 } __attribute__ ((__packed__)) u; 866 } __attribute__ ((__packed__)) u;
888} __attribute__ ((__packed__)); 867} __attribute__ ((__packed__));
889// 868//
890// this is 44 bytes long 869// this is 44 bytes long
@@ -919,7 +898,6 @@ struct stat_data {
919#define sd_v2_attrs(sdp) (le16_to_cpu((sdp)->sd_attrs)) 898#define sd_v2_attrs(sdp) (le16_to_cpu((sdp)->sd_attrs))
920#define set_sd_v2_attrs(sdp,v) ((sdp)->sd_attrs = cpu_to_le16(v)) 899#define set_sd_v2_attrs(sdp,v) ((sdp)->sd_attrs = cpu_to_le16(v))
921 900
922
923/***************************************************************************/ 901/***************************************************************************/
924/* DIRECTORY STRUCTURE */ 902/* DIRECTORY STRUCTURE */
925/***************************************************************************/ 903/***************************************************************************/
@@ -954,17 +932,14 @@ struct stat_data {
954/* NOT IMPLEMENTED: 932/* NOT IMPLEMENTED:
955 Directory will someday contain stat data of object */ 933 Directory will someday contain stat data of object */
956 934
957 935struct reiserfs_de_head {
958 936 __le32 deh_offset; /* third component of the directory entry key */
959struct reiserfs_de_head 937 __le32 deh_dir_id; /* objectid of the parent directory of the object, that is referenced
960{ 938 by directory entry */
961 __le32 deh_offset; /* third component of the directory entry key */ 939 __le32 deh_objectid; /* objectid of the object, that is referenced by directory entry */
962 __le32 deh_dir_id; /* objectid of the parent directory of the object, that is referenced 940 __le16 deh_location; /* offset of name in the whole item */
963 by directory entry */ 941 __le16 deh_state; /* whether 1) entry contains stat data (for future), and 2) whether
964 __le32 deh_objectid; /* objectid of the object, that is referenced by directory entry */ 942 entry is hidden (unlinked) */
965 __le16 deh_location; /* offset of name in the whole item */
966 __le16 deh_state; /* whether 1) entry contains stat data (for future), and 2) whether
967 entry is hidden (unlinked) */
968} __attribute__ ((__packed__)); 943} __attribute__ ((__packed__));
969#define DEH_SIZE sizeof(struct reiserfs_de_head) 944#define DEH_SIZE sizeof(struct reiserfs_de_head)
970#define deh_offset(p_deh) (le32_to_cpu((p_deh)->deh_offset)) 945#define deh_offset(p_deh) (le32_to_cpu((p_deh)->deh_offset))
@@ -986,7 +961,7 @@ struct reiserfs_de_head
986/* old format directories have this size when empty */ 961/* old format directories have this size when empty */
987#define EMPTY_DIR_SIZE_V1 (DEH_SIZE * 2 + 3) 962#define EMPTY_DIR_SIZE_V1 (DEH_SIZE * 2 + 3)
988 963
989#define DEH_Statdata 0 /* not used now */ 964#define DEH_Statdata 0 /* not used now */
990#define DEH_Visible 2 965#define DEH_Visible 2
991 966
992/* 64 bit systems (and the S/390) need to be aligned explicitly -jdm */ 967/* 64 bit systems (and the S/390) need to be aligned explicitly -jdm */
@@ -1023,10 +998,10 @@ struct reiserfs_de_head
1023#define de_visible(deh) test_bit_unaligned (DEH_Visible, &((deh)->deh_state)) 998#define de_visible(deh) test_bit_unaligned (DEH_Visible, &((deh)->deh_state))
1024#define de_hidden(deh) !test_bit_unaligned (DEH_Visible, &((deh)->deh_state)) 999#define de_hidden(deh) !test_bit_unaligned (DEH_Visible, &((deh)->deh_state))
1025 1000
1026extern void make_empty_dir_item_v1 (char * body, __le32 dirid, __le32 objid, 1001extern void make_empty_dir_item_v1(char *body, __le32 dirid, __le32 objid,
1027 __le32 par_dirid, __le32 par_objid); 1002 __le32 par_dirid, __le32 par_objid);
1028extern void make_empty_dir_item (char * body, __le32 dirid, __le32 objid, 1003extern void make_empty_dir_item(char *body, __le32 dirid, __le32 objid,
1029 __le32 par_dirid, __le32 par_objid); 1004 __le32 par_dirid, __le32 par_objid);
1030 1005
1031/* array of the entry headers */ 1006/* array of the entry headers */
1032 /* get item body */ 1007 /* get item body */
@@ -1043,53 +1018,48 @@ extern void make_empty_dir_item (char * body, __le32 dirid, __le32 objid,
1043#define I_DEH_N_ENTRY_LENGTH(ih,deh,i) \ 1018#define I_DEH_N_ENTRY_LENGTH(ih,deh,i) \
1044((i) ? (deh_location((deh)-1) - deh_location((deh))) : (ih_item_len((ih)) - deh_location((deh)))) 1019((i) ? (deh_location((deh)-1) - deh_location((deh))) : (ih_item_len((ih)) - deh_location((deh))))
1045*/ 1020*/
1046static inline int entry_length (const struct buffer_head * bh, 1021static inline int entry_length(const struct buffer_head *bh,
1047 const struct item_head * ih, int pos_in_item) 1022 const struct item_head *ih, int pos_in_item)
1048{ 1023{
1049 struct reiserfs_de_head * deh; 1024 struct reiserfs_de_head *deh;
1050 1025
1051 deh = B_I_DEH (bh, ih) + pos_in_item; 1026 deh = B_I_DEH(bh, ih) + pos_in_item;
1052 if (pos_in_item) 1027 if (pos_in_item)
1053 return deh_location(deh-1) - deh_location(deh); 1028 return deh_location(deh - 1) - deh_location(deh);
1054 1029
1055 return ih_item_len(ih) - deh_location(deh); 1030 return ih_item_len(ih) - deh_location(deh);
1056} 1031}
1057 1032
1058
1059
1060/* number of entries in the directory item, depends on ENTRY_COUNT being at the start of directory dynamic data. */ 1033/* number of entries in the directory item, depends on ENTRY_COUNT being at the start of directory dynamic data. */
1061#define I_ENTRY_COUNT(ih) (ih_entry_count((ih))) 1034#define I_ENTRY_COUNT(ih) (ih_entry_count((ih)))
1062 1035
1063
1064/* name by bh, ih and entry_num */ 1036/* name by bh, ih and entry_num */
1065#define B_I_E_NAME(bh,ih,entry_num) ((char *)(bh->b_data + ih_location(ih) + deh_location(B_I_DEH(bh,ih)+(entry_num)))) 1037#define B_I_E_NAME(bh,ih,entry_num) ((char *)(bh->b_data + ih_location(ih) + deh_location(B_I_DEH(bh,ih)+(entry_num))))
1066 1038
1067// two entries per block (at least) 1039// two entries per block (at least)
1068#define REISERFS_MAX_NAME(block_size) 255 1040#define REISERFS_MAX_NAME(block_size) 255
1069 1041
1070
1071/* this structure is used for operations on directory entries. It is 1042/* this structure is used for operations on directory entries. It is
1072 not a disk structure. */ 1043 not a disk structure. */
1073/* When reiserfs_find_entry or search_by_entry_key find directory 1044/* When reiserfs_find_entry or search_by_entry_key find directory
1074 entry, they return filled reiserfs_dir_entry structure */ 1045 entry, they return filled reiserfs_dir_entry structure */
1075struct reiserfs_dir_entry 1046struct reiserfs_dir_entry {
1076{ 1047 struct buffer_head *de_bh;
1077 struct buffer_head * de_bh; 1048 int de_item_num;
1078 int de_item_num; 1049 struct item_head *de_ih;
1079 struct item_head * de_ih; 1050 int de_entry_num;
1080 int de_entry_num; 1051 struct reiserfs_de_head *de_deh;
1081 struct reiserfs_de_head * de_deh; 1052 int de_entrylen;
1082 int de_entrylen; 1053 int de_namelen;
1083 int de_namelen; 1054 char *de_name;
1084 char * de_name; 1055 char *de_gen_number_bit_string;
1085 char * de_gen_number_bit_string; 1056
1086 1057 __u32 de_dir_id;
1087 __u32 de_dir_id; 1058 __u32 de_objectid;
1088 __u32 de_objectid; 1059
1089 1060 struct cpu_key de_entry_key;
1090 struct cpu_key de_entry_key;
1091}; 1061};
1092 1062
1093/* these defines are useful when a particular member of a reiserfs_dir_entry is needed */ 1063/* these defines are useful when a particular member of a reiserfs_dir_entry is needed */
1094 1064
1095/* pointer to file name, stored in entry */ 1065/* pointer to file name, stored in entry */
@@ -1099,8 +1069,6 @@ struct reiserfs_dir_entry
1099#define I_DEH_N_ENTRY_FILE_NAME_LENGTH(ih,deh,entry_num) \ 1069#define I_DEH_N_ENTRY_FILE_NAME_LENGTH(ih,deh,entry_num) \
1100(I_DEH_N_ENTRY_LENGTH (ih, deh, entry_num) - (de_with_sd (deh) ? SD_SIZE : 0)) 1070(I_DEH_N_ENTRY_LENGTH (ih, deh, entry_num) - (de_with_sd (deh) ? SD_SIZE : 0))
1101 1071
1102
1103
1104/* hash value occupies bits from 7 up to 30 */ 1072/* hash value occupies bits from 7 up to 30 */
1105#define GET_HASH_VALUE(offset) ((offset) & 0x7fffff80LL) 1073#define GET_HASH_VALUE(offset) ((offset) & 0x7fffff80LL)
1106/* generation number occupies 7 bits starting from 0 up to 6 */ 1074/* generation number occupies 7 bits starting from 0 up to 6 */
@@ -1109,7 +1077,6 @@ struct reiserfs_dir_entry
1109 1077
1110#define SET_GENERATION_NUMBER(offset,gen_number) (GET_HASH_VALUE(offset)|(gen_number)) 1078#define SET_GENERATION_NUMBER(offset,gen_number) (GET_HASH_VALUE(offset)|(gen_number))
1111 1079
1112
1113/* 1080/*
1114 * Picture represents an internal node of the reiserfs tree 1081 * Picture represents an internal node of the reiserfs tree
1115 * ______________________________________________________ 1082 * ______________________________________________________
@@ -1125,9 +1092,9 @@ struct reiserfs_dir_entry
1125/* Disk child pointer: The pointer from an internal node of the tree 1092/* Disk child pointer: The pointer from an internal node of the tree
1126 to a node that is on disk. */ 1093 to a node that is on disk. */
1127struct disk_child { 1094struct disk_child {
1128 __le32 dc_block_number; /* Disk child's block number. */ 1095 __le32 dc_block_number; /* Disk child's block number. */
1129 __le16 dc_size; /* Disk child's used space. */ 1096 __le16 dc_size; /* Disk child's used space. */
1130 __le16 dc_reserved; 1097 __le16 dc_reserved;
1131}; 1098};
1132 1099
1133#define DC_SIZE (sizeof(struct disk_child)) 1100#define DC_SIZE (sizeof(struct disk_child))
@@ -1144,7 +1111,7 @@ struct disk_child {
1144#define B_N_CHILD_NUM(p_s_bh,n_pos) (dc_block_number(B_N_CHILD(p_s_bh,n_pos))) 1111#define B_N_CHILD_NUM(p_s_bh,n_pos) (dc_block_number(B_N_CHILD(p_s_bh,n_pos)))
1145#define PUT_B_N_CHILD_NUM(p_s_bh,n_pos, val) (put_dc_block_number(B_N_CHILD(p_s_bh,n_pos), val )) 1112#define PUT_B_N_CHILD_NUM(p_s_bh,n_pos, val) (put_dc_block_number(B_N_CHILD(p_s_bh,n_pos), val ))
1146 1113
1147 /* maximal value of field child_size in structure disk_child */ 1114 /* maximal value of field child_size in structure disk_child */
1148 /* child size is the combined size of all items and their headers */ 1115 /* child size is the combined size of all items and their headers */
1149#define MAX_CHILD_SIZE(bh) ((int)( (bh)->b_size - BLKH_SIZE )) 1116#define MAX_CHILD_SIZE(bh) ((int)( (bh)->b_size - BLKH_SIZE ))
1150 1117
@@ -1159,7 +1126,6 @@ struct disk_child {
1159/* PATH STRUCTURES AND DEFINES */ 1126/* PATH STRUCTURES AND DEFINES */
1160/***************************************************************************/ 1127/***************************************************************************/
1161 1128
1162
1163/* Search_by_key fills up the path from the root to the leaf as it descends the tree looking for the 1129/* Search_by_key fills up the path from the root to the leaf as it descends the tree looking for the
1164 key. It uses reiserfs_bread to try to find buffers in the cache given their block number. If it 1130 key. It uses reiserfs_bread to try to find buffers in the cache given their block number. If it
1165 does not find them in the cache it reads them from disk. For each node search_by_key finds using 1131 does not find them in the cache it reads them from disk. For each node search_by_key finds using
@@ -1168,20 +1134,18 @@ struct disk_child {
1168 is looking through a leaf node bin_search will find the position of the item which has key either 1134 is looking through a leaf node bin_search will find the position of the item which has key either
1169 equal to given key, or which is the maximal key less than the given key. */ 1135 equal to given key, or which is the maximal key less than the given key. */
1170 1136
1171struct path_element { 1137struct path_element {
1172 struct buffer_head * pe_buffer; /* Pointer to the buffer at the path in the tree. */ 1138 struct buffer_head *pe_buffer; /* Pointer to the buffer at the path in the tree. */
1173 int pe_position; /* Position in the tree node which is placed in the */ 1139 int pe_position; /* Position in the tree node which is placed in the */
1174 /* buffer above. */ 1140 /* buffer above. */
1175}; 1141};
1176 1142
1177#define MAX_HEIGHT 5 /* maximal height of a tree. don't change this without changing JOURNAL_PER_BALANCE_CNT */ 1143#define MAX_HEIGHT 5 /* maximal height of a tree. don't change this without changing JOURNAL_PER_BALANCE_CNT */
1178#define EXTENDED_MAX_HEIGHT 7 /* Must be equals MAX_HEIGHT + FIRST_PATH_ELEMENT_OFFSET */ 1144#define EXTENDED_MAX_HEIGHT 7 /* Must be equals MAX_HEIGHT + FIRST_PATH_ELEMENT_OFFSET */
1179#define FIRST_PATH_ELEMENT_OFFSET 2 /* Must be equal to at least 2. */ 1145#define FIRST_PATH_ELEMENT_OFFSET 2 /* Must be equal to at least 2. */
1180
1181#define ILLEGAL_PATH_ELEMENT_OFFSET 1 /* Must be equal to FIRST_PATH_ELEMENT_OFFSET - 1 */
1182#define MAX_FEB_SIZE 6 /* this MUST be MAX_HEIGHT + 1. See about FEB below */
1183
1184 1146
1147#define ILLEGAL_PATH_ELEMENT_OFFSET 1 /* Must be equal to FIRST_PATH_ELEMENT_OFFSET - 1 */
1148#define MAX_FEB_SIZE 6 /* this MUST be MAX_HEIGHT + 1. See about FEB below */
1185 1149
1186/* We need to keep track of who the ancestors of nodes are. When we 1150/* We need to keep track of who the ancestors of nodes are. When we
1187 perform a search we record which nodes were visited while 1151 perform a search we record which nodes were visited while
@@ -1200,14 +1164,14 @@ excessive effort to avoid disturbing the precious VFS code.:-( The
1200gods only know how we are going to SMP the code that uses them. 1164gods only know how we are going to SMP the code that uses them.
1201znodes are the way! */ 1165znodes are the way! */
1202 1166
1203#define PATH_READA 0x1 /* do read ahead */ 1167#define PATH_READA 0x1 /* do read ahead */
1204#define PATH_READA_BACK 0x2 /* read backwards */ 1168#define PATH_READA_BACK 0x2 /* read backwards */
1205 1169
1206struct path { 1170struct path {
1207 int path_length; /* Length of the array above. */ 1171 int path_length; /* Length of the array above. */
1208 int reada; 1172 int reada;
1209 struct path_element path_elements[EXTENDED_MAX_HEIGHT]; /* Array of the path elements. */ 1173 struct path_element path_elements[EXTENDED_MAX_HEIGHT]; /* Array of the path elements. */
1210 int pos_in_item; 1174 int pos_in_item;
1211}; 1175};
1212 1176
1213#define pos_in_item(path) ((path)->pos_in_item) 1177#define pos_in_item(path) ((path)->pos_in_item)
@@ -1224,25 +1188,23 @@ struct path var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,}
1224/* Get position in the element at the path by path and path position. */ 1188/* Get position in the element at the path by path and path position. */
1225#define PATH_OFFSET_POSITION(p_s_path,n_offset) (PATH_OFFSET_PELEMENT(p_s_path,n_offset)->pe_position) 1189#define PATH_OFFSET_POSITION(p_s_path,n_offset) (PATH_OFFSET_PELEMENT(p_s_path,n_offset)->pe_position)
1226 1190
1227
1228#define PATH_PLAST_BUFFER(p_s_path) (PATH_OFFSET_PBUFFER((p_s_path), (p_s_path)->path_length)) 1191#define PATH_PLAST_BUFFER(p_s_path) (PATH_OFFSET_PBUFFER((p_s_path), (p_s_path)->path_length))
1229 /* you know, to the person who didn't 1192 /* you know, to the person who didn't
1230 write this the macro name does not 1193 write this the macro name does not
1231 at first suggest what it does. 1194 at first suggest what it does.
1232 Maybe POSITION_FROM_PATH_END? Or 1195 Maybe POSITION_FROM_PATH_END? Or
1233 maybe we should just focus on 1196 maybe we should just focus on
1234 dumping paths... -Hans */ 1197 dumping paths... -Hans */
1235#define PATH_LAST_POSITION(p_s_path) (PATH_OFFSET_POSITION((p_s_path), (p_s_path)->path_length)) 1198#define PATH_LAST_POSITION(p_s_path) (PATH_OFFSET_POSITION((p_s_path), (p_s_path)->path_length))
1236 1199
1237
1238#define PATH_PITEM_HEAD(p_s_path) B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_path),PATH_LAST_POSITION(p_s_path)) 1200#define PATH_PITEM_HEAD(p_s_path) B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_path),PATH_LAST_POSITION(p_s_path))
1239 1201
1240/* in do_balance leaf has h == 0 in contrast with path structure, 1202/* in do_balance leaf has h == 0 in contrast with path structure,
1241 where root has level == 0. That is why we need these defines */ 1203 where root has level == 0. That is why we need these defines */
1242#define PATH_H_PBUFFER(p_s_path, h) PATH_OFFSET_PBUFFER (p_s_path, p_s_path->path_length - (h)) /* tb->S[h] */ 1204#define PATH_H_PBUFFER(p_s_path, h) PATH_OFFSET_PBUFFER (p_s_path, p_s_path->path_length - (h)) /* tb->S[h] */
1243#define PATH_H_PPARENT(path, h) PATH_H_PBUFFER (path, (h) + 1) /* tb->F[h] or tb->S[0]->b_parent */ 1205#define PATH_H_PPARENT(path, h) PATH_H_PBUFFER (path, (h) + 1) /* tb->F[h] or tb->S[0]->b_parent */
1244#define PATH_H_POSITION(path, h) PATH_OFFSET_POSITION (path, path->path_length - (h)) 1206#define PATH_H_POSITION(path, h) PATH_OFFSET_POSITION (path, path->path_length - (h))
1245#define PATH_H_B_ITEM_ORDER(path, h) PATH_H_POSITION(path, h + 1) /* tb->S[h]->b_item_order */ 1207#define PATH_H_B_ITEM_ORDER(path, h) PATH_H_POSITION(path, h + 1) /* tb->S[h]->b_item_order */
1246 1208
1247#define PATH_H_PATH_OFFSET(p_s_path, n_h) ((p_s_path)->path_length - (n_h)) 1209#define PATH_H_PATH_OFFSET(p_s_path, n_h) ((p_s_path)->path_length - (n_h))
1248 1210
@@ -1253,7 +1215,6 @@ struct path var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,}
1253#define item_moved(ih,path) comp_items(ih, path) 1215#define item_moved(ih,path) comp_items(ih, path)
1254#define path_changed(ih,path) comp_items (ih, path) 1216#define path_changed(ih,path) comp_items (ih, path)
1255 1217
1256
1257/***************************************************************************/ 1218/***************************************************************************/
1258/* MISC */ 1219/* MISC */
1259/***************************************************************************/ 1220/***************************************************************************/
@@ -1272,30 +1233,26 @@ struct path var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,}
1272// reiserfs version 2 has max offset 60 bits. Version 1 - 32 bit offset 1233// reiserfs version 2 has max offset 60 bits. Version 1 - 32 bit offset
1273#define U32_MAX (~(__u32)0) 1234#define U32_MAX (~(__u32)0)
1274 1235
1275static inline loff_t max_reiserfs_offset (struct inode * inode) 1236static inline loff_t max_reiserfs_offset(struct inode *inode)
1276{ 1237{
1277 if (get_inode_item_key_version(inode) == KEY_FORMAT_3_5) 1238 if (get_inode_item_key_version(inode) == KEY_FORMAT_3_5)
1278 return (loff_t)U32_MAX; 1239 return (loff_t) U32_MAX;
1279 1240
1280 return (loff_t)((~(__u64)0) >> 4); 1241 return (loff_t) ((~(__u64) 0) >> 4);
1281} 1242}
1282 1243
1283
1284/*#define MAX_KEY_UNIQUENESS MAX_UL_INT*/ 1244/*#define MAX_KEY_UNIQUENESS MAX_UL_INT*/
1285#define MAX_KEY_OBJECTID MAX_UL_INT 1245#define MAX_KEY_OBJECTID MAX_UL_INT
1286 1246
1287
1288#define MAX_B_NUM MAX_UL_INT 1247#define MAX_B_NUM MAX_UL_INT
1289#define MAX_FC_NUM MAX_US_INT 1248#define MAX_FC_NUM MAX_US_INT
1290 1249
1291
1292/* the purpose is to detect overflow of an unsigned short */ 1250/* the purpose is to detect overflow of an unsigned short */
1293#define REISERFS_LINK_MAX (MAX_US_INT - 1000) 1251#define REISERFS_LINK_MAX (MAX_US_INT - 1000)
1294 1252
1295
1296/* The following defines are used in reiserfs_insert_item and reiserfs_append_item */ 1253/* The following defines are used in reiserfs_insert_item and reiserfs_append_item */
1297#define REISERFS_KERNEL_MEM 0 /* reiserfs kernel memory mode */ 1254#define REISERFS_KERNEL_MEM 0 /* reiserfs kernel memory mode */
1298#define REISERFS_USER_MEM 1 /* reiserfs user memory mode */ 1255#define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
1299 1256
1300#define fs_generation(s) (REISERFS_SB(s)->s_generation_counter) 1257#define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
1301#define get_generation(s) atomic_read (&fs_generation(s)) 1258#define get_generation(s) atomic_read (&fs_generation(s))
@@ -1303,7 +1260,6 @@ static inline loff_t max_reiserfs_offset (struct inode * inode)
1303#define __fs_changed(gen,s) (gen != get_generation (s)) 1260#define __fs_changed(gen,s) (gen != get_generation (s))
1304#define fs_changed(gen,s) ({cond_resched(); __fs_changed(gen, s);}) 1261#define fs_changed(gen,s) ({cond_resched(); __fs_changed(gen, s);})
1305 1262
1306
1307/***************************************************************************/ 1263/***************************************************************************/
1308/* FIXATE NODES */ 1264/* FIXATE NODES */
1309/***************************************************************************/ 1265/***************************************************************************/
@@ -1324,38 +1280,34 @@ static inline loff_t max_reiserfs_offset (struct inode * inode)
1324 calculating what we can shift to neighbors and how many nodes we 1280 calculating what we can shift to neighbors and how many nodes we
1325 have to have if we do not any shiftings, if we shift to left/right 1281 have to have if we do not any shiftings, if we shift to left/right
1326 neighbor or to both. */ 1282 neighbor or to both. */
1327struct virtual_item 1283struct virtual_item {
1328{ 1284 int vi_index; // index in the array of item operations
1329 int vi_index; // index in the array of item operations 1285 unsigned short vi_type; // left/right mergeability
1330 unsigned short vi_type; // left/right mergeability 1286 unsigned short vi_item_len; /* length of item that it will have after balancing */
1331 unsigned short vi_item_len; /* length of item that it will have after balancing */ 1287 struct item_head *vi_ih;
1332 struct item_head * vi_ih; 1288 const char *vi_item; // body of item (old or new)
1333 const char * vi_item; // body of item (old or new) 1289 const void *vi_new_data; // 0 always but paste mode
1334 const void * vi_new_data; // 0 always but paste mode 1290 void *vi_uarea; // item specific area
1335 void * vi_uarea; // item specific area
1336}; 1291};
1337 1292
1338 1293struct virtual_node {
1339struct virtual_node 1294 char *vn_free_ptr; /* this is a pointer to the free space in the buffer */
1340{ 1295 unsigned short vn_nr_item; /* number of items in virtual node */
1341 char * vn_free_ptr; /* this is a pointer to the free space in the buffer */ 1296 short vn_size; /* size of node , that node would have if it has unlimited size and no balancing is performed */
1342 unsigned short vn_nr_item; /* number of items in virtual node */ 1297 short vn_mode; /* mode of balancing (paste, insert, delete, cut) */
1343 short vn_size; /* size of node , that node would have if it has unlimited size and no balancing is performed */ 1298 short vn_affected_item_num;
1344 short vn_mode; /* mode of balancing (paste, insert, delete, cut) */ 1299 short vn_pos_in_item;
1345 short vn_affected_item_num; 1300 struct item_head *vn_ins_ih; /* item header of inserted item, 0 for other modes */
1346 short vn_pos_in_item; 1301 const void *vn_data;
1347 struct item_head * vn_ins_ih; /* item header of inserted item, 0 for other modes */ 1302 struct virtual_item *vn_vi; /* array of items (including a new one, excluding item to be deleted) */
1348 const void * vn_data;
1349 struct virtual_item * vn_vi; /* array of items (including a new one, excluding item to be deleted) */
1350}; 1303};
1351 1304
1352/* used by directory items when creating virtual nodes */ 1305/* used by directory items when creating virtual nodes */
1353struct direntry_uarea { 1306struct direntry_uarea {
1354 int flags; 1307 int flags;
1355 __u16 entry_count; 1308 __u16 entry_count;
1356 __u16 entry_sizes[1]; 1309 __u16 entry_sizes[1];
1357} __attribute__ ((__packed__)) ; 1310} __attribute__ ((__packed__));
1358
1359 1311
1360/***************************************************************************/ 1312/***************************************************************************/
1361/* TREE BALANCE */ 1313/* TREE BALANCE */
@@ -1378,73 +1330,72 @@ struct direntry_uarea {
1378#define MAX_AMOUNT_NEEDED 2 1330#define MAX_AMOUNT_NEEDED 2
1379 1331
1380/* someday somebody will prefix every field in this struct with tb_ */ 1332/* someday somebody will prefix every field in this struct with tb_ */
1381struct tree_balance 1333struct tree_balance {
1382{ 1334 int tb_mode;
1383 int tb_mode; 1335 int need_balance_dirty;
1384 int need_balance_dirty; 1336 struct super_block *tb_sb;
1385 struct super_block * tb_sb; 1337 struct reiserfs_transaction_handle *transaction_handle;
1386 struct reiserfs_transaction_handle *transaction_handle ; 1338 struct path *tb_path;
1387 struct path * tb_path; 1339 struct buffer_head *L[MAX_HEIGHT]; /* array of left neighbors of nodes in the path */
1388 struct buffer_head * L[MAX_HEIGHT]; /* array of left neighbors of nodes in the path */ 1340 struct buffer_head *R[MAX_HEIGHT]; /* array of right neighbors of nodes in the path */
1389 struct buffer_head * R[MAX_HEIGHT]; /* array of right neighbors of nodes in the path*/ 1341 struct buffer_head *FL[MAX_HEIGHT]; /* array of fathers of the left neighbors */
1390 struct buffer_head * FL[MAX_HEIGHT]; /* array of fathers of the left neighbors */ 1342 struct buffer_head *FR[MAX_HEIGHT]; /* array of fathers of the right neighbors */
1391 struct buffer_head * FR[MAX_HEIGHT]; /* array of fathers of the right neighbors */ 1343 struct buffer_head *CFL[MAX_HEIGHT]; /* array of common parents of center node and its left neighbor */
1392 struct buffer_head * CFL[MAX_HEIGHT]; /* array of common parents of center node and its left neighbor */ 1344 struct buffer_head *CFR[MAX_HEIGHT]; /* array of common parents of center node and its right neighbor */
1393 struct buffer_head * CFR[MAX_HEIGHT]; /* array of common parents of center node and its right neighbor */ 1345
1394 1346 struct buffer_head *FEB[MAX_FEB_SIZE]; /* array of empty buffers. Number of buffers in array equals
1395 struct buffer_head * FEB[MAX_FEB_SIZE]; /* array of empty buffers. Number of buffers in array equals 1347 cur_blknum. */
1396 cur_blknum. */ 1348 struct buffer_head *used[MAX_FEB_SIZE];
1397 struct buffer_head * used[MAX_FEB_SIZE]; 1349 struct buffer_head *thrown[MAX_FEB_SIZE];
1398 struct buffer_head * thrown[MAX_FEB_SIZE]; 1350 int lnum[MAX_HEIGHT]; /* array of number of items which must be
1399 int lnum[MAX_HEIGHT]; /* array of number of items which must be 1351 shifted to the left in order to balance the
1400 shifted to the left in order to balance the 1352 current node; for leaves includes item that
1401 current node; for leaves includes item that 1353 will be partially shifted; for internal
1402 will be partially shifted; for internal 1354 nodes, it is the number of child pointers
1403 nodes, it is the number of child pointers 1355 rather than items. It includes the new item
1404 rather than items. It includes the new item 1356 being created. The code sometimes subtracts
1405 being created. The code sometimes subtracts 1357 one to get the number of wholly shifted
1406 one to get the number of wholly shifted 1358 items for other purposes. */
1407 items for other purposes. */ 1359 int rnum[MAX_HEIGHT]; /* substitute right for left in comment above */
1408 int rnum[MAX_HEIGHT]; /* substitute right for left in comment above */ 1360 int lkey[MAX_HEIGHT]; /* array indexed by height h mapping the key delimiting L[h] and
1409 int lkey[MAX_HEIGHT]; /* array indexed by height h mapping the key delimiting L[h] and 1361 S[h] to its item number within the node CFL[h] */
1410 S[h] to its item number within the node CFL[h] */ 1362 int rkey[MAX_HEIGHT]; /* substitute r for l in comment above */
1411 int rkey[MAX_HEIGHT]; /* substitute r for l in comment above */ 1363 int insert_size[MAX_HEIGHT]; /* the number of bytes by we are trying to add or remove from
1412 int insert_size[MAX_HEIGHT]; /* the number of bytes by we are trying to add or remove from 1364 S[h]. A negative value means removing. */
1413 S[h]. A negative value means removing. */ 1365 int blknum[MAX_HEIGHT]; /* number of nodes that will replace node S[h] after
1414 int blknum[MAX_HEIGHT]; /* number of nodes that will replace node S[h] after 1366 balancing on the level h of the tree. If 0 then S is
1415 balancing on the level h of the tree. If 0 then S is 1367 being deleted, if 1 then S is remaining and no new nodes
1416 being deleted, if 1 then S is remaining and no new nodes 1368 are being created, if 2 or 3 then 1 or 2 new nodes is
1417 are being created, if 2 or 3 then 1 or 2 new nodes is 1369 being created */
1418 being created */ 1370
1419 1371 /* fields that are used only for balancing leaves of the tree */
1420 /* fields that are used only for balancing leaves of the tree */ 1372 int cur_blknum; /* number of empty blocks having been already allocated */
1421 int cur_blknum; /* number of empty blocks having been already allocated */ 1373 int s0num; /* number of items that fall into left most node when S[0] splits */
1422 int s0num; /* number of items that fall into left most node when S[0] splits */ 1374 int s1num; /* number of items that fall into first new node when S[0] splits */
1423 int s1num; /* number of items that fall into first new node when S[0] splits */ 1375 int s2num; /* number of items that fall into second new node when S[0] splits */
1424 int s2num; /* number of items that fall into second new node when S[0] splits */ 1376 int lbytes; /* number of bytes which can flow to the left neighbor from the left */
1425 int lbytes; /* number of bytes which can flow to the left neighbor from the left */ 1377 /* most liquid item that cannot be shifted from S[0] entirely */
1426 /* most liquid item that cannot be shifted from S[0] entirely */ 1378 /* if -1 then nothing will be partially shifted */
1427 /* if -1 then nothing will be partially shifted */ 1379 int rbytes; /* number of bytes which will flow to the right neighbor from the right */
1428 int rbytes; /* number of bytes which will flow to the right neighbor from the right */ 1380 /* most liquid item that cannot be shifted from S[0] entirely */
1429 /* most liquid item that cannot be shifted from S[0] entirely */ 1381 /* if -1 then nothing will be partially shifted */
1430 /* if -1 then nothing will be partially shifted */ 1382 int s1bytes; /* number of bytes which flow to the first new node when S[0] splits */
1431 int s1bytes; /* number of bytes which flow to the first new node when S[0] splits */ 1383 /* note: if S[0] splits into 3 nodes, then items do not need to be cut */
1432 /* note: if S[0] splits into 3 nodes, then items do not need to be cut */ 1384 int s2bytes;
1433 int s2bytes; 1385 struct buffer_head *buf_to_free[MAX_FREE_BLOCK]; /* buffers which are to be freed after do_balance finishes by unfix_nodes */
1434 struct buffer_head * buf_to_free[MAX_FREE_BLOCK]; /* buffers which are to be freed after do_balance finishes by unfix_nodes */ 1386 char *vn_buf; /* kmalloced memory. Used to create
1435 char * vn_buf; /* kmalloced memory. Used to create
1436 virtual node and keep map of 1387 virtual node and keep map of
1437 dirtied bitmap blocks */ 1388 dirtied bitmap blocks */
1438 int vn_buf_size; /* size of the vn_buf */ 1389 int vn_buf_size; /* size of the vn_buf */
1439 struct virtual_node * tb_vn; /* VN starts after bitmap of bitmap blocks */ 1390 struct virtual_node *tb_vn; /* VN starts after bitmap of bitmap blocks */
1440 1391
1441 int fs_gen; /* saved value of `reiserfs_generation' counter 1392 int fs_gen; /* saved value of `reiserfs_generation' counter
1442 see FILESYSTEM_CHANGED() macro in reiserfs_fs.h */ 1393 see FILESYSTEM_CHANGED() macro in reiserfs_fs.h */
1443#ifdef DISPLACE_NEW_PACKING_LOCALITIES 1394#ifdef DISPLACE_NEW_PACKING_LOCALITIES
1444 struct in_core_key key; /* key pointer, to pass to block allocator or 1395 struct in_core_key key; /* key pointer, to pass to block allocator or
1445 another low-level subsystem */ 1396 another low-level subsystem */
1446#endif 1397#endif
1447} ; 1398};
1448 1399
1449/* These are modes of balancing */ 1400/* These are modes of balancing */
1450 1401
@@ -1479,13 +1430,12 @@ struct tree_balance
1479/* used in do_balance for passing parent of node information that has 1430/* used in do_balance for passing parent of node information that has
1480 been gotten from tb struct */ 1431 been gotten from tb struct */
1481struct buffer_info { 1432struct buffer_info {
1482 struct tree_balance * tb; 1433 struct tree_balance *tb;
1483 struct buffer_head * bi_bh; 1434 struct buffer_head *bi_bh;
1484 struct buffer_head * bi_parent; 1435 struct buffer_head *bi_parent;
1485 int bi_position; 1436 int bi_position;
1486}; 1437};
1487 1438
1488
1489/* there are 4 types of items: stat data, directory item, indirect, direct. 1439/* there are 4 types of items: stat data, directory item, indirect, direct.
1490+-------------------+------------+--------------+------------+ 1440+-------------------+------------+--------------+------------+
1491| | k_offset | k_uniqueness | mergeable? | 1441| | k_offset | k_uniqueness | mergeable? |
@@ -1503,24 +1453,24 @@ struct buffer_info {
1503*/ 1453*/
1504 1454
1505struct item_operations { 1455struct item_operations {
1506 int (*bytes_number) (struct item_head * ih, int block_size); 1456 int (*bytes_number) (struct item_head * ih, int block_size);
1507 void (*decrement_key) (struct cpu_key *); 1457 void (*decrement_key) (struct cpu_key *);
1508 int (*is_left_mergeable) (struct reiserfs_key * ih, unsigned long bsize); 1458 int (*is_left_mergeable) (struct reiserfs_key * ih,
1509 void (*print_item) (struct item_head *, char * item); 1459 unsigned long bsize);
1510 void (*check_item) (struct item_head *, char * item); 1460 void (*print_item) (struct item_head *, char *item);
1511 1461 void (*check_item) (struct item_head *, char *item);
1512 int (*create_vi) (struct virtual_node * vn, struct virtual_item * vi, 1462
1513 int is_affected, int insert_size); 1463 int (*create_vi) (struct virtual_node * vn, struct virtual_item * vi,
1514 int (*check_left) (struct virtual_item * vi, int free, 1464 int is_affected, int insert_size);
1515 int start_skip, int end_skip); 1465 int (*check_left) (struct virtual_item * vi, int free,
1516 int (*check_right) (struct virtual_item * vi, int free); 1466 int start_skip, int end_skip);
1517 int (*part_size) (struct virtual_item * vi, int from, int to); 1467 int (*check_right) (struct virtual_item * vi, int free);
1518 int (*unit_num) (struct virtual_item * vi); 1468 int (*part_size) (struct virtual_item * vi, int from, int to);
1519 void (*print_vi) (struct virtual_item * vi); 1469 int (*unit_num) (struct virtual_item * vi);
1470 void (*print_vi) (struct virtual_item * vi);
1520}; 1471};
1521 1472
1522 1473extern struct item_operations *item_ops[TYPE_ANY + 1];
1523extern struct item_operations * item_ops [TYPE_ANY + 1];
1524 1474
1525#define op_bytes_number(ih,bsize) item_ops[le_ih_k_type (ih)]->bytes_number (ih, bsize) 1475#define op_bytes_number(ih,bsize) item_ops[le_ih_k_type (ih)]->bytes_number (ih, bsize)
1526#define op_is_left_mergeable(key,bsize) item_ops[le_key_k_type (le_key_version (key), key)]->is_left_mergeable (key, bsize) 1476#define op_is_left_mergeable(key,bsize) item_ops[le_key_k_type (le_key_version (key), key)]->is_left_mergeable (key, bsize)
@@ -1533,8 +1483,6 @@ extern struct item_operations * item_ops [TYPE_ANY + 1];
1533#define op_unit_num(vi) item_ops[(vi)->vi_index]->unit_num (vi) 1483#define op_unit_num(vi) item_ops[(vi)->vi_index]->unit_num (vi)
1534#define op_print_vi(vi) item_ops[(vi)->vi_index]->print_vi (vi) 1484#define op_print_vi(vi) item_ops[(vi)->vi_index]->print_vi (vi)
1535 1485
1536
1537
1538#define COMP_SHORT_KEYS comp_short_keys 1486#define COMP_SHORT_KEYS comp_short_keys
1539 1487
1540/* number of blocks pointed to by the indirect item */ 1488/* number of blocks pointed to by the indirect item */
@@ -1545,8 +1493,7 @@ extern struct item_operations * item_ops [TYPE_ANY + 1];
1545 1493
1546/* number of bytes contained by the direct item or the unformatted nodes the indirect item points to */ 1494/* number of bytes contained by the direct item or the unformatted nodes the indirect item points to */
1547 1495
1548 1496/* get the item header */
1549/* get the item header */
1550#define B_N_PITEM_HEAD(bh,item_num) ( (struct item_head * )((bh)->b_data + BLKH_SIZE) + (item_num) ) 1497#define B_N_PITEM_HEAD(bh,item_num) ( (struct item_head * )((bh)->b_data + BLKH_SIZE) + (item_num) )
1551 1498
1552/* get key */ 1499/* get key */
@@ -1577,9 +1524,9 @@ extern struct item_operations * item_ops [TYPE_ANY + 1];
1577#define PUT_B_I_POS_UNFM_POINTER(bh,ih,pos, val) do {*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)) = cpu_to_le32(val); } while (0) 1524#define PUT_B_I_POS_UNFM_POINTER(bh,ih,pos, val) do {*(((unp_t *)B_I_PITEM(bh,ih)) + (pos)) = cpu_to_le32(val); } while (0)
1578 1525
1579struct reiserfs_iget_args { 1526struct reiserfs_iget_args {
1580 __u32 objectid ; 1527 __u32 objectid;
1581 __u32 dirid ; 1528 __u32 dirid;
1582} ; 1529};
1583 1530
1584/***************************************************************************/ 1531/***************************************************************************/
1585/* FUNCTION DECLARATIONS */ 1532/* FUNCTION DECLARATIONS */
@@ -1595,11 +1542,11 @@ struct reiserfs_iget_args {
1595 1542
1596/* first block written in a commit. */ 1543/* first block written in a commit. */
1597struct reiserfs_journal_desc { 1544struct reiserfs_journal_desc {
1598 __le32 j_trans_id ; /* id of commit */ 1545 __le32 j_trans_id; /* id of commit */
1599 __le32 j_len ; /* length of commit. len +1 is the commit block */ 1546 __le32 j_len; /* length of commit. len +1 is the commit block */
1600 __le32 j_mount_id ; /* mount id of this trans*/ 1547 __le32 j_mount_id; /* mount id of this trans */
1601 __le32 j_realblock[1] ; /* real locations for each block */ 1548 __le32 j_realblock[1]; /* real locations for each block */
1602} ; 1549};
1603 1550
1604#define get_desc_trans_id(d) le32_to_cpu((d)->j_trans_id) 1551#define get_desc_trans_id(d) le32_to_cpu((d)->j_trans_id)
1605#define get_desc_trans_len(d) le32_to_cpu((d)->j_len) 1552#define get_desc_trans_len(d) le32_to_cpu((d)->j_len)
@@ -1611,10 +1558,10 @@ struct reiserfs_journal_desc {
1611 1558
1612/* last block written in a commit */ 1559/* last block written in a commit */
1613struct reiserfs_journal_commit { 1560struct reiserfs_journal_commit {
1614 __le32 j_trans_id ; /* must match j_trans_id from the desc block */ 1561 __le32 j_trans_id; /* must match j_trans_id from the desc block */
1615 __le32 j_len ; /* ditto */ 1562 __le32 j_len; /* ditto */
1616 __le32 j_realblock[1] ; /* real locations for each block */ 1563 __le32 j_realblock[1]; /* real locations for each block */
1617} ; 1564};
1618 1565
1619#define get_commit_trans_id(c) le32_to_cpu((c)->j_trans_id) 1566#define get_commit_trans_id(c) le32_to_cpu((c)->j_trans_id)
1620#define get_commit_trans_len(c) le32_to_cpu((c)->j_len) 1567#define get_commit_trans_len(c) le32_to_cpu((c)->j_len)
@@ -1628,19 +1575,19 @@ struct reiserfs_journal_commit {
1628** and this transaction does not need to be replayed. 1575** and this transaction does not need to be replayed.
1629*/ 1576*/
1630struct reiserfs_journal_header { 1577struct reiserfs_journal_header {
1631 __le32 j_last_flush_trans_id ; /* id of last fully flushed transaction */ 1578 __le32 j_last_flush_trans_id; /* id of last fully flushed transaction */
1632 __le32 j_first_unflushed_offset ; /* offset in the log of where to start replay after a crash */ 1579 __le32 j_first_unflushed_offset; /* offset in the log of where to start replay after a crash */
1633 __le32 j_mount_id ; 1580 __le32 j_mount_id;
1634 /* 12 */ struct journal_params jh_journal; 1581 /* 12 */ struct journal_params jh_journal;
1635} ; 1582};
1636 1583
1637/* biggest tunable defines are right here */ 1584/* biggest tunable defines are right here */
1638#define JOURNAL_BLOCK_COUNT 8192 /* number of blocks in the journal */ 1585#define JOURNAL_BLOCK_COUNT 8192 /* number of blocks in the journal */
1639#define JOURNAL_TRANS_MAX_DEFAULT 1024 /* biggest possible single transaction, don't change for now (8/3/99) */ 1586#define JOURNAL_TRANS_MAX_DEFAULT 1024 /* biggest possible single transaction, don't change for now (8/3/99) */
1640#define JOURNAL_TRANS_MIN_DEFAULT 256 1587#define JOURNAL_TRANS_MIN_DEFAULT 256
1641#define JOURNAL_MAX_BATCH_DEFAULT 900 /* max blocks to batch into one transaction, don't make this any bigger than 900 */ 1588#define JOURNAL_MAX_BATCH_DEFAULT 900 /* max blocks to batch into one transaction, don't make this any bigger than 900 */
1642#define JOURNAL_MIN_RATIO 2 1589#define JOURNAL_MIN_RATIO 2
1643#define JOURNAL_MAX_COMMIT_AGE 30 1590#define JOURNAL_MAX_COMMIT_AGE 30
1644#define JOURNAL_MAX_TRANS_AGE 30 1591#define JOURNAL_MAX_TRANS_AGE 30
1645#define JOURNAL_PER_BALANCE_CNT (3 * (MAX_HEIGHT-2) + 9) 1592#define JOURNAL_PER_BALANCE_CNT (3 * (MAX_HEIGHT-2) + 9)
1646#ifdef CONFIG_QUOTA 1593#ifdef CONFIG_QUOTA
@@ -1664,10 +1611,10 @@ struct reiserfs_journal_header {
1664** the current number of nodes is > max, the node is freed, otherwise, 1611** the current number of nodes is > max, the node is freed, otherwise,
1665** it is put on a free list for faster use later. 1612** it is put on a free list for faster use later.
1666*/ 1613*/
1667#define REISERFS_MIN_BITMAP_NODES 10 1614#define REISERFS_MIN_BITMAP_NODES 10
1668#define REISERFS_MAX_BITMAP_NODES 100 1615#define REISERFS_MAX_BITMAP_NODES 100
1669 1616
1670#define JBH_HASH_SHIFT 13 /* these are based on journal hash size of 8192 */ 1617#define JBH_HASH_SHIFT 13 /* these are based on journal hash size of 8192 */
1671#define JBH_HASH_MASK 8191 1618#define JBH_HASH_MASK 8191
1672 1619
1673#define _jhashfn(sb,block) \ 1620#define _jhashfn(sb,block) \
@@ -1681,14 +1628,14 @@ struct reiserfs_journal_header {
1681#define journal_bread(s, block) __bread(SB_JOURNAL(s)->j_dev_bd, block, s->s_blocksize) 1628#define journal_bread(s, block) __bread(SB_JOURNAL(s)->j_dev_bd, block, s->s_blocksize)
1682 1629
1683enum reiserfs_bh_state_bits { 1630enum reiserfs_bh_state_bits {
1684 BH_JDirty = BH_PrivateStart, /* buffer is in current transaction */ 1631 BH_JDirty = BH_PrivateStart, /* buffer is in current transaction */
1685 BH_JDirty_wait, 1632 BH_JDirty_wait,
1686 BH_JNew, /* disk block was taken off free list before 1633 BH_JNew, /* disk block was taken off free list before
1687 * being in a finished transaction, or 1634 * being in a finished transaction, or
1688 * written to disk. Can be reused immed. */ 1635 * written to disk. Can be reused immed. */
1689 BH_JPrepared, 1636 BH_JPrepared,
1690 BH_JRestore_dirty, 1637 BH_JRestore_dirty,
1691 BH_JTest, // debugging only will go away 1638 BH_JTest, // debugging only will go away
1692}; 1639};
1693 1640
1694BUFFER_FNS(JDirty, journaled); 1641BUFFER_FNS(JDirty, journaled);
@@ -1708,175 +1655,192 @@ TAS_BUFFER_FNS(JTest, journal_test);
1708** transaction handle which is passed around for all journal calls 1655** transaction handle which is passed around for all journal calls
1709*/ 1656*/
1710struct reiserfs_transaction_handle { 1657struct reiserfs_transaction_handle {
1711 struct super_block *t_super ; /* super for this FS when journal_begin was 1658 struct super_block *t_super; /* super for this FS when journal_begin was
1712 called. saves calls to reiserfs_get_super 1659 called. saves calls to reiserfs_get_super
1713 also used by nested transactions to make 1660 also used by nested transactions to make
1714 sure they are nesting on the right FS 1661 sure they are nesting on the right FS
1715 _must_ be first in the handle 1662 _must_ be first in the handle
1716 */ 1663 */
1717 int t_refcount; 1664 int t_refcount;
1718 int t_blocks_logged ; /* number of blocks this writer has logged */ 1665 int t_blocks_logged; /* number of blocks this writer has logged */
1719 int t_blocks_allocated ; /* number of blocks this writer allocated */ 1666 int t_blocks_allocated; /* number of blocks this writer allocated */
1720 unsigned long t_trans_id ; /* sanity check, equals the current trans id */ 1667 unsigned long t_trans_id; /* sanity check, equals the current trans id */
1721 void *t_handle_save ; /* save existing current->journal_info */ 1668 void *t_handle_save; /* save existing current->journal_info */
1722 unsigned displace_new_blocks:1; /* if new block allocation occurres, that block 1669 unsigned displace_new_blocks:1; /* if new block allocation occurres, that block
1723 should be displaced from others */ 1670 should be displaced from others */
1724 struct list_head t_list; 1671 struct list_head t_list;
1725} ; 1672};
1726 1673
1727/* used to keep track of ordered and tail writes, attached to the buffer 1674/* used to keep track of ordered and tail writes, attached to the buffer
1728 * head through b_journal_head. 1675 * head through b_journal_head.
1729 */ 1676 */
1730struct reiserfs_jh { 1677struct reiserfs_jh {
1731 struct reiserfs_journal_list *jl; 1678 struct reiserfs_journal_list *jl;
1732 struct buffer_head *bh; 1679 struct buffer_head *bh;
1733 struct list_head list; 1680 struct list_head list;
1734}; 1681};
1735 1682
1736void reiserfs_free_jh(struct buffer_head *bh); 1683void reiserfs_free_jh(struct buffer_head *bh);
1737int reiserfs_add_tail_list(struct inode *inode, struct buffer_head *bh); 1684int reiserfs_add_tail_list(struct inode *inode, struct buffer_head *bh);
1738int reiserfs_add_ordered_list(struct inode *inode, struct buffer_head *bh); 1685int reiserfs_add_ordered_list(struct inode *inode, struct buffer_head *bh);
1739int journal_mark_dirty(struct reiserfs_transaction_handle *, struct super_block *, struct buffer_head *bh) ; 1686int journal_mark_dirty(struct reiserfs_transaction_handle *,
1740 1687 struct super_block *, struct buffer_head *bh);
1741static inline int 1688
1742reiserfs_file_data_log(struct inode *inode) { 1689static inline int reiserfs_file_data_log(struct inode *inode)
1743 if (reiserfs_data_log(inode->i_sb) || 1690{
1744 (REISERFS_I(inode)->i_flags & i_data_log)) 1691 if (reiserfs_data_log(inode->i_sb) ||
1745 return 1 ; 1692 (REISERFS_I(inode)->i_flags & i_data_log))
1746 return 0 ; 1693 return 1;
1694 return 0;
1747} 1695}
1748 1696
1749static inline int reiserfs_transaction_running(struct super_block *s) { 1697static inline int reiserfs_transaction_running(struct super_block *s)
1750 struct reiserfs_transaction_handle *th = current->journal_info ; 1698{
1751 if (th && th->t_super == s) 1699 struct reiserfs_transaction_handle *th = current->journal_info;
1752 return 1 ; 1700 if (th && th->t_super == s)
1753 if (th && th->t_super == NULL) 1701 return 1;
1754 BUG(); 1702 if (th && th->t_super == NULL)
1755 return 0 ; 1703 BUG();
1704 return 0;
1756} 1705}
1757 1706
1758int reiserfs_async_progress_wait(struct super_block *s); 1707int reiserfs_async_progress_wait(struct super_block *s);
1759 1708
1760struct reiserfs_transaction_handle * 1709struct reiserfs_transaction_handle *reiserfs_persistent_transaction(struct
1761reiserfs_persistent_transaction(struct super_block *, int count); 1710 super_block
1711 *,
1712 int count);
1762int reiserfs_end_persistent_transaction(struct reiserfs_transaction_handle *); 1713int reiserfs_end_persistent_transaction(struct reiserfs_transaction_handle *);
1763int reiserfs_commit_page(struct inode *inode, struct page *page, 1714int reiserfs_commit_page(struct inode *inode, struct page *page,
1764 unsigned from, unsigned to); 1715 unsigned from, unsigned to);
1765int reiserfs_flush_old_commits(struct super_block *); 1716int reiserfs_flush_old_commits(struct super_block *);
1766int reiserfs_commit_for_inode(struct inode *) ; 1717int reiserfs_commit_for_inode(struct inode *);
1767int reiserfs_inode_needs_commit(struct inode *) ; 1718int reiserfs_inode_needs_commit(struct inode *);
1768void reiserfs_update_inode_transaction(struct inode *) ; 1719void reiserfs_update_inode_transaction(struct inode *);
1769void reiserfs_wait_on_write_block(struct super_block *s) ; 1720void reiserfs_wait_on_write_block(struct super_block *s);
1770void reiserfs_block_writes(struct reiserfs_transaction_handle *th) ; 1721void reiserfs_block_writes(struct reiserfs_transaction_handle *th);
1771void reiserfs_allow_writes(struct super_block *s) ; 1722void reiserfs_allow_writes(struct super_block *s);
1772void reiserfs_check_lock_depth(struct super_block *s, char *caller) ; 1723void reiserfs_check_lock_depth(struct super_block *s, char *caller);
1773int reiserfs_prepare_for_journal(struct super_block *, struct buffer_head *bh, int wait) ; 1724int reiserfs_prepare_for_journal(struct super_block *, struct buffer_head *bh,
1774void reiserfs_restore_prepared_buffer(struct super_block *, struct buffer_head *bh) ; 1725 int wait);
1775int journal_init(struct super_block *, const char * j_dev_name, int old_format, unsigned int) ; 1726void reiserfs_restore_prepared_buffer(struct super_block *,
1776int journal_release(struct reiserfs_transaction_handle*, struct super_block *) ; 1727 struct buffer_head *bh);
1777int journal_release_error(struct reiserfs_transaction_handle*, struct super_block *) ; 1728int journal_init(struct super_block *, const char *j_dev_name, int old_format,
1778int journal_end(struct reiserfs_transaction_handle *, struct super_block *, unsigned long) ; 1729 unsigned int);
1779int journal_end_sync(struct reiserfs_transaction_handle *, struct super_block *, unsigned long) ; 1730int journal_release(struct reiserfs_transaction_handle *, struct super_block *);
1780int journal_mark_freed(struct reiserfs_transaction_handle *, struct super_block *, b_blocknr_t blocknr) ; 1731int journal_release_error(struct reiserfs_transaction_handle *,
1781int journal_transaction_should_end(struct reiserfs_transaction_handle *, int) ; 1732 struct super_block *);
1782int reiserfs_in_journal(struct super_block *p_s_sb, int bmap_nr, int bit_nr, int searchall, b_blocknr_t *next) ; 1733int journal_end(struct reiserfs_transaction_handle *, struct super_block *,
1783int journal_begin(struct reiserfs_transaction_handle *, struct super_block *p_s_sb, unsigned long) ; 1734 unsigned long);
1784int journal_join_abort(struct reiserfs_transaction_handle *, struct super_block *p_s_sb, unsigned long) ; 1735int journal_end_sync(struct reiserfs_transaction_handle *, struct super_block *,
1785void reiserfs_journal_abort (struct super_block *sb, int errno); 1736 unsigned long);
1786void reiserfs_abort (struct super_block *sb, int errno, const char *fmt, ...); 1737int journal_mark_freed(struct reiserfs_transaction_handle *,
1787int reiserfs_allocate_list_bitmaps(struct super_block *s, struct reiserfs_list_bitmap *, int) ; 1738 struct super_block *, b_blocknr_t blocknr);
1788 1739int journal_transaction_should_end(struct reiserfs_transaction_handle *, int);
1789void add_save_link (struct reiserfs_transaction_handle * th, 1740int reiserfs_in_journal(struct super_block *p_s_sb, int bmap_nr, int bit_nr,
1790 struct inode * inode, int truncate); 1741 int searchall, b_blocknr_t * next);
1791int remove_save_link (struct inode * inode, int truncate); 1742int journal_begin(struct reiserfs_transaction_handle *,
1743 struct super_block *p_s_sb, unsigned long);
1744int journal_join_abort(struct reiserfs_transaction_handle *,
1745 struct super_block *p_s_sb, unsigned long);
1746void reiserfs_journal_abort(struct super_block *sb, int errno);
1747void reiserfs_abort(struct super_block *sb, int errno, const char *fmt, ...);
1748int reiserfs_allocate_list_bitmaps(struct super_block *s,
1749 struct reiserfs_list_bitmap *, int);
1750
1751void add_save_link(struct reiserfs_transaction_handle *th,
1752 struct inode *inode, int truncate);
1753int remove_save_link(struct inode *inode, int truncate);
1792 1754
1793/* objectid.c */ 1755/* objectid.c */
1794__u32 reiserfs_get_unused_objectid (struct reiserfs_transaction_handle *th); 1756__u32 reiserfs_get_unused_objectid(struct reiserfs_transaction_handle *th);
1795void reiserfs_release_objectid (struct reiserfs_transaction_handle *th, __u32 objectid_to_release); 1757void reiserfs_release_objectid(struct reiserfs_transaction_handle *th,
1796int reiserfs_convert_objectid_map_v1(struct super_block *) ; 1758 __u32 objectid_to_release);
1759int reiserfs_convert_objectid_map_v1(struct super_block *);
1797 1760
1798/* stree.c */ 1761/* stree.c */
1799int B_IS_IN_TREE(const struct buffer_head *); 1762int B_IS_IN_TREE(const struct buffer_head *);
1800extern void copy_item_head(struct item_head * p_v_to, 1763extern void copy_item_head(struct item_head *p_v_to,
1801 const struct item_head * p_v_from); 1764 const struct item_head *p_v_from);
1802 1765
1803// first key is in cpu form, second - le 1766// first key is in cpu form, second - le
1804extern int comp_short_keys (const struct reiserfs_key * le_key, 1767extern int comp_short_keys(const struct reiserfs_key *le_key,
1805 const struct cpu_key * cpu_key); 1768 const struct cpu_key *cpu_key);
1806extern void le_key2cpu_key (struct cpu_key * to, const struct reiserfs_key * from); 1769extern void le_key2cpu_key(struct cpu_key *to, const struct reiserfs_key *from);
1807 1770
1808// both are in le form 1771// both are in le form
1809extern int comp_le_keys (const struct reiserfs_key *, const struct reiserfs_key *); 1772extern int comp_le_keys(const struct reiserfs_key *,
1810extern int comp_short_le_keys (const struct reiserfs_key *, const struct reiserfs_key *); 1773 const struct reiserfs_key *);
1774extern int comp_short_le_keys(const struct reiserfs_key *,
1775 const struct reiserfs_key *);
1811 1776
1812// 1777//
1813// get key version from on disk key - kludge 1778// get key version from on disk key - kludge
1814// 1779//
1815static inline int le_key_version (const struct reiserfs_key * key) 1780static inline int le_key_version(const struct reiserfs_key *key)
1816{ 1781{
1817 int type; 1782 int type;
1818
1819 type = offset_v2_k_type( &(key->u.k_offset_v2));
1820 if (type != TYPE_DIRECT && type != TYPE_INDIRECT && type != TYPE_DIRENTRY)
1821 return KEY_FORMAT_3_5;
1822
1823 return KEY_FORMAT_3_6;
1824
1825}
1826 1783
1784 type = offset_v2_k_type(&(key->u.k_offset_v2));
1785 if (type != TYPE_DIRECT && type != TYPE_INDIRECT
1786 && type != TYPE_DIRENTRY)
1787 return KEY_FORMAT_3_5;
1788
1789 return KEY_FORMAT_3_6;
1827 1790
1828static inline void copy_key (struct reiserfs_key *to, const struct reiserfs_key *from)
1829{
1830 memcpy (to, from, KEY_SIZE);
1831} 1791}
1832 1792
1793static inline void copy_key(struct reiserfs_key *to,
1794 const struct reiserfs_key *from)
1795{
1796 memcpy(to, from, KEY_SIZE);
1797}
1833 1798
1834int comp_items (const struct item_head * stored_ih, const struct path * p_s_path); 1799int comp_items(const struct item_head *stored_ih, const struct path *p_s_path);
1835const struct reiserfs_key * get_rkey (const struct path * p_s_chk_path, 1800const struct reiserfs_key *get_rkey(const struct path *p_s_chk_path,
1836 const struct super_block * p_s_sb); 1801 const struct super_block *p_s_sb);
1837int search_by_key (struct super_block *, const struct cpu_key *, 1802int search_by_key(struct super_block *, const struct cpu_key *,
1838 struct path *, int); 1803 struct path *, int);
1839#define search_item(s,key,path) search_by_key (s, key, path, DISK_LEAF_NODE_LEVEL) 1804#define search_item(s,key,path) search_by_key (s, key, path, DISK_LEAF_NODE_LEVEL)
1840int search_for_position_by_key (struct super_block * p_s_sb, 1805int search_for_position_by_key(struct super_block *p_s_sb,
1841 const struct cpu_key * p_s_cpu_key, 1806 const struct cpu_key *p_s_cpu_key,
1842 struct path * p_s_search_path); 1807 struct path *p_s_search_path);
1843extern void decrement_bcount (struct buffer_head * p_s_bh); 1808extern void decrement_bcount(struct buffer_head *p_s_bh);
1844void decrement_counters_in_path (struct path * p_s_search_path); 1809void decrement_counters_in_path(struct path *p_s_search_path);
1845void pathrelse (struct path * p_s_search_path); 1810void pathrelse(struct path *p_s_search_path);
1846int reiserfs_check_path(struct path *p) ; 1811int reiserfs_check_path(struct path *p);
1847void pathrelse_and_restore (struct super_block *s, struct path * p_s_search_path); 1812void pathrelse_and_restore(struct super_block *s, struct path *p_s_search_path);
1848 1813
1849int reiserfs_insert_item (struct reiserfs_transaction_handle *th, 1814int reiserfs_insert_item(struct reiserfs_transaction_handle *th,
1850 struct path * path, 1815 struct path *path,
1851 const struct cpu_key * key, 1816 const struct cpu_key *key,
1852 struct item_head * ih, 1817 struct item_head *ih,
1853 struct inode *inode, const char * body); 1818 struct inode *inode, const char *body);
1854 1819
1855int reiserfs_paste_into_item (struct reiserfs_transaction_handle *th, 1820int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th,
1856 struct path * path, 1821 struct path *path,
1857 const struct cpu_key * key, 1822 const struct cpu_key *key,
1858 struct inode *inode, 1823 struct inode *inode,
1859 const char * body, int paste_size); 1824 const char *body, int paste_size);
1860 1825
1861int reiserfs_cut_from_item (struct reiserfs_transaction_handle *th, 1826int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th,
1862 struct path * path, 1827 struct path *path,
1863 struct cpu_key * key, 1828 struct cpu_key *key,
1864 struct inode * inode, 1829 struct inode *inode,
1865 struct page *page, 1830 struct page *page, loff_t new_file_size);
1866 loff_t new_file_size); 1831
1867 1832int reiserfs_delete_item(struct reiserfs_transaction_handle *th,
1868int reiserfs_delete_item (struct reiserfs_transaction_handle *th, 1833 struct path *path,
1869 struct path * path, 1834 const struct cpu_key *key,
1870 const struct cpu_key * key, 1835 struct inode *inode, struct buffer_head *p_s_un_bh);
1871 struct inode * inode, 1836
1872 struct buffer_head * p_s_un_bh); 1837void reiserfs_delete_solid_item(struct reiserfs_transaction_handle *th,
1873 1838 struct inode *inode, struct reiserfs_key *key);
1874void reiserfs_delete_solid_item (struct reiserfs_transaction_handle *th, 1839int reiserfs_delete_object(struct reiserfs_transaction_handle *th,
1875 struct inode *inode, struct reiserfs_key * key); 1840 struct inode *p_s_inode);
1876int reiserfs_delete_object (struct reiserfs_transaction_handle *th, struct inode * p_s_inode); 1841int reiserfs_do_truncate(struct reiserfs_transaction_handle *th,
1877int reiserfs_do_truncate (struct reiserfs_transaction_handle *th, 1842 struct inode *p_s_inode, struct page *,
1878 struct inode * p_s_inode, struct page *, 1843 int update_timestamps);
1879 int update_timestamps);
1880 1844
1881#define i_block_size(inode) ((inode)->i_sb->s_blocksize) 1845#define i_block_size(inode) ((inode)->i_sb->s_blocksize)
1882#define file_size(inode) ((inode)->i_size) 1846#define file_size(inode) ((inode)->i_size)
@@ -1885,66 +1849,67 @@ int reiserfs_do_truncate (struct reiserfs_transaction_handle *th,
1885#define tail_has_to_be_packed(inode) (have_large_tails ((inode)->i_sb)?\ 1849#define tail_has_to_be_packed(inode) (have_large_tails ((inode)->i_sb)?\
1886!STORE_TAIL_IN_UNFM_S1(file_size (inode), tail_size(inode), inode->i_sb->s_blocksize):have_small_tails ((inode)->i_sb)?!STORE_TAIL_IN_UNFM_S2(file_size (inode), tail_size(inode), inode->i_sb->s_blocksize):0 ) 1850!STORE_TAIL_IN_UNFM_S1(file_size (inode), tail_size(inode), inode->i_sb->s_blocksize):have_small_tails ((inode)->i_sb)?!STORE_TAIL_IN_UNFM_S2(file_size (inode), tail_size(inode), inode->i_sb->s_blocksize):0 )
1887 1851
1888void padd_item (char * item, int total_length, int length); 1852void padd_item(char *item, int total_length, int length);
1889 1853
1890/* inode.c */ 1854/* inode.c */
1891/* args for the create parameter of reiserfs_get_block */ 1855/* args for the create parameter of reiserfs_get_block */
1892#define GET_BLOCK_NO_CREATE 0 /* don't create new blocks or convert tails */ 1856#define GET_BLOCK_NO_CREATE 0 /* don't create new blocks or convert tails */
1893#define GET_BLOCK_CREATE 1 /* add anything you need to find block */ 1857#define GET_BLOCK_CREATE 1 /* add anything you need to find block */
1894#define GET_BLOCK_NO_HOLE 2 /* return -ENOENT for file holes */ 1858#define GET_BLOCK_NO_HOLE 2 /* return -ENOENT for file holes */
1895#define GET_BLOCK_READ_DIRECT 4 /* read the tail if indirect item not found */ 1859#define GET_BLOCK_READ_DIRECT 4 /* read the tail if indirect item not found */
1896#define GET_BLOCK_NO_ISEM 8 /* i_sem is not held, don't preallocate */ 1860#define GET_BLOCK_NO_ISEM 8 /* i_sem is not held, don't preallocate */
1897#define GET_BLOCK_NO_DANGLE 16 /* don't leave any transactions running */ 1861#define GET_BLOCK_NO_DANGLE 16 /* don't leave any transactions running */
1898 1862
1899int restart_transaction(struct reiserfs_transaction_handle *th, struct inode *inode, struct path *path); 1863int restart_transaction(struct reiserfs_transaction_handle *th,
1900void reiserfs_read_locked_inode(struct inode * inode, struct reiserfs_iget_args *args) ; 1864 struct inode *inode, struct path *path);
1901int reiserfs_find_actor(struct inode * inode, void *p) ; 1865void reiserfs_read_locked_inode(struct inode *inode,
1902int reiserfs_init_locked_inode(struct inode * inode, void *p) ; 1866 struct reiserfs_iget_args *args);
1903void reiserfs_delete_inode (struct inode * inode); 1867int reiserfs_find_actor(struct inode *inode, void *p);
1904int reiserfs_write_inode (struct inode * inode, int) ; 1868int reiserfs_init_locked_inode(struct inode *inode, void *p);
1905int reiserfs_get_block (struct inode * inode, sector_t block, struct buffer_head * bh_result, int create); 1869void reiserfs_delete_inode(struct inode *inode);
1906struct dentry *reiserfs_get_dentry(struct super_block *, void *) ; 1870int reiserfs_write_inode(struct inode *inode, int);
1907struct dentry *reiserfs_decode_fh(struct super_block *sb, __u32 *data, 1871int reiserfs_get_block(struct inode *inode, sector_t block,
1908 int len, int fhtype, 1872 struct buffer_head *bh_result, int create);
1909 int (*acceptable)(void *contect, struct dentry *de), 1873struct dentry *reiserfs_get_dentry(struct super_block *, void *);
1910 void *context) ; 1874struct dentry *reiserfs_decode_fh(struct super_block *sb, __u32 * data,
1911int reiserfs_encode_fh( struct dentry *dentry, __u32 *data, int *lenp, 1875 int len, int fhtype,
1912 int connectable ); 1876 int (*acceptable) (void *contect,
1913 1877 struct dentry * de),
1914int reiserfs_truncate_file(struct inode *, int update_timestamps) ; 1878 void *context);
1915void make_cpu_key (struct cpu_key * cpu_key, struct inode * inode, loff_t offset, 1879int reiserfs_encode_fh(struct dentry *dentry, __u32 * data, int *lenp,
1916 int type, int key_length); 1880 int connectable);
1917void make_le_item_head (struct item_head * ih, const struct cpu_key * key, 1881
1918 int version, 1882int reiserfs_truncate_file(struct inode *, int update_timestamps);
1919 loff_t offset, int type, int length, int entry_count); 1883void make_cpu_key(struct cpu_key *cpu_key, struct inode *inode, loff_t offset,
1920struct inode * reiserfs_iget (struct super_block * s, 1884 int type, int key_length);
1921 const struct cpu_key * key); 1885void make_le_item_head(struct item_head *ih, const struct cpu_key *key,
1922 1886 int version,
1923 1887 loff_t offset, int type, int length, int entry_count);
1924int reiserfs_new_inode (struct reiserfs_transaction_handle *th, 1888struct inode *reiserfs_iget(struct super_block *s, const struct cpu_key *key);
1925 struct inode * dir, int mode, 1889
1926 const char * symname, loff_t i_size, 1890int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
1927 struct dentry *dentry, struct inode *inode); 1891 struct inode *dir, int mode,
1928 1892 const char *symname, loff_t i_size,
1929void reiserfs_update_sd_size (struct reiserfs_transaction_handle *th, 1893 struct dentry *dentry, struct inode *inode);
1930 struct inode * inode, loff_t size); 1894
1895void reiserfs_update_sd_size(struct reiserfs_transaction_handle *th,
1896 struct inode *inode, loff_t size);
1931 1897
1932static inline void reiserfs_update_sd(struct reiserfs_transaction_handle *th, 1898static inline void reiserfs_update_sd(struct reiserfs_transaction_handle *th,
1933 struct inode *inode) 1899 struct inode *inode)
1934{ 1900{
1935 reiserfs_update_sd_size(th, inode, inode->i_size) ; 1901 reiserfs_update_sd_size(th, inode, inode->i_size);
1936} 1902}
1937 1903
1938void sd_attrs_to_i_attrs( __u16 sd_attrs, struct inode *inode ); 1904void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
1939void i_attrs_to_sd_attrs( struct inode *inode, __u16 *sd_attrs ); 1905void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
1940int reiserfs_setattr(struct dentry *dentry, struct iattr *attr); 1906int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
1941 1907
1942/* namei.c */ 1908/* namei.c */
1943void set_de_name_and_namelen (struct reiserfs_dir_entry * de); 1909void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
1944int search_by_entry_key (struct super_block * sb, const struct cpu_key * key, 1910int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
1945 struct path * path, 1911 struct path *path, struct reiserfs_dir_entry *de);
1946 struct reiserfs_dir_entry * de); 1912struct dentry *reiserfs_get_parent(struct dentry *);
1947struct dentry *reiserfs_get_parent(struct dentry *) ;
1948/* procfs.c */ 1913/* procfs.c */
1949 1914
1950#if defined( CONFIG_PROC_FS ) && defined( CONFIG_REISERFS_PROC_INFO ) 1915#if defined( CONFIG_PROC_FS ) && defined( CONFIG_REISERFS_PROC_INFO )
@@ -1953,15 +1918,15 @@ struct dentry *reiserfs_get_parent(struct dentry *) ;
1953#undef REISERFS_PROC_INFO 1918#undef REISERFS_PROC_INFO
1954#endif 1919#endif
1955 1920
1956int reiserfs_proc_info_init( struct super_block *sb ); 1921int reiserfs_proc_info_init(struct super_block *sb);
1957int reiserfs_proc_info_done( struct super_block *sb ); 1922int reiserfs_proc_info_done(struct super_block *sb);
1958struct proc_dir_entry *reiserfs_proc_register_global( char *name, 1923struct proc_dir_entry *reiserfs_proc_register_global(char *name,
1959 read_proc_t *func ); 1924 read_proc_t * func);
1960void reiserfs_proc_unregister_global( const char *name ); 1925void reiserfs_proc_unregister_global(const char *name);
1961int reiserfs_proc_info_global_init( void ); 1926int reiserfs_proc_info_global_init(void);
1962int reiserfs_proc_info_global_done( void ); 1927int reiserfs_proc_info_global_done(void);
1963int reiserfs_global_version_in_proc( char *buffer, char **start, off_t offset, 1928int reiserfs_global_version_in_proc(char *buffer, char **start, off_t offset,
1964 int count, int *eof, void *data ); 1929 int count, int *eof, void *data);
1965 1930
1966#if defined( REISERFS_PROC_INFO ) 1931#if defined( REISERFS_PROC_INFO )
1967 1932
@@ -1993,123 +1958,132 @@ extern struct inode_operations reiserfs_special_inode_operations;
1993extern struct file_operations reiserfs_dir_operations; 1958extern struct file_operations reiserfs_dir_operations;
1994 1959
1995/* tail_conversion.c */ 1960/* tail_conversion.c */
1996int direct2indirect (struct reiserfs_transaction_handle *, struct inode *, struct path *, struct buffer_head *, loff_t); 1961int direct2indirect(struct reiserfs_transaction_handle *, struct inode *,
1997int indirect2direct (struct reiserfs_transaction_handle *, struct inode *, struct page *, struct path *, const struct cpu_key *, loff_t, char *); 1962 struct path *, struct buffer_head *, loff_t);
1998void reiserfs_unmap_buffer(struct buffer_head *) ; 1963int indirect2direct(struct reiserfs_transaction_handle *, struct inode *,
1999 1964 struct page *, struct path *, const struct cpu_key *,
1965 loff_t, char *);
1966void reiserfs_unmap_buffer(struct buffer_head *);
2000 1967
2001/* file.c */ 1968/* file.c */
2002extern struct inode_operations reiserfs_file_inode_operations; 1969extern struct inode_operations reiserfs_file_inode_operations;
2003extern struct file_operations reiserfs_file_operations; 1970extern struct file_operations reiserfs_file_operations;
2004extern struct address_space_operations reiserfs_address_space_operations ; 1971extern struct address_space_operations reiserfs_address_space_operations;
2005 1972
2006/* fix_nodes.c */ 1973/* fix_nodes.c */
2007#ifdef CONFIG_REISERFS_CHECK 1974#ifdef CONFIG_REISERFS_CHECK
2008void * reiserfs_kmalloc (size_t size, int flags, struct super_block * s); 1975void *reiserfs_kmalloc(size_t size, int flags, struct super_block *s);
2009void reiserfs_kfree (const void * vp, size_t size, struct super_block * s); 1976void reiserfs_kfree(const void *vp, size_t size, struct super_block *s);
2010#else 1977#else
2011static inline void *reiserfs_kmalloc(size_t size, int flags, 1978static inline void *reiserfs_kmalloc(size_t size, int flags,
2012 struct super_block *s) 1979 struct super_block *s)
2013{ 1980{
2014 return kmalloc(size, flags); 1981 return kmalloc(size, flags);
2015} 1982}
2016 1983
2017static inline void reiserfs_kfree(const void *vp, size_t size, 1984static inline void reiserfs_kfree(const void *vp, size_t size,
2018 struct super_block *s) 1985 struct super_block *s)
2019{ 1986{
2020 kfree(vp); 1987 kfree(vp);
2021} 1988}
2022#endif 1989#endif
2023 1990
2024int fix_nodes (int n_op_mode, struct tree_balance * p_s_tb, 1991int fix_nodes(int n_op_mode, struct tree_balance *p_s_tb,
2025 struct item_head * p_s_ins_ih, const void *); 1992 struct item_head *p_s_ins_ih, const void *);
2026void unfix_nodes (struct tree_balance *); 1993void unfix_nodes(struct tree_balance *);
2027
2028 1994
2029/* prints.c */ 1995/* prints.c */
2030void reiserfs_panic (struct super_block * s, const char * fmt, ...) __attribute__ ( ( noreturn ) ); 1996void reiserfs_panic(struct super_block *s, const char *fmt, ...)
2031void reiserfs_info (struct super_block *s, const char * fmt, ...); 1997 __attribute__ ((noreturn));
2032void reiserfs_debug (struct super_block *s, int level, const char * fmt, ...); 1998void reiserfs_info(struct super_block *s, const char *fmt, ...);
2033void print_indirect_item (struct buffer_head * bh, int item_num); 1999void reiserfs_debug(struct super_block *s, int level, const char *fmt, ...);
2034void store_print_tb (struct tree_balance * tb); 2000void print_indirect_item(struct buffer_head *bh, int item_num);
2035void print_cur_tb (char * mes); 2001void store_print_tb(struct tree_balance *tb);
2036void print_de (struct reiserfs_dir_entry * de); 2002void print_cur_tb(char *mes);
2037void print_bi (struct buffer_info * bi, char * mes); 2003void print_de(struct reiserfs_dir_entry *de);
2038#define PRINT_LEAF_ITEMS 1 /* print all items */ 2004void print_bi(struct buffer_info *bi, char *mes);
2039#define PRINT_DIRECTORY_ITEMS 2 /* print directory items */ 2005#define PRINT_LEAF_ITEMS 1 /* print all items */
2040#define PRINT_DIRECT_ITEMS 4 /* print contents of direct items */ 2006#define PRINT_DIRECTORY_ITEMS 2 /* print directory items */
2041void print_block (struct buffer_head * bh, ...); 2007#define PRINT_DIRECT_ITEMS 4 /* print contents of direct items */
2042void print_bmap (struct super_block * s, int silent); 2008void print_block(struct buffer_head *bh, ...);
2043void print_bmap_block (int i, char * data, int size, int silent); 2009void print_bmap(struct super_block *s, int silent);
2010void print_bmap_block(int i, char *data, int size, int silent);
2044/*void print_super_block (struct super_block * s, char * mes);*/ 2011/*void print_super_block (struct super_block * s, char * mes);*/
2045void print_objectid_map (struct super_block * s); 2012void print_objectid_map(struct super_block *s);
2046void print_block_head (struct buffer_head * bh, char * mes); 2013void print_block_head(struct buffer_head *bh, char *mes);
2047void check_leaf (struct buffer_head * bh); 2014void check_leaf(struct buffer_head *bh);
2048void check_internal (struct buffer_head * bh); 2015void check_internal(struct buffer_head *bh);
2049void print_statistics (struct super_block * s); 2016void print_statistics(struct super_block *s);
2050char * reiserfs_hashname(int code); 2017char *reiserfs_hashname(int code);
2051 2018
2052/* lbalance.c */ 2019/* lbalance.c */
2053int leaf_move_items (int shift_mode, struct tree_balance * tb, int mov_num, int mov_bytes, struct buffer_head * Snew); 2020int leaf_move_items(int shift_mode, struct tree_balance *tb, int mov_num,
2054int leaf_shift_left (struct tree_balance * tb, int shift_num, int shift_bytes); 2021 int mov_bytes, struct buffer_head *Snew);
2055int leaf_shift_right (struct tree_balance * tb, int shift_num, int shift_bytes); 2022int leaf_shift_left(struct tree_balance *tb, int shift_num, int shift_bytes);
2056void leaf_delete_items (struct buffer_info * cur_bi, int last_first, int first, int del_num, int del_bytes); 2023int leaf_shift_right(struct tree_balance *tb, int shift_num, int shift_bytes);
2057void leaf_insert_into_buf (struct buffer_info * bi, int before, 2024void leaf_delete_items(struct buffer_info *cur_bi, int last_first, int first,
2058 struct item_head * inserted_item_ih, const char * inserted_item_body, int zeros_number); 2025 int del_num, int del_bytes);
2059void leaf_paste_in_buffer (struct buffer_info * bi, int pasted_item_num, 2026void leaf_insert_into_buf(struct buffer_info *bi, int before,
2060 int pos_in_item, int paste_size, const char * body, int zeros_number); 2027 struct item_head *inserted_item_ih,
2061void leaf_cut_from_buffer (struct buffer_info * bi, int cut_item_num, int pos_in_item, 2028 const char *inserted_item_body, int zeros_number);
2062 int cut_size); 2029void leaf_paste_in_buffer(struct buffer_info *bi, int pasted_item_num,
2063void leaf_paste_entries (struct buffer_head * bh, int item_num, int before, 2030 int pos_in_item, int paste_size, const char *body,
2064 int new_entry_count, struct reiserfs_de_head * new_dehs, const char * records, int paste_size); 2031 int zeros_number);
2032void leaf_cut_from_buffer(struct buffer_info *bi, int cut_item_num,
2033 int pos_in_item, int cut_size);
2034void leaf_paste_entries(struct buffer_head *bh, int item_num, int before,
2035 int new_entry_count, struct reiserfs_de_head *new_dehs,
2036 const char *records, int paste_size);
2065/* ibalance.c */ 2037/* ibalance.c */
2066int balance_internal (struct tree_balance * , int, int, struct item_head * , 2038int balance_internal(struct tree_balance *, int, int, struct item_head *,
2067 struct buffer_head **); 2039 struct buffer_head **);
2068 2040
2069/* do_balance.c */ 2041/* do_balance.c */
2070void do_balance_mark_leaf_dirty (struct tree_balance * tb, 2042void do_balance_mark_leaf_dirty(struct tree_balance *tb,
2071 struct buffer_head * bh, int flag); 2043 struct buffer_head *bh, int flag);
2072#define do_balance_mark_internal_dirty do_balance_mark_leaf_dirty 2044#define do_balance_mark_internal_dirty do_balance_mark_leaf_dirty
2073#define do_balance_mark_sb_dirty do_balance_mark_leaf_dirty 2045#define do_balance_mark_sb_dirty do_balance_mark_leaf_dirty
2074 2046
2075void do_balance (struct tree_balance * tb, struct item_head * ih, 2047void do_balance(struct tree_balance *tb, struct item_head *ih,
2076 const char * body, int flag); 2048 const char *body, int flag);
2077void reiserfs_invalidate_buffer (struct tree_balance * tb, struct buffer_head * bh); 2049void reiserfs_invalidate_buffer(struct tree_balance *tb,
2050 struct buffer_head *bh);
2078 2051
2079int get_left_neighbor_position (struct tree_balance * tb, int h); 2052int get_left_neighbor_position(struct tree_balance *tb, int h);
2080int get_right_neighbor_position (struct tree_balance * tb, int h); 2053int get_right_neighbor_position(struct tree_balance *tb, int h);
2081void replace_key (struct tree_balance * tb, struct buffer_head *, int, struct buffer_head *, int); 2054void replace_key(struct tree_balance *tb, struct buffer_head *, int,
2082void make_empty_node (struct buffer_info *); 2055 struct buffer_head *, int);
2083struct buffer_head * get_FEB (struct tree_balance *); 2056void make_empty_node(struct buffer_info *);
2057struct buffer_head *get_FEB(struct tree_balance *);
2084 2058
2085/* bitmap.c */ 2059/* bitmap.c */
2086 2060
2087/* structure contains hints for block allocator, and it is a container for 2061/* structure contains hints for block allocator, and it is a container for
2088 * arguments, such as node, search path, transaction_handle, etc. */ 2062 * arguments, such as node, search path, transaction_handle, etc. */
2089 struct __reiserfs_blocknr_hint { 2063struct __reiserfs_blocknr_hint {
2090 struct inode * inode; /* inode passed to allocator, if we allocate unf. nodes */ 2064 struct inode *inode; /* inode passed to allocator, if we allocate unf. nodes */
2091 long block; /* file offset, in blocks */ 2065 long block; /* file offset, in blocks */
2092 struct in_core_key key; 2066 struct in_core_key key;
2093 struct path * path; /* search path, used by allocator to deternine search_start by 2067 struct path *path; /* search path, used by allocator to deternine search_start by
2094 * various ways */ 2068 * various ways */
2095 struct reiserfs_transaction_handle * th; /* transaction handle is needed to log super blocks and 2069 struct reiserfs_transaction_handle *th; /* transaction handle is needed to log super blocks and
2096 * bitmap blocks changes */ 2070 * bitmap blocks changes */
2097 b_blocknr_t beg, end; 2071 b_blocknr_t beg, end;
2098 b_blocknr_t search_start; /* a field used to transfer search start value (block number) 2072 b_blocknr_t search_start; /* a field used to transfer search start value (block number)
2099 * between different block allocator procedures 2073 * between different block allocator procedures
2100 * (determine_search_start() and others) */ 2074 * (determine_search_start() and others) */
2101 int prealloc_size; /* is set in determine_prealloc_size() function, used by underlayed 2075 int prealloc_size; /* is set in determine_prealloc_size() function, used by underlayed
2102 * function that do actual allocation */ 2076 * function that do actual allocation */
2103 2077
2104 unsigned formatted_node:1; /* the allocator uses different polices for getting disk space for 2078 unsigned formatted_node:1; /* the allocator uses different polices for getting disk space for
2105 * formatted/unformatted blocks with/without preallocation */ 2079 * formatted/unformatted blocks with/without preallocation */
2106 unsigned preallocate:1; 2080 unsigned preallocate:1;
2107}; 2081};
2108 2082
2109typedef struct __reiserfs_blocknr_hint reiserfs_blocknr_hint_t; 2083typedef struct __reiserfs_blocknr_hint reiserfs_blocknr_hint_t;
2110 2084
2111int reiserfs_parse_alloc_options (struct super_block *, char *); 2085int reiserfs_parse_alloc_options(struct super_block *, char *);
2112void reiserfs_init_alloc_options (struct super_block *s); 2086void reiserfs_init_alloc_options(struct super_block *s);
2113 2087
2114/* 2088/*
2115 * given a directory, this will tell you what packing locality 2089 * given a directory, this will tell you what packing locality
@@ -2118,68 +2092,72 @@ void reiserfs_init_alloc_options (struct super_block *s);
2118 */ 2092 */
2119__le32 reiserfs_choose_packing(struct inode *dir); 2093__le32 reiserfs_choose_packing(struct inode *dir);
2120 2094
2121int is_reusable (struct super_block * s, b_blocknr_t block, int bit_value); 2095int is_reusable(struct super_block *s, b_blocknr_t block, int bit_value);
2122void reiserfs_free_block (struct reiserfs_transaction_handle *th, struct inode *, b_blocknr_t, int for_unformatted); 2096void reiserfs_free_block(struct reiserfs_transaction_handle *th, struct inode *,
2123int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t *, b_blocknr_t * , int, int); 2097 b_blocknr_t, int for_unformatted);
2124extern inline int reiserfs_new_form_blocknrs (struct tree_balance * tb, 2098int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t *, b_blocknr_t *, int,
2125 b_blocknr_t *new_blocknrs, int amount_needed) 2099 int);
2100extern inline int reiserfs_new_form_blocknrs(struct tree_balance *tb,
2101 b_blocknr_t * new_blocknrs,
2102 int amount_needed)
2126{ 2103{
2127 reiserfs_blocknr_hint_t hint = { 2104 reiserfs_blocknr_hint_t hint = {
2128 .th = tb->transaction_handle, 2105 .th = tb->transaction_handle,
2129 .path = tb->tb_path, 2106 .path = tb->tb_path,
2130 .inode = NULL, 2107 .inode = NULL,
2131 .key = tb->key, 2108 .key = tb->key,
2132 .block = 0, 2109 .block = 0,
2133 .formatted_node = 1 2110 .formatted_node = 1
2134 }; 2111 };
2135 return reiserfs_allocate_blocknrs(&hint, new_blocknrs, amount_needed, 0); 2112 return reiserfs_allocate_blocknrs(&hint, new_blocknrs, amount_needed,
2113 0);
2136} 2114}
2137 2115
2138extern inline int reiserfs_new_unf_blocknrs (struct reiserfs_transaction_handle *th, 2116extern inline int reiserfs_new_unf_blocknrs(struct reiserfs_transaction_handle
2139 struct inode *inode, 2117 *th, struct inode *inode,
2140 b_blocknr_t *new_blocknrs, 2118 b_blocknr_t * new_blocknrs,
2141 struct path * path, long block) 2119 struct path *path, long block)
2142{ 2120{
2143 reiserfs_blocknr_hint_t hint = { 2121 reiserfs_blocknr_hint_t hint = {
2144 .th = th, 2122 .th = th,
2145 .path = path, 2123 .path = path,
2146 .inode = inode, 2124 .inode = inode,
2147 .block = block, 2125 .block = block,
2148 .formatted_node = 0, 2126 .formatted_node = 0,
2149 .preallocate = 0 2127 .preallocate = 0
2150 }; 2128 };
2151 return reiserfs_allocate_blocknrs(&hint, new_blocknrs, 1, 0); 2129 return reiserfs_allocate_blocknrs(&hint, new_blocknrs, 1, 0);
2152} 2130}
2153 2131
2154#ifdef REISERFS_PREALLOCATE 2132#ifdef REISERFS_PREALLOCATE
2155extern inline int reiserfs_new_unf_blocknrs2(struct reiserfs_transaction_handle *th, 2133extern inline int reiserfs_new_unf_blocknrs2(struct reiserfs_transaction_handle
2156 struct inode * inode, 2134 *th, struct inode *inode,
2157 b_blocknr_t *new_blocknrs, 2135 b_blocknr_t * new_blocknrs,
2158 struct path * path, long block) 2136 struct path *path, long block)
2159{ 2137{
2160 reiserfs_blocknr_hint_t hint = { 2138 reiserfs_blocknr_hint_t hint = {
2161 .th = th, 2139 .th = th,
2162 .path = path, 2140 .path = path,
2163 .inode = inode, 2141 .inode = inode,
2164 .block = block, 2142 .block = block,
2165 .formatted_node = 0, 2143 .formatted_node = 0,
2166 .preallocate = 1 2144 .preallocate = 1
2167 }; 2145 };
2168 return reiserfs_allocate_blocknrs(&hint, new_blocknrs, 1, 0); 2146 return reiserfs_allocate_blocknrs(&hint, new_blocknrs, 1, 0);
2169} 2147}
2170 2148
2171void reiserfs_discard_prealloc (struct reiserfs_transaction_handle *th, 2149void reiserfs_discard_prealloc(struct reiserfs_transaction_handle *th,
2172 struct inode * inode); 2150 struct inode *inode);
2173void reiserfs_discard_all_prealloc (struct reiserfs_transaction_handle *th); 2151void reiserfs_discard_all_prealloc(struct reiserfs_transaction_handle *th);
2174#endif 2152#endif
2175void reiserfs_claim_blocks_to_be_allocated( struct super_block *sb, int blocks); 2153void reiserfs_claim_blocks_to_be_allocated(struct super_block *sb, int blocks);
2176void reiserfs_release_claimed_blocks( struct super_block *sb, int blocks); 2154void reiserfs_release_claimed_blocks(struct super_block *sb, int blocks);
2177int reiserfs_can_fit_pages(struct super_block *sb); 2155int reiserfs_can_fit_pages(struct super_block *sb);
2178 2156
2179/* hashes.c */ 2157/* hashes.c */
2180__u32 keyed_hash (const signed char *msg, int len); 2158__u32 keyed_hash(const signed char *msg, int len);
2181__u32 yura_hash (const signed char *msg, int len); 2159__u32 yura_hash(const signed char *msg, int len);
2182__u32 r5_hash (const signed char *msg, int len); 2160__u32 r5_hash(const signed char *msg, int len);
2183 2161
2184/* the ext2 bit routines adjust for big or little endian as 2162/* the ext2 bit routines adjust for big or little endian as
2185** appropriate for the arch, so in our laziness we use them rather 2163** appropriate for the arch, so in our laziness we use them rather
@@ -2199,11 +2177,10 @@ __u32 r5_hash (const signed char *msg, int len);
2199 absolutely safe */ 2177 absolutely safe */
2200#define SPARE_SPACE 500 2178#define SPARE_SPACE 500
2201 2179
2202
2203/* prototypes from ioctl.c */ 2180/* prototypes from ioctl.c */
2204int reiserfs_ioctl (struct inode * inode, struct file * filp, 2181int reiserfs_ioctl(struct inode *inode, struct file *filp,
2205 unsigned int cmd, unsigned long arg); 2182 unsigned int cmd, unsigned long arg);
2206 2183
2207/* ioctl's command */ 2184/* ioctl's command */
2208#define REISERFS_IOC_UNPACK _IOW(0xCD,1,long) 2185#define REISERFS_IOC_UNPACK _IOW(0xCD,1,long)
2209/* define following flags to be the same as in ext2, so that chattr(1), 2186/* define following flags to be the same as in ext2, so that chattr(1),
@@ -2218,10 +2195,8 @@ int reiserfs_ioctl (struct inode * inode, struct file * filp,
2218 would evolve into real per-fs locks */ 2195 would evolve into real per-fs locks */
2219#define reiserfs_write_lock( sb ) lock_kernel() 2196#define reiserfs_write_lock( sb ) lock_kernel()
2220#define reiserfs_write_unlock( sb ) unlock_kernel() 2197#define reiserfs_write_unlock( sb ) unlock_kernel()
2221 2198
2222/* xattr stuff */ 2199/* xattr stuff */
2223#define REISERFS_XATTR_DIR_SEM(s) (REISERFS_SB(s)->xattr_dir_sem) 2200#define REISERFS_XATTR_DIR_SEM(s) (REISERFS_SB(s)->xattr_dir_sem)
2224 2201
2225#endif /* _LINUX_REISER_FS_H */ 2202#endif /* _LINUX_REISER_FS_H */
2226
2227