diff options
author | Jeff Mahoney <jeffm@suse.com> | 2009-03-30 14:02:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-03-30 15:16:40 -0400 |
commit | d68caa9530a8ba54f97002e02bf6a0ad2462b8c0 (patch) | |
tree | 39a2b877483270253f95f3678a4559e9bd5524e8 /fs/reiserfs/stree.c | |
parent | a063ae17925cafabe55ebe1957ca0e8c480bd132 (diff) |
reiserfs: rename p_._ variables
This patch is a simple s/p_._//g to the reiserfs code. This is the
fifth in a series of patches to rip out some of the awful variable
naming in reiserfs.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/reiserfs/stree.c')
-rw-r--r-- | fs/reiserfs/stree.c | 472 |
1 files changed, 240 insertions, 232 deletions
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c index 5e867be559ea..fd769c8dac32 100644 --- a/fs/reiserfs/stree.c +++ b/fs/reiserfs/stree.c | |||
@@ -68,10 +68,10 @@ inline int B_IS_IN_TREE(const struct buffer_head *bh) | |||
68 | // | 68 | // |
69 | // to gets item head in le form | 69 | // to gets item head in le form |
70 | // | 70 | // |
71 | inline void copy_item_head(struct item_head *p_v_to, | 71 | inline void copy_item_head(struct item_head *to, |
72 | const struct item_head *p_v_from) | 72 | const struct item_head *from) |
73 | { | 73 | { |
74 | memcpy(p_v_to, p_v_from, IH_SIZE); | 74 | memcpy(to, from, IH_SIZE); |
75 | } | 75 | } |
76 | 76 | ||
77 | /* k1 is pointer to on-disk structure which is stored in little-endian | 77 | /* k1 is pointer to on-disk structure which is stored in little-endian |
@@ -135,15 +135,15 @@ static inline int comp_keys(const struct reiserfs_key *le_key, | |||
135 | inline int comp_short_le_keys(const struct reiserfs_key *key1, | 135 | inline int comp_short_le_keys(const struct reiserfs_key *key1, |
136 | const struct reiserfs_key *key2) | 136 | const struct reiserfs_key *key2) |
137 | { | 137 | { |
138 | __u32 *p_s_1_u32, *p_s_2_u32; | 138 | __u32 *k1_u32, *k2_u32; |
139 | int n_key_length = REISERFS_SHORT_KEY_LEN; | 139 | int n_key_length = REISERFS_SHORT_KEY_LEN; |
140 | 140 | ||
141 | p_s_1_u32 = (__u32 *) key1; | 141 | k1_u32 = (__u32 *) key1; |
142 | p_s_2_u32 = (__u32 *) key2; | 142 | k2_u32 = (__u32 *) key2; |
143 | for (; n_key_length--; ++p_s_1_u32, ++p_s_2_u32) { | 143 | for (; n_key_length--; ++k1_u32, ++k2_u32) { |
144 | if (le32_to_cpu(*p_s_1_u32) < le32_to_cpu(*p_s_2_u32)) | 144 | if (le32_to_cpu(*k1_u32) < le32_to_cpu(*k2_u32)) |
145 | return -1; | 145 | return -1; |
146 | if (le32_to_cpu(*p_s_1_u32) > le32_to_cpu(*p_s_2_u32)) | 146 | if (le32_to_cpu(*k1_u32) > le32_to_cpu(*k2_u32)) |
147 | return 1; | 147 | return 1; |
148 | } | 148 | } |
149 | return 0; | 149 | return 0; |
@@ -174,8 +174,8 @@ inline int comp_le_keys(const struct reiserfs_key *k1, | |||
174 | * Binary search toolkit function * | 174 | * Binary search toolkit function * |
175 | * Search for an item in the array by the item key * | 175 | * Search for an item in the array by the item key * |
176 | * Returns: 1 if found, 0 if not found; * | 176 | * Returns: 1 if found, 0 if not found; * |
177 | * *p_n_pos = number of the searched element if found, else the * | 177 | * *pos = number of the searched element if found, else the * |
178 | * number of the first element that is larger than p_v_key. * | 178 | * number of the first element that is larger than key. * |
179 | **************************************************************************/ | 179 | **************************************************************************/ |
180 | /* For those not familiar with binary search: n_lbound is the leftmost item that it | 180 | /* For those not familiar with binary search: n_lbound is the leftmost item that it |
181 | could be, n_rbound the rightmost item that it could be. We examine the item | 181 | could be, n_rbound the rightmost item that it could be. We examine the item |
@@ -184,28 +184,28 @@ inline int comp_le_keys(const struct reiserfs_key *k1, | |||
184 | there are no possible items, and we have not found it. With each examination we | 184 | there are no possible items, and we have not found it. With each examination we |
185 | cut the number of possible items it could be by one more than half rounded down, | 185 | cut the number of possible items it could be by one more than half rounded down, |
186 | or we find it. */ | 186 | or we find it. */ |
187 | static inline int bin_search(const void *p_v_key, /* Key to search for. */ | 187 | static inline int bin_search(const void *key, /* Key to search for. */ |
188 | const void *p_v_base, /* First item in the array. */ | 188 | const void *base, /* First item in the array. */ |
189 | int p_n_num, /* Number of items in the array. */ | 189 | int num, /* Number of items in the array. */ |
190 | int p_n_width, /* Item size in the array. | 190 | int width, /* Item size in the array. |
191 | searched. Lest the reader be | 191 | searched. Lest the reader be |
192 | confused, note that this is crafted | 192 | confused, note that this is crafted |
193 | as a general function, and when it | 193 | as a general function, and when it |
194 | is applied specifically to the array | 194 | is applied specifically to the array |
195 | of item headers in a node, p_n_width | 195 | of item headers in a node, width |
196 | is actually the item header size not | 196 | is actually the item header size not |
197 | the item size. */ | 197 | the item size. */ |
198 | int *p_n_pos /* Number of the searched for element. */ | 198 | int *pos /* Number of the searched for element. */ |
199 | ) | 199 | ) |
200 | { | 200 | { |
201 | int n_rbound, n_lbound, n_j; | 201 | int n_rbound, n_lbound, n_j; |
202 | 202 | ||
203 | for (n_j = ((n_rbound = p_n_num - 1) + (n_lbound = 0)) / 2; | 203 | for (n_j = ((n_rbound = num - 1) + (n_lbound = 0)) / 2; |
204 | n_lbound <= n_rbound; n_j = (n_rbound + n_lbound) / 2) | 204 | n_lbound <= n_rbound; n_j = (n_rbound + n_lbound) / 2) |
205 | switch (comp_keys | 205 | switch (comp_keys |
206 | ((struct reiserfs_key *)((char *)p_v_base + | 206 | ((struct reiserfs_key *)((char *)base + |
207 | n_j * p_n_width), | 207 | n_j * width), |
208 | (struct cpu_key *)p_v_key)) { | 208 | (struct cpu_key *)key)) { |
209 | case -1: | 209 | case -1: |
210 | n_lbound = n_j + 1; | 210 | n_lbound = n_j + 1; |
211 | continue; | 211 | continue; |
@@ -213,13 +213,13 @@ static inline int bin_search(const void *p_v_key, /* Key to search for. | |||
213 | n_rbound = n_j - 1; | 213 | n_rbound = n_j - 1; |
214 | continue; | 214 | continue; |
215 | case 0: | 215 | case 0: |
216 | *p_n_pos = n_j; | 216 | *pos = n_j; |
217 | return ITEM_FOUND; /* Key found in the array. */ | 217 | return ITEM_FOUND; /* Key found in the array. */ |
218 | } | 218 | } |
219 | 219 | ||
220 | /* bin_search did not find given key, it returns position of key, | 220 | /* bin_search did not find given key, it returns position of key, |
221 | that is minimal and greater than the given one. */ | 221 | that is minimal and greater than the given one. */ |
222 | *p_n_pos = n_lbound; | 222 | *pos = n_lbound; |
223 | return ITEM_NOT_FOUND; | 223 | return ITEM_NOT_FOUND; |
224 | } | 224 | } |
225 | 225 | ||
@@ -243,12 +243,12 @@ static const struct reiserfs_key MAX_KEY = { | |||
243 | the path, there is no delimiting key in the tree (buffer is first or last buffer in tree), and in this | 243 | the path, there is no delimiting key in the tree (buffer is first or last buffer in tree), and in this |
244 | case we return a special key, either MIN_KEY or MAX_KEY. */ | 244 | case we return a special key, either MIN_KEY or MAX_KEY. */ |
245 | static inline const struct reiserfs_key *get_lkey(const struct treepath | 245 | static inline const struct reiserfs_key *get_lkey(const struct treepath |
246 | *p_s_chk_path, | 246 | *chk_path, |
247 | const struct super_block | 247 | const struct super_block |
248 | *sb) | 248 | *sb) |
249 | { | 249 | { |
250 | int n_position, n_path_offset = p_s_chk_path->path_length; | 250 | int n_position, n_path_offset = chk_path->path_length; |
251 | struct buffer_head *p_s_parent; | 251 | struct buffer_head *parent; |
252 | 252 | ||
253 | RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET, | 253 | RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET, |
254 | "PAP-5010: invalid offset in the path"); | 254 | "PAP-5010: invalid offset in the path"); |
@@ -257,42 +257,42 @@ static inline const struct reiserfs_key *get_lkey(const struct treepath | |||
257 | while (n_path_offset-- > FIRST_PATH_ELEMENT_OFFSET) { | 257 | while (n_path_offset-- > FIRST_PATH_ELEMENT_OFFSET) { |
258 | 258 | ||
259 | RFALSE(!buffer_uptodate | 259 | RFALSE(!buffer_uptodate |
260 | (PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)), | 260 | (PATH_OFFSET_PBUFFER(chk_path, n_path_offset)), |
261 | "PAP-5020: parent is not uptodate"); | 261 | "PAP-5020: parent is not uptodate"); |
262 | 262 | ||
263 | /* Parent at the path is not in the tree now. */ | 263 | /* Parent at the path is not in the tree now. */ |
264 | if (!B_IS_IN_TREE | 264 | if (!B_IS_IN_TREE |
265 | (p_s_parent = | 265 | (parent = |
266 | PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset))) | 266 | PATH_OFFSET_PBUFFER(chk_path, n_path_offset))) |
267 | return &MAX_KEY; | 267 | return &MAX_KEY; |
268 | /* Check whether position in the parent is correct. */ | 268 | /* Check whether position in the parent is correct. */ |
269 | if ((n_position = | 269 | if ((n_position = |
270 | PATH_OFFSET_POSITION(p_s_chk_path, | 270 | PATH_OFFSET_POSITION(chk_path, |
271 | n_path_offset)) > | 271 | n_path_offset)) > |
272 | B_NR_ITEMS(p_s_parent)) | 272 | B_NR_ITEMS(parent)) |
273 | return &MAX_KEY; | 273 | return &MAX_KEY; |
274 | /* Check whether parent at the path really points to the child. */ | 274 | /* Check whether parent at the path really points to the child. */ |
275 | if (B_N_CHILD_NUM(p_s_parent, n_position) != | 275 | if (B_N_CHILD_NUM(parent, n_position) != |
276 | PATH_OFFSET_PBUFFER(p_s_chk_path, | 276 | PATH_OFFSET_PBUFFER(chk_path, |
277 | n_path_offset + 1)->b_blocknr) | 277 | n_path_offset + 1)->b_blocknr) |
278 | return &MAX_KEY; | 278 | return &MAX_KEY; |
279 | /* Return delimiting key if position in the parent is not equal to zero. */ | 279 | /* Return delimiting key if position in the parent is not equal to zero. */ |
280 | if (n_position) | 280 | if (n_position) |
281 | return B_N_PDELIM_KEY(p_s_parent, n_position - 1); | 281 | return B_N_PDELIM_KEY(parent, n_position - 1); |
282 | } | 282 | } |
283 | /* Return MIN_KEY if we are in the root of the buffer tree. */ | 283 | /* Return MIN_KEY if we are in the root of the buffer tree. */ |
284 | if (PATH_OFFSET_PBUFFER(p_s_chk_path, FIRST_PATH_ELEMENT_OFFSET)-> | 284 | if (PATH_OFFSET_PBUFFER(chk_path, FIRST_PATH_ELEMENT_OFFSET)-> |
285 | b_blocknr == SB_ROOT_BLOCK(sb)) | 285 | b_blocknr == SB_ROOT_BLOCK(sb)) |
286 | return &MIN_KEY; | 286 | return &MIN_KEY; |
287 | return &MAX_KEY; | 287 | return &MAX_KEY; |
288 | } | 288 | } |
289 | 289 | ||
290 | /* Get delimiting key of the buffer at the path and its right neighbor. */ | 290 | /* Get delimiting key of the buffer at the path and its right neighbor. */ |
291 | inline const struct reiserfs_key *get_rkey(const struct treepath *p_s_chk_path, | 291 | inline const struct reiserfs_key *get_rkey(const struct treepath *chk_path, |
292 | const struct super_block *sb) | 292 | const struct super_block *sb) |
293 | { | 293 | { |
294 | int n_position, n_path_offset = p_s_chk_path->path_length; | 294 | int n_position, n_path_offset = chk_path->path_length; |
295 | struct buffer_head *p_s_parent; | 295 | struct buffer_head *parent; |
296 | 296 | ||
297 | RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET, | 297 | RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET, |
298 | "PAP-5030: invalid offset in the path"); | 298 | "PAP-5030: invalid offset in the path"); |
@@ -300,31 +300,31 @@ inline const struct reiserfs_key *get_rkey(const struct treepath *p_s_chk_path, | |||
300 | while (n_path_offset-- > FIRST_PATH_ELEMENT_OFFSET) { | 300 | while (n_path_offset-- > FIRST_PATH_ELEMENT_OFFSET) { |
301 | 301 | ||
302 | RFALSE(!buffer_uptodate | 302 | RFALSE(!buffer_uptodate |
303 | (PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)), | 303 | (PATH_OFFSET_PBUFFER(chk_path, n_path_offset)), |
304 | "PAP-5040: parent is not uptodate"); | 304 | "PAP-5040: parent is not uptodate"); |
305 | 305 | ||
306 | /* Parent at the path is not in the tree now. */ | 306 | /* Parent at the path is not in the tree now. */ |
307 | if (!B_IS_IN_TREE | 307 | if (!B_IS_IN_TREE |
308 | (p_s_parent = | 308 | (parent = |
309 | PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset))) | 309 | PATH_OFFSET_PBUFFER(chk_path, n_path_offset))) |
310 | return &MIN_KEY; | 310 | return &MIN_KEY; |
311 | /* Check whether position in the parent is correct. */ | 311 | /* Check whether position in the parent is correct. */ |
312 | if ((n_position = | 312 | if ((n_position = |
313 | PATH_OFFSET_POSITION(p_s_chk_path, | 313 | PATH_OFFSET_POSITION(chk_path, |
314 | n_path_offset)) > | 314 | n_path_offset)) > |
315 | B_NR_ITEMS(p_s_parent)) | 315 | B_NR_ITEMS(parent)) |
316 | return &MIN_KEY; | 316 | return &MIN_KEY; |
317 | /* Check whether parent at the path really points to the child. */ | 317 | /* Check whether parent at the path really points to the child. */ |
318 | if (B_N_CHILD_NUM(p_s_parent, n_position) != | 318 | if (B_N_CHILD_NUM(parent, n_position) != |
319 | PATH_OFFSET_PBUFFER(p_s_chk_path, | 319 | PATH_OFFSET_PBUFFER(chk_path, |
320 | n_path_offset + 1)->b_blocknr) | 320 | n_path_offset + 1)->b_blocknr) |
321 | return &MIN_KEY; | 321 | return &MIN_KEY; |
322 | /* Return delimiting key if position in the parent is not the last one. */ | 322 | /* Return delimiting key if position in the parent is not the last one. */ |
323 | if (n_position != B_NR_ITEMS(p_s_parent)) | 323 | if (n_position != B_NR_ITEMS(parent)) |
324 | return B_N_PDELIM_KEY(p_s_parent, n_position); | 324 | return B_N_PDELIM_KEY(parent, n_position); |
325 | } | 325 | } |
326 | /* Return MAX_KEY if we are in the root of the buffer tree. */ | 326 | /* Return MAX_KEY if we are in the root of the buffer tree. */ |
327 | if (PATH_OFFSET_PBUFFER(p_s_chk_path, FIRST_PATH_ELEMENT_OFFSET)-> | 327 | if (PATH_OFFSET_PBUFFER(chk_path, FIRST_PATH_ELEMENT_OFFSET)-> |
328 | b_blocknr == SB_ROOT_BLOCK(sb)) | 328 | b_blocknr == SB_ROOT_BLOCK(sb)) |
329 | return &MAX_KEY; | 329 | return &MAX_KEY; |
330 | return &MIN_KEY; | 330 | return &MIN_KEY; |
@@ -335,25 +335,25 @@ inline const struct reiserfs_key *get_rkey(const struct treepath *p_s_chk_path, | |||
335 | the path. These delimiting keys are stored at least one level above that buffer in the tree. If the | 335 | the path. These delimiting keys are stored at least one level above that buffer in the tree. If the |
336 | buffer is the first or last node in the tree order then one of the delimiting keys may be absent, and in | 336 | buffer is the first or last node in the tree order then one of the delimiting keys may be absent, and in |
337 | this case get_lkey and get_rkey return a special key which is MIN_KEY or MAX_KEY. */ | 337 | this case get_lkey and get_rkey return a special key which is MIN_KEY or MAX_KEY. */ |
338 | static inline int key_in_buffer(struct treepath *p_s_chk_path, /* Path which should be checked. */ | 338 | static inline int key_in_buffer(struct treepath *chk_path, /* Path which should be checked. */ |
339 | const struct cpu_key *p_s_key, /* Key which should be checked. */ | 339 | const struct cpu_key *key, /* Key which should be checked. */ |
340 | struct super_block *sb /* Super block pointer. */ | 340 | struct super_block *sb |
341 | ) | 341 | ) |
342 | { | 342 | { |
343 | 343 | ||
344 | RFALSE(!p_s_key || p_s_chk_path->path_length < FIRST_PATH_ELEMENT_OFFSET | 344 | RFALSE(!key || chk_path->path_length < FIRST_PATH_ELEMENT_OFFSET |
345 | || p_s_chk_path->path_length > MAX_HEIGHT, | 345 | || chk_path->path_length > MAX_HEIGHT, |
346 | "PAP-5050: pointer to the key(%p) is NULL or invalid path length(%d)", | 346 | "PAP-5050: pointer to the key(%p) is NULL or invalid path length(%d)", |
347 | p_s_key, p_s_chk_path->path_length); | 347 | key, chk_path->path_length); |
348 | RFALSE(!PATH_PLAST_BUFFER(p_s_chk_path)->b_bdev, | 348 | RFALSE(!PATH_PLAST_BUFFER(chk_path)->b_bdev, |
349 | "PAP-5060: device must not be NODEV"); | 349 | "PAP-5060: device must not be NODEV"); |
350 | 350 | ||
351 | if (comp_keys(get_lkey(p_s_chk_path, sb), p_s_key) == 1) | 351 | if (comp_keys(get_lkey(chk_path, sb), key) == 1) |
352 | /* left delimiting key is bigger, that the key we look for */ | 352 | /* left delimiting key is bigger, that the key we look for */ |
353 | return 0; | 353 | return 0; |
354 | // if ( comp_keys(p_s_key, get_rkey(p_s_chk_path, sb)) != -1 ) | 354 | /* if ( comp_keys(key, get_rkey(chk_path, sb)) != -1 ) */ |
355 | if (comp_keys(get_rkey(p_s_chk_path, sb), p_s_key) != 1) | 355 | if (comp_keys(get_rkey(chk_path, sb), key) != 1) |
356 | /* p_s_key must be less than right delimitiing key */ | 356 | /* key must be less than right delimitiing key */ |
357 | return 0; | 357 | return 0; |
358 | return 1; | 358 | return 1; |
359 | } | 359 | } |
@@ -369,34 +369,34 @@ int reiserfs_check_path(struct treepath *p) | |||
369 | * dirty bits clean when preparing the buffer for the log. | 369 | * dirty bits clean when preparing the buffer for the log. |
370 | * This version should only be called from fix_nodes() */ | 370 | * This version should only be called from fix_nodes() */ |
371 | void pathrelse_and_restore(struct super_block *sb, | 371 | void pathrelse_and_restore(struct super_block *sb, |
372 | struct treepath *p_s_search_path) | 372 | struct treepath *search_path) |
373 | { | 373 | { |
374 | int n_path_offset = p_s_search_path->path_length; | 374 | int n_path_offset = search_path->path_length; |
375 | 375 | ||
376 | RFALSE(n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET, | 376 | RFALSE(n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET, |
377 | "clm-4000: invalid path offset"); | 377 | "clm-4000: invalid path offset"); |
378 | 378 | ||
379 | while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET) { | 379 | while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET) { |
380 | struct buffer_head *bh; | 380 | struct buffer_head *bh; |
381 | bh = PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--); | 381 | bh = PATH_OFFSET_PBUFFER(search_path, n_path_offset--); |
382 | reiserfs_restore_prepared_buffer(sb, bh); | 382 | reiserfs_restore_prepared_buffer(sb, bh); |
383 | brelse(bh); | 383 | brelse(bh); |
384 | } | 384 | } |
385 | p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET; | 385 | search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET; |
386 | } | 386 | } |
387 | 387 | ||
388 | /* Drop the reference to each buffer in a path */ | 388 | /* Drop the reference to each buffer in a path */ |
389 | void pathrelse(struct treepath *p_s_search_path) | 389 | void pathrelse(struct treepath *search_path) |
390 | { | 390 | { |
391 | int n_path_offset = p_s_search_path->path_length; | 391 | int n_path_offset = search_path->path_length; |
392 | 392 | ||
393 | RFALSE(n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET, | 393 | RFALSE(n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET, |
394 | "PAP-5090: invalid path offset"); | 394 | "PAP-5090: invalid path offset"); |
395 | 395 | ||
396 | while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET) | 396 | while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET) |
397 | brelse(PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--)); | 397 | brelse(PATH_OFFSET_PBUFFER(search_path, n_path_offset--)); |
398 | 398 | ||
399 | p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET; | 399 | search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET; |
400 | } | 400 | } |
401 | 401 | ||
402 | static int is_leaf(char *buf, int blocksize, struct buffer_head *bh) | 402 | static int is_leaf(char *buf, int blocksize, struct buffer_head *bh) |
@@ -547,9 +547,9 @@ static void search_by_key_reada(struct super_block *s, | |||
547 | * Algorithm SearchByKey * | 547 | * Algorithm SearchByKey * |
548 | * look for item in the Disk S+Tree by its key * | 548 | * look for item in the Disk S+Tree by its key * |
549 | * Input: sb - super block * | 549 | * Input: sb - super block * |
550 | * p_s_key - pointer to the key to search * | 550 | * key - pointer to the key to search * |
551 | * Output: ITEM_FOUND, ITEM_NOT_FOUND or IO_ERROR * | 551 | * Output: ITEM_FOUND, ITEM_NOT_FOUND or IO_ERROR * |
552 | * p_s_search_path - path from the root to the needed leaf * | 552 | * search_path - path from the root to the needed leaf * |
553 | **************************************************************************/ | 553 | **************************************************************************/ |
554 | 554 | ||
555 | /* This function fills up the path from the root to the leaf as it | 555 | /* This function fills up the path from the root to the leaf as it |
@@ -566,8 +566,8 @@ static void search_by_key_reada(struct super_block *s, | |||
566 | correctness of the top of the path but need not be checked for the | 566 | correctness of the top of the path but need not be checked for the |
567 | correctness of the bottom of the path */ | 567 | correctness of the bottom of the path */ |
568 | /* The function is NOT SCHEDULE-SAFE! */ | 568 | /* The function is NOT SCHEDULE-SAFE! */ |
569 | int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key to search. */ | 569 | int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to search. */ |
570 | struct treepath *p_s_search_path,/* This structure was | 570 | struct treepath *search_path,/* This structure was |
571 | allocated and initialized | 571 | allocated and initialized |
572 | by the calling | 572 | by the calling |
573 | function. It is filled up | 573 | function. It is filled up |
@@ -580,7 +580,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key | |||
580 | b_blocknr_t n_block_number; | 580 | b_blocknr_t n_block_number; |
581 | int expected_level; | 581 | int expected_level; |
582 | struct buffer_head *bh; | 582 | struct buffer_head *bh; |
583 | struct path_element *p_s_last_element; | 583 | struct path_element *last_element; |
584 | int n_node_level, n_retval; | 584 | int n_node_level, n_retval; |
585 | int right_neighbor_of_leaf_node; | 585 | int right_neighbor_of_leaf_node; |
586 | int fs_gen; | 586 | int fs_gen; |
@@ -598,7 +598,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key | |||
598 | we must be careful to release all nodes in a path before we either | 598 | we must be careful to release all nodes in a path before we either |
599 | discard the path struct or re-use the path struct, as we do here. */ | 599 | discard the path struct or re-use the path struct, as we do here. */ |
600 | 600 | ||
601 | pathrelse(p_s_search_path); | 601 | pathrelse(search_path); |
602 | 602 | ||
603 | right_neighbor_of_leaf_node = 0; | 603 | right_neighbor_of_leaf_node = 0; |
604 | 604 | ||
@@ -615,18 +615,18 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key | |||
615 | "%s: there were %d iterations of " | 615 | "%s: there were %d iterations of " |
616 | "while loop looking for key %K", | 616 | "while loop looking for key %K", |
617 | current->comm, n_repeat_counter, | 617 | current->comm, n_repeat_counter, |
618 | p_s_key); | 618 | key); |
619 | #endif | 619 | #endif |
620 | 620 | ||
621 | /* prep path to have another element added to it. */ | 621 | /* prep path to have another element added to it. */ |
622 | p_s_last_element = | 622 | last_element = |
623 | PATH_OFFSET_PELEMENT(p_s_search_path, | 623 | PATH_OFFSET_PELEMENT(search_path, |
624 | ++p_s_search_path->path_length); | 624 | ++search_path->path_length); |
625 | fs_gen = get_generation(sb); | 625 | fs_gen = get_generation(sb); |
626 | 626 | ||
627 | /* Read the next tree node, and set the last element in the path to | 627 | /* Read the next tree node, and set the last element in the path to |
628 | have a pointer to it. */ | 628 | have a pointer to it. */ |
629 | if ((bh = p_s_last_element->pe_buffer = | 629 | if ((bh = last_element->pe_buffer = |
630 | sb_getblk(sb, n_block_number))) { | 630 | sb_getblk(sb, n_block_number))) { |
631 | if (!buffer_uptodate(bh) && reada_count > 1) | 631 | if (!buffer_uptodate(bh) && reada_count > 1) |
632 | search_by_key_reada(sb, reada_bh, | 632 | search_by_key_reada(sb, reada_bh, |
@@ -637,8 +637,8 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key | |||
637 | goto io_error; | 637 | goto io_error; |
638 | } else { | 638 | } else { |
639 | io_error: | 639 | io_error: |
640 | p_s_search_path->path_length--; | 640 | search_path->path_length--; |
641 | pathrelse(p_s_search_path); | 641 | pathrelse(search_path); |
642 | return IO_ERROR; | 642 | return IO_ERROR; |
643 | } | 643 | } |
644 | reada_count = 0; | 644 | reada_count = 0; |
@@ -652,12 +652,12 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key | |||
652 | if (fs_changed(fs_gen, sb) && | 652 | if (fs_changed(fs_gen, sb) && |
653 | (!B_IS_IN_TREE(bh) || | 653 | (!B_IS_IN_TREE(bh) || |
654 | B_LEVEL(bh) != expected_level || | 654 | B_LEVEL(bh) != expected_level || |
655 | !key_in_buffer(p_s_search_path, p_s_key, sb))) { | 655 | !key_in_buffer(search_path, key, sb))) { |
656 | PROC_INFO_INC(sb, search_by_key_fs_changed); | 656 | PROC_INFO_INC(sb, search_by_key_fs_changed); |
657 | PROC_INFO_INC(sb, search_by_key_restarted); | 657 | PROC_INFO_INC(sb, search_by_key_restarted); |
658 | PROC_INFO_INC(sb, | 658 | PROC_INFO_INC(sb, |
659 | sbk_restarted[expected_level - 1]); | 659 | sbk_restarted[expected_level - 1]); |
660 | pathrelse(p_s_search_path); | 660 | pathrelse(search_path); |
661 | 661 | ||
662 | /* Get the root block number so that we can repeat the search | 662 | /* Get the root block number so that we can repeat the search |
663 | starting from the root. */ | 663 | starting from the root. */ |
@@ -669,11 +669,11 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key | |||
669 | continue; | 669 | continue; |
670 | } | 670 | } |
671 | 671 | ||
672 | /* only check that the key is in the buffer if p_s_key is not | 672 | /* only check that the key is in the buffer if key is not |
673 | equal to the MAX_KEY. Latter case is only possible in | 673 | equal to the MAX_KEY. Latter case is only possible in |
674 | "finish_unfinished()" processing during mount. */ | 674 | "finish_unfinished()" processing during mount. */ |
675 | RFALSE(comp_keys(&MAX_KEY, p_s_key) && | 675 | RFALSE(comp_keys(&MAX_KEY, key) && |
676 | !key_in_buffer(p_s_search_path, p_s_key, sb), | 676 | !key_in_buffer(search_path, key, sb), |
677 | "PAP-5130: key is not in the buffer"); | 677 | "PAP-5130: key is not in the buffer"); |
678 | #ifdef CONFIG_REISERFS_CHECK | 678 | #ifdef CONFIG_REISERFS_CHECK |
679 | if (cur_tb) { | 679 | if (cur_tb) { |
@@ -689,7 +689,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key | |||
689 | reiserfs_error(sb, "vs-5150", | 689 | reiserfs_error(sb, "vs-5150", |
690 | "invalid format found in block %ld. " | 690 | "invalid format found in block %ld. " |
691 | "Fsck?", bh->b_blocknr); | 691 | "Fsck?", bh->b_blocknr); |
692 | pathrelse(p_s_search_path); | 692 | pathrelse(search_path); |
693 | return IO_ERROR; | 693 | return IO_ERROR; |
694 | } | 694 | } |
695 | 695 | ||
@@ -702,12 +702,12 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key | |||
702 | "vs-5152: tree level (%d) is less than stop level (%d)", | 702 | "vs-5152: tree level (%d) is less than stop level (%d)", |
703 | n_node_level, n_stop_level); | 703 | n_node_level, n_stop_level); |
704 | 704 | ||
705 | n_retval = bin_search(p_s_key, B_N_PITEM_HEAD(bh, 0), | 705 | n_retval = bin_search(key, B_N_PITEM_HEAD(bh, 0), |
706 | B_NR_ITEMS(bh), | 706 | B_NR_ITEMS(bh), |
707 | (n_node_level == | 707 | (n_node_level == |
708 | DISK_LEAF_NODE_LEVEL) ? IH_SIZE : | 708 | DISK_LEAF_NODE_LEVEL) ? IH_SIZE : |
709 | KEY_SIZE, | 709 | KEY_SIZE, |
710 | &(p_s_last_element->pe_position)); | 710 | &(last_element->pe_position)); |
711 | if (n_node_level == n_stop_level) { | 711 | if (n_node_level == n_stop_level) { |
712 | return n_retval; | 712 | return n_retval; |
713 | } | 713 | } |
@@ -715,7 +715,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key | |||
715 | /* we are not in the stop level */ | 715 | /* we are not in the stop level */ |
716 | if (n_retval == ITEM_FOUND) | 716 | if (n_retval == ITEM_FOUND) |
717 | /* item has been found, so we choose the pointer which is to the right of the found one */ | 717 | /* item has been found, so we choose the pointer which is to the right of the found one */ |
718 | p_s_last_element->pe_position++; | 718 | last_element->pe_position++; |
719 | 719 | ||
720 | /* if item was not found we choose the position which is to | 720 | /* if item was not found we choose the position which is to |
721 | the left of the found item. This requires no code, | 721 | the left of the found item. This requires no code, |
@@ -725,23 +725,23 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key | |||
725 | an internal node. Now we calculate child block number by | 725 | an internal node. Now we calculate child block number by |
726 | position in the node. */ | 726 | position in the node. */ |
727 | n_block_number = | 727 | n_block_number = |
728 | B_N_CHILD_NUM(bh, p_s_last_element->pe_position); | 728 | B_N_CHILD_NUM(bh, last_element->pe_position); |
729 | 729 | ||
730 | /* if we are going to read leaf nodes, try for read ahead as well */ | 730 | /* if we are going to read leaf nodes, try for read ahead as well */ |
731 | if ((p_s_search_path->reada & PATH_READA) && | 731 | if ((search_path->reada & PATH_READA) && |
732 | n_node_level == DISK_LEAF_NODE_LEVEL + 1) { | 732 | n_node_level == DISK_LEAF_NODE_LEVEL + 1) { |
733 | int pos = p_s_last_element->pe_position; | 733 | int pos = last_element->pe_position; |
734 | int limit = B_NR_ITEMS(bh); | 734 | int limit = B_NR_ITEMS(bh); |
735 | struct reiserfs_key *le_key; | 735 | struct reiserfs_key *le_key; |
736 | 736 | ||
737 | if (p_s_search_path->reada & PATH_READA_BACK) | 737 | if (search_path->reada & PATH_READA_BACK) |
738 | limit = 0; | 738 | limit = 0; |
739 | while (reada_count < SEARCH_BY_KEY_READA) { | 739 | while (reada_count < SEARCH_BY_KEY_READA) { |
740 | if (pos == limit) | 740 | if (pos == limit) |
741 | break; | 741 | break; |
742 | reada_blocks[reada_count++] = | 742 | reada_blocks[reada_count++] = |
743 | B_N_CHILD_NUM(bh, pos); | 743 | B_N_CHILD_NUM(bh, pos); |
744 | if (p_s_search_path->reada & PATH_READA_BACK) | 744 | if (search_path->reada & PATH_READA_BACK) |
745 | pos--; | 745 | pos--; |
746 | else | 746 | else |
747 | pos++; | 747 | pos++; |
@@ -751,7 +751,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key | |||
751 | */ | 751 | */ |
752 | le_key = B_N_PDELIM_KEY(bh, pos); | 752 | le_key = B_N_PDELIM_KEY(bh, pos); |
753 | if (le32_to_cpu(le_key->k_objectid) != | 753 | if (le32_to_cpu(le_key->k_objectid) != |
754 | p_s_key->on_disk_key.k_objectid) { | 754 | key->on_disk_key.k_objectid) { |
755 | break; | 755 | break; |
756 | } | 756 | } |
757 | } | 757 | } |
@@ -760,11 +760,11 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key | |||
760 | } | 760 | } |
761 | 761 | ||
762 | /* Form the path to an item and position in this item which contains | 762 | /* Form the path to an item and position in this item which contains |
763 | file byte defined by p_s_key. If there is no such item | 763 | file byte defined by key. If there is no such item |
764 | corresponding to the key, we point the path to the item with | 764 | corresponding to the key, we point the path to the item with |
765 | maximal key less than p_s_key, and *p_n_pos_in_item is set to one | 765 | maximal key less than key, and *pos_in_item is set to one |
766 | past the last entry/byte in the item. If searching for entry in a | 766 | past the last entry/byte in the item. If searching for entry in a |
767 | directory item, and it is not found, *p_n_pos_in_item is set to one | 767 | directory item, and it is not found, *pos_in_item is set to one |
768 | entry more than the entry with maximal key which is less than the | 768 | entry more than the entry with maximal key which is less than the |
769 | sought key. | 769 | sought key. |
770 | 770 | ||
@@ -777,7 +777,7 @@ int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key | |||
777 | /* The function is NOT SCHEDULE-SAFE! */ | 777 | /* The function is NOT SCHEDULE-SAFE! */ |
778 | int search_for_position_by_key(struct super_block *sb, /* Pointer to the super block. */ | 778 | int search_for_position_by_key(struct super_block *sb, /* Pointer to the super block. */ |
779 | const struct cpu_key *p_cpu_key, /* Key to search (cpu variable) */ | 779 | const struct cpu_key *p_cpu_key, /* Key to search (cpu variable) */ |
780 | struct treepath *p_s_search_path /* Filled up by this function. */ | 780 | struct treepath *search_path /* Filled up by this function. */ |
781 | ) | 781 | ) |
782 | { | 782 | { |
783 | struct item_head *p_le_ih; /* pointer to on-disk structure */ | 783 | struct item_head *p_le_ih; /* pointer to on-disk structure */ |
@@ -788,34 +788,34 @@ int search_for_position_by_key(struct super_block *sb, /* Pointer to the super b | |||
788 | 788 | ||
789 | /* If searching for directory entry. */ | 789 | /* If searching for directory entry. */ |
790 | if (is_direntry_cpu_key(p_cpu_key)) | 790 | if (is_direntry_cpu_key(p_cpu_key)) |
791 | return search_by_entry_key(sb, p_cpu_key, p_s_search_path, | 791 | return search_by_entry_key(sb, p_cpu_key, search_path, |
792 | &de); | 792 | &de); |
793 | 793 | ||
794 | /* If not searching for directory entry. */ | 794 | /* If not searching for directory entry. */ |
795 | 795 | ||
796 | /* If item is found. */ | 796 | /* If item is found. */ |
797 | retval = search_item(sb, p_cpu_key, p_s_search_path); | 797 | retval = search_item(sb, p_cpu_key, search_path); |
798 | if (retval == IO_ERROR) | 798 | if (retval == IO_ERROR) |
799 | return retval; | 799 | return retval; |
800 | if (retval == ITEM_FOUND) { | 800 | if (retval == ITEM_FOUND) { |
801 | 801 | ||
802 | RFALSE(!ih_item_len | 802 | RFALSE(!ih_item_len |
803 | (B_N_PITEM_HEAD | 803 | (B_N_PITEM_HEAD |
804 | (PATH_PLAST_BUFFER(p_s_search_path), | 804 | (PATH_PLAST_BUFFER(search_path), |
805 | PATH_LAST_POSITION(p_s_search_path))), | 805 | PATH_LAST_POSITION(search_path))), |
806 | "PAP-5165: item length equals zero"); | 806 | "PAP-5165: item length equals zero"); |
807 | 807 | ||
808 | pos_in_item(p_s_search_path) = 0; | 808 | pos_in_item(search_path) = 0; |
809 | return POSITION_FOUND; | 809 | return POSITION_FOUND; |
810 | } | 810 | } |
811 | 811 | ||
812 | RFALSE(!PATH_LAST_POSITION(p_s_search_path), | 812 | RFALSE(!PATH_LAST_POSITION(search_path), |
813 | "PAP-5170: position equals zero"); | 813 | "PAP-5170: position equals zero"); |
814 | 814 | ||
815 | /* Item is not found. Set path to the previous item. */ | 815 | /* Item is not found. Set path to the previous item. */ |
816 | p_le_ih = | 816 | p_le_ih = |
817 | B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_search_path), | 817 | B_N_PITEM_HEAD(PATH_PLAST_BUFFER(search_path), |
818 | --PATH_LAST_POSITION(p_s_search_path)); | 818 | --PATH_LAST_POSITION(search_path)); |
819 | n_blk_size = sb->s_blocksize; | 819 | n_blk_size = sb->s_blocksize; |
820 | 820 | ||
821 | if (comp_short_keys(&(p_le_ih->ih_key), p_cpu_key)) { | 821 | if (comp_short_keys(&(p_le_ih->ih_key), p_cpu_key)) { |
@@ -829,9 +829,9 @@ int search_for_position_by_key(struct super_block *sb, /* Pointer to the super b | |||
829 | /* Needed byte is contained in the item pointed to by the path. */ | 829 | /* Needed byte is contained in the item pointed to by the path. */ |
830 | if (item_offset <= offset && | 830 | if (item_offset <= offset && |
831 | item_offset + op_bytes_number(p_le_ih, n_blk_size) > offset) { | 831 | item_offset + op_bytes_number(p_le_ih, n_blk_size) > offset) { |
832 | pos_in_item(p_s_search_path) = offset - item_offset; | 832 | pos_in_item(search_path) = offset - item_offset; |
833 | if (is_indirect_le_ih(p_le_ih)) { | 833 | if (is_indirect_le_ih(p_le_ih)) { |
834 | pos_in_item(p_s_search_path) /= n_blk_size; | 834 | pos_in_item(search_path) /= n_blk_size; |
835 | } | 835 | } |
836 | return POSITION_FOUND; | 836 | return POSITION_FOUND; |
837 | } | 837 | } |
@@ -839,18 +839,18 @@ int search_for_position_by_key(struct super_block *sb, /* Pointer to the super b | |||
839 | /* Needed byte is not contained in the item pointed to by the | 839 | /* Needed byte is not contained in the item pointed to by the |
840 | path. Set pos_in_item out of the item. */ | 840 | path. Set pos_in_item out of the item. */ |
841 | if (is_indirect_le_ih(p_le_ih)) | 841 | if (is_indirect_le_ih(p_le_ih)) |
842 | pos_in_item(p_s_search_path) = | 842 | pos_in_item(search_path) = |
843 | ih_item_len(p_le_ih) / UNFM_P_SIZE; | 843 | ih_item_len(p_le_ih) / UNFM_P_SIZE; |
844 | else | 844 | else |
845 | pos_in_item(p_s_search_path) = ih_item_len(p_le_ih); | 845 | pos_in_item(search_path) = ih_item_len(p_le_ih); |
846 | 846 | ||
847 | return POSITION_NOT_FOUND; | 847 | return POSITION_NOT_FOUND; |
848 | } | 848 | } |
849 | 849 | ||
850 | /* Compare given item and item pointed to by the path. */ | 850 | /* Compare given item and item pointed to by the path. */ |
851 | int comp_items(const struct item_head *stored_ih, const struct treepath *p_s_path) | 851 | int comp_items(const struct item_head *stored_ih, const struct treepath *path) |
852 | { | 852 | { |
853 | struct buffer_head *bh = PATH_PLAST_BUFFER(p_s_path); | 853 | struct buffer_head *bh = PATH_PLAST_BUFFER(path); |
854 | struct item_head *ih; | 854 | struct item_head *ih; |
855 | 855 | ||
856 | /* Last buffer at the path is not in the tree. */ | 856 | /* Last buffer at the path is not in the tree. */ |
@@ -858,11 +858,11 @@ int comp_items(const struct item_head *stored_ih, const struct treepath *p_s_pat | |||
858 | return 1; | 858 | return 1; |
859 | 859 | ||
860 | /* Last path position is invalid. */ | 860 | /* Last path position is invalid. */ |
861 | if (PATH_LAST_POSITION(p_s_path) >= B_NR_ITEMS(bh)) | 861 | if (PATH_LAST_POSITION(path) >= B_NR_ITEMS(bh)) |
862 | return 1; | 862 | return 1; |
863 | 863 | ||
864 | /* we need only to know, whether it is the same item */ | 864 | /* we need only to know, whether it is the same item */ |
865 | ih = get_ih(p_s_path); | 865 | ih = get_ih(path); |
866 | return memcmp(stored_ih, ih, IH_SIZE); | 866 | return memcmp(stored_ih, ih, IH_SIZE); |
867 | } | 867 | } |
868 | 868 | ||
@@ -951,14 +951,14 @@ static inline int prepare_for_direntry_item(struct treepath *path, | |||
951 | In case of file truncate calculate whether this item must be deleted/truncated or last | 951 | In case of file truncate calculate whether this item must be deleted/truncated or last |
952 | unformatted node of this item will be converted to a direct item. | 952 | unformatted node of this item will be converted to a direct item. |
953 | This function returns a determination of what balance mode the calling function should employ. */ | 953 | This function returns a determination of what balance mode the calling function should employ. */ |
954 | static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, struct inode *inode, struct treepath *p_s_path, const struct cpu_key *p_s_item_key, int *p_n_removed, /* Number of unformatted nodes which were removed | 954 | static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, struct inode *inode, struct treepath *path, const struct cpu_key *item_key, int *removed, /* Number of unformatted nodes which were removed |
955 | from end of the file. */ | 955 | from end of the file. */ |
956 | int *p_n_cut_size, unsigned long long n_new_file_length /* MAX_KEY_OFFSET in case of delete. */ | 956 | int *cut_size, unsigned long long n_new_file_length /* MAX_KEY_OFFSET in case of delete. */ |
957 | ) | 957 | ) |
958 | { | 958 | { |
959 | struct super_block *sb = inode->i_sb; | 959 | struct super_block *sb = inode->i_sb; |
960 | struct item_head *p_le_ih = PATH_PITEM_HEAD(p_s_path); | 960 | struct item_head *p_le_ih = PATH_PITEM_HEAD(path); |
961 | struct buffer_head *bh = PATH_PLAST_BUFFER(p_s_path); | 961 | struct buffer_head *bh = PATH_PLAST_BUFFER(path); |
962 | 962 | ||
963 | BUG_ON(!th->t_trans_id); | 963 | BUG_ON(!th->t_trans_id); |
964 | 964 | ||
@@ -968,20 +968,20 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st | |||
968 | RFALSE(n_new_file_length != max_reiserfs_offset(inode), | 968 | RFALSE(n_new_file_length != max_reiserfs_offset(inode), |
969 | "PAP-5210: mode must be M_DELETE"); | 969 | "PAP-5210: mode must be M_DELETE"); |
970 | 970 | ||
971 | *p_n_cut_size = -(IH_SIZE + ih_item_len(p_le_ih)); | 971 | *cut_size = -(IH_SIZE + ih_item_len(p_le_ih)); |
972 | return M_DELETE; | 972 | return M_DELETE; |
973 | } | 973 | } |
974 | 974 | ||
975 | /* Directory item. */ | 975 | /* Directory item. */ |
976 | if (is_direntry_le_ih(p_le_ih)) | 976 | if (is_direntry_le_ih(p_le_ih)) |
977 | return prepare_for_direntry_item(p_s_path, p_le_ih, inode, | 977 | return prepare_for_direntry_item(path, p_le_ih, inode, |
978 | n_new_file_length, | 978 | n_new_file_length, |
979 | p_n_cut_size); | 979 | cut_size); |
980 | 980 | ||
981 | /* Direct item. */ | 981 | /* Direct item. */ |
982 | if (is_direct_le_ih(p_le_ih)) | 982 | if (is_direct_le_ih(p_le_ih)) |
983 | return prepare_for_direct_item(p_s_path, p_le_ih, inode, | 983 | return prepare_for_direct_item(path, p_le_ih, inode, |
984 | n_new_file_length, p_n_cut_size); | 984 | n_new_file_length, cut_size); |
985 | 985 | ||
986 | /* Case of an indirect item. */ | 986 | /* Case of an indirect item. */ |
987 | { | 987 | { |
@@ -1001,9 +1001,9 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st | |||
1001 | 1001 | ||
1002 | do { | 1002 | do { |
1003 | need_re_search = 0; | 1003 | need_re_search = 0; |
1004 | *p_n_cut_size = 0; | 1004 | *cut_size = 0; |
1005 | bh = PATH_PLAST_BUFFER(p_s_path); | 1005 | bh = PATH_PLAST_BUFFER(path); |
1006 | copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path)); | 1006 | copy_item_head(&s_ih, PATH_PITEM_HEAD(path)); |
1007 | pos = I_UNFM_NUM(&s_ih); | 1007 | pos = I_UNFM_NUM(&s_ih); |
1008 | 1008 | ||
1009 | while (le_ih_k_offset (&s_ih) + (pos - 1) * blk_size > n_new_file_length) { | 1009 | while (le_ih_k_offset (&s_ih) + (pos - 1) * blk_size > n_new_file_length) { |
@@ -1013,10 +1013,9 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st | |||
1013 | /* Each unformatted block deletion may involve one additional | 1013 | /* Each unformatted block deletion may involve one additional |
1014 | * bitmap block into the transaction, thereby the initial | 1014 | * bitmap block into the transaction, thereby the initial |
1015 | * journal space reservation might not be enough. */ | 1015 | * journal space reservation might not be enough. */ |
1016 | if (!delete && (*p_n_cut_size) != 0 && | 1016 | if (!delete && (*cut_size) != 0 && |
1017 | reiserfs_transaction_free_space(th) < JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) { | 1017 | reiserfs_transaction_free_space(th) < JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) |
1018 | break; | 1018 | break; |
1019 | } | ||
1020 | 1019 | ||
1021 | unfm = (__le32 *)B_I_PITEM(bh, &s_ih) + pos - 1; | 1020 | unfm = (__le32 *)B_I_PITEM(bh, &s_ih) + pos - 1; |
1022 | block = get_block_num(unfm, 0); | 1021 | block = get_block_num(unfm, 0); |
@@ -1030,17 +1029,17 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st | |||
1030 | 1029 | ||
1031 | cond_resched(); | 1030 | cond_resched(); |
1032 | 1031 | ||
1033 | if (item_moved (&s_ih, p_s_path)) { | 1032 | if (item_moved (&s_ih, path)) { |
1034 | need_re_search = 1; | 1033 | need_re_search = 1; |
1035 | break; | 1034 | break; |
1036 | } | 1035 | } |
1037 | 1036 | ||
1038 | pos --; | 1037 | pos --; |
1039 | (*p_n_removed) ++; | 1038 | (*removed)++; |
1040 | (*p_n_cut_size) -= UNFM_P_SIZE; | 1039 | (*cut_size) -= UNFM_P_SIZE; |
1041 | 1040 | ||
1042 | if (pos == 0) { | 1041 | if (pos == 0) { |
1043 | (*p_n_cut_size) -= IH_SIZE; | 1042 | (*cut_size) -= IH_SIZE; |
1044 | result = M_DELETE; | 1043 | result = M_DELETE; |
1045 | break; | 1044 | break; |
1046 | } | 1045 | } |
@@ -1050,10 +1049,10 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st | |||
1050 | ** buffer */ | 1049 | ** buffer */ |
1051 | reiserfs_restore_prepared_buffer(sb, bh); | 1050 | reiserfs_restore_prepared_buffer(sb, bh); |
1052 | } while (need_re_search && | 1051 | } while (need_re_search && |
1053 | search_for_position_by_key(sb, p_s_item_key, p_s_path) == POSITION_FOUND); | 1052 | search_for_position_by_key(sb, item_key, path) == POSITION_FOUND); |
1054 | pos_in_item(p_s_path) = pos * UNFM_P_SIZE; | 1053 | pos_in_item(path) = pos * UNFM_P_SIZE; |
1055 | 1054 | ||
1056 | if (*p_n_cut_size == 0) { | 1055 | if (*cut_size == 0) { |
1057 | /* Nothing were cut. maybe convert last unformatted node to the | 1056 | /* Nothing were cut. maybe convert last unformatted node to the |
1058 | * direct item? */ | 1057 | * direct item? */ |
1059 | result = M_CONVERT; | 1058 | result = M_CONVERT; |
@@ -1091,7 +1090,7 @@ static int calc_deleted_bytes_number(struct tree_balance *tb, char c_mode) | |||
1091 | static void init_tb_struct(struct reiserfs_transaction_handle *th, | 1090 | static void init_tb_struct(struct reiserfs_transaction_handle *th, |
1092 | struct tree_balance *tb, | 1091 | struct tree_balance *tb, |
1093 | struct super_block *sb, | 1092 | struct super_block *sb, |
1094 | struct treepath *p_s_path, int n_size) | 1093 | struct treepath *path, int n_size) |
1095 | { | 1094 | { |
1096 | 1095 | ||
1097 | BUG_ON(!th->t_trans_id); | 1096 | BUG_ON(!th->t_trans_id); |
@@ -1099,9 +1098,9 @@ static void init_tb_struct(struct reiserfs_transaction_handle *th, | |||
1099 | memset(tb, '\0', sizeof(struct tree_balance)); | 1098 | memset(tb, '\0', sizeof(struct tree_balance)); |
1100 | tb->transaction_handle = th; | 1099 | tb->transaction_handle = th; |
1101 | tb->tb_sb = sb; | 1100 | tb->tb_sb = sb; |
1102 | tb->tb_path = p_s_path; | 1101 | tb->tb_path = path; |
1103 | PATH_OFFSET_PBUFFER(p_s_path, ILLEGAL_PATH_ELEMENT_OFFSET) = NULL; | 1102 | PATH_OFFSET_PBUFFER(path, ILLEGAL_PATH_ELEMENT_OFFSET) = NULL; |
1104 | PATH_OFFSET_POSITION(p_s_path, ILLEGAL_PATH_ELEMENT_OFFSET) = 0; | 1103 | PATH_OFFSET_POSITION(path, ILLEGAL_PATH_ELEMENT_OFFSET) = 0; |
1105 | tb->insert_size[0] = n_size; | 1104 | tb->insert_size[0] = n_size; |
1106 | } | 1105 | } |
1107 | 1106 | ||
@@ -1141,13 +1140,17 @@ char head2type(struct item_head *ih) | |||
1141 | } | 1140 | } |
1142 | #endif | 1141 | #endif |
1143 | 1142 | ||
1144 | /* Delete object item. */ | 1143 | /* Delete object item. |
1145 | int reiserfs_delete_item(struct reiserfs_transaction_handle *th, struct treepath *p_s_path, /* Path to the deleted item. */ | 1144 | * th - active transaction handle |
1146 | const struct cpu_key *p_s_item_key, /* Key to search for the deleted item. */ | 1145 | * path - path to the deleted item |
1147 | struct inode *inode, /* inode is here just to update | 1146 | * item_key - key to search for the deleted item |
1148 | * i_blocks and quotas */ | 1147 | * indode - used for updating i_blocks and quotas |
1149 | struct buffer_head *p_s_un_bh) | 1148 | * un_bh - NULL or unformatted node pointer |
1150 | { /* NULL or unformatted node pointer. */ | 1149 | */ |
1150 | int reiserfs_delete_item(struct reiserfs_transaction_handle *th, | ||
1151 | struct treepath *path, const struct cpu_key *item_key, | ||
1152 | struct inode *inode, struct buffer_head *un_bh) | ||
1153 | { | ||
1151 | struct super_block *sb = inode->i_sb; | 1154 | struct super_block *sb = inode->i_sb; |
1152 | struct tree_balance s_del_balance; | 1155 | struct tree_balance s_del_balance; |
1153 | struct item_head s_ih; | 1156 | struct item_head s_ih; |
@@ -1162,7 +1165,7 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th, struct treepath | |||
1162 | 1165 | ||
1163 | BUG_ON(!th->t_trans_id); | 1166 | BUG_ON(!th->t_trans_id); |
1164 | 1167 | ||
1165 | init_tb_struct(th, &s_del_balance, sb, p_s_path, | 1168 | init_tb_struct(th, &s_del_balance, sb, path, |
1166 | 0 /*size is unknown */ ); | 1169 | 0 /*size is unknown */ ); |
1167 | 1170 | ||
1168 | while (1) { | 1171 | while (1) { |
@@ -1172,14 +1175,14 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th, struct treepath | |||
1172 | n_iter++; | 1175 | n_iter++; |
1173 | c_mode = | 1176 | c_mode = |
1174 | #endif | 1177 | #endif |
1175 | prepare_for_delete_or_cut(th, inode, p_s_path, | 1178 | prepare_for_delete_or_cut(th, inode, path, |
1176 | p_s_item_key, &n_removed, | 1179 | item_key, &n_removed, |
1177 | &n_del_size, | 1180 | &n_del_size, |
1178 | max_reiserfs_offset(inode)); | 1181 | max_reiserfs_offset(inode)); |
1179 | 1182 | ||
1180 | RFALSE(c_mode != M_DELETE, "PAP-5320: mode must be M_DELETE"); | 1183 | RFALSE(c_mode != M_DELETE, "PAP-5320: mode must be M_DELETE"); |
1181 | 1184 | ||
1182 | copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path)); | 1185 | copy_item_head(&s_ih, PATH_PITEM_HEAD(path)); |
1183 | s_del_balance.insert_size[0] = n_del_size; | 1186 | s_del_balance.insert_size[0] = n_del_size; |
1184 | 1187 | ||
1185 | n_ret_value = fix_nodes(M_DELETE, &s_del_balance, NULL, NULL); | 1188 | n_ret_value = fix_nodes(M_DELETE, &s_del_balance, NULL, NULL); |
@@ -1190,13 +1193,13 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th, struct treepath | |||
1190 | 1193 | ||
1191 | // file system changed, repeat search | 1194 | // file system changed, repeat search |
1192 | n_ret_value = | 1195 | n_ret_value = |
1193 | search_for_position_by_key(sb, p_s_item_key, p_s_path); | 1196 | search_for_position_by_key(sb, item_key, path); |
1194 | if (n_ret_value == IO_ERROR) | 1197 | if (n_ret_value == IO_ERROR) |
1195 | break; | 1198 | break; |
1196 | if (n_ret_value == FILE_NOT_FOUND) { | 1199 | if (n_ret_value == FILE_NOT_FOUND) { |
1197 | reiserfs_warning(sb, "vs-5340", | 1200 | reiserfs_warning(sb, "vs-5340", |
1198 | "no items of the file %K found", | 1201 | "no items of the file %K found", |
1199 | p_s_item_key); | 1202 | item_key); |
1200 | break; | 1203 | break; |
1201 | } | 1204 | } |
1202 | } /* while (1) */ | 1205 | } /* while (1) */ |
@@ -1207,7 +1210,7 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th, struct treepath | |||
1207 | } | 1210 | } |
1208 | // reiserfs_delete_item returns item length when success | 1211 | // reiserfs_delete_item returns item length when success |
1209 | n_ret_value = calc_deleted_bytes_number(&s_del_balance, M_DELETE); | 1212 | n_ret_value = calc_deleted_bytes_number(&s_del_balance, M_DELETE); |
1210 | q_ih = get_ih(p_s_path); | 1213 | q_ih = get_ih(path); |
1211 | quota_cut_bytes = ih_item_len(q_ih); | 1214 | quota_cut_bytes = ih_item_len(q_ih); |
1212 | 1215 | ||
1213 | /* hack so the quota code doesn't have to guess if the file | 1216 | /* hack so the quota code doesn't have to guess if the file |
@@ -1224,7 +1227,7 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th, struct treepath | |||
1224 | } | 1227 | } |
1225 | } | 1228 | } |
1226 | 1229 | ||
1227 | if (p_s_un_bh) { | 1230 | if (un_bh) { |
1228 | int off; | 1231 | int off; |
1229 | char *data; | 1232 | char *data; |
1230 | 1233 | ||
@@ -1242,16 +1245,16 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th, struct treepath | |||
1242 | ** The unformatted node must be dirtied later on. We can't be | 1245 | ** The unformatted node must be dirtied later on. We can't be |
1243 | ** sure here if the entire tail has been deleted yet. | 1246 | ** sure here if the entire tail has been deleted yet. |
1244 | ** | 1247 | ** |
1245 | ** p_s_un_bh is from the page cache (all unformatted nodes are | 1248 | ** un_bh is from the page cache (all unformatted nodes are |
1246 | ** from the page cache) and might be a highmem page. So, we | 1249 | ** from the page cache) and might be a highmem page. So, we |
1247 | ** can't use p_s_un_bh->b_data. | 1250 | ** can't use un_bh->b_data. |
1248 | ** -clm | 1251 | ** -clm |
1249 | */ | 1252 | */ |
1250 | 1253 | ||
1251 | data = kmap_atomic(p_s_un_bh->b_page, KM_USER0); | 1254 | data = kmap_atomic(un_bh->b_page, KM_USER0); |
1252 | off = ((le_ih_k_offset(&s_ih) - 1) & (PAGE_CACHE_SIZE - 1)); | 1255 | off = ((le_ih_k_offset(&s_ih) - 1) & (PAGE_CACHE_SIZE - 1)); |
1253 | memcpy(data + off, | 1256 | memcpy(data + off, |
1254 | B_I_PITEM(PATH_PLAST_BUFFER(p_s_path), &s_ih), | 1257 | B_I_PITEM(PATH_PLAST_BUFFER(path), &s_ih), |
1255 | n_ret_value); | 1258 | n_ret_value); |
1256 | kunmap_atomic(data, KM_USER0); | 1259 | kunmap_atomic(data, KM_USER0); |
1257 | } | 1260 | } |
@@ -1427,9 +1430,9 @@ static void unmap_buffers(struct page *page, loff_t pos) | |||
1427 | static int maybe_indirect_to_direct(struct reiserfs_transaction_handle *th, | 1430 | static int maybe_indirect_to_direct(struct reiserfs_transaction_handle *th, |
1428 | struct inode *inode, | 1431 | struct inode *inode, |
1429 | struct page *page, | 1432 | struct page *page, |
1430 | struct treepath *p_s_path, | 1433 | struct treepath *path, |
1431 | const struct cpu_key *p_s_item_key, | 1434 | const struct cpu_key *item_key, |
1432 | loff_t n_new_file_size, char *p_c_mode) | 1435 | loff_t n_new_file_size, char *mode) |
1433 | { | 1436 | { |
1434 | struct super_block *sb = inode->i_sb; | 1437 | struct super_block *sb = inode->i_sb; |
1435 | int n_block_size = sb->s_blocksize; | 1438 | int n_block_size = sb->s_blocksize; |
@@ -1445,17 +1448,17 @@ static int maybe_indirect_to_direct(struct reiserfs_transaction_handle *th, | |||
1445 | !tail_has_to_be_packed(inode) || | 1448 | !tail_has_to_be_packed(inode) || |
1446 | !page || (REISERFS_I(inode)->i_flags & i_nopack_mask)) { | 1449 | !page || (REISERFS_I(inode)->i_flags & i_nopack_mask)) { |
1447 | /* leave tail in an unformatted node */ | 1450 | /* leave tail in an unformatted node */ |
1448 | *p_c_mode = M_SKIP_BALANCING; | 1451 | *mode = M_SKIP_BALANCING; |
1449 | cut_bytes = | 1452 | cut_bytes = |
1450 | n_block_size - (n_new_file_size & (n_block_size - 1)); | 1453 | n_block_size - (n_new_file_size & (n_block_size - 1)); |
1451 | pathrelse(p_s_path); | 1454 | pathrelse(path); |
1452 | return cut_bytes; | 1455 | return cut_bytes; |
1453 | } | 1456 | } |
1454 | /* Permorm the conversion to a direct_item. */ | 1457 | /* Perform the conversion to a direct_item. */ |
1455 | /* return indirect_to_direct(inode, p_s_path, p_s_item_key, | 1458 | /* return indirect_to_direct(inode, path, item_key, |
1456 | n_new_file_size, p_c_mode); */ | 1459 | n_new_file_size, mode); */ |
1457 | return indirect2direct(th, inode, page, p_s_path, p_s_item_key, | 1460 | return indirect2direct(th, inode, page, path, item_key, |
1458 | n_new_file_size, p_c_mode); | 1461 | n_new_file_size, mode); |
1459 | } | 1462 | } |
1460 | 1463 | ||
1461 | /* we did indirect_to_direct conversion. And we have inserted direct | 1464 | /* we did indirect_to_direct conversion. And we have inserted direct |
@@ -1506,8 +1509,8 @@ static void indirect_to_direct_roll_back(struct reiserfs_transaction_handle *th, | |||
1506 | 1509 | ||
1507 | /* (Truncate or cut entry) or delete object item. Returns < 0 on failure */ | 1510 | /* (Truncate or cut entry) or delete object item. Returns < 0 on failure */ |
1508 | int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, | 1511 | int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, |
1509 | struct treepath *p_s_path, | 1512 | struct treepath *path, |
1510 | struct cpu_key *p_s_item_key, | 1513 | struct cpu_key *item_key, |
1511 | struct inode *inode, | 1514 | struct inode *inode, |
1512 | struct page *page, loff_t n_new_file_size) | 1515 | struct page *page, loff_t n_new_file_size) |
1513 | { | 1516 | { |
@@ -1528,7 +1531,7 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, | |||
1528 | 1531 | ||
1529 | BUG_ON(!th->t_trans_id); | 1532 | BUG_ON(!th->t_trans_id); |
1530 | 1533 | ||
1531 | init_tb_struct(th, &s_cut_balance, inode->i_sb, p_s_path, | 1534 | init_tb_struct(th, &s_cut_balance, inode->i_sb, path, |
1532 | n_cut_size); | 1535 | n_cut_size); |
1533 | 1536 | ||
1534 | /* Repeat this loop until we either cut the item without needing | 1537 | /* Repeat this loop until we either cut the item without needing |
@@ -1540,8 +1543,8 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, | |||
1540 | pointers. */ | 1543 | pointers. */ |
1541 | 1544 | ||
1542 | c_mode = | 1545 | c_mode = |
1543 | prepare_for_delete_or_cut(th, inode, p_s_path, | 1546 | prepare_for_delete_or_cut(th, inode, path, |
1544 | p_s_item_key, &n_removed, | 1547 | item_key, &n_removed, |
1545 | &n_cut_size, n_new_file_size); | 1548 | &n_cut_size, n_new_file_size); |
1546 | if (c_mode == M_CONVERT) { | 1549 | if (c_mode == M_CONVERT) { |
1547 | /* convert last unformatted node to direct item or leave | 1550 | /* convert last unformatted node to direct item or leave |
@@ -1551,7 +1554,7 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, | |||
1551 | 1554 | ||
1552 | n_ret_value = | 1555 | n_ret_value = |
1553 | maybe_indirect_to_direct(th, inode, page, | 1556 | maybe_indirect_to_direct(th, inode, page, |
1554 | p_s_path, p_s_item_key, | 1557 | path, item_key, |
1555 | n_new_file_size, &c_mode); | 1558 | n_new_file_size, &c_mode); |
1556 | if (c_mode == M_SKIP_BALANCING) | 1559 | if (c_mode == M_SKIP_BALANCING) |
1557 | /* tail has been left in the unformatted node */ | 1560 | /* tail has been left in the unformatted node */ |
@@ -1568,26 +1571,26 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, | |||
1568 | inserting the new direct item. Now we are removing the | 1571 | inserting the new direct item. Now we are removing the |
1569 | last unformatted node pointer. Set key to search for | 1572 | last unformatted node pointer. Set key to search for |
1570 | it. */ | 1573 | it. */ |
1571 | set_cpu_key_k_type(p_s_item_key, TYPE_INDIRECT); | 1574 | set_cpu_key_k_type(item_key, TYPE_INDIRECT); |
1572 | p_s_item_key->key_length = 4; | 1575 | item_key->key_length = 4; |
1573 | n_new_file_size -= | 1576 | n_new_file_size -= |
1574 | (n_new_file_size & (sb->s_blocksize - 1)); | 1577 | (n_new_file_size & (sb->s_blocksize - 1)); |
1575 | tail_pos = n_new_file_size; | 1578 | tail_pos = n_new_file_size; |
1576 | set_cpu_key_k_offset(p_s_item_key, n_new_file_size + 1); | 1579 | set_cpu_key_k_offset(item_key, n_new_file_size + 1); |
1577 | if (search_for_position_by_key | 1580 | if (search_for_position_by_key |
1578 | (sb, p_s_item_key, | 1581 | (sb, item_key, |
1579 | p_s_path) == POSITION_NOT_FOUND) { | 1582 | path) == POSITION_NOT_FOUND) { |
1580 | print_block(PATH_PLAST_BUFFER(p_s_path), 3, | 1583 | print_block(PATH_PLAST_BUFFER(path), 3, |
1581 | PATH_LAST_POSITION(p_s_path) - 1, | 1584 | PATH_LAST_POSITION(path) - 1, |
1582 | PATH_LAST_POSITION(p_s_path) + 1); | 1585 | PATH_LAST_POSITION(path) + 1); |
1583 | reiserfs_panic(sb, "PAP-5580", "item to " | 1586 | reiserfs_panic(sb, "PAP-5580", "item to " |
1584 | "convert does not exist (%K)", | 1587 | "convert does not exist (%K)", |
1585 | p_s_item_key); | 1588 | item_key); |
1586 | } | 1589 | } |
1587 | continue; | 1590 | continue; |
1588 | } | 1591 | } |
1589 | if (n_cut_size == 0) { | 1592 | if (n_cut_size == 0) { |
1590 | pathrelse(p_s_path); | 1593 | pathrelse(path); |
1591 | return 0; | 1594 | return 0; |
1592 | } | 1595 | } |
1593 | 1596 | ||
@@ -1600,12 +1603,12 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, | |||
1600 | PROC_INFO_INC(sb, cut_from_item_restarted); | 1603 | PROC_INFO_INC(sb, cut_from_item_restarted); |
1601 | 1604 | ||
1602 | n_ret_value = | 1605 | n_ret_value = |
1603 | search_for_position_by_key(sb, p_s_item_key, p_s_path); | 1606 | search_for_position_by_key(sb, item_key, path); |
1604 | if (n_ret_value == POSITION_FOUND) | 1607 | if (n_ret_value == POSITION_FOUND) |
1605 | continue; | 1608 | continue; |
1606 | 1609 | ||
1607 | reiserfs_warning(sb, "PAP-5610", "item %K not found", | 1610 | reiserfs_warning(sb, "PAP-5610", "item %K not found", |
1608 | p_s_item_key); | 1611 | item_key); |
1609 | unfix_nodes(&s_cut_balance); | 1612 | unfix_nodes(&s_cut_balance); |
1610 | return (n_ret_value == IO_ERROR) ? -EIO : -ENOENT; | 1613 | return (n_ret_value == IO_ERROR) ? -EIO : -ENOENT; |
1611 | } /* while */ | 1614 | } /* while */ |
@@ -1615,7 +1618,7 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, | |||
1615 | if (n_is_inode_locked) { | 1618 | if (n_is_inode_locked) { |
1616 | // FIXME: this seems to be not needed: we are always able | 1619 | // FIXME: this seems to be not needed: we are always able |
1617 | // to cut item | 1620 | // to cut item |
1618 | indirect_to_direct_roll_back(th, inode, p_s_path); | 1621 | indirect_to_direct_roll_back(th, inode, path); |
1619 | } | 1622 | } |
1620 | if (n_ret_value == NO_DISK_SPACE) | 1623 | if (n_ret_value == NO_DISK_SPACE) |
1621 | reiserfs_warning(sb, "reiserfs-5092", | 1624 | reiserfs_warning(sb, "reiserfs-5092", |
@@ -1631,7 +1634,7 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th, | |||
1631 | /* Calculate number of bytes that need to be cut from the item. */ | 1634 | /* Calculate number of bytes that need to be cut from the item. */ |
1632 | quota_cut_bytes = | 1635 | quota_cut_bytes = |
1633 | (c_mode == | 1636 | (c_mode == |
1634 | M_DELETE) ? ih_item_len(get_ih(p_s_path)) : -s_cut_balance. | 1637 | M_DELETE) ? ih_item_len(get_ih(path)) : -s_cut_balance. |
1635 | insert_size[0]; | 1638 | insert_size[0]; |
1636 | if (retval2 == -1) | 1639 | if (retval2 == -1) |
1637 | n_ret_value = calc_deleted_bytes_number(&s_cut_balance, c_mode); | 1640 | n_ret_value = calc_deleted_bytes_number(&s_cut_balance, c_mode); |
@@ -1878,7 +1881,7 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, | |||
1878 | #ifdef CONFIG_REISERFS_CHECK | 1881 | #ifdef CONFIG_REISERFS_CHECK |
1879 | // this makes sure, that we __append__, not overwrite or add holes | 1882 | // this makes sure, that we __append__, not overwrite or add holes |
1880 | static void check_research_for_paste(struct treepath *path, | 1883 | static void check_research_for_paste(struct treepath *path, |
1881 | const struct cpu_key *p_s_key) | 1884 | const struct cpu_key *key) |
1882 | { | 1885 | { |
1883 | struct item_head *found_ih = get_ih(path); | 1886 | struct item_head *found_ih = get_ih(path); |
1884 | 1887 | ||
@@ -1886,35 +1889,35 @@ static void check_research_for_paste(struct treepath *path, | |||
1886 | if (le_ih_k_offset(found_ih) + | 1889 | if (le_ih_k_offset(found_ih) + |
1887 | op_bytes_number(found_ih, | 1890 | op_bytes_number(found_ih, |
1888 | get_last_bh(path)->b_size) != | 1891 | get_last_bh(path)->b_size) != |
1889 | cpu_key_k_offset(p_s_key) | 1892 | cpu_key_k_offset(key) |
1890 | || op_bytes_number(found_ih, | 1893 | || op_bytes_number(found_ih, |
1891 | get_last_bh(path)->b_size) != | 1894 | get_last_bh(path)->b_size) != |
1892 | pos_in_item(path)) | 1895 | pos_in_item(path)) |
1893 | reiserfs_panic(NULL, "PAP-5720", "found direct item " | 1896 | reiserfs_panic(NULL, "PAP-5720", "found direct item " |
1894 | "%h or position (%d) does not match " | 1897 | "%h or position (%d) does not match " |
1895 | "to key %K", found_ih, | 1898 | "to key %K", found_ih, |
1896 | pos_in_item(path), p_s_key); | 1899 | pos_in_item(path), key); |
1897 | } | 1900 | } |
1898 | if (is_indirect_le_ih(found_ih)) { | 1901 | if (is_indirect_le_ih(found_ih)) { |
1899 | if (le_ih_k_offset(found_ih) + | 1902 | if (le_ih_k_offset(found_ih) + |
1900 | op_bytes_number(found_ih, | 1903 | op_bytes_number(found_ih, |
1901 | get_last_bh(path)->b_size) != | 1904 | get_last_bh(path)->b_size) != |
1902 | cpu_key_k_offset(p_s_key) | 1905 | cpu_key_k_offset(key) |
1903 | || I_UNFM_NUM(found_ih) != pos_in_item(path) | 1906 | || I_UNFM_NUM(found_ih) != pos_in_item(path) |
1904 | || get_ih_free_space(found_ih) != 0) | 1907 | || get_ih_free_space(found_ih) != 0) |
1905 | reiserfs_panic(NULL, "PAP-5730", "found indirect " | 1908 | reiserfs_panic(NULL, "PAP-5730", "found indirect " |
1906 | "item (%h) or position (%d) does not " | 1909 | "item (%h) or position (%d) does not " |
1907 | "match to key (%K)", | 1910 | "match to key (%K)", |
1908 | found_ih, pos_in_item(path), p_s_key); | 1911 | found_ih, pos_in_item(path), key); |
1909 | } | 1912 | } |
1910 | } | 1913 | } |
1911 | #endif /* config reiserfs check */ | 1914 | #endif /* config reiserfs check */ |
1912 | 1915 | ||
1913 | /* Paste bytes to the existing item. Returns bytes number pasted into the item. */ | 1916 | /* Paste bytes to the existing item. Returns bytes number pasted into the item. */ |
1914 | int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct treepath *p_s_search_path, /* Path to the pasted item. */ | 1917 | int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct treepath *search_path, /* Path to the pasted item. */ |
1915 | const struct cpu_key *p_s_key, /* Key to search for the needed item. */ | 1918 | const struct cpu_key *key, /* Key to search for the needed item. */ |
1916 | struct inode *inode, /* Inode item belongs to */ | 1919 | struct inode *inode, /* Inode item belongs to */ |
1917 | const char *p_c_body, /* Pointer to the bytes to paste. */ | 1920 | const char *body, /* Pointer to the bytes to paste. */ |
1918 | int n_pasted_size) | 1921 | int n_pasted_size) |
1919 | { /* Size of pasted bytes. */ | 1922 | { /* Size of pasted bytes. */ |
1920 | struct tree_balance s_paste_balance; | 1923 | struct tree_balance s_paste_balance; |
@@ -1929,17 +1932,17 @@ int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct tree | |||
1929 | reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE, | 1932 | reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE, |
1930 | "reiserquota paste_into_item(): allocating %u id=%u type=%c", | 1933 | "reiserquota paste_into_item(): allocating %u id=%u type=%c", |
1931 | n_pasted_size, inode->i_uid, | 1934 | n_pasted_size, inode->i_uid, |
1932 | key2type(&(p_s_key->on_disk_key))); | 1935 | key2type(&(key->on_disk_key))); |
1933 | #endif | 1936 | #endif |
1934 | 1937 | ||
1935 | if (DQUOT_ALLOC_SPACE_NODIRTY(inode, n_pasted_size)) { | 1938 | if (DQUOT_ALLOC_SPACE_NODIRTY(inode, n_pasted_size)) { |
1936 | pathrelse(p_s_search_path); | 1939 | pathrelse(search_path); |
1937 | return -EDQUOT; | 1940 | return -EDQUOT; |
1938 | } | 1941 | } |
1939 | init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path, | 1942 | init_tb_struct(th, &s_paste_balance, th->t_super, search_path, |
1940 | n_pasted_size); | 1943 | n_pasted_size); |
1941 | #ifdef DISPLACE_NEW_PACKING_LOCALITIES | 1944 | #ifdef DISPLACE_NEW_PACKING_LOCALITIES |
1942 | s_paste_balance.key = p_s_key->on_disk_key; | 1945 | s_paste_balance.key = key->on_disk_key; |
1943 | #endif | 1946 | #endif |
1944 | 1947 | ||
1945 | /* DQUOT_* can schedule, must check before the fix_nodes */ | 1948 | /* DQUOT_* can schedule, must check before the fix_nodes */ |
@@ -1949,13 +1952,13 @@ int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct tree | |||
1949 | 1952 | ||
1950 | while ((retval = | 1953 | while ((retval = |
1951 | fix_nodes(M_PASTE, &s_paste_balance, NULL, | 1954 | fix_nodes(M_PASTE, &s_paste_balance, NULL, |
1952 | p_c_body)) == REPEAT_SEARCH) { | 1955 | body)) == REPEAT_SEARCH) { |
1953 | search_again: | 1956 | search_again: |
1954 | /* file system changed while we were in the fix_nodes */ | 1957 | /* file system changed while we were in the fix_nodes */ |
1955 | PROC_INFO_INC(th->t_super, paste_into_item_restarted); | 1958 | PROC_INFO_INC(th->t_super, paste_into_item_restarted); |
1956 | retval = | 1959 | retval = |
1957 | search_for_position_by_key(th->t_super, p_s_key, | 1960 | search_for_position_by_key(th->t_super, key, |
1958 | p_s_search_path); | 1961 | search_path); |
1959 | if (retval == IO_ERROR) { | 1962 | if (retval == IO_ERROR) { |
1960 | retval = -EIO; | 1963 | retval = -EIO; |
1961 | goto error_out; | 1964 | goto error_out; |
@@ -1963,19 +1966,19 @@ int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct tree | |||
1963 | if (retval == POSITION_FOUND) { | 1966 | if (retval == POSITION_FOUND) { |
1964 | reiserfs_warning(inode->i_sb, "PAP-5710", | 1967 | reiserfs_warning(inode->i_sb, "PAP-5710", |
1965 | "entry or pasted byte (%K) exists", | 1968 | "entry or pasted byte (%K) exists", |
1966 | p_s_key); | 1969 | key); |
1967 | retval = -EEXIST; | 1970 | retval = -EEXIST; |
1968 | goto error_out; | 1971 | goto error_out; |
1969 | } | 1972 | } |
1970 | #ifdef CONFIG_REISERFS_CHECK | 1973 | #ifdef CONFIG_REISERFS_CHECK |
1971 | check_research_for_paste(p_s_search_path, p_s_key); | 1974 | check_research_for_paste(search_path, key); |
1972 | #endif | 1975 | #endif |
1973 | } | 1976 | } |
1974 | 1977 | ||
1975 | /* Perform balancing after all resources are collected by fix_nodes, and | 1978 | /* Perform balancing after all resources are collected by fix_nodes, and |
1976 | accessing them will not risk triggering schedule. */ | 1979 | accessing them will not risk triggering schedule. */ |
1977 | if (retval == CARRY_ON) { | 1980 | if (retval == CARRY_ON) { |
1978 | do_balance(&s_paste_balance, NULL /*ih */ , p_c_body, M_PASTE); | 1981 | do_balance(&s_paste_balance, NULL /*ih */ , body, M_PASTE); |
1979 | return 0; | 1982 | return 0; |
1980 | } | 1983 | } |
1981 | retval = (retval == NO_DISK_SPACE) ? -ENOSPC : -EIO; | 1984 | retval = (retval == NO_DISK_SPACE) ? -ENOSPC : -EIO; |
@@ -1986,17 +1989,23 @@ int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct tree | |||
1986 | reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE, | 1989 | reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE, |
1987 | "reiserquota paste_into_item(): freeing %u id=%u type=%c", | 1990 | "reiserquota paste_into_item(): freeing %u id=%u type=%c", |
1988 | n_pasted_size, inode->i_uid, | 1991 | n_pasted_size, inode->i_uid, |
1989 | key2type(&(p_s_key->on_disk_key))); | 1992 | key2type(&(key->on_disk_key))); |
1990 | #endif | 1993 | #endif |
1991 | DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size); | 1994 | DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size); |
1992 | return retval; | 1995 | return retval; |
1993 | } | 1996 | } |
1994 | 1997 | ||
1995 | /* Insert new item into the buffer at the path. */ | 1998 | /* Insert new item into the buffer at the path. |
1996 | int reiserfs_insert_item(struct reiserfs_transaction_handle *th, struct treepath *p_s_path, /* Path to the inserteded item. */ | 1999 | * th - active transaction handle |
1997 | const struct cpu_key *key, struct item_head *p_s_ih, /* Pointer to the item header to insert. */ | 2000 | * path - path to the inserted item |
1998 | struct inode *inode, const char *p_c_body) | 2001 | * ih - pointer to the item header to insert |
1999 | { /* Pointer to the bytes to insert. */ | 2002 | * body - pointer to the bytes to insert |
2003 | */ | ||
2004 | int reiserfs_insert_item(struct reiserfs_transaction_handle *th, | ||
2005 | struct treepath *path, const struct cpu_key *key, | ||
2006 | struct item_head *ih, struct inode *inode, | ||
2007 | const char *body) | ||
2008 | { | ||
2000 | struct tree_balance s_ins_balance; | 2009 | struct tree_balance s_ins_balance; |
2001 | int retval; | 2010 | int retval; |
2002 | int fs_gen = 0; | 2011 | int fs_gen = 0; |
@@ -2006,28 +2015,27 @@ int reiserfs_insert_item(struct reiserfs_transaction_handle *th, struct treepath | |||
2006 | 2015 | ||
2007 | if (inode) { /* Do we count quotas for item? */ | 2016 | if (inode) { /* Do we count quotas for item? */ |
2008 | fs_gen = get_generation(inode->i_sb); | 2017 | fs_gen = get_generation(inode->i_sb); |
2009 | quota_bytes = ih_item_len(p_s_ih); | 2018 | quota_bytes = ih_item_len(ih); |
2010 | 2019 | ||
2011 | /* hack so the quota code doesn't have to guess if the file has | 2020 | /* hack so the quota code doesn't have to guess if the file has |
2012 | ** a tail, links are always tails, so there's no guessing needed | 2021 | ** a tail, links are always tails, so there's no guessing needed |
2013 | */ | 2022 | */ |
2014 | if (!S_ISLNK(inode->i_mode) && is_direct_le_ih(p_s_ih)) { | 2023 | if (!S_ISLNK(inode->i_mode) && is_direct_le_ih(ih)) |
2015 | quota_bytes = inode->i_sb->s_blocksize + UNFM_P_SIZE; | 2024 | quota_bytes = inode->i_sb->s_blocksize + UNFM_P_SIZE; |
2016 | } | ||
2017 | #ifdef REISERQUOTA_DEBUG | 2025 | #ifdef REISERQUOTA_DEBUG |
2018 | reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE, | 2026 | reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE, |
2019 | "reiserquota insert_item(): allocating %u id=%u type=%c", | 2027 | "reiserquota insert_item(): allocating %u id=%u type=%c", |
2020 | quota_bytes, inode->i_uid, head2type(p_s_ih)); | 2028 | quota_bytes, inode->i_uid, head2type(ih)); |
2021 | #endif | 2029 | #endif |
2022 | /* We can't dirty inode here. It would be immediately written but | 2030 | /* We can't dirty inode here. It would be immediately written but |
2023 | * appropriate stat item isn't inserted yet... */ | 2031 | * appropriate stat item isn't inserted yet... */ |
2024 | if (DQUOT_ALLOC_SPACE_NODIRTY(inode, quota_bytes)) { | 2032 | if (DQUOT_ALLOC_SPACE_NODIRTY(inode, quota_bytes)) { |
2025 | pathrelse(p_s_path); | 2033 | pathrelse(path); |
2026 | return -EDQUOT; | 2034 | return -EDQUOT; |
2027 | } | 2035 | } |
2028 | } | 2036 | } |
2029 | init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path, | 2037 | init_tb_struct(th, &s_ins_balance, th->t_super, path, |
2030 | IH_SIZE + ih_item_len(p_s_ih)); | 2038 | IH_SIZE + ih_item_len(ih)); |
2031 | #ifdef DISPLACE_NEW_PACKING_LOCALITIES | 2039 | #ifdef DISPLACE_NEW_PACKING_LOCALITIES |
2032 | s_ins_balance.key = key->on_disk_key; | 2040 | s_ins_balance.key = key->on_disk_key; |
2033 | #endif | 2041 | #endif |
@@ -2037,12 +2045,12 @@ int reiserfs_insert_item(struct reiserfs_transaction_handle *th, struct treepath | |||
2037 | } | 2045 | } |
2038 | 2046 | ||
2039 | while ((retval = | 2047 | while ((retval = |
2040 | fix_nodes(M_INSERT, &s_ins_balance, p_s_ih, | 2048 | fix_nodes(M_INSERT, &s_ins_balance, ih, |
2041 | p_c_body)) == REPEAT_SEARCH) { | 2049 | body)) == REPEAT_SEARCH) { |
2042 | search_again: | 2050 | search_again: |
2043 | /* file system changed while we were in the fix_nodes */ | 2051 | /* file system changed while we were in the fix_nodes */ |
2044 | PROC_INFO_INC(th->t_super, insert_item_restarted); | 2052 | PROC_INFO_INC(th->t_super, insert_item_restarted); |
2045 | retval = search_item(th->t_super, key, p_s_path); | 2053 | retval = search_item(th->t_super, key, path); |
2046 | if (retval == IO_ERROR) { | 2054 | if (retval == IO_ERROR) { |
2047 | retval = -EIO; | 2055 | retval = -EIO; |
2048 | goto error_out; | 2056 | goto error_out; |
@@ -2058,7 +2066,7 @@ int reiserfs_insert_item(struct reiserfs_transaction_handle *th, struct treepath | |||
2058 | 2066 | ||
2059 | /* make balancing after all resources will be collected at a time */ | 2067 | /* make balancing after all resources will be collected at a time */ |
2060 | if (retval == CARRY_ON) { | 2068 | if (retval == CARRY_ON) { |
2061 | do_balance(&s_ins_balance, p_s_ih, p_c_body, M_INSERT); | 2069 | do_balance(&s_ins_balance, ih, body, M_INSERT); |
2062 | return 0; | 2070 | return 0; |
2063 | } | 2071 | } |
2064 | 2072 | ||
@@ -2069,7 +2077,7 @@ int reiserfs_insert_item(struct reiserfs_transaction_handle *th, struct treepath | |||
2069 | #ifdef REISERQUOTA_DEBUG | 2077 | #ifdef REISERQUOTA_DEBUG |
2070 | reiserfs_debug(th->t_super, REISERFS_DEBUG_CODE, | 2078 | reiserfs_debug(th->t_super, REISERFS_DEBUG_CODE, |
2071 | "reiserquota insert_item(): freeing %u id=%u type=%c", | 2079 | "reiserquota insert_item(): freeing %u id=%u type=%c", |
2072 | quota_bytes, inode->i_uid, head2type(p_s_ih)); | 2080 | quota_bytes, inode->i_uid, head2type(ih)); |
2073 | #endif | 2081 | #endif |
2074 | if (inode) | 2082 | if (inode) |
2075 | DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes); | 2083 | DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes); |