@@ -1410,14 +1410,15 @@ static int ext4_fc_record_modified_inode(struct super_block *sb, int ino)
1410
1410
if (state -> fc_modified_inodes [i ] == ino )
1411
1411
return 0 ;
1412
1412
if (state -> fc_modified_inodes_used == state -> fc_modified_inodes_size ) {
1413
- state -> fc_modified_inodes_size +=
1414
- EXT4_FC_REPLAY_REALLOC_INCREMENT ;
1415
1413
state -> fc_modified_inodes = krealloc (
1416
- state -> fc_modified_inodes , sizeof (int ) *
1417
- state -> fc_modified_inodes_size ,
1418
- GFP_KERNEL );
1414
+ state -> fc_modified_inodes ,
1415
+ sizeof (int ) * (state -> fc_modified_inodes_size +
1416
+ EXT4_FC_REPLAY_REALLOC_INCREMENT ),
1417
+ GFP_KERNEL );
1419
1418
if (!state -> fc_modified_inodes )
1420
1419
return - ENOMEM ;
1420
+ state -> fc_modified_inodes_size +=
1421
+ EXT4_FC_REPLAY_REALLOC_INCREMENT ;
1421
1422
}
1422
1423
state -> fc_modified_inodes [state -> fc_modified_inodes_used ++ ] = ino ;
1423
1424
return 0 ;
@@ -1449,7 +1450,9 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl,
1449
1450
}
1450
1451
inode = NULL ;
1451
1452
1452
- ext4_fc_record_modified_inode (sb , ino );
1453
+ ret = ext4_fc_record_modified_inode (sb , ino );
1454
+ if (ret )
1455
+ goto out ;
1453
1456
1454
1457
raw_fc_inode = (struct ext4_inode * )
1455
1458
(val + offsetof(struct ext4_fc_inode , fc_raw_inode ));
@@ -1649,6 +1652,8 @@ static int ext4_fc_replay_add_range(struct super_block *sb,
1649
1652
}
1650
1653
1651
1654
ret = ext4_fc_record_modified_inode (sb , inode -> i_ino );
1655
+ if (ret )
1656
+ goto out ;
1652
1657
1653
1658
start = le32_to_cpu (ex -> ee_block );
1654
1659
start_pblk = ext4_ext_pblock (ex );
@@ -1666,18 +1671,14 @@ static int ext4_fc_replay_add_range(struct super_block *sb,
1666
1671
map .m_pblk = 0 ;
1667
1672
ret = ext4_map_blocks (NULL , inode , & map , 0 );
1668
1673
1669
- if (ret < 0 ) {
1670
- iput (inode );
1671
- return 0 ;
1672
- }
1674
+ if (ret < 0 )
1675
+ goto out ;
1673
1676
1674
1677
if (ret == 0 ) {
1675
1678
/* Range is not mapped */
1676
1679
path = ext4_find_extent (inode , cur , NULL , 0 );
1677
- if (IS_ERR (path )) {
1678
- iput (inode );
1679
- return 0 ;
1680
- }
1680
+ if (IS_ERR (path ))
1681
+ goto out ;
1681
1682
memset (& newex , 0 , sizeof (newex ));
1682
1683
newex .ee_block = cpu_to_le32 (cur );
1683
1684
ext4_ext_store_pblock (
@@ -1691,10 +1692,8 @@ static int ext4_fc_replay_add_range(struct super_block *sb,
1691
1692
up_write ((& EXT4_I (inode )-> i_data_sem ));
1692
1693
ext4_ext_drop_refs (path );
1693
1694
kfree (path );
1694
- if (ret ) {
1695
- iput (inode );
1696
- return 0 ;
1697
- }
1695
+ if (ret )
1696
+ goto out ;
1698
1697
goto next ;
1699
1698
}
1700
1699
@@ -1707,10 +1706,8 @@ static int ext4_fc_replay_add_range(struct super_block *sb,
1707
1706
ret = ext4_ext_replay_update_ex (inode , cur , map .m_len ,
1708
1707
ext4_ext_is_unwritten (ex ),
1709
1708
start_pblk + cur - start );
1710
- if (ret ) {
1711
- iput (inode );
1712
- return 0 ;
1713
- }
1709
+ if (ret )
1710
+ goto out ;
1714
1711
/*
1715
1712
* Mark the old blocks as free since they aren't used
1716
1713
* anymore. We maintain an array of all the modified
@@ -1730,10 +1727,8 @@ static int ext4_fc_replay_add_range(struct super_block *sb,
1730
1727
ext4_ext_is_unwritten (ex ), map .m_pblk );
1731
1728
ret = ext4_ext_replay_update_ex (inode , cur , map .m_len ,
1732
1729
ext4_ext_is_unwritten (ex ), map .m_pblk );
1733
- if (ret ) {
1734
- iput (inode );
1735
- return 0 ;
1736
- }
1730
+ if (ret )
1731
+ goto out ;
1737
1732
/*
1738
1733
* We may have split the extent tree while toggling the state.
1739
1734
* Try to shrink the extent tree now.
@@ -1745,6 +1740,7 @@ static int ext4_fc_replay_add_range(struct super_block *sb,
1745
1740
}
1746
1741
ext4_ext_replay_shrink_inode (inode , i_size_read (inode ) >>
1747
1742
sb -> s_blocksize_bits );
1743
+ out :
1748
1744
iput (inode );
1749
1745
return 0 ;
1750
1746
}
@@ -1774,6 +1770,8 @@ ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl,
1774
1770
}
1775
1771
1776
1772
ret = ext4_fc_record_modified_inode (sb , inode -> i_ino );
1773
+ if (ret )
1774
+ goto out ;
1777
1775
1778
1776
jbd_debug (1 , "DEL_RANGE, inode %ld, lblk %d, len %d\n" ,
1779
1777
inode -> i_ino , le32_to_cpu (lrange .fc_lblk ),
@@ -1783,10 +1781,8 @@ ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl,
1783
1781
map .m_len = remaining ;
1784
1782
1785
1783
ret = ext4_map_blocks (NULL , inode , & map , 0 );
1786
- if (ret < 0 ) {
1787
- iput (inode );
1788
- return 0 ;
1789
- }
1784
+ if (ret < 0 )
1785
+ goto out ;
1790
1786
if (ret > 0 ) {
1791
1787
remaining -= ret ;
1792
1788
cur += ret ;
@@ -1801,15 +1797,13 @@ ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl,
1801
1797
ret = ext4_ext_remove_space (inode , lrange .fc_lblk ,
1802
1798
lrange .fc_lblk + lrange .fc_len - 1 );
1803
1799
up_write (& EXT4_I (inode )-> i_data_sem );
1804
- if (ret ) {
1805
- iput (inode );
1806
- return 0 ;
1807
- }
1800
+ if (ret )
1801
+ goto out ;
1808
1802
ext4_ext_replay_shrink_inode (inode ,
1809
1803
i_size_read (inode ) >> sb -> s_blocksize_bits );
1810
1804
ext4_mark_inode_dirty (NULL , inode );
1805
+ out :
1811
1806
iput (inode );
1812
-
1813
1807
return 0 ;
1814
1808
}
1815
1809
0 commit comments