fast_commit.c (6f84981772535e670e4e2df051a672af229b6694) | fast_commit.c (11768cfd98136dd8399480c60b7a5d3d3c7b109b) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2 3/* 4 * fs/ext4/fast_commit.c 5 * 6 * Written by Harshad Shirwadkar <harshadshirwadkar@gmail.com> 7 * 8 * Ext4 fast commits routines. --- 1318 unchanged lines hidden (view full) --- 1327/* Ext4 Replay Path Routines */ 1328 1329/* Helper struct for dentry replay routines */ 1330struct dentry_info_args { 1331 int parent_ino, dname_len, ino, inode_len; 1332 char *dname; 1333}; 1334 | 1// SPDX-License-Identifier: GPL-2.0 2 3/* 4 * fs/ext4/fast_commit.c 5 * 6 * Written by Harshad Shirwadkar <harshadshirwadkar@gmail.com> 7 * 8 * Ext4 fast commits routines. --- 1318 unchanged lines hidden (view full) --- 1327/* Ext4 Replay Path Routines */ 1328 1329/* Helper struct for dentry replay routines */ 1330struct dentry_info_args { 1331 int parent_ino, dname_len, ino, inode_len; 1332 char *dname; 1333}; 1334 |
1335/* Same as struct ext4_fc_tl, but uses native endianness fields */ 1336struct ext4_fc_tl_mem { 1337 u16 fc_tag; 1338 u16 fc_len; 1339}; 1340 |
|
1335static inline void tl_to_darg(struct dentry_info_args *darg, | 1341static inline void tl_to_darg(struct dentry_info_args *darg, |
1336 struct ext4_fc_tl *tl, u8 *val) | 1342 struct ext4_fc_tl_mem *tl, u8 *val) |
1337{ 1338 struct ext4_fc_dentry_info fcd; 1339 1340 memcpy(&fcd, val, sizeof(fcd)); 1341 1342 darg->parent_ino = le32_to_cpu(fcd.fc_parent_ino); 1343 darg->ino = le32_to_cpu(fcd.fc_ino); 1344 darg->dname = val + offsetof(struct ext4_fc_dentry_info, fc_dname); 1345 darg->dname_len = tl->fc_len - sizeof(struct ext4_fc_dentry_info); 1346} 1347 | 1343{ 1344 struct ext4_fc_dentry_info fcd; 1345 1346 memcpy(&fcd, val, sizeof(fcd)); 1347 1348 darg->parent_ino = le32_to_cpu(fcd.fc_parent_ino); 1349 darg->ino = le32_to_cpu(fcd.fc_ino); 1350 darg->dname = val + offsetof(struct ext4_fc_dentry_info, fc_dname); 1351 darg->dname_len = tl->fc_len - sizeof(struct ext4_fc_dentry_info); 1352} 1353 |
1348static inline void ext4_fc_get_tl(struct ext4_fc_tl *tl, u8 *val) | 1354static inline void ext4_fc_get_tl(struct ext4_fc_tl_mem *tl, u8 *val) |
1349{ | 1355{ |
1350 memcpy(tl, val, EXT4_FC_TAG_BASE_LEN); 1351 tl->fc_len = le16_to_cpu(tl->fc_len); 1352 tl->fc_tag = le16_to_cpu(tl->fc_tag); | 1356 struct ext4_fc_tl tl_disk; 1357 1358 memcpy(&tl_disk, val, EXT4_FC_TAG_BASE_LEN); 1359 tl->fc_len = le16_to_cpu(tl_disk.fc_len); 1360 tl->fc_tag = le16_to_cpu(tl_disk.fc_tag); |
1353} 1354 1355/* Unlink replay function */ | 1361} 1362 1363/* Unlink replay function */ |
1356static int ext4_fc_replay_unlink(struct super_block *sb, struct ext4_fc_tl *tl, 1357 u8 *val) | 1364static int ext4_fc_replay_unlink(struct super_block *sb, 1365 struct ext4_fc_tl_mem *tl, u8 *val) |
1358{ 1359 struct inode *inode, *old_parent; 1360 struct qstr entry; 1361 struct dentry_info_args darg; 1362 int ret = 0; 1363 1364 tl_to_darg(&darg, tl, val); 1365 --- 80 unchanged lines hidden (view full) --- 1446 d_drop(dentry_inode); 1447 dput(dentry_inode); 1448 } 1449 1450 return ret; 1451} 1452 1453/* Link replay function */ | 1366{ 1367 struct inode *inode, *old_parent; 1368 struct qstr entry; 1369 struct dentry_info_args darg; 1370 int ret = 0; 1371 1372 tl_to_darg(&darg, tl, val); 1373 --- 80 unchanged lines hidden (view full) --- 1454 d_drop(dentry_inode); 1455 dput(dentry_inode); 1456 } 1457 1458 return ret; 1459} 1460 1461/* Link replay function */ |
1454static int ext4_fc_replay_link(struct super_block *sb, struct ext4_fc_tl *tl, 1455 u8 *val) | 1462static int ext4_fc_replay_link(struct super_block *sb, 1463 struct ext4_fc_tl_mem *tl, u8 *val) |
1456{ 1457 struct inode *inode; 1458 struct dentry_info_args darg; 1459 int ret = 0; 1460 1461 tl_to_darg(&darg, tl, val); 1462 trace_ext4_fc_replay(sb, EXT4_FC_TAG_LINK, darg.ino, 1463 darg.parent_ino, darg.dname_len); --- 37 unchanged lines hidden (view full) --- 1501 } 1502 state->fc_modified_inodes[state->fc_modified_inodes_used++] = ino; 1503 return 0; 1504} 1505 1506/* 1507 * Inode replay function 1508 */ | 1464{ 1465 struct inode *inode; 1466 struct dentry_info_args darg; 1467 int ret = 0; 1468 1469 tl_to_darg(&darg, tl, val); 1470 trace_ext4_fc_replay(sb, EXT4_FC_TAG_LINK, darg.ino, 1471 darg.parent_ino, darg.dname_len); --- 37 unchanged lines hidden (view full) --- 1509 } 1510 state->fc_modified_inodes[state->fc_modified_inodes_used++] = ino; 1511 return 0; 1512} 1513 1514/* 1515 * Inode replay function 1516 */ |
1509static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl, 1510 u8 *val) | 1517static int ext4_fc_replay_inode(struct super_block *sb, 1518 struct ext4_fc_tl_mem *tl, u8 *val) |
1511{ 1512 struct ext4_fc_inode fc_inode; 1513 struct ext4_inode *raw_inode; 1514 struct ext4_inode *raw_fc_inode; 1515 struct inode *inode = NULL; 1516 struct ext4_iloc iloc; 1517 int inode_len, ino, ret, tag = tl->fc_tag; 1518 struct ext4_extent_header *eh; --- 85 unchanged lines hidden (view full) --- 1604 1605/* 1606 * Dentry create replay function. 1607 * 1608 * EXT4_FC_TAG_CREAT is preceded by EXT4_FC_TAG_INODE_FULL. Which means, the 1609 * inode for which we are trying to create a dentry here, should already have 1610 * been replayed before we start here. 1611 */ | 1519{ 1520 struct ext4_fc_inode fc_inode; 1521 struct ext4_inode *raw_inode; 1522 struct ext4_inode *raw_fc_inode; 1523 struct inode *inode = NULL; 1524 struct ext4_iloc iloc; 1525 int inode_len, ino, ret, tag = tl->fc_tag; 1526 struct ext4_extent_header *eh; --- 85 unchanged lines hidden (view full) --- 1612 1613/* 1614 * Dentry create replay function. 1615 * 1616 * EXT4_FC_TAG_CREAT is preceded by EXT4_FC_TAG_INODE_FULL. Which means, the 1617 * inode for which we are trying to create a dentry here, should already have 1618 * been replayed before we start here. 1619 */ |
1612static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl, 1613 u8 *val) | 1620static int ext4_fc_replay_create(struct super_block *sb, 1621 struct ext4_fc_tl_mem *tl, u8 *val) |
1614{ 1615 int ret = 0; 1616 struct inode *inode = NULL; 1617 struct inode *dir = NULL; 1618 struct dentry_info_args darg; 1619 1620 tl_to_darg(&darg, tl, val); 1621 --- 81 unchanged lines hidden (view full) --- 1703 if (replay) 1704 state->fc_regions_valid++; 1705 1706 return 0; 1707} 1708 1709/* Replay add range tag */ 1710static int ext4_fc_replay_add_range(struct super_block *sb, | 1622{ 1623 int ret = 0; 1624 struct inode *inode = NULL; 1625 struct inode *dir = NULL; 1626 struct dentry_info_args darg; 1627 1628 tl_to_darg(&darg, tl, val); 1629 --- 81 unchanged lines hidden (view full) --- 1711 if (replay) 1712 state->fc_regions_valid++; 1713 1714 return 0; 1715} 1716 1717/* Replay add range tag */ 1718static int ext4_fc_replay_add_range(struct super_block *sb, |
1711 struct ext4_fc_tl *tl, u8 *val) | 1719 struct ext4_fc_tl_mem *tl, u8 *val) |
1712{ 1713 struct ext4_fc_add_range fc_add_ex; 1714 struct ext4_extent newex, *ex; 1715 struct inode *inode; 1716 ext4_lblk_t start, cur; 1717 int remaining, len; 1718 ext4_fsblk_t start_pblk; 1719 struct ext4_map_blocks map; --- 103 unchanged lines hidden (view full) --- 1823 sb->s_blocksize_bits); 1824out: 1825 iput(inode); 1826 return 0; 1827} 1828 1829/* Replay DEL_RANGE tag */ 1830static int | 1720{ 1721 struct ext4_fc_add_range fc_add_ex; 1722 struct ext4_extent newex, *ex; 1723 struct inode *inode; 1724 ext4_lblk_t start, cur; 1725 int remaining, len; 1726 ext4_fsblk_t start_pblk; 1727 struct ext4_map_blocks map; --- 103 unchanged lines hidden (view full) --- 1831 sb->s_blocksize_bits); 1832out: 1833 iput(inode); 1834 return 0; 1835} 1836 1837/* Replay DEL_RANGE tag */ 1838static int |
1831ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl, 1832 u8 *val) | 1839ext4_fc_replay_del_range(struct super_block *sb, 1840 struct ext4_fc_tl_mem *tl, u8 *val) |
1833{ 1834 struct inode *inode; 1835 struct ext4_fc_del_range lrange; 1836 struct ext4_map_blocks map; 1837 ext4_lblk_t cur, remaining; 1838 int ret; 1839 1840 memcpy(&lrange, val, sizeof(lrange)); --- 179 unchanged lines hidden (view full) --- 2020 struct buffer_head *bh, int off, 2021 tid_t expected_tid) 2022{ 2023 struct super_block *sb = journal->j_private; 2024 struct ext4_sb_info *sbi = EXT4_SB(sb); 2025 struct ext4_fc_replay_state *state; 2026 int ret = JBD2_FC_REPLAY_CONTINUE; 2027 struct ext4_fc_add_range ext; | 1841{ 1842 struct inode *inode; 1843 struct ext4_fc_del_range lrange; 1844 struct ext4_map_blocks map; 1845 ext4_lblk_t cur, remaining; 1846 int ret; 1847 1848 memcpy(&lrange, val, sizeof(lrange)); --- 179 unchanged lines hidden (view full) --- 2028 struct buffer_head *bh, int off, 2029 tid_t expected_tid) 2030{ 2031 struct super_block *sb = journal->j_private; 2032 struct ext4_sb_info *sbi = EXT4_SB(sb); 2033 struct ext4_fc_replay_state *state; 2034 int ret = JBD2_FC_REPLAY_CONTINUE; 2035 struct ext4_fc_add_range ext; |
2028 struct ext4_fc_tl tl; | 2036 struct ext4_fc_tl_mem tl; |
2029 struct ext4_fc_tail tail; 2030 __u8 *start, *end, *cur, *val; 2031 struct ext4_fc_head head; 2032 struct ext4_extent *ex; 2033 2034 state = &sbi->s_fc_replay_state; 2035 2036 start = (u8 *)bh->b_data; --- 102 unchanged lines hidden (view full) --- 2139 * Main recovery path entry point. 2140 * The meaning of return codes is similar as above. 2141 */ 2142static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh, 2143 enum passtype pass, int off, tid_t expected_tid) 2144{ 2145 struct super_block *sb = journal->j_private; 2146 struct ext4_sb_info *sbi = EXT4_SB(sb); | 2037 struct ext4_fc_tail tail; 2038 __u8 *start, *end, *cur, *val; 2039 struct ext4_fc_head head; 2040 struct ext4_extent *ex; 2041 2042 state = &sbi->s_fc_replay_state; 2043 2044 start = (u8 *)bh->b_data; --- 102 unchanged lines hidden (view full) --- 2147 * Main recovery path entry point. 2148 * The meaning of return codes is similar as above. 2149 */ 2150static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh, 2151 enum passtype pass, int off, tid_t expected_tid) 2152{ 2153 struct super_block *sb = journal->j_private; 2154 struct ext4_sb_info *sbi = EXT4_SB(sb); |
2147 struct ext4_fc_tl tl; | 2155 struct ext4_fc_tl_mem tl; |
2148 __u8 *start, *end, *cur, *val; 2149 int ret = JBD2_FC_REPLAY_CONTINUE; 2150 struct ext4_fc_replay_state *state = &sbi->s_fc_replay_state; 2151 struct ext4_fc_tail tail; 2152 2153 if (pass == PASS_SCAN) { 2154 state->fc_current_pass = PASS_SCAN; 2155 return ext4_fc_replay_scan(journal, bh, off, expected_tid); --- 141 unchanged lines hidden --- | 2156 __u8 *start, *end, *cur, *val; 2157 int ret = JBD2_FC_REPLAY_CONTINUE; 2158 struct ext4_fc_replay_state *state = &sbi->s_fc_replay_state; 2159 struct ext4_fc_tail tail; 2160 2161 if (pass == PASS_SCAN) { 2162 state->fc_current_pass = PASS_SCAN; 2163 return ext4_fc_replay_scan(journal, bh, off, expected_tid); --- 141 unchanged lines hidden --- |