@@ -1623,7 +1623,8 @@ static int indx_add_allocate(struct ntfs_index *indx, struct ntfs_inode *ni,
16231623static int indx_insert_into_root (struct ntfs_index * indx , struct ntfs_inode * ni ,
16241624 const struct NTFS_DE * new_de ,
16251625 struct NTFS_DE * root_de , const void * ctx ,
1626- struct ntfs_fnd * fnd , bool undo , NTFS_CMP_FUNC cmp )
1626+ struct ntfs_fnd * fnd , bool undo ,
1627+ NTFS_CMP_FUNC cmp )
16271628{
16281629 int err = 0 ;
16291630 struct NTFS_DE * e , * e0 , * re ;
@@ -1848,13 +1849,15 @@ static int indx_insert_into_root(struct ntfs_index *indx, struct ntfs_inode *ni,
18481849 * Attempt to insert an entry into an Index Allocation Buffer.
18491850 * If necessary, it will split the buffer.
18501851 */
1851- static int
1852- indx_insert_into_buffer (struct ntfs_index * indx , struct ntfs_inode * ni ,
1853- struct INDEX_ROOT * root , const struct NTFS_DE * new_de ,
1854- const void * ctx , int level , struct ntfs_fnd * fnd , NTFS_CMP_FUNC cmp )
1852+ static int indx_insert_into_buffer (struct ntfs_index * indx ,
1853+ struct ntfs_inode * ni ,
1854+ struct INDEX_ROOT * root ,
1855+ const struct NTFS_DE * new_de ,
1856+ const void * ctx , int level ,
1857+ struct ntfs_fnd * fnd , NTFS_CMP_FUNC cmp )
18551858{
18561859 int err ;
1857- const struct NTFS_DE * sp ;
1860+ const struct NTFS_DE * sp ; /* split_point */
18581861 struct NTFS_DE * e , * de_t , * up_e ;
18591862 struct indx_node * n2 ;
18601863 struct indx_node * n1 = fnd -> nodes [level ];
@@ -1880,10 +1883,9 @@ indx_insert_into_buffer(struct ntfs_index *indx, struct ntfs_inode *ni,
18801883 * No space to insert into buffer. Split it.
18811884 * To split we:
18821885 * - Save split point ('cause index buffers will be changed)
1883- * - Allocate NewBuffer and copy all entries <= sp into new buffer
1884- * - Remove all entries (sp including) from TargetBuffer
1885- * - Insert NewEntry into left or right buffer (depending on sp <=>
1886- * NewEntry)
1886+ * - Allocate new buffer (up_e) and copy all entries <= sp into new buffer
1887+ * - Remove all entries (sp including) from hdr1
1888+ * - Insert new_de into left or right buffer (depending on sp <=> new_de)
18871889 * - Insert sp into parent buffer (or root)
18881890 * - Make sp a parent for new buffer
18891891 */
@@ -1897,6 +1899,7 @@ indx_insert_into_buffer(struct ntfs_index *indx, struct ntfs_inode *ni,
18971899 return - ENOMEM ;
18981900 memcpy (up_e , sp , sp_size );
18991901
1902+ /* Make a copy for undo. */
19001903 used1 = le32_to_cpu (hdr1 -> used );
19011904
19021905 /*
@@ -1960,8 +1963,7 @@ indx_insert_into_buffer(struct ntfs_index *indx, struct ntfs_inode *ni,
19601963 */
19611964 hdr_insert_de (indx ,
19621965 (* cmp )(new_de + 1 , le16_to_cpu (new_de -> key_size ),
1963- up_e + 1 , le16_to_cpu (up_e -> key_size ),
1964- ctx ) < 0 ?
1966+ up_e + 1 , le16_to_cpu (up_e -> key_size ), ctx ) < 0 ?
19651967 hdr2 :
19661968 hdr1 ,
19671969 new_de , NULL , ctx , cmp );
@@ -1978,11 +1980,13 @@ indx_insert_into_buffer(struct ntfs_index *indx, struct ntfs_inode *ni,
19781980 * insert the promoted entry into the parent.
19791981 */
19801982 if (!level ) {
1981- /* Insert in root. */
1982- err = indx_insert_into_root (indx , ni , up_e , NULL , ctx , fnd , 0 , cmp );
1983+ /* Insert split_point in root. */
1984+ err = indx_insert_into_root (indx , ni , up_e , NULL , ctx , fnd , 0 ,
1985+ cmp );
19831986 } else {
19841987 /*
19851988 * The target buffer's parent is another index buffer.
1989+ * Insert split_point in parent index ( call itself recursively )
19861990 * TODO: Remove recursion.
19871991 */
19881992 err = indx_insert_into_buffer (indx , ni , root , up_e , ctx ,
0 commit comments