Merge tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4

Pull ext4 fixes from Ted Ts'o:
"Miscellaneous ext4 bug fixes"

* tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
ext4: Only advertise encrypted_casefold when encryption and unicode are enabled
ext4: fix no-key deletion for encrypt+casefold
ext4: fix memory leak in ext4_fill_super
ext4: fix fast commit alignment issues
ext4: fix bug on in ext4_es_cache_extent as ext4_split_extent_at failed
ext4: fix accessing uninit percpu counter variable with fast_commit
ext4: fix memory leak in ext4_mb_init_backend on error path.

+23 -20
fs/ext4/extents.c
··· 3206 3206 ext4_ext_mark_unwritten(ex2); 3207 3207 3208 3208 err = ext4_ext_insert_extent(handle, inode, ppath, &newex, flags); 3209 - if (err == -ENOSPC && (EXT4_EXT_MAY_ZEROOUT & split_flag)) { 3209 + if (err != -ENOSPC && err != -EDQUOT) 3210 + goto out; 3211 + 3212 + if (EXT4_EXT_MAY_ZEROOUT & split_flag) { 3210 3213 if (split_flag & (EXT4_EXT_DATA_VALID1|EXT4_EXT_DATA_VALID2)) { 3211 3214 if (split_flag & EXT4_EXT_DATA_VALID1) { 3212 3215 err = ext4_ext_zeroout(inode, ex2); ··· 3235 3232 ext4_ext_pblock(&orig_ex)); 3236 3233 } 3237 3234 3238 - if (err) 3239 - goto fix_extent_len; 3240 - /* update the extent length and mark as initialized */ 3241 - ex->ee_len = cpu_to_le16(ee_len); 3242 - ext4_ext_try_to_merge(handle, inode, path, ex); 3243 - err = ext4_ext_dirty(handle, inode, path + path->p_depth); 3244 - if (err) 3245 - goto fix_extent_len; 3246 - 3247 - /* update extent status tree */ 3248 - err = ext4_zeroout_es(inode, &zero_ex); 3249 - 3250 - goto out; 3251 - } else if (err) 3252 - goto fix_extent_len; 3253 - 3254 - out: 3255 - ext4_ext_show_leaf(inode, path); 3256 - return err; 3235 + if (!err) { 3236 + /* update the extent length and mark as initialized */ 3237 + ex->ee_len = cpu_to_le16(ee_len); 3238 + ext4_ext_try_to_merge(handle, inode, path, ex); 3239 + err = ext4_ext_dirty(handle, inode, path + path->p_depth); 3240 + if (!err) 3241 + /* update extent status tree */ 3242 + err = ext4_zeroout_es(inode, &zero_ex); 3243 + /* If we failed at this point, we don't know in which 3244 + * state the extent tree exactly is so don't try to fix 3245 + * length of the original extent as it may do even more 3246 + * damage. 3247 + */ 3248 + goto out; 3249 + } 3250 + } 3257 3251 3258 3252 fix_extent_len: 3259 3253 ex->ee_len = orig_ex.ee_len; ··· 3259 3259 * and err is a non-zero error code. 3260 3260 */ 3261 3261 ext4_ext_dirty(handle, inode, path + path->p_depth); 3262 + return err; 3263 + out: 3264 + ext4_ext_show_leaf(inode, path); 3262 3265 return err; 3263 3266 } 3264 3267
+90 -80
fs/ext4/fast_commit.c
··· 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); ··· 1400 1399 } 1401 1400 1402 1401 /* Link replay function */ 1403 - static int ext4_fc_replay_link(struct super_block *sb, struct ext4_fc_tl *tl) 1402 + static int ext4_fc_replay_link(struct super_block *sb, struct ext4_fc_tl *tl, 1403 + u8 *val) 1404 1404 { 1405 1405 struct inode *inode; 1406 1406 struct dentry_info_args darg; 1407 1407 int ret = 0; 1408 1408 1409 - tl_to_darg(&darg, tl); 1409 + tl_to_darg(&darg, tl, val); 1410 1410 trace_ext4_fc_replay(sb, EXT4_FC_TAG_LINK, darg.ino, 1411 1411 darg.parent_ino, darg.dname_len); 1412 1412 ··· 1452 1450 /* 1453 1451 * Inode replay function 1454 1452 */ 1455 - static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl) 1453 + static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl, 1454 + u8 *val) 1456 1455 { 1457 - struct ext4_fc_inode *fc_inode; 1456 + struct ext4_fc_inode fc_inode; 1458 1457 struct ext4_inode *raw_inode; 1459 1458 struct ext4_inode *raw_fc_inode; 1460 1459 struct inode *inode = NULL; ··· 1463 1460 int inode_len, ino, ret, tag = le16_to_cpu(tl->fc_tag); 1464 1461 struct ext4_extent_header *eh; 1465 1462 1466 - fc_inode = (struct ext4_fc_inode *)ext4_fc_tag_val(tl); 1463 + memcpy(&fc_inode, val, sizeof(fc_inode)); 1467 1464 1468 - ino = le32_to_cpu(fc_inode->fc_ino); 1465 + ino = le32_to_cpu(fc_inode.fc_ino); 1469 1466 trace_ext4_fc_replay(sb, tag, ino, 0, 0); 1470 1467 1471 1468 inode = ext4_iget(sb, ino, EXT4_IGET_NORMAL); ··· 1477 1474 1478 1475 ext4_fc_record_modified_inode(sb, ino); 1479 1476 1480 - raw_fc_inode = (struct ext4_inode *)fc_inode->fc_raw_inode; 1477 + raw_fc_inode = (struct ext4_inode *) 1478 + (val + offsetof(struct ext4_fc_inode, fc_raw_inode)); 1481 1479 ret = ext4_get_fc_inode_loc(sb, ino, &iloc); 1482 1480 if (ret) 1483 1481 goto out; 1484 1482 1485 - inode_len = ext4_fc_tag_len(tl) - sizeof(struct ext4_fc_inode); 1483 + inode_len = le16_to_cpu(tl->fc_len) - sizeof(struct ext4_fc_inode); 1486 1484 raw_inode = ext4_raw_inode(&iloc); 1487 1485 1488 1486 memcpy(raw_inode, raw_fc_inode, offsetof(struct ext4_inode, i_block)); ··· 1551 1547 * inode for which we are trying to create a dentry here, should already have 1552 1548 * been replayed before we start here. 1553 1549 */ 1554 - static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl) 1550 + static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl, 1551 + u8 *val) 1555 1552 { 1556 1553 int ret = 0; 1557 1554 struct inode *inode = NULL; 1558 1555 struct inode *dir = NULL; 1559 1556 struct dentry_info_args darg; 1560 1557 1561 - tl_to_darg(&darg, tl); 1558 + tl_to_darg(&darg, tl, val); 1562 1559 1563 1560 trace_ext4_fc_replay(sb, EXT4_FC_TAG_CREAT, darg.ino, 1564 1561 darg.parent_ino, darg.dname_len); ··· 1638 1633 1639 1634 /* Replay add range tag */ 1640 1635 static int ext4_fc_replay_add_range(struct super_block *sb, 1641 - struct ext4_fc_tl *tl) 1636 + struct ext4_fc_tl *tl, u8 *val) 1642 1637 { 1643 - struct ext4_fc_add_range *fc_add_ex; 1638 + struct ext4_fc_add_range fc_add_ex; 1644 1639 struct ext4_extent newex, *ex; 1645 1640 struct inode *inode; 1646 1641 ext4_lblk_t start, cur; ··· 1650 1645 struct ext4_ext_path *path = NULL; 1651 1646 int ret; 1652 1647 1653 - fc_add_ex = (struct ext4_fc_add_range *)ext4_fc_tag_val(tl); 1654 - ex = (struct ext4_extent *)&fc_add_ex->fc_ex; 1648 + memcpy(&fc_add_ex, val, sizeof(fc_add_ex)); 1649 + ex = (struct ext4_extent *)&fc_add_ex.fc_ex; 1655 1650 1656 1651 trace_ext4_fc_replay(sb, EXT4_FC_TAG_ADD_RANGE, 1657 - le32_to_cpu(fc_add_ex->fc_ino), le32_to_cpu(ex->ee_block), 1652 + le32_to_cpu(fc_add_ex.fc_ino), le32_to_cpu(ex->ee_block), 1658 1653 ext4_ext_get_actual_len(ex)); 1659 1654 1660 - inode = ext4_iget(sb, le32_to_cpu(fc_add_ex->fc_ino), 1661 - EXT4_IGET_NORMAL); 1655 + inode = ext4_iget(sb, le32_to_cpu(fc_add_ex.fc_ino), EXT4_IGET_NORMAL); 1662 1656 if (IS_ERR(inode)) { 1663 1657 jbd_debug(1, "Inode not found."); 1664 1658 return 0; ··· 1766 1762 1767 1763 /* Replay DEL_RANGE tag */ 1768 1764 static int 1769 - ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl) 1765 + ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl, 1766 + u8 *val) 1770 1767 { 1771 1768 struct inode *inode; 1772 - struct ext4_fc_del_range *lrange; 1769 + struct ext4_fc_del_range lrange; 1773 1770 struct ext4_map_blocks map; 1774 1771 ext4_lblk_t cur, remaining; 1775 1772 int ret; 1776 1773 1777 - lrange = (struct ext4_fc_del_range *)ext4_fc_tag_val(tl); 1778 - cur = le32_to_cpu(lrange->fc_lblk); 1779 - remaining = le32_to_cpu(lrange->fc_len); 1774 + memcpy(&lrange, val, sizeof(lrange)); 1775 + cur = le32_to_cpu(lrange.fc_lblk); 1776 + remaining = le32_to_cpu(lrange.fc_len); 1780 1777 1781 1778 trace_ext4_fc_replay(sb, EXT4_FC_TAG_DEL_RANGE, 1782 - le32_to_cpu(lrange->fc_ino), cur, remaining); 1779 + le32_to_cpu(lrange.fc_ino), cur, remaining); 1783 1780 1784 - inode = ext4_iget(sb, le32_to_cpu(lrange->fc_ino), EXT4_IGET_NORMAL); 1781 + inode = ext4_iget(sb, le32_to_cpu(lrange.fc_ino), EXT4_IGET_NORMAL); 1785 1782 if (IS_ERR(inode)) { 1786 - jbd_debug(1, "Inode %d not found", le32_to_cpu(lrange->fc_ino)); 1783 + jbd_debug(1, "Inode %d not found", le32_to_cpu(lrange.fc_ino)); 1787 1784 return 0; 1788 1785 } 1789 1786 1790 1787 ret = ext4_fc_record_modified_inode(sb, inode->i_ino); 1791 1788 1792 1789 jbd_debug(1, "DEL_RANGE, inode %ld, lblk %d, len %d\n", 1793 - inode->i_ino, le32_to_cpu(lrange->fc_lblk), 1794 - le32_to_cpu(lrange->fc_len)); 1790 + inode->i_ino, le32_to_cpu(lrange.fc_lblk), 1791 + le32_to_cpu(lrange.fc_len)); 1795 1792 while (remaining > 0) { 1796 1793 map.m_lblk = cur; 1797 1794 map.m_len = remaining; ··· 1813 1808 } 1814 1809 1815 1810 ret = ext4_punch_hole(inode, 1816 - le32_to_cpu(lrange->fc_lblk) << sb->s_blocksize_bits, 1817 - le32_to_cpu(lrange->fc_len) << sb->s_blocksize_bits); 1811 + le32_to_cpu(lrange.fc_lblk) << sb->s_blocksize_bits, 1812 + le32_to_cpu(lrange.fc_len) << sb->s_blocksize_bits); 1818 1813 if (ret) 1819 1814 jbd_debug(1, "ext4_punch_hole returned %d", ret); 1820 1815 ext4_ext_replay_shrink_inode(inode, ··· 1930 1925 struct ext4_sb_info *sbi = EXT4_SB(sb); 1931 1926 struct ext4_fc_replay_state *state; 1932 1927 int ret = JBD2_FC_REPLAY_CONTINUE; 1933 - struct ext4_fc_add_range *ext; 1934 - struct ext4_fc_tl *tl; 1935 - struct ext4_fc_tail *tail; 1936 - __u8 *start, *end; 1937 - struct ext4_fc_head *head; 1928 + struct ext4_fc_add_range ext; 1929 + struct ext4_fc_tl tl; 1930 + struct ext4_fc_tail tail; 1931 + __u8 *start, *end, *cur, *val; 1932 + struct ext4_fc_head head; 1938 1933 struct ext4_extent *ex; 1939 1934 1940 1935 state = &sbi->s_fc_replay_state; ··· 1961 1956 } 1962 1957 1963 1958 state->fc_replay_expected_off++; 1964 - fc_for_each_tl(start, end, tl) { 1959 + for (cur = start; cur < end; cur = cur + sizeof(tl) + le16_to_cpu(tl.fc_len)) { 1960 + memcpy(&tl, cur, sizeof(tl)); 1961 + val = cur + sizeof(tl); 1965 1962 jbd_debug(3, "Scan phase, tag:%s, blk %lld\n", 1966 - tag2str(le16_to_cpu(tl->fc_tag)), bh->b_blocknr); 1967 - switch (le16_to_cpu(tl->fc_tag)) { 1963 + tag2str(le16_to_cpu(tl.fc_tag)), bh->b_blocknr); 1964 + switch (le16_to_cpu(tl.fc_tag)) { 1968 1965 case EXT4_FC_TAG_ADD_RANGE: 1969 - ext = (struct ext4_fc_add_range *)ext4_fc_tag_val(tl); 1970 - ex = (struct ext4_extent *)&ext->fc_ex; 1966 + memcpy(&ext, val, sizeof(ext)); 1967 + ex = (struct ext4_extent *)&ext.fc_ex; 1971 1968 ret = ext4_fc_record_regions(sb, 1972 - le32_to_cpu(ext->fc_ino), 1969 + le32_to_cpu(ext.fc_ino), 1973 1970 le32_to_cpu(ex->ee_block), ext4_ext_pblock(ex), 1974 1971 ext4_ext_get_actual_len(ex)); 1975 1972 if (ret < 0) ··· 1985 1978 case EXT4_FC_TAG_INODE: 1986 1979 case EXT4_FC_TAG_PAD: 1987 1980 state->fc_cur_tag++; 1988 - state->fc_crc = ext4_chksum(sbi, state->fc_crc, tl, 1989 - sizeof(*tl) + ext4_fc_tag_len(tl)); 1981 + state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur, 1982 + sizeof(tl) + le16_to_cpu(tl.fc_len)); 1990 1983 break; 1991 1984 case EXT4_FC_TAG_TAIL: 1992 1985 state->fc_cur_tag++; 1993 - tail = (struct ext4_fc_tail *)ext4_fc_tag_val(tl); 1994 - state->fc_crc = ext4_chksum(sbi, state->fc_crc, tl, 1995 - sizeof(*tl) + 1986 + memcpy(&tail, val, sizeof(tail)); 1987 + state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur, 1988 + sizeof(tl) + 1996 1989 offsetof(struct ext4_fc_tail, 1997 1990 fc_crc)); 1998 - if (le32_to_cpu(tail->fc_tid) == expected_tid && 1999 - le32_to_cpu(tail->fc_crc) == state->fc_crc) { 1991 + if (le32_to_cpu(tail.fc_tid) == expected_tid && 1992 + le32_to_cpu(tail.fc_crc) == state->fc_crc) { 2000 1993 state->fc_replay_num_tags = state->fc_cur_tag; 2001 1994 state->fc_regions_valid = 2002 1995 state->fc_regions_used; ··· 2007 2000 state->fc_crc = 0; 2008 2001 break; 2009 2002 case EXT4_FC_TAG_HEAD: 2010 - head = (struct ext4_fc_head *)ext4_fc_tag_val(tl); 2011 - if (le32_to_cpu(head->fc_features) & 2003 + memcpy(&head, val, sizeof(head)); 2004 + if (le32_to_cpu(head.fc_features) & 2012 2005 ~EXT4_FC_SUPPORTED_FEATURES) { 2013 2006 ret = -EOPNOTSUPP; 2014 2007 break; 2015 2008 } 2016 - if (le32_to_cpu(head->fc_tid) != expected_tid) { 2009 + if (le32_to_cpu(head.fc_tid) != expected_tid) { 2017 2010 ret = JBD2_FC_REPLAY_STOP; 2018 2011 break; 2019 2012 } 2020 2013 state->fc_cur_tag++; 2021 - state->fc_crc = ext4_chksum(sbi, state->fc_crc, tl, 2022 - sizeof(*tl) + ext4_fc_tag_len(tl)); 2014 + state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur, 2015 + sizeof(tl) + le16_to_cpu(tl.fc_len)); 2023 2016 break; 2024 2017 default: 2025 2018 ret = state->fc_replay_num_tags ? ··· 2043 2036 { 2044 2037 struct super_block *sb = journal->j_private; 2045 2038 struct ext4_sb_info *sbi = EXT4_SB(sb); 2046 - struct ext4_fc_tl *tl; 2047 - __u8 *start, *end; 2039 + struct ext4_fc_tl tl; 2040 + __u8 *start, *end, *cur, *val; 2048 2041 int ret = JBD2_FC_REPLAY_CONTINUE; 2049 2042 struct ext4_fc_replay_state *state = &sbi->s_fc_replay_state; 2050 - struct ext4_fc_tail *tail; 2043 + struct ext4_fc_tail tail; 2051 2044 2052 2045 if (pass == PASS_SCAN) { 2053 2046 state->fc_current_pass = PASS_SCAN; ··· 2074 2067 start = (u8 *)bh->b_data; 2075 2068 end = (__u8 *)bh->b_data + journal->j_blocksize - 1; 2076 2069 2077 - fc_for_each_tl(start, end, tl) { 2070 + for (cur = start; cur < end; cur = cur + sizeof(tl) + le16_to_cpu(tl.fc_len)) { 2071 + memcpy(&tl, cur, sizeof(tl)); 2072 + val = cur + sizeof(tl); 2073 + 2078 2074 if (state->fc_replay_num_tags == 0) { 2079 2075 ret = JBD2_FC_REPLAY_STOP; 2080 2076 ext4_fc_set_bitmaps_and_counters(sb); 2081 2077 break; 2082 2078 } 2083 2079 jbd_debug(3, "Replay phase, tag:%s\n", 2084 - tag2str(le16_to_cpu(tl->fc_tag))); 2080 + tag2str(le16_to_cpu(tl.fc_tag))); 2085 2081 state->fc_replay_num_tags--; 2086 - switch (le16_to_cpu(tl->fc_tag)) { 2082 + switch (le16_to_cpu(tl.fc_tag)) { 2087 2083 case EXT4_FC_TAG_LINK: 2088 - ret = ext4_fc_replay_link(sb, tl); 2084 + ret = ext4_fc_replay_link(sb, &tl, val); 2089 2085 break; 2090 2086 case EXT4_FC_TAG_UNLINK: 2091 - ret = ext4_fc_replay_unlink(sb, tl); 2087 + ret = ext4_fc_replay_unlink(sb, &tl, val); 2092 2088 break; 2093 2089 case EXT4_FC_TAG_ADD_RANGE: 2094 - ret = ext4_fc_replay_add_range(sb, tl); 2090 + ret = ext4_fc_replay_add_range(sb, &tl, val); 2095 2091 break; 2096 2092 case EXT4_FC_TAG_CREAT: 2097 - ret = ext4_fc_replay_create(sb, tl); 2093 + ret = ext4_fc_replay_create(sb, &tl, val); 2098 2094 break; 2099 2095 case EXT4_FC_TAG_DEL_RANGE: 2100 - ret = ext4_fc_replay_del_range(sb, tl); 2096 + ret = ext4_fc_replay_del_range(sb, &tl, val); 2101 2097 break; 2102 2098 case EXT4_FC_TAG_INODE: 2103 - ret = ext4_fc_replay_inode(sb, tl); 2099 + ret = ext4_fc_replay_inode(sb, &tl, val); 2104 2100 break; 2105 2101 case EXT4_FC_TAG_PAD: 2106 2102 trace_ext4_fc_replay(sb, EXT4_FC_TAG_PAD, 0, 2107 - ext4_fc_tag_len(tl), 0); 2103 + le16_to_cpu(tl.fc_len), 0); 2108 2104 break; 2109 2105 case EXT4_FC_TAG_TAIL: 2110 2106 trace_ext4_fc_replay(sb, EXT4_FC_TAG_TAIL, 0, 2111 - ext4_fc_tag_len(tl), 0); 2112 - tail = (struct ext4_fc_tail *)ext4_fc_tag_val(tl); 2113 - WARN_ON(le32_to_cpu(tail->fc_tid) != expected_tid); 2107 + le16_to_cpu(tl.fc_len), 0); 2108 + memcpy(&tail, val, sizeof(tail)); 2109 + WARN_ON(le32_to_cpu(tail.fc_tid) != expected_tid); 2114 2110 break; 2115 2111 case EXT4_FC_TAG_HEAD: 2116 2112 break; 2117 2113 default: 2118 - trace_ext4_fc_replay(sb, le16_to_cpu(tl->fc_tag), 0, 2119 - ext4_fc_tag_len(tl), 0); 2114 + trace_ext4_fc_replay(sb, le16_to_cpu(tl.fc_tag), 0, 2115 + le16_to_cpu(tl.fc_len), 0); 2120 2116 ret = -ECANCELED; 2121 2117 break; 2122 2118 }
-19
fs/ext4/fast_commit.h
··· 153 153 #define region_last(__region) (((__region)->lblk) + ((__region)->len) - 1) 154 154 #endif 155 155 156 - #define fc_for_each_tl(__start, __end, __tl) \ 157 - for (tl = (struct ext4_fc_tl *)(__start); \ 158 - (__u8 *)tl < (__u8 *)(__end); \ 159 - tl = (struct ext4_fc_tl *)((__u8 *)tl + \ 160 - sizeof(struct ext4_fc_tl) + \ 161 - + le16_to_cpu(tl->fc_len))) 162 - 163 156 static inline const char *tag2str(__u16 tag) 164 157 { 165 158 switch (tag) { ··· 177 184 default: 178 185 return "ERROR"; 179 186 } 180 - } 181 - 182 - /* Get length of a particular tlv */ 183 - static inline int ext4_fc_tag_len(struct ext4_fc_tl *tl) 184 - { 185 - return le16_to_cpu(tl->fc_len); 186 - } 187 - 188 - /* Get a pointer to "value" of a tlv */ 189 - static inline __u8 *ext4_fc_tag_val(struct ext4_fc_tl *tl) 190 - { 191 - return (__u8 *)tl + sizeof(*tl); 192 187 } 193 188 194 189 #endif /* __FAST_COMMIT_H__ */
+4 -2
fs/ext4/ialloc.c
··· 322 322 if (is_directory) { 323 323 count = ext4_used_dirs_count(sb, gdp) - 1; 324 324 ext4_used_dirs_set(sb, gdp, count); 325 - percpu_counter_dec(&sbi->s_dirs_counter); 325 + if (percpu_counter_initialized(&sbi->s_dirs_counter)) 326 + percpu_counter_dec(&sbi->s_dirs_counter); 326 327 } 327 328 ext4_inode_bitmap_csum_set(sb, block_group, gdp, bitmap_bh, 328 329 EXT4_INODES_PER_GROUP(sb) / 8); 329 330 ext4_group_desc_csum_set(sb, block_group, gdp); 330 331 ext4_unlock_group(sb, block_group); 331 332 332 - percpu_counter_inc(&sbi->s_freeinodes_counter); 333 + if (percpu_counter_initialized(&sbi->s_freeinodes_counter)) 334 + percpu_counter_inc(&sbi->s_freeinodes_counter); 333 335 if (sbi->s_log_groups_per_flex) { 334 336 struct flex_groups *fg; 335 337
+1 -1
fs/ext4/mballoc.c
··· 3217 3217 */ 3218 3218 if (sbi->s_es->s_log_groups_per_flex >= 32) { 3219 3219 ext4_msg(sb, KERN_ERR, "too many log groups per flexible block group"); 3220 - goto err_freesgi; 3220 + goto err_freebuddy; 3221 3221 } 3222 3222 sbi->s_mb_prefetch = min_t(uint, 1 << sbi->s_es->s_log_groups_per_flex, 3223 3223 BLK_MAX_SEGMENT_SIZE >> (sb->s_blocksize_bits - 9));
+4 -2
fs/ext4/namei.c
··· 1376 1376 struct dx_hash_info *hinfo = &name->hinfo; 1377 1377 int len; 1378 1378 1379 - if (!IS_CASEFOLDED(dir) || !dir->i_sb->s_encoding) { 1379 + if (!IS_CASEFOLDED(dir) || !dir->i_sb->s_encoding || 1380 + (IS_ENCRYPTED(dir) && !fscrypt_has_encryption_key(dir))) { 1380 1381 cf_name->name = NULL; 1381 1382 return 0; 1382 1383 } ··· 1428 1427 #endif 1429 1428 1430 1429 #ifdef CONFIG_UNICODE 1431 - if (parent->i_sb->s_encoding && IS_CASEFOLDED(parent)) { 1430 + if (parent->i_sb->s_encoding && IS_CASEFOLDED(parent) && 1431 + (!IS_ENCRYPTED(parent) || fscrypt_has_encryption_key(parent))) { 1432 1432 if (fname->cf_name.name) { 1433 1433 struct qstr cf = {.name = fname->cf_name.name, 1434 1434 .len = fname->cf_name.len};
+9 -2
fs/ext4/super.c
··· 4462 4462 } 4463 4463 4464 4464 if (sb->s_blocksize != blocksize) { 4465 + /* 4466 + * bh must be released before kill_bdev(), otherwise 4467 + * it won't be freed and its page also. kill_bdev() 4468 + * is called by sb_set_blocksize(). 4469 + */ 4470 + brelse(bh); 4465 4471 /* Validate the filesystem blocksize */ 4466 4472 if (!sb_set_blocksize(sb, blocksize)) { 4467 4473 ext4_msg(sb, KERN_ERR, "bad block size %d", 4468 4474 blocksize); 4475 + bh = NULL; 4469 4476 goto failed_mount; 4470 4477 } 4471 4478 4472 - brelse(bh); 4473 4479 logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE; 4474 4480 offset = do_div(logical_sb_block, blocksize); 4475 4481 bh = ext4_sb_bread_unmovable(sb, logical_sb_block); ··· 5208 5202 kfree(get_qf_name(sb, sbi, i)); 5209 5203 #endif 5210 5204 fscrypt_free_dummy_policy(&sbi->s_dummy_enc_policy); 5211 - ext4_blkdev_remove(sbi); 5205 + /* ext4_blkdev_remove() calls kill_bdev(), release bh before it. */ 5212 5206 brelse(bh); 5207 + ext4_blkdev_remove(sbi); 5213 5208 out_fail: 5214 5209 sb->s_fs_info = NULL; 5215 5210 kfree(sbi->s_blockgroup_lock);
+4
fs/ext4/sysfs.c
··· 315 315 #endif 316 316 EXT4_ATTR_FEATURE(metadata_csum_seed); 317 317 EXT4_ATTR_FEATURE(fast_commit); 318 + #if defined(CONFIG_UNICODE) && defined(CONFIG_FS_ENCRYPTION) 318 319 EXT4_ATTR_FEATURE(encrypted_casefold); 320 + #endif 319 321 320 322 static struct attribute *ext4_feat_attrs[] = { 321 323 ATTR_LIST(lazy_itable_init), ··· 335 333 #endif 336 334 ATTR_LIST(metadata_csum_seed), 337 335 ATTR_LIST(fast_commit), 336 + #if defined(CONFIG_UNICODE) && defined(CONFIG_FS_ENCRYPTION) 338 337 ATTR_LIST(encrypted_casefold), 338 + #endif 339 339 NULL, 340 340 }; 341 341 ATTRIBUTE_GROUPS(ext4_feat);