From: Al Viro struct reiserfs_key cloned; (currently) identical struct in_core_key added. Places that expect host-endian data in reiserfs_key switched to in_core_key. Basically, we get annotation of reiserfs_key users and keep the resulting tree obviously equivalent to original. Signed-off-by: Al Viro Cc: Signed-off-by: Andrew Morton --- fs/reiserfs/bitmap.c | 4 ++-- fs/reiserfs/stree.c | 1 + fs/reiserfs/super.c | 4 ++-- include/linux/reiserfs_fs.h | 32 +++++++++++++++++++++++++++++--- 4 files changed, 34 insertions(+), 7 deletions(-) diff -puN fs/reiserfs/bitmap.c~reiserfs-endianness-clone-struct-reiserfs_key fs/reiserfs/bitmap.c --- 25/fs/reiserfs/bitmap.c~reiserfs-endianness-clone-struct-reiserfs_key 2005-04-26 20:29:28.161919520 -0700 +++ 25-akpm/fs/reiserfs/bitmap.c 2005-04-26 20:29:28.172917848 -0700 @@ -736,7 +736,7 @@ static inline int this_blocknr_allocatio #ifdef DISPLACE_NEW_PACKING_LOCALITIES static inline void displace_new_packing_locality (reiserfs_blocknr_hint_t *hint) { - struct reiserfs_key * key = &hint->key; + struct in_core_key * key = &hint->key; hint->th->displace_new_blocks = 0; hint->search_start = hint->beg + keyed_hash((char*)(&key->k_objectid),4) % (hint->end - hint->beg); @@ -777,7 +777,7 @@ static inline int old_way (reiserfs_bloc static inline void hundredth_slices (reiserfs_blocknr_hint_t * hint) { - struct reiserfs_key * key = &hint->key; + struct in_core_key * key = &hint->key; b_blocknr_t slice_start; slice_start = (keyed_hash((char*)(&key->k_dir_id),4) % 100) * (hint->end / 100); diff -puN fs/reiserfs/stree.c~reiserfs-endianness-clone-struct-reiserfs_key fs/reiserfs/stree.c --- 25/fs/reiserfs/stree.c~reiserfs-endianness-clone-struct-reiserfs_key 2005-04-26 20:29:28.164919064 -0700 +++ 25-akpm/fs/reiserfs/stree.c 2005-04-26 20:29:28.174917544 -0700 @@ -229,6 +229,7 @@ const struct reiserfs_key MIN_KEY = {0, /* Maximal possible key. It is never in the tree. */ const struct reiserfs_key MAX_KEY = {0xffffffff, 0xffffffff, {{0xffffffff, 0xffffffff},}}; +const struct in_core_key MAX_IN_CORE_KEY = {0xffffffff, 0xffffffff, {{0xffffffff, 0xffffffff},}}; /* Get delimiting key of the buffer by looking for it in the buffers in the path, starting from the bottom diff -puN fs/reiserfs/super.c~reiserfs-endianness-clone-struct-reiserfs_key fs/reiserfs/super.c --- 25/fs/reiserfs/super.c~reiserfs-endianness-clone-struct-reiserfs_key 2005-04-26 20:29:28.166918760 -0700 +++ 25-akpm/fs/reiserfs/super.c 2005-04-26 20:29:28.176917240 -0700 @@ -110,7 +110,7 @@ static void reiserfs_unlockfs(struct sup reiserfs_allow_writes(s) ; } -extern const struct reiserfs_key MAX_KEY; +extern const struct in_core_key MAX_IN_CORE_KEY; /* this is used to delete "save link" when there are no items of a @@ -163,7 +163,7 @@ static int finish_unfinished (struct sup /* compose key to look for "save" links */ max_cpu_key.version = KEY_FORMAT_3_5; - max_cpu_key.on_disk_key = MAX_KEY; + max_cpu_key.on_disk_key = MAX_IN_CORE_KEY; max_cpu_key.key_length = 3; #ifdef CONFIG_QUOTA diff -puN include/linux/reiserfs_fs.h~reiserfs-endianness-clone-struct-reiserfs_key include/linux/reiserfs_fs.h --- 25/include/linux/reiserfs_fs.h~reiserfs-endianness-clone-struct-reiserfs_key 2005-04-26 20:29:28.168918456 -0700 +++ 25-akpm/include/linux/reiserfs_fs.h 2005-04-26 20:29:28.179916784 -0700 @@ -433,6 +433,23 @@ static inline void set_offset_v2_k_offse # define set_offset_v2_k_offset(v2,val) (offset_v2_k_offset(v2) = (val)) #endif +struct in_core_offset_v1 { + __u32 k_offset; + __u32 k_uniqueness; +} __attribute__ ((__packed__)); + +struct in_core_offset_v2 { +#ifdef __LITTLE_ENDIAN + /* little endian version */ + __u64 k_offset:60; + __u64 k_type: 4; +#else + /* big endian version */ + __u64 k_type: 4; + __u64 k_offset:60; +#endif +} __attribute__ ((__packed__)); + /* Key of an item determines its location in the S+tree, and is composed of 4 components */ struct reiserfs_key { @@ -445,9 +462,18 @@ struct reiserfs_key { } __attribute__ ((__packed__)) u; } __attribute__ ((__packed__)); +struct in_core_key { + __u32 k_dir_id; /* packing locality: by default parent + directory object id */ + __u32 k_objectid; /* object identifier */ + union { + struct in_core_offset_v1 k_offset_v1; + struct in_core_offset_v2 k_offset_v2; + } __attribute__ ((__packed__)) u; +} __attribute__ ((__packed__)); struct cpu_key { - struct reiserfs_key on_disk_key; + struct in_core_key on_disk_key; int version; int key_length; /* 3 in all cases but direct2indirect and indirect2direct conversion */ @@ -1476,7 +1502,7 @@ struct tree_balance int fs_gen; /* saved value of `reiserfs_generation' counter see FILESYSTEM_CHANGED() macro in reiserfs_fs.h */ #ifdef DISPLACE_NEW_PACKING_LOCALITIES - struct reiserfs_key key; /* key pointer, to pass to block allocator or + struct in_core_key key; /* key pointer, to pass to block allocator or another low-level subsystem */ #endif } ; @@ -2117,7 +2143,7 @@ struct buffer_head * get_FEB (struct tre struct __reiserfs_blocknr_hint { struct inode * inode; /* inode passed to allocator, if we allocate unf. nodes */ long block; /* file offset, in blocks */ - struct reiserfs_key key; + struct in_core_key key; struct path * path; /* search path, used by allocator to deternine search_start by * various ways */ struct reiserfs_transaction_handle * th; /* transaction handle is needed to log super blocks and _