aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@www.linux.org.uk>2005-05-01 11:59:19 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-01 11:59:19 -0400
commit6b9f5829e6e3af44f20c681e26524c637d4f82ff (patch)
tree2694220606477b9afc5a98d73f6980e334048c1f /fs
parentb8cc936f6295bba23513a49d858ea82f64982faf (diff)
[PATCH] reiserfs endianness: comp_short_keys() cleanup
comp_short_keys() massaged into sane form, which kills the last place where pointer to in_core_key (or any object containing such) would be cast to or from something else. At that point we are free to change layout of in_core_key - nothing depends on it anymore. So we drop the mess with union in there and simply use (unconditional) __u64 k_offset and __u8 k_type instead; places using in_core_key switched to those. That gives _far_ better code than current mess - on all platforms. Signed-off-by: Al Viro <viro@parcelfarce.linux.theplanet.co.uk> Cc: <reiserfs-dev@namesys.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/reiserfs/inode.c4
-rw-r--r--fs/reiserfs/stree.c36
-rw-r--r--fs/reiserfs/super.c4
3 files changed, 19 insertions, 25 deletions
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 5fdb9f97b99e..2711dff1b7b4 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -1341,8 +1341,8 @@ void reiserfs_read_locked_inode (struct inode * inode, struct reiserfs_iget_args
1341 key.version = KEY_FORMAT_3_5; 1341 key.version = KEY_FORMAT_3_5;
1342 key.on_disk_key.k_dir_id = dirino; 1342 key.on_disk_key.k_dir_id = dirino;
1343 key.on_disk_key.k_objectid = inode->i_ino; 1343 key.on_disk_key.k_objectid = inode->i_ino;
1344 key.on_disk_key.u.k_offset_v1.k_offset = SD_OFFSET; 1344 key.on_disk_key.k_offset = 0;
1345 key.on_disk_key.u.k_offset_v1.k_uniqueness = SD_UNIQUENESS; 1345 key.on_disk_key.k_type = 0;
1346 1346
1347 /* look for the object's stat data */ 1347 /* look for the object's stat data */
1348 retval = search_item (inode->i_sb, &key, &path_to_sd); 1348 retval = search_item (inode->i_sb, &key, &path_to_sd);
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
index 15fa4cbdce3e..da23ba75f3d5 100644
--- a/fs/reiserfs/stree.c
+++ b/fs/reiserfs/stree.c
@@ -87,23 +87,20 @@ inline void copy_item_head(struct item_head * p_v_to,
87inline int comp_short_keys (const struct reiserfs_key * le_key, 87inline int comp_short_keys (const struct reiserfs_key * le_key,
88 const struct cpu_key * cpu_key) 88 const struct cpu_key * cpu_key)
89{ 89{
90 __le32 * p_s_le_u32; 90 __u32 n;
91 __u32 * p_s_cpu_u32; 91 n = le32_to_cpu(le_key->k_dir_id);
92 int n_key_length = REISERFS_SHORT_KEY_LEN; 92 if (n < cpu_key->on_disk_key.k_dir_id)
93
94 p_s_le_u32 = (__le32 *)le_key;
95 p_s_cpu_u32 = (__u32 *)&cpu_key->on_disk_key;
96 for( ; n_key_length--; ++p_s_le_u32, ++p_s_cpu_u32 ) {
97 if ( le32_to_cpu (*p_s_le_u32) < *p_s_cpu_u32 )
98 return -1; 93 return -1;
99 if ( le32_to_cpu (*p_s_le_u32) > *p_s_cpu_u32 ) 94 if (n > cpu_key->on_disk_key.k_dir_id)
95 return 1;
96 n = le32_to_cpu(le_key->k_objectid);
97 if (n < cpu_key->on_disk_key.k_objectid)
98 return -1;
99 if (n > cpu_key->on_disk_key.k_objectid)
100 return 1; 100 return 1;
101 }
102
103 return 0; 101 return 0;
104} 102}
105 103
106
107/* k1 is pointer to on-disk structure which is stored in little-endian 104/* k1 is pointer to on-disk structure which is stored in little-endian
108 form. k2 is pointer to cpu variable. 105 form. k2 is pointer to cpu variable.
109 Compare keys using all 4 key fields. 106 Compare keys using all 4 key fields.
@@ -153,18 +150,15 @@ inline int comp_short_le_keys (const struct reiserfs_key * key1, const struct re
153 150
154inline void le_key2cpu_key (struct cpu_key * to, const struct reiserfs_key * from) 151inline void le_key2cpu_key (struct cpu_key * to, const struct reiserfs_key * from)
155{ 152{
153 int version;
156 to->on_disk_key.k_dir_id = le32_to_cpu (from->k_dir_id); 154 to->on_disk_key.k_dir_id = le32_to_cpu (from->k_dir_id);
157 to->on_disk_key.k_objectid = le32_to_cpu (from->k_objectid); 155 to->on_disk_key.k_objectid = le32_to_cpu (from->k_objectid);
158 156
159 // find out version of the key 157 // find out version of the key
160 to->version = le_key_version (from); 158 version = le_key_version (from);
161 if (to->version == KEY_FORMAT_3_5) { 159 to->version = version;
162 to->on_disk_key.u.k_offset_v1.k_offset = le32_to_cpu (from->u.k_offset_v1.k_offset); 160 to->on_disk_key.k_offset = le_key_k_offset(version, from);
163 to->on_disk_key.u.k_offset_v1.k_uniqueness = le32_to_cpu (from->u.k_offset_v1.k_uniqueness); 161 to->on_disk_key.k_type = le_key_k_type(version, from);
164 } else {
165 to->on_disk_key.u.k_offset_v2.k_offset = offset_v2_k_offset(&from->u.k_offset_v2);
166 to->on_disk_key.u.k_offset_v2.k_type = offset_v2_k_type(&from->u.k_offset_v2);
167 }
168} 162}
169 163
170 164
@@ -235,8 +229,8 @@ const struct reiserfs_key MAX_KEY = {
235 {{__constant_cpu_to_le32(0xffffffff), 229 {{__constant_cpu_to_le32(0xffffffff),
236 __constant_cpu_to_le32(0xffffffff)},} 230 __constant_cpu_to_le32(0xffffffff)},}
237}; 231};
238const struct in_core_key MAX_IN_CORE_KEY = {0xffffffff, 0xffffffff, {{0xffffffff, 0xffffffff},}};
239 232
233const struct in_core_key MAX_IN_CORE_KEY = {~0U, ~0U, ~0ULL>>4, 15};
240 234
241/* Get delimiting key of the buffer by looking for it in the buffers in the path, starting from the bottom 235/* Get delimiting key of the buffer by looking for it in the buffers in the path, starting from the bottom
242 of the path, and going upwards. We must check the path's validity at each step. If the key is not in 236 of the path, and going upwards. We must check the path's validity at each step. If the key is not in
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 2283f18aa1dc..31e75125f48b 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -218,8 +218,8 @@ static int finish_unfinished (struct super_block * s)
218 item = B_I_PITEM (bh, ih); 218 item = B_I_PITEM (bh, ih);
219 obj_key.on_disk_key.k_dir_id = le32_to_cpu (*(__le32 *)item); 219 obj_key.on_disk_key.k_dir_id = le32_to_cpu (*(__le32 *)item);
220 obj_key.on_disk_key.k_objectid = le32_to_cpu (ih->ih_key.k_objectid); 220 obj_key.on_disk_key.k_objectid = le32_to_cpu (ih->ih_key.k_objectid);
221 obj_key.on_disk_key.u.k_offset_v1.k_offset = 0; 221 obj_key.on_disk_key.k_offset = 0;
222 obj_key.on_disk_key.u.k_offset_v1.k_uniqueness = 0; 222 obj_key.on_disk_key.k_type = 0;
223 223
224 pathrelse (&path); 224 pathrelse (&path);
225 225