Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

reiserfs: balance_leaf refactor, reformat balance_leaf comments

The comments in balance_leaf are as bad as the code. This patch shifts
them around to fit in 80 columns and be easier to read.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Jan Kara <jack@suse.cz>

authored by

Jeff Mahoney and committed by
Jan Kara
97fd4b97 c48138c2

+52 -32
+52 -32
fs/reiserfs/do_balan.c
··· 290 290 return 0; 291 291 } 292 292 293 - static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item header of inserted item (this is on little endian) */ 294 - const char *body, /* body of inserted item or bytes to paste */ 295 - int flag, /* i - insert, d - delete, c - cut, p - paste 296 - (see comment to do_balance) */ 297 - struct item_head *insert_key, /* in our processing of one level we sometimes determine what 298 - must be inserted into the next higher level. This insertion 299 - consists of a key or two keys and their corresponding 300 - pointers */ 301 - struct buffer_head **insert_ptr /* inserted node-ptrs for the next level */ 302 - ) 293 + /** 294 + * balance_leaf - reiserfs tree balancing algorithm 295 + * @tb: tree balance state 296 + * @ih: item header of inserted item (little endian) 297 + * @body: body of inserted item or bytes to paste 298 + * @flag: i - insert, d - delete, c - cut, p - paste (see do_balance) 299 + * passed back: 300 + * @insert_key: key to insert new nodes 301 + * @insert_ptr: array of nodes to insert at the next level 302 + * 303 + * In our processing of one level we sometimes determine what must be 304 + * inserted into the next higher level. This insertion consists of a 305 + * key or two keys and their corresponding pointers. 306 + */ 307 + static int balance_leaf(struct tree_balance *tb, struct item_head *ih, 308 + const char *body, int flag, 309 + struct item_head *insert_key, 310 + struct buffer_head **insert_ptr) 303 311 { 304 312 struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path); 305 - int item_pos = PATH_LAST_POSITION(tb->tb_path); /* index into the array of item headers in S[0] 306 - of the affected item */ 313 + /* index into the array of item headers in S[0] of the affected item */ 314 + int item_pos = PATH_LAST_POSITION(tb->tb_path); 307 315 struct buffer_info bi; 308 - struct buffer_head *S_new[2]; /* new nodes allocated to hold what could not fit into S */ 309 - int snum[2]; /* number of items that will be placed 310 - into S_new (includes partially shifted 311 - items) */ 312 - int sbytes[2]; /* if an item is partially shifted into S_new then 313 - if it is a directory item 314 - it is the number of entries from the item that are shifted into S_new 315 - else 316 - it is the number of bytes from the item that are shifted into S_new 317 - */ 316 + /* new nodes allocated to hold what could not fit into S */ 317 + struct buffer_head *S_new[2]; 318 + /* 319 + * number of items that will be placed into S_new 320 + * (includes partially shifted items) 321 + */ 322 + int snum[2]; 323 + /* 324 + * if an item is partially shifted into S_new then if it is a 325 + * directory item it is the number of entries from the item that 326 + * are shifted into S_new else it is the number of bytes from 327 + * the item that are shifted into S_new 328 + */ 329 + int sbytes[2]; 318 330 int n, i; 319 331 int ret_val; 320 332 int pos_in_item; ··· 343 331 zeros_num = ih_item_len(ih); 344 332 345 333 pos_in_item = tb->tb_path->pos_in_item; 346 - /* for indirect item pos_in_item is measured in unformatted node 347 - pointers. Recalculate to bytes */ 334 + /* 335 + * for indirect item pos_in_item is measured in unformatted node 336 + * pointers. Recalculate to bytes 337 + */ 348 338 if (flag != M_INSERT 349 339 && is_indirect_le_ih(item_head(tbS0, item_pos))) 350 340 pos_in_item *= UNFM_P_SIZE; ··· 806 792 RFALSE(tb->blknum[0] < 0, 807 793 "PAP-12185: blknum can not be %d. It must be >= 0", tb->blknum[0]); 808 794 809 - /* if while adding to a node we discover that it is possible to split 810 - it in two, and merge the left part into the left neighbor and the 811 - right part into the right neighbor, eliminating the node */ 795 + /* 796 + * if while adding to a node we discover that it is possible to split 797 + * it in two, and merge the left part into the left neighbor and the 798 + * right part into the right neighbor, eliminating the node 799 + */ 812 800 if (tb->blknum[0] == 0) { /* node S[0] is empty now */ 813 801 814 802 RFALSE(!tb->lnum[0] || !tb->rnum[0], 815 803 "PAP-12190: lnum and rnum must not be zero"); 816 - /* if insertion was done before 0-th position in R[0], right 817 - delimiting key of the tb->L[0]'s and left delimiting key are 818 - not set correctly */ 804 + /* 805 + * if insertion was done before 0-th position in R[0], right 806 + * delimiting key of the tb->L[0]'s and left delimiting key are 807 + * not set correctly 808 + */ 819 809 if (tb->CFL[0]) { 820 810 if (!tb->CFR[0]) 821 811 reiserfs_panic(tb->tb_sb, "vs-12195", ··· 1177 1159 "PAP-12290", "insert_size is still not 0 (%d)", 1178 1160 tb->insert_size[0]); 1179 1161 } 1180 - #endif /* CONFIG_REISERFS_CHECK */ 1162 + #endif 1163 + 1164 + /* Leaf level of the tree is balanced (end of balance_leaf) */ 1181 1165 return 0; 1182 - } /* Leaf level of the tree is balanced (end of balance_leaf) */ 1166 + } 1183 1167 1184 1168 /* Make empty node */ 1185 1169 void make_empty_node(struct buffer_info *bi)