@@ -1288,28 +1288,29 @@ struct dentry_info_args {
1288
1288
};
1289
1289
1290
1290
static inline void tl_to_darg (struct dentry_info_args * darg ,
1291
- struct ext4_fc_tl * tl )
1291
+ struct ext4_fc_tl * tl , u8 * val )
1292
1292
{
1293
- struct ext4_fc_dentry_info * fcd ;
1293
+ struct ext4_fc_dentry_info fcd ;
1294
1294
1295
- fcd = ( struct ext4_fc_dentry_info * ) ext4_fc_tag_val ( tl );
1295
+ memcpy ( & fcd , val , sizeof ( fcd ) );
1296
1296
1297
- darg -> parent_ino = le32_to_cpu (fcd -> fc_parent_ino );
1298
- darg -> ino = le32_to_cpu (fcd -> fc_ino );
1299
- darg -> dname = fcd -> fc_dname ;
1300
- darg -> dname_len = ext4_fc_tag_len (tl ) -
1301
- sizeof (struct ext4_fc_dentry_info );
1297
+ darg -> parent_ino = le32_to_cpu (fcd . fc_parent_ino );
1298
+ darg -> ino = le32_to_cpu (fcd . fc_ino );
1299
+ darg -> dname = val + offsetof( struct ext4_fc_dentry_info , fc_dname ) ;
1300
+ darg -> dname_len = le16_to_cpu (tl -> fc_len ) -
1301
+ sizeof (struct ext4_fc_dentry_info );
1302
1302
}
1303
1303
1304
1304
/* Unlink replay function */
1305
- static int ext4_fc_replay_unlink (struct super_block * sb , struct ext4_fc_tl * tl )
1305
+ static int ext4_fc_replay_unlink (struct super_block * sb , struct ext4_fc_tl * tl ,
1306
+ u8 * val )
1306
1307
{
1307
1308
struct inode * inode , * old_parent ;
1308
1309
struct qstr entry ;
1309
1310
struct dentry_info_args darg ;
1310
1311
int ret = 0 ;
1311
1312
1312
- tl_to_darg (& darg , tl );
1313
+ tl_to_darg (& darg , tl , val );
1313
1314
1314
1315
trace_ext4_fc_replay (sb , EXT4_FC_TAG_UNLINK , darg .ino ,
1315
1316
darg .parent_ino , darg .dname_len );
@@ -1399,13 +1400,14 @@ static int ext4_fc_replay_link_internal(struct super_block *sb,
1399
1400
}
1400
1401
1401
1402
/* Link replay function */
1402
- static int ext4_fc_replay_link (struct super_block * sb , struct ext4_fc_tl * tl )
1403
+ static int ext4_fc_replay_link (struct super_block * sb , struct ext4_fc_tl * tl ,
1404
+ u8 * val )
1403
1405
{
1404
1406
struct inode * inode ;
1405
1407
struct dentry_info_args darg ;
1406
1408
int ret = 0 ;
1407
1409
1408
- tl_to_darg (& darg , tl );
1410
+ tl_to_darg (& darg , tl , val );
1409
1411
trace_ext4_fc_replay (sb , EXT4_FC_TAG_LINK , darg .ino ,
1410
1412
darg .parent_ino , darg .dname_len );
1411
1413
@@ -1450,19 +1452,20 @@ static int ext4_fc_record_modified_inode(struct super_block *sb, int ino)
1450
1452
/*
1451
1453
* Inode replay function
1452
1454
*/
1453
- static int ext4_fc_replay_inode (struct super_block * sb , struct ext4_fc_tl * tl )
1455
+ static int ext4_fc_replay_inode (struct super_block * sb , struct ext4_fc_tl * tl ,
1456
+ u8 * val )
1454
1457
{
1455
- struct ext4_fc_inode * fc_inode ;
1458
+ struct ext4_fc_inode fc_inode ;
1456
1459
struct ext4_inode * raw_inode ;
1457
1460
struct ext4_inode * raw_fc_inode ;
1458
1461
struct inode * inode = NULL ;
1459
1462
struct ext4_iloc iloc ;
1460
1463
int inode_len , ino , ret , tag = le16_to_cpu (tl -> fc_tag );
1461
1464
struct ext4_extent_header * eh ;
1462
1465
1463
- fc_inode = ( struct ext4_fc_inode * ) ext4_fc_tag_val ( tl );
1466
+ memcpy ( & fc_inode , val , sizeof ( fc_inode ) );
1464
1467
1465
- ino = le32_to_cpu (fc_inode -> fc_ino );
1468
+ ino = le32_to_cpu (fc_inode . fc_ino );
1466
1469
trace_ext4_fc_replay (sb , tag , ino , 0 , 0 );
1467
1470
1468
1471
inode = ext4_iget (sb , ino , EXT4_IGET_NORMAL );
@@ -1474,12 +1477,13 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl)
1474
1477
1475
1478
ext4_fc_record_modified_inode (sb , ino );
1476
1479
1477
- raw_fc_inode = (struct ext4_inode * )fc_inode -> fc_raw_inode ;
1480
+ raw_fc_inode = (struct ext4_inode * )
1481
+ (val + offsetof(struct ext4_fc_inode , fc_raw_inode ));
1478
1482
ret = ext4_get_fc_inode_loc (sb , ino , & iloc );
1479
1483
if (ret )
1480
1484
goto out ;
1481
1485
1482
- inode_len = ext4_fc_tag_len (tl ) - sizeof (struct ext4_fc_inode );
1486
+ inode_len = le16_to_cpu (tl -> fc_len ) - sizeof (struct ext4_fc_inode );
1483
1487
raw_inode = ext4_raw_inode (& iloc );
1484
1488
1485
1489
memcpy (raw_inode , raw_fc_inode , offsetof(struct ext4_inode , i_block ));
@@ -1547,14 +1551,15 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl)
1547
1551
* inode for which we are trying to create a dentry here, should already have
1548
1552
* been replayed before we start here.
1549
1553
*/
1550
- static int ext4_fc_replay_create (struct super_block * sb , struct ext4_fc_tl * tl )
1554
+ static int ext4_fc_replay_create (struct super_block * sb , struct ext4_fc_tl * tl ,
1555
+ u8 * val )
1551
1556
{
1552
1557
int ret = 0 ;
1553
1558
struct inode * inode = NULL ;
1554
1559
struct inode * dir = NULL ;
1555
1560
struct dentry_info_args darg ;
1556
1561
1557
- tl_to_darg (& darg , tl );
1562
+ tl_to_darg (& darg , tl , val );
1558
1563
1559
1564
trace_ext4_fc_replay (sb , EXT4_FC_TAG_CREAT , darg .ino ,
1560
1565
darg .parent_ino , darg .dname_len );
@@ -1633,9 +1638,9 @@ static int ext4_fc_record_regions(struct super_block *sb, int ino,
1633
1638
1634
1639
/* Replay add range tag */
1635
1640
static int ext4_fc_replay_add_range (struct super_block * sb ,
1636
- struct ext4_fc_tl * tl )
1641
+ struct ext4_fc_tl * tl , u8 * val )
1637
1642
{
1638
- struct ext4_fc_add_range * fc_add_ex ;
1643
+ struct ext4_fc_add_range fc_add_ex ;
1639
1644
struct ext4_extent newex , * ex ;
1640
1645
struct inode * inode ;
1641
1646
ext4_lblk_t start , cur ;
@@ -1645,15 +1650,14 @@ static int ext4_fc_replay_add_range(struct super_block *sb,
1645
1650
struct ext4_ext_path * path = NULL ;
1646
1651
int ret ;
1647
1652
1648
- fc_add_ex = ( struct ext4_fc_add_range * ) ext4_fc_tag_val ( tl );
1649
- ex = (struct ext4_extent * )& fc_add_ex -> fc_ex ;
1653
+ memcpy ( & fc_add_ex , val , sizeof ( fc_add_ex ) );
1654
+ ex = (struct ext4_extent * )& fc_add_ex . fc_ex ;
1650
1655
1651
1656
trace_ext4_fc_replay (sb , EXT4_FC_TAG_ADD_RANGE ,
1652
- le32_to_cpu (fc_add_ex -> fc_ino ), le32_to_cpu (ex -> ee_block ),
1657
+ le32_to_cpu (fc_add_ex . fc_ino ), le32_to_cpu (ex -> ee_block ),
1653
1658
ext4_ext_get_actual_len (ex ));
1654
1659
1655
- inode = ext4_iget (sb , le32_to_cpu (fc_add_ex -> fc_ino ),
1656
- EXT4_IGET_NORMAL );
1660
+ inode = ext4_iget (sb , le32_to_cpu (fc_add_ex .fc_ino ), EXT4_IGET_NORMAL );
1657
1661
if (IS_ERR (inode )) {
1658
1662
jbd_debug (1 , "Inode not found." );
1659
1663
return 0 ;
@@ -1762,32 +1766,33 @@ static int ext4_fc_replay_add_range(struct super_block *sb,
1762
1766
1763
1767
/* Replay DEL_RANGE tag */
1764
1768
static int
1765
- ext4_fc_replay_del_range (struct super_block * sb , struct ext4_fc_tl * tl )
1769
+ ext4_fc_replay_del_range (struct super_block * sb , struct ext4_fc_tl * tl ,
1770
+ u8 * val )
1766
1771
{
1767
1772
struct inode * inode ;
1768
- struct ext4_fc_del_range * lrange ;
1773
+ struct ext4_fc_del_range lrange ;
1769
1774
struct ext4_map_blocks map ;
1770
1775
ext4_lblk_t cur , remaining ;
1771
1776
int ret ;
1772
1777
1773
- lrange = ( struct ext4_fc_del_range * ) ext4_fc_tag_val ( tl );
1774
- cur = le32_to_cpu (lrange -> fc_lblk );
1775
- remaining = le32_to_cpu (lrange -> fc_len );
1778
+ memcpy ( & lrange , val , sizeof ( lrange ) );
1779
+ cur = le32_to_cpu (lrange . fc_lblk );
1780
+ remaining = le32_to_cpu (lrange . fc_len );
1776
1781
1777
1782
trace_ext4_fc_replay (sb , EXT4_FC_TAG_DEL_RANGE ,
1778
- le32_to_cpu (lrange -> fc_ino ), cur , remaining );
1783
+ le32_to_cpu (lrange . fc_ino ), cur , remaining );
1779
1784
1780
- inode = ext4_iget (sb , le32_to_cpu (lrange -> fc_ino ), EXT4_IGET_NORMAL );
1785
+ inode = ext4_iget (sb , le32_to_cpu (lrange . fc_ino ), EXT4_IGET_NORMAL );
1781
1786
if (IS_ERR (inode )) {
1782
- jbd_debug (1 , "Inode %d not found" , le32_to_cpu (lrange -> fc_ino ));
1787
+ jbd_debug (1 , "Inode %d not found" , le32_to_cpu (lrange . fc_ino ));
1783
1788
return 0 ;
1784
1789
}
1785
1790
1786
1791
ret = ext4_fc_record_modified_inode (sb , inode -> i_ino );
1787
1792
1788
1793
jbd_debug (1 , "DEL_RANGE, inode %ld, lblk %d, len %d\n" ,
1789
- inode -> i_ino , le32_to_cpu (lrange -> fc_lblk ),
1790
- le32_to_cpu (lrange -> fc_len ));
1794
+ inode -> i_ino , le32_to_cpu (lrange . fc_lblk ),
1795
+ le32_to_cpu (lrange . fc_len ));
1791
1796
while (remaining > 0 ) {
1792
1797
map .m_lblk = cur ;
1793
1798
map .m_len = remaining ;
@@ -1808,8 +1813,8 @@ ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl)
1808
1813
}
1809
1814
1810
1815
ret = ext4_punch_hole (inode ,
1811
- le32_to_cpu (lrange -> fc_lblk ) << sb -> s_blocksize_bits ,
1812
- le32_to_cpu (lrange -> fc_len ) << sb -> s_blocksize_bits );
1816
+ le32_to_cpu (lrange . fc_lblk ) << sb -> s_blocksize_bits ,
1817
+ le32_to_cpu (lrange . fc_len ) << sb -> s_blocksize_bits );
1813
1818
if (ret )
1814
1819
jbd_debug (1 , "ext4_punch_hole returned %d" , ret );
1815
1820
ext4_ext_replay_shrink_inode (inode ,
@@ -1925,11 +1930,11 @@ static int ext4_fc_replay_scan(journal_t *journal,
1925
1930
struct ext4_sb_info * sbi = EXT4_SB (sb );
1926
1931
struct ext4_fc_replay_state * state ;
1927
1932
int ret = JBD2_FC_REPLAY_CONTINUE ;
1928
- struct ext4_fc_add_range * ext ;
1929
- struct ext4_fc_tl * tl ;
1930
- struct ext4_fc_tail * tail ;
1931
- __u8 * start , * end ;
1932
- struct ext4_fc_head * head ;
1933
+ struct ext4_fc_add_range ext ;
1934
+ struct ext4_fc_tl tl ;
1935
+ struct ext4_fc_tail tail ;
1936
+ __u8 * start , * end , * cur , * val ;
1937
+ struct ext4_fc_head head ;
1933
1938
struct ext4_extent * ex ;
1934
1939
1935
1940
state = & sbi -> s_fc_replay_state ;
@@ -1956,15 +1961,17 @@ static int ext4_fc_replay_scan(journal_t *journal,
1956
1961
}
1957
1962
1958
1963
state -> fc_replay_expected_off ++ ;
1959
- fc_for_each_tl (start , end , tl ) {
1964
+ for (cur = start ; cur < end ; cur = cur + sizeof (tl ) + le16_to_cpu (tl .fc_len )) {
1965
+ memcpy (& tl , cur , sizeof (tl ));
1966
+ val = cur + sizeof (tl );
1960
1967
jbd_debug (3 , "Scan phase, tag:%s, blk %lld\n" ,
1961
- tag2str (le16_to_cpu (tl -> fc_tag )), bh -> b_blocknr );
1962
- switch (le16_to_cpu (tl -> fc_tag )) {
1968
+ tag2str (le16_to_cpu (tl . fc_tag )), bh -> b_blocknr );
1969
+ switch (le16_to_cpu (tl . fc_tag )) {
1963
1970
case EXT4_FC_TAG_ADD_RANGE :
1964
- ext = ( struct ext4_fc_add_range * ) ext4_fc_tag_val ( tl );
1965
- ex = (struct ext4_extent * )& ext -> fc_ex ;
1971
+ memcpy ( & ext , val , sizeof ( ext ) );
1972
+ ex = (struct ext4_extent * )& ext . fc_ex ;
1966
1973
ret = ext4_fc_record_regions (sb ,
1967
- le32_to_cpu (ext -> fc_ino ),
1974
+ le32_to_cpu (ext . fc_ino ),
1968
1975
le32_to_cpu (ex -> ee_block ), ext4_ext_pblock (ex ),
1969
1976
ext4_ext_get_actual_len (ex ));
1970
1977
if (ret < 0 )
@@ -1978,18 +1985,18 @@ static int ext4_fc_replay_scan(journal_t *journal,
1978
1985
case EXT4_FC_TAG_INODE :
1979
1986
case EXT4_FC_TAG_PAD :
1980
1987
state -> fc_cur_tag ++ ;
1981
- state -> fc_crc = ext4_chksum (sbi , state -> fc_crc , tl ,
1982
- sizeof (* tl ) + ext4_fc_tag_len (tl ));
1988
+ state -> fc_crc = ext4_chksum (sbi , state -> fc_crc , cur ,
1989
+ sizeof (tl ) + le16_to_cpu (tl . fc_len ));
1983
1990
break ;
1984
1991
case EXT4_FC_TAG_TAIL :
1985
1992
state -> fc_cur_tag ++ ;
1986
- tail = ( struct ext4_fc_tail * ) ext4_fc_tag_val ( tl );
1987
- state -> fc_crc = ext4_chksum (sbi , state -> fc_crc , tl ,
1988
- sizeof (* tl ) +
1993
+ memcpy ( & tail , val , sizeof ( tail ) );
1994
+ state -> fc_crc = ext4_chksum (sbi , state -> fc_crc , cur ,
1995
+ sizeof (tl ) +
1989
1996
offsetof(struct ext4_fc_tail ,
1990
1997
fc_crc ));
1991
- if (le32_to_cpu (tail -> fc_tid ) == expected_tid &&
1992
- le32_to_cpu (tail -> fc_crc ) == state -> fc_crc ) {
1998
+ if (le32_to_cpu (tail . fc_tid ) == expected_tid &&
1999
+ le32_to_cpu (tail . fc_crc ) == state -> fc_crc ) {
1993
2000
state -> fc_replay_num_tags = state -> fc_cur_tag ;
1994
2001
state -> fc_regions_valid =
1995
2002
state -> fc_regions_used ;
@@ -2000,19 +2007,19 @@ static int ext4_fc_replay_scan(journal_t *journal,
2000
2007
state -> fc_crc = 0 ;
2001
2008
break ;
2002
2009
case EXT4_FC_TAG_HEAD :
2003
- head = ( struct ext4_fc_head * ) ext4_fc_tag_val ( tl );
2004
- if (le32_to_cpu (head -> fc_features ) &
2010
+ memcpy ( & head , val , sizeof ( head ) );
2011
+ if (le32_to_cpu (head . fc_features ) &
2005
2012
~EXT4_FC_SUPPORTED_FEATURES ) {
2006
2013
ret = - EOPNOTSUPP ;
2007
2014
break ;
2008
2015
}
2009
- if (le32_to_cpu (head -> fc_tid ) != expected_tid ) {
2016
+ if (le32_to_cpu (head . fc_tid ) != expected_tid ) {
2010
2017
ret = JBD2_FC_REPLAY_STOP ;
2011
2018
break ;
2012
2019
}
2013
2020
state -> fc_cur_tag ++ ;
2014
- state -> fc_crc = ext4_chksum (sbi , state -> fc_crc , tl ,
2015
- sizeof (* tl ) + ext4_fc_tag_len (tl ));
2021
+ state -> fc_crc = ext4_chksum (sbi , state -> fc_crc , cur ,
2022
+ sizeof (tl ) + le16_to_cpu (tl . fc_len ));
2016
2023
break ;
2017
2024
default :
2018
2025
ret = state -> fc_replay_num_tags ?
@@ -2036,11 +2043,11 @@ static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh,
2036
2043
{
2037
2044
struct super_block * sb = journal -> j_private ;
2038
2045
struct ext4_sb_info * sbi = EXT4_SB (sb );
2039
- struct ext4_fc_tl * tl ;
2040
- __u8 * start , * end ;
2046
+ struct ext4_fc_tl tl ;
2047
+ __u8 * start , * end , * cur , * val ;
2041
2048
int ret = JBD2_FC_REPLAY_CONTINUE ;
2042
2049
struct ext4_fc_replay_state * state = & sbi -> s_fc_replay_state ;
2043
- struct ext4_fc_tail * tail ;
2050
+ struct ext4_fc_tail tail ;
2044
2051
2045
2052
if (pass == PASS_SCAN ) {
2046
2053
state -> fc_current_pass = PASS_SCAN ;
@@ -2067,49 +2074,52 @@ static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh,
2067
2074
start = (u8 * )bh -> b_data ;
2068
2075
end = (__u8 * )bh -> b_data + journal -> j_blocksize - 1 ;
2069
2076
2070
- fc_for_each_tl (start , end , tl ) {
2077
+ for (cur = start ; cur < end ; cur = cur + sizeof (tl ) + le16_to_cpu (tl .fc_len )) {
2078
+ memcpy (& tl , cur , sizeof (tl ));
2079
+ val = cur + sizeof (tl );
2080
+
2071
2081
if (state -> fc_replay_num_tags == 0 ) {
2072
2082
ret = JBD2_FC_REPLAY_STOP ;
2073
2083
ext4_fc_set_bitmaps_and_counters (sb );
2074
2084
break ;
2075
2085
}
2076
2086
jbd_debug (3 , "Replay phase, tag:%s\n" ,
2077
- tag2str (le16_to_cpu (tl -> fc_tag )));
2087
+ tag2str (le16_to_cpu (tl . fc_tag )));
2078
2088
state -> fc_replay_num_tags -- ;
2079
- switch (le16_to_cpu (tl -> fc_tag )) {
2089
+ switch (le16_to_cpu (tl . fc_tag )) {
2080
2090
case EXT4_FC_TAG_LINK :
2081
- ret = ext4_fc_replay_link (sb , tl );
2091
+ ret = ext4_fc_replay_link (sb , & tl , val );
2082
2092
break ;
2083
2093
case EXT4_FC_TAG_UNLINK :
2084
- ret = ext4_fc_replay_unlink (sb , tl );
2094
+ ret = ext4_fc_replay_unlink (sb , & tl , val );
2085
2095
break ;
2086
2096
case EXT4_FC_TAG_ADD_RANGE :
2087
- ret = ext4_fc_replay_add_range (sb , tl );
2097
+ ret = ext4_fc_replay_add_range (sb , & tl , val );
2088
2098
break ;
2089
2099
case EXT4_FC_TAG_CREAT :
2090
- ret = ext4_fc_replay_create (sb , tl );
2100
+ ret = ext4_fc_replay_create (sb , & tl , val );
2091
2101
break ;
2092
2102
case EXT4_FC_TAG_DEL_RANGE :
2093
- ret = ext4_fc_replay_del_range (sb , tl );
2103
+ ret = ext4_fc_replay_del_range (sb , & tl , val );
2094
2104
break ;
2095
2105
case EXT4_FC_TAG_INODE :
2096
- ret = ext4_fc_replay_inode (sb , tl );
2106
+ ret = ext4_fc_replay_inode (sb , & tl , val );
2097
2107
break ;
2098
2108
case EXT4_FC_TAG_PAD :
2099
2109
trace_ext4_fc_replay (sb , EXT4_FC_TAG_PAD , 0 ,
2100
- ext4_fc_tag_len (tl ), 0 );
2110
+ le16_to_cpu (tl . fc_len ), 0 );
2101
2111
break ;
2102
2112
case EXT4_FC_TAG_TAIL :
2103
2113
trace_ext4_fc_replay (sb , EXT4_FC_TAG_TAIL , 0 ,
2104
- ext4_fc_tag_len (tl ), 0 );
2105
- tail = ( struct ext4_fc_tail * ) ext4_fc_tag_val ( tl );
2106
- WARN_ON (le32_to_cpu (tail -> fc_tid ) != expected_tid );
2114
+ le16_to_cpu (tl . fc_len ), 0 );
2115
+ memcpy ( & tail , val , sizeof ( tail ) );
2116
+ WARN_ON (le32_to_cpu (tail . fc_tid ) != expected_tid );
2107
2117
break ;
2108
2118
case EXT4_FC_TAG_HEAD :
2109
2119
break ;
2110
2120
default :
2111
- trace_ext4_fc_replay (sb , le16_to_cpu (tl -> fc_tag ), 0 ,
2112
- ext4_fc_tag_len (tl ), 0 );
2121
+ trace_ext4_fc_replay (sb , le16_to_cpu (tl . fc_tag ), 0 ,
2122
+ le16_to_cpu (tl . fc_len ), 0 );
2113
2123
ret = - ECANCELED ;
2114
2124
break ;
2115
2125
}
0 commit comments