diff options
Diffstat (limited to 'fs/reiserfs/stree.c')
-rw-r--r-- | fs/reiserfs/stree.c | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c index 73ec5212178b..da23ba75f3d5 100644 --- a/fs/reiserfs/stree.c +++ b/fs/reiserfs/stree.c | |||
@@ -87,22 +87,20 @@ inline void copy_item_head(struct item_head * p_v_to, | |||
87 | inline int comp_short_keys (const struct reiserfs_key * le_key, | 87 | inline 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 | __u32 * p_s_le_u32, * p_s_cpu_u32; | 90 | __u32 n; |
91 | int n_key_length = REISERFS_SHORT_KEY_LEN; | 91 | n = le32_to_cpu(le_key->k_dir_id); |
92 | 92 | if (n < cpu_key->on_disk_key.k_dir_id) | |
93 | p_s_le_u32 = (__u32 *)le_key; | ||
94 | p_s_cpu_u32 = (__u32 *)&cpu_key->on_disk_key; | ||
95 | for( ; n_key_length--; ++p_s_le_u32, ++p_s_cpu_u32 ) { | ||
96 | if ( le32_to_cpu (*p_s_le_u32) < *p_s_cpu_u32 ) | ||
97 | return -1; | 93 | return -1; |
98 | 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) | ||
99 | return 1; | 100 | return 1; |
100 | } | ||
101 | |||
102 | return 0; | 101 | return 0; |
103 | } | 102 | } |
104 | 103 | ||
105 | |||
106 | /* 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 |
107 | form. k2 is pointer to cpu variable. | 105 | form. k2 is pointer to cpu variable. |
108 | Compare keys using all 4 key fields. | 106 | Compare keys using all 4 key fields. |
@@ -152,18 +150,15 @@ inline int comp_short_le_keys (const struct reiserfs_key * key1, const struct re | |||
152 | 150 | ||
153 | inline void le_key2cpu_key (struct cpu_key * to, const struct reiserfs_key * from) | 151 | inline void le_key2cpu_key (struct cpu_key * to, const struct reiserfs_key * from) |
154 | { | 152 | { |
153 | int version; | ||
155 | 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); |
156 | 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); |
157 | 156 | ||
158 | // find out version of the key | 157 | // find out version of the key |
159 | to->version = le_key_version (from); | 158 | version = le_key_version (from); |
160 | if (to->version == KEY_FORMAT_3_5) { | 159 | to->version = version; |
161 | 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); |
162 | 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); |
163 | } else { | ||
164 | to->on_disk_key.u.k_offset_v2.k_offset = offset_v2_k_offset(&from->u.k_offset_v2); | ||
165 | to->on_disk_key.u.k_offset_v2.k_type = offset_v2_k_type(&from->u.k_offset_v2); | ||
166 | } | ||
167 | } | 162 | } |
168 | 163 | ||
169 | 164 | ||
@@ -228,8 +223,14 @@ extern struct tree_balance * cur_tb; | |||
228 | const struct reiserfs_key MIN_KEY = {0, 0, {{0, 0},}}; | 223 | const struct reiserfs_key MIN_KEY = {0, 0, {{0, 0},}}; |
229 | 224 | ||
230 | /* Maximal possible key. It is never in the tree. */ | 225 | /* Maximal possible key. It is never in the tree. */ |
231 | const struct reiserfs_key MAX_KEY = {0xffffffff, 0xffffffff, {{0xffffffff, 0xffffffff},}}; | 226 | const struct reiserfs_key MAX_KEY = { |
227 | __constant_cpu_to_le32(0xffffffff), | ||
228 | __constant_cpu_to_le32(0xffffffff), | ||
229 | {{__constant_cpu_to_le32(0xffffffff), | ||
230 | __constant_cpu_to_le32(0xffffffff)},} | ||
231 | }; | ||
232 | 232 | ||
233 | const struct in_core_key MAX_IN_CORE_KEY = {~0U, ~0U, ~0ULL>>4, 15}; | ||
233 | 234 | ||
234 | /* 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 |
235 | 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 |
@@ -997,7 +998,7 @@ static char prepare_for_delete_or_cut( | |||
997 | int n_unfm_number, /* Number of the item unformatted nodes. */ | 998 | int n_unfm_number, /* Number of the item unformatted nodes. */ |
998 | n_counter, | 999 | n_counter, |
999 | n_blk_size; | 1000 | n_blk_size; |
1000 | __u32 * p_n_unfm_pointer; /* Pointer to the unformatted node number. */ | 1001 | __le32 * p_n_unfm_pointer; /* Pointer to the unformatted node number. */ |
1001 | __u32 tmp; | 1002 | __u32 tmp; |
1002 | struct item_head s_ih; /* Item header. */ | 1003 | struct item_head s_ih; /* Item header. */ |
1003 | char c_mode; /* Returned mode of the balance. */ | 1004 | char c_mode; /* Returned mode of the balance. */ |
@@ -1059,7 +1060,7 @@ static char prepare_for_delete_or_cut( | |||
1059 | /* pointers to be cut */ | 1060 | /* pointers to be cut */ |
1060 | n_unfm_number -= pos_in_item (p_s_path); | 1061 | n_unfm_number -= pos_in_item (p_s_path); |
1061 | /* Set pointer to the last unformatted node pointer that is to be cut. */ | 1062 | /* Set pointer to the last unformatted node pointer that is to be cut. */ |
1062 | p_n_unfm_pointer = (__u32 *)B_I_PITEM(p_s_bh, &s_ih) + I_UNFM_NUM(&s_ih) - 1 - *p_n_removed; | 1063 | p_n_unfm_pointer = (__le32 *)B_I_PITEM(p_s_bh, &s_ih) + I_UNFM_NUM(&s_ih) - 1 - *p_n_removed; |
1063 | 1064 | ||
1064 | 1065 | ||
1065 | /* We go through the unformatted nodes pointers of the indirect | 1066 | /* We go through the unformatted nodes pointers of the indirect |
@@ -1081,8 +1082,8 @@ static char prepare_for_delete_or_cut( | |||
1081 | need_research = 1 ; | 1082 | need_research = 1 ; |
1082 | break; | 1083 | break; |
1083 | } | 1084 | } |
1084 | RFALSE( p_n_unfm_pointer < (__u32 *)B_I_PITEM(p_s_bh, &s_ih) || | 1085 | RFALSE( p_n_unfm_pointer < (__le32 *)B_I_PITEM(p_s_bh, &s_ih) || |
1085 | p_n_unfm_pointer > (__u32 *)B_I_PITEM(p_s_bh, &s_ih) + I_UNFM_NUM(&s_ih) - 1, | 1086 | p_n_unfm_pointer > (__le32 *)B_I_PITEM(p_s_bh, &s_ih) + I_UNFM_NUM(&s_ih) - 1, |
1086 | "vs-5265: pointer out of range"); | 1087 | "vs-5265: pointer out of range"); |
1087 | 1088 | ||
1088 | /* Hole, nothing to remove. */ | 1089 | /* Hole, nothing to remove. */ |
@@ -1431,7 +1432,7 @@ int reiserfs_delete_object (struct reiserfs_transaction_handle *th, struct inode | |||
1431 | #if defined( USE_INODE_GENERATION_COUNTER ) | 1432 | #if defined( USE_INODE_GENERATION_COUNTER ) |
1432 | if( !old_format_only ( th -> t_super ) ) | 1433 | if( !old_format_only ( th -> t_super ) ) |
1433 | { | 1434 | { |
1434 | __u32 *inode_generation; | 1435 | __le32 *inode_generation; |
1435 | 1436 | ||
1436 | inode_generation = | 1437 | inode_generation = |
1437 | &REISERFS_SB(th -> t_super) -> s_rs -> s_inode_generation; | 1438 | &REISERFS_SB(th -> t_super) -> s_rs -> s_inode_generation; |