aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2014-04-23 10:00:56 -0400
committerJan Kara <jack@suse.cz>2014-05-07 13:05:57 -0400
commit4bf4de6bc45a6b1cfa6af6cf235480287c8784fb (patch)
treea0709839b090ddb808563dc254ccdde6699a0dd6 /fs/reiserfs
parent0080e9f9d3ac717537dbd6db1fc8ef72ce0b9cc1 (diff)
reiserfs: balance_leaf refactor, format balance_leaf_insert_left
Reformat balance_leaf_insert_left to adhere to CodingStyle. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/reiserfs')
-rw-r--r--fs/reiserfs/do_balan.c93
1 files changed, 50 insertions, 43 deletions
diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
index b7085b7e7524..cca685daf26d 100644
--- a/fs/reiserfs/do_balan.c
+++ b/fs/reiserfs/do_balan.c
@@ -293,59 +293,66 @@ static int balance_leaf_when_delete(struct tree_balance *tb, int flag)
293static void balance_leaf_insert_left(struct tree_balance *tb, 293static void balance_leaf_insert_left(struct tree_balance *tb,
294 struct item_head *ih, const char *body) 294 struct item_head *ih, const char *body)
295{ 295{
296 int ret_val; 296 int ret;
297 struct buffer_info bi; 297 struct buffer_info bi;
298 int n = B_NR_ITEMS(tb->L[0]); 298 int n = B_NR_ITEMS(tb->L[0]);
299 299
300 if (tb->item_pos == tb->lnum[0] - 1 && tb->lbytes != -1) { 300 if (tb->item_pos == tb->lnum[0] - 1 && tb->lbytes != -1) {
301 /* part of new item falls into L[0] */ 301 /* part of new item falls into L[0] */
302 int new_item_len; 302 int new_item_len, shift;
303 int version; 303 int version;
304 304
305 ret_val = leaf_shift_left(tb, tb->lnum[0] - 1, -1); 305 ret = leaf_shift_left(tb, tb->lnum[0] - 1, -1);
306 306
307 /* Calculate item length to insert to S[0] */ 307 /* Calculate item length to insert to S[0] */
308 new_item_len = ih_item_len(ih) - tb->lbytes; 308 new_item_len = ih_item_len(ih) - tb->lbytes;
309 /* Calculate and check item length to insert to L[0] */
310 put_ih_item_len(ih, ih_item_len(ih) - new_item_len);
311 309
312 RFALSE(ih_item_len(ih) <= 0, 310 /* Calculate and check item length to insert to L[0] */
313 "PAP-12080: there is nothing to insert into L[0]: ih_item_len=%d", 311 put_ih_item_len(ih, ih_item_len(ih) - new_item_len);
314 ih_item_len(ih));
315 312
316 /* Insert new item into L[0] */ 313 RFALSE(ih_item_len(ih) <= 0,
317 buffer_info_init_left(tb, &bi); 314 "PAP-12080: there is nothing to insert into L[0]: "
318 leaf_insert_into_buf(&bi, 315 "ih_item_len=%d", ih_item_len(ih));
319 n + tb->item_pos - ret_val, ih, body,
320 tb->zeroes_num > ih_item_len(ih) ? ih_item_len(ih) : tb->zeroes_num);
321 316
322 version = ih_version(ih); 317 /* Insert new item into L[0] */
318 buffer_info_init_left(tb, &bi);
319 leaf_insert_into_buf(&bi, n + tb->item_pos - ret, ih, body,
320 min_t(int, tb->zeroes_num, ih_item_len(ih)));
323 321
324 /* Calculate key component, item length and body to insert into S[0] */ 322 version = ih_version(ih);
325 set_le_ih_k_offset(ih, le_ih_k_offset(ih) +
326 (tb->lbytes << (is_indirect_le_ih(ih) ? tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT : 0)));
327
328 put_ih_item_len(ih, new_item_len);
329 if (tb->lbytes > tb->zeroes_num) {
330 body += (tb->lbytes - tb->zeroes_num);
331 tb->zeroes_num = 0;
332 } else
333 tb->zeroes_num -= tb->lbytes;
334
335 RFALSE(ih_item_len(ih) <= 0,
336 "PAP-12085: there is nothing to insert into S[0]: ih_item_len=%d",
337 ih_item_len(ih));
338 } else {
339 /* new item in whole falls into L[0] */
340 /* Shift lnum[0]-1 items to L[0] */
341 ret_val = leaf_shift_left(tb, tb->lnum[0] - 1, tb->lbytes);
342 /* Insert new item into L[0] */
343 buffer_info_init_left(tb, &bi);
344 leaf_insert_into_buf(&bi, n + tb->item_pos - ret_val, ih, body, tb->zeroes_num);
345 tb->insert_size[0] = 0;
346 tb->zeroes_num = 0;
347 }
348 323
324 /*
325 * Calculate key component, item length and body to
326 * insert into S[0]
327 */
328 shift = 0;
329 if (is_indirect_le_ih(ih))
330 shift = tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT;
331
332 add_le_ih_k_offset(ih, tb->lbytes << shift);
333
334 put_ih_item_len(ih, new_item_len);
335 if (tb->lbytes > tb->zeroes_num) {
336 body += (tb->lbytes - tb->zeroes_num);
337 tb->zeroes_num = 0;
338 } else
339 tb->zeroes_num -= tb->lbytes;
340
341 RFALSE(ih_item_len(ih) <= 0,
342 "PAP-12085: there is nothing to insert into S[0]: "
343 "ih_item_len=%d", ih_item_len(ih));
344 } else {
345 /* new item in whole falls into L[0] */
346 /* Shift lnum[0]-1 items to L[0] */
347 ret = leaf_shift_left(tb, tb->lnum[0] - 1, tb->lbytes);
348
349 /* Insert new item into L[0] */
350 buffer_info_init_left(tb, &bi);
351 leaf_insert_into_buf(&bi, n + tb->item_pos - ret, ih, body,
352 tb->zeroes_num);
353 tb->insert_size[0] = 0;
354 tb->zeroes_num = 0;
355 }
349} 356}
350 357
351static void balance_leaf_paste_left(struct tree_balance *tb, 358static void balance_leaf_paste_left(struct tree_balance *tb,