@@ -3700,21 +3700,21 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
37003700 * being filled will be convert to initialized by the end_io callback function
37013701 * via ext4_convert_unwritten_extents().
37023702 *
3703- * Returns the size of unwritten extent to be written on success.
3703+ * The size of unwritten extent to be written is passed to the caller via the
3704+ * allocated pointer. Return an extent path pointer on success, or an error
3705+ * pointer on failure.
37043706 */
3705- static int ext4_split_convert_extents (handle_t * handle ,
3707+ static struct ext4_ext_path * ext4_split_convert_extents (handle_t * handle ,
37063708 struct inode * inode ,
37073709 struct ext4_map_blocks * map ,
3708- struct ext4_ext_path * * ppath ,
3709- int flags )
3710+ struct ext4_ext_path * path ,
3711+ int flags , unsigned int * allocated )
37103712{
3711- struct ext4_ext_path * path = * ppath ;
37123713 ext4_lblk_t eof_block ;
37133714 ext4_lblk_t ee_block ;
37143715 struct ext4_extent * ex ;
37153716 unsigned int ee_len ;
37163717 int split_flag = 0 , depth ;
3717- unsigned int allocated = 0 ;
37183718
37193719 ext_debug (inode , "logical block %llu, max_blocks %u\n" ,
37203720 (unsigned long long )map -> m_lblk , map -> m_len );
@@ -3742,14 +3742,8 @@ static int ext4_split_convert_extents(handle_t *handle,
37423742 split_flag |= (EXT4_EXT_MARK_UNWRIT2 | EXT4_EXT_DATA_VALID2 );
37433743 }
37443744 flags |= EXT4_GET_BLOCKS_PRE_IO ;
3745- path = ext4_split_extent (handle , inode , path , map , split_flag , flags ,
3746- & allocated );
3747- if (IS_ERR (path )) {
3748- * ppath = NULL ;
3749- return PTR_ERR (path );
3750- }
3751- * ppath = path ;
3752- return allocated ;
3745+ return ext4_split_extent (handle , inode , path , map , split_flag , flags ,
3746+ allocated );
37533747}
37543748
37553749static int ext4_convert_unwritten_extents_endio (handle_t * handle ,
@@ -3785,11 +3779,14 @@ static int ext4_convert_unwritten_extents_endio(handle_t *handle,
37853779 inode -> i_ino , (unsigned long long )ee_block , ee_len ,
37863780 (unsigned long long )map -> m_lblk , map -> m_len );
37873781#endif
3788- err = ext4_split_convert_extents (handle , inode , map , ppath ,
3789- EXT4_GET_BLOCKS_CONVERT );
3790- if (err < 0 )
3791- return err ;
3792- path = ext4_find_extent (inode , map -> m_lblk , * ppath , 0 );
3782+ path = ext4_split_convert_extents (handle , inode , map , path ,
3783+ EXT4_GET_BLOCKS_CONVERT , NULL );
3784+ if (IS_ERR (path )) {
3785+ * ppath = NULL ;
3786+ return PTR_ERR (path );
3787+ }
3788+
3789+ path = ext4_find_extent (inode , map -> m_lblk , path , 0 );
37933790 if (IS_ERR (path )) {
37943791 * ppath = NULL ;
37953792 return PTR_ERR (path );
@@ -3846,11 +3843,14 @@ convert_initialized_extent(handle_t *handle, struct inode *inode,
38463843 (unsigned long long )ee_block , ee_len );
38473844
38483845 if (ee_block != map -> m_lblk || ee_len > map -> m_len ) {
3849- err = ext4_split_convert_extents (handle , inode , map , ppath ,
3850- EXT4_GET_BLOCKS_CONVERT_UNWRITTEN );
3851- if (err < 0 )
3852- return err ;
3853- path = ext4_find_extent (inode , map -> m_lblk , * ppath , 0 );
3846+ path = ext4_split_convert_extents (handle , inode , map , path ,
3847+ EXT4_GET_BLOCKS_CONVERT_UNWRITTEN , NULL );
3848+ if (IS_ERR (path )) {
3849+ * ppath = NULL ;
3850+ return PTR_ERR (path );
3851+ }
3852+
3853+ path = ext4_find_extent (inode , map -> m_lblk , path , 0 );
38543854 if (IS_ERR (path )) {
38553855 * ppath = NULL ;
38563856 return PTR_ERR (path );
@@ -3916,19 +3916,20 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode,
39163916
39173917 /* get_block() before submitting IO, split the extent */
39183918 if (flags & EXT4_GET_BLOCKS_PRE_IO ) {
3919- ret = ext4_split_convert_extents (handle , inode , map , ppath ,
3920- flags | EXT4_GET_BLOCKS_CONVERT );
3921- if (ret < 0 ) {
3922- err = ret ;
3919+ * ppath = ext4_split_convert_extents (handle , inode , map , * ppath ,
3920+ flags | EXT4_GET_BLOCKS_CONVERT , & allocated );
3921+ if (IS_ERR (* ppath )) {
3922+ err = PTR_ERR (* ppath );
3923+ * ppath = NULL ;
39233924 goto out2 ;
39243925 }
39253926 /*
3926- * shouldn't get a 0 return when splitting an extent unless
3927+ * shouldn't get a 0 allocated when splitting an extent unless
39273928 * m_len is 0 (bug) or extent has been corrupted
39283929 */
3929- if (unlikely (ret == 0 )) {
3930+ if (unlikely (allocated == 0 )) {
39303931 EXT4_ERROR_INODE (inode ,
3931- "unexpected ret == 0, m_len = %u" ,
3932+ "unexpected allocated == 0, m_len = %u" ,
39323933 map -> m_len );
39333934 err = - EFSCORRUPTED ;
39343935 goto out2 ;
@@ -3989,9 +3990,9 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode,
39893990 err = - EFSCORRUPTED ;
39903991 goto out2 ;
39913992 }
3993+ allocated = ret ;
39923994
39933995out :
3994- allocated = ret ;
39953996 map -> m_flags |= EXT4_MAP_NEW ;
39963997map_out :
39973998 map -> m_flags |= EXT4_MAP_MAPPED ;
0 commit comments