@@ -290,31 +290,43 @@ static int balance_leaf_when_delete(struct tree_balance *tb, int flag)
290290 return 0 ;
291291}
292292
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 )
303311{
304312 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 );
307315 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 ];
318330 int n , i ;
319331 int ret_val ;
320332 int pos_in_item ;
@@ -331,8 +343,10 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
331343 zeros_num = ih_item_len (ih );
332344
333345 pos_in_item = tb -> tb_path -> pos_in_item ;
334- /* for indirect item pos_in_item is measured in unformatted node
335- pointers. Recalculate to bytes */
346+ /*
347+ * for indirect item pos_in_item is measured in unformatted node
348+ * pointers. Recalculate to bytes
349+ */
336350 if (flag != M_INSERT
337351 && is_indirect_le_ih (item_head (tbS0 , item_pos )))
338352 pos_in_item *= UNFM_P_SIZE ;
@@ -792,16 +806,20 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
792806 RFALSE (tb -> blknum [0 ] < 0 ,
793807 "PAP-12185: blknum can not be %d. It must be >= 0" , tb -> blknum [0 ]);
794808
795- /* if while adding to a node we discover that it is possible to split
796- it in two, and merge the left part into the left neighbor and the
797- right part into the right neighbor, eliminating the node */
809+ /*
810+ * if while adding to a node we discover that it is possible to split
811+ * it in two, and merge the left part into the left neighbor and the
812+ * right part into the right neighbor, eliminating the node
813+ */
798814 if (tb -> blknum [0 ] == 0 ) { /* node S[0] is empty now */
799815
800816 RFALSE (!tb -> lnum [0 ] || !tb -> rnum [0 ],
801817 "PAP-12190: lnum and rnum must not be zero" );
802- /* if insertion was done before 0-th position in R[0], right
803- delimiting key of the tb->L[0]'s and left delimiting key are
804- not set correctly */
818+ /*
819+ * if insertion was done before 0-th position in R[0], right
820+ * delimiting key of the tb->L[0]'s and left delimiting key are
821+ * not set correctly
822+ */
805823 if (tb -> CFL [0 ]) {
806824 if (!tb -> CFR [0 ])
807825 reiserfs_panic (tb -> tb_sb , "vs-12195" ,
@@ -1159,9 +1177,11 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
11591177 "PAP-12290" , "insert_size is still not 0 (%d)" ,
11601178 tb -> insert_size [0 ]);
11611179 }
1162- #endif /* CONFIG_REISERFS_CHECK */
1180+ #endif
1181+
1182+ /* Leaf level of the tree is balanced (end of balance_leaf) */
11631183 return 0 ;
1164- } /* Leaf level of the tree is balanced (end of balance_leaf) */
1184+ }
11651185
11661186/* Make empty node */
11671187void make_empty_node (struct buffer_info * bi )
0 commit comments