do_balan.c (fba4ebb5f0f84a6f9989e9591741ddff946de320) | do_balan.c (0222e6571c332563a48d4cf5487b67feabe60b5e) |
---|---|
1/* 2 * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README 3 */ 4 5/* Now we have all buffers that must be used in balancing of the tree */ 6/* Further calculations can not cause schedule(), and thus the buffer */ 7/* tree will be stable until the balancing will be finished */ 8/* balance the tree according to the analysis made before, */ --- 62 unchanged lines hidden (view full) --- 71{ 72 journal_mark_dirty(tb->transaction_handle, 73 tb->transaction_handle->t_super, bh); 74} 75 76#define do_balance_mark_internal_dirty do_balance_mark_leaf_dirty 77#define do_balance_mark_sb_dirty do_balance_mark_leaf_dirty 78 | 1/* 2 * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README 3 */ 4 5/* Now we have all buffers that must be used in balancing of the tree */ 6/* Further calculations can not cause schedule(), and thus the buffer */ 7/* tree will be stable until the balancing will be finished */ 8/* balance the tree according to the analysis made before, */ --- 62 unchanged lines hidden (view full) --- 71{ 72 journal_mark_dirty(tb->transaction_handle, 73 tb->transaction_handle->t_super, bh); 74} 75 76#define do_balance_mark_internal_dirty do_balance_mark_leaf_dirty 77#define do_balance_mark_sb_dirty do_balance_mark_leaf_dirty 78 |
79/* summary: | 79/* summary: |
80 if deleting something ( tb->insert_size[0] < 0 ) 81 return(balance_leaf_when_delete()); (flag d handled here) 82 else 83 if lnum is larger than 0 we put items into the left node 84 if rnum is larger than 0 we put items into the right node 85 if snum1 is larger than 0 we put items into the new node s1 | 80 if deleting something ( tb->insert_size[0] < 0 ) 81 return(balance_leaf_when_delete()); (flag d handled here) 82 else 83 if lnum is larger than 0 we put items into the left node 84 if rnum is larger than 0 we put items into the right node 85 if snum1 is larger than 0 we put items into the new node s1 |
86 if snum2 is larger than 0 we put items into the new node s2 | 86 if snum2 is larger than 0 we put items into the new node s2 |
87Note that all *num* count new items being created. 88 89It would be easier to read balance_leaf() if each of these summary 90lines was a separate procedure rather than being inlined. I think 91that there are many passages here and in balance_leaf_when_delete() in 92which two calls to one procedure can replace two passages, and it | 87Note that all *num* count new items being created. 88 89It would be easier to read balance_leaf() if each of these summary 90lines was a separate procedure rather than being inlined. I think 91that there are many passages here and in balance_leaf_when_delete() in 92which two calls to one procedure can replace two passages, and it |
93might save cache space and improve software maintenance costs to do so. | 93might save cache space and improve software maintenance costs to do so. |
94 95Vladimir made the perceptive comment that we should offload most of 96the decision making in this function into fix_nodes/check_balance, and 97then create some sort of structure in tb that says what actions should 98be performed by do_balance. 99 100-Hans */ 101 --- 181 unchanged lines hidden (view full) --- 283 struct item_head *insert_key, /* in our processing of one level we sometimes determine what 284 must be inserted into the next higher level. This insertion 285 consists of a key or two keys and their corresponding 286 pointers */ 287 struct buffer_head **insert_ptr /* inserted node-ptrs for the next level */ 288 ) 289{ 290 struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path); | 94 95Vladimir made the perceptive comment that we should offload most of 96the decision making in this function into fix_nodes/check_balance, and 97then create some sort of structure in tb that says what actions should 98be performed by do_balance. 99 100-Hans */ 101 --- 181 unchanged lines hidden (view full) --- 283 struct item_head *insert_key, /* in our processing of one level we sometimes determine what 284 must be inserted into the next higher level. This insertion 285 consists of a key or two keys and their corresponding 286 pointers */ 287 struct buffer_head **insert_ptr /* inserted node-ptrs for the next level */ 288 ) 289{ 290 struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path); |
291 int item_pos = PATH_LAST_POSITION(tb->tb_path); /* index into the array of item headers in S[0] | 291 int item_pos = PATH_LAST_POSITION(tb->tb_path); /* index into the array of item headers in S[0] |
292 of the affected item */ 293 struct buffer_info bi; 294 struct buffer_head *S_new[2]; /* new nodes allocated to hold what could not fit into S */ 295 int snum[2]; /* number of items that will be placed 296 into S_new (includes partially shifted 297 items) */ | 292 of the affected item */ 293 struct buffer_info bi; 294 struct buffer_head *S_new[2]; /* new nodes allocated to hold what could not fit into S */ 295 int snum[2]; /* number of items that will be placed 296 into S_new (includes partially shifted 297 items) */ |
298 int sbytes[2]; /* if an item is partially shifted into S_new then 299 if it is a directory item | 298 int sbytes[2]; /* if an item is partially shifted into S_new then 299 if it is a directory item |
300 it is the number of entries from the item that are shifted into S_new 301 else 302 it is the number of bytes from the item that are shifted into S_new 303 */ 304 int n, i; 305 int ret_val; 306 int pos_in_item; 307 int zeros_num; --- 1670 unchanged lines hidden (view full) --- 1978static inline void do_balance_starts(struct tree_balance *tb) 1979{ 1980 /* use print_cur_tb() to see initial state of struct 1981 tree_balance */ 1982 1983 /* store_print_tb (tb); */ 1984 1985 /* do not delete, just comment it out */ | 300 it is the number of entries from the item that are shifted into S_new 301 else 302 it is the number of bytes from the item that are shifted into S_new 303 */ 304 int n, i; 305 int ret_val; 306 int pos_in_item; 307 int zeros_num; --- 1670 unchanged lines hidden (view full) --- 1978static inline void do_balance_starts(struct tree_balance *tb) 1979{ 1980 /* use print_cur_tb() to see initial state of struct 1981 tree_balance */ 1982 1983 /* store_print_tb (tb); */ 1984 1985 /* do not delete, just comment it out */ |
1986/* print_tb(flag, PATH_LAST_POSITION(tb->tb_path), tb->tb_path->pos_in_item, tb, | 1986/* print_tb(flag, PATH_LAST_POSITION(tb->tb_path), tb->tb_path->pos_in_item, tb, |
1987 "check");*/ 1988 RFALSE(check_before_balancing(tb), "PAP-12340: locked buffers in TB"); 1989#ifdef CONFIG_REISERFS_CHECK 1990 cur_tb = tb; 1991#endif 1992} 1993 1994static inline void do_balance_completed(struct tree_balance *tb) --- 88 unchanged lines hidden --- | 1987 "check");*/ 1988 RFALSE(check_before_balancing(tb), "PAP-12340: locked buffers in TB"); 1989#ifdef CONFIG_REISERFS_CHECK 1990 cur_tb = tb; 1991#endif 1992} 1993 1994static inline void do_balance_completed(struct tree_balance *tb) --- 88 unchanged lines hidden --- |