super.c (ccec4a4a4f27b22e51ec6a143319db49b7570581) | super.c (8a363970d1dc38c4ec4ad575c862f776f468d057) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * linux/fs/ext4/super.c 4 * 5 * Copyright (C) 1992, 1993, 1994, 1995 6 * Remy Card (card@masi.ibp.fr) 7 * Laboratoire MASI - Institut Blaise Pascal 8 * Universite Pierre et Marie Curie (Paris VI) --- 126 unchanged lines hidden (view full) --- 135 .mount = ext4_mount, 136 .kill_sb = kill_block_super, 137 .fs_flags = FS_REQUIRES_DEV, 138}; 139MODULE_ALIAS_FS("ext3"); 140MODULE_ALIAS("ext3"); 141#define IS_EXT3_SB(sb) ((sb)->s_bdev->bd_holder == &ext3_fs_type) 142 | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * linux/fs/ext4/super.c 4 * 5 * Copyright (C) 1992, 1993, 1994, 1995 6 * Remy Card (card@masi.ibp.fr) 7 * Laboratoire MASI - Institut Blaise Pascal 8 * Universite Pierre et Marie Curie (Paris VI) --- 126 unchanged lines hidden (view full) --- 135 .mount = ext4_mount, 136 .kill_sb = kill_block_super, 137 .fs_flags = FS_REQUIRES_DEV, 138}; 139MODULE_ALIAS_FS("ext3"); 140MODULE_ALIAS("ext3"); 141#define IS_EXT3_SB(sb) ((sb)->s_bdev->bd_holder == &ext3_fs_type) 142 |
143/* 144 * This works like sb_bread() except it uses ERR_PTR for error 145 * returns. Currently with sb_bread it's impossible to distinguish 146 * between ENOMEM and EIO situations (since both result in a NULL 147 * return. 148 */ 149struct buffer_head * 150ext4_sb_bread(struct super_block *sb, sector_t block, int op_flags) 151{ 152 struct buffer_head *bh = sb_getblk(sb, block); 153 154 if (bh == NULL) 155 return ERR_PTR(-ENOMEM); 156 if (buffer_uptodate(bh)) 157 return bh; 158 ll_rw_block(REQ_OP_READ, REQ_META | op_flags, 1, &bh); 159 wait_on_buffer(bh); 160 if (buffer_uptodate(bh)) 161 return bh; 162 put_bh(bh); 163 return ERR_PTR(-EIO); 164} 165 |
|
143static int ext4_verify_csum_type(struct super_block *sb, 144 struct ext4_super_block *es) 145{ 146 if (!ext4_has_feature_metadata_csum(sb)) 147 return 1; 148 149 return es->s_checksum_type == EXT4_CRC32C_CHKSUM; 150} --- 844 unchanged lines hidden (view full) --- 995 * Invalidate the journal device's buffers. We don't want them 996 * floating about in memory - the physical journal device may 997 * hotswapped, and it breaks the `ro-after' testing code. 998 */ 999 sync_blockdev(sbi->journal_bdev); 1000 invalidate_bdev(sbi->journal_bdev); 1001 ext4_blkdev_remove(sbi); 1002 } | 166static int ext4_verify_csum_type(struct super_block *sb, 167 struct ext4_super_block *es) 168{ 169 if (!ext4_has_feature_metadata_csum(sb)) 170 return 1; 171 172 return es->s_checksum_type == EXT4_CRC32C_CHKSUM; 173} --- 844 unchanged lines hidden (view full) --- 1018 * Invalidate the journal device's buffers. We don't want them 1019 * floating about in memory - the physical journal device may 1020 * hotswapped, and it breaks the `ro-after' testing code. 1021 */ 1022 sync_blockdev(sbi->journal_bdev); 1023 invalidate_bdev(sbi->journal_bdev); 1024 ext4_blkdev_remove(sbi); 1025 } |
1003 if (sbi->s_ea_inode_cache) { 1004 ext4_xattr_destroy_cache(sbi->s_ea_inode_cache); 1005 sbi->s_ea_inode_cache = NULL; 1006 } 1007 if (sbi->s_ea_block_cache) { 1008 ext4_xattr_destroy_cache(sbi->s_ea_block_cache); 1009 sbi->s_ea_block_cache = NULL; 1010 } | 1026 1027 ext4_xattr_destroy_cache(sbi->s_ea_inode_cache); 1028 sbi->s_ea_inode_cache = NULL; 1029 1030 ext4_xattr_destroy_cache(sbi->s_ea_block_cache); 1031 sbi->s_ea_block_cache = NULL; 1032 |
1011 if (sbi->s_mmp_tsk) 1012 kthread_stop(sbi->s_mmp_tsk); 1013 brelse(sbi->s_sbh); 1014 sb->s_fs_info = NULL; 1015 /* 1016 * Now that we are completely done shutting down the 1017 * superblock, we need to actually destroy the kobject. 1018 */ --- 127 unchanged lines hidden (view full) --- 1146 fscrypt_put_encryption_info(inode); 1147} 1148 1149static struct inode *ext4_nfs_get_inode(struct super_block *sb, 1150 u64 ino, u32 generation) 1151{ 1152 struct inode *inode; 1153 | 1033 if (sbi->s_mmp_tsk) 1034 kthread_stop(sbi->s_mmp_tsk); 1035 brelse(sbi->s_sbh); 1036 sb->s_fs_info = NULL; 1037 /* 1038 * Now that we are completely done shutting down the 1039 * superblock, we need to actually destroy the kobject. 1040 */ --- 127 unchanged lines hidden (view full) --- 1168 fscrypt_put_encryption_info(inode); 1169} 1170 1171static struct inode *ext4_nfs_get_inode(struct super_block *sb, 1172 u64 ino, u32 generation) 1173{ 1174 struct inode *inode; 1175 |
1154 if (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO) 1155 return ERR_PTR(-ESTALE); 1156 if (ino > le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count)) 1157 return ERR_PTR(-ESTALE); 1158 1159 /* iget isn't really right if the inode is currently unallocated!! 1160 * 1161 * ext4_read_inode will return a bad_inode if the inode had been 1162 * deleted, so we should be safe. 1163 * | 1176 /* |
1164 * Currently we don't know the generation for parent directory, so 1165 * a generation of 0 means "accept any" 1166 */ | 1177 * Currently we don't know the generation for parent directory, so 1178 * a generation of 0 means "accept any" 1179 */ |
1167 inode = ext4_iget_normal(sb, ino); | 1180 inode = ext4_iget(sb, ino, EXT4_IGET_HANDLE); |
1168 if (IS_ERR(inode)) 1169 return ERR_CAST(inode); 1170 if (generation && inode->i_generation != generation) { 1171 iput(inode); 1172 return ERR_PTR(-ESTALE); 1173 } 1174 1175 return inode; --- 758 unchanged lines hidden (view full) --- 1934 return 1; 1935 } 1936 sbi->s_jquota_fmt = m->mount_opt; 1937#endif 1938 } else if (token == Opt_dax) { 1939#ifdef CONFIG_FS_DAX 1940 ext4_msg(sb, KERN_WARNING, 1941 "DAX enabled. Warning: EXPERIMENTAL, use at your own risk"); | 1181 if (IS_ERR(inode)) 1182 return ERR_CAST(inode); 1183 if (generation && inode->i_generation != generation) { 1184 iput(inode); 1185 return ERR_PTR(-ESTALE); 1186 } 1187 1188 return inode; --- 758 unchanged lines hidden (view full) --- 1947 return 1; 1948 } 1949 sbi->s_jquota_fmt = m->mount_opt; 1950#endif 1951 } else if (token == Opt_dax) { 1952#ifdef CONFIG_FS_DAX 1953 ext4_msg(sb, KERN_WARNING, 1954 "DAX enabled. Warning: EXPERIMENTAL, use at your own risk"); |
1942 sbi->s_mount_opt |= m->mount_opt; | 1955 sbi->s_mount_opt |= m->mount_opt; |
1943#else 1944 ext4_msg(sb, KERN_INFO, "dax option not supported"); 1945 return -1; 1946#endif 1947 } else if (token == Opt_data_err_abort) { 1948 sbi->s_mount_opt |= m->mount_opt; 1949 } else if (token == Opt_data_err_ignore) { 1950 sbi->s_mount_opt &= ~m->mount_opt; --- 1886 unchanged lines hidden (view full) --- 3837 le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks)); 3838 goto failed_mount; 3839 } 3840 3841 if (sbi->s_mount_opt & EXT4_MOUNT_DAX) { 3842 if (ext4_has_feature_inline_data(sb)) { 3843 ext4_msg(sb, KERN_ERR, "Cannot use DAX on a filesystem" 3844 " that may contain inline data"); | 1956#else 1957 ext4_msg(sb, KERN_INFO, "dax option not supported"); 1958 return -1; 1959#endif 1960 } else if (token == Opt_data_err_abort) { 1961 sbi->s_mount_opt |= m->mount_opt; 1962 } else if (token == Opt_data_err_ignore) { 1963 sbi->s_mount_opt &= ~m->mount_opt; --- 1886 unchanged lines hidden (view full) --- 3850 le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks)); 3851 goto failed_mount; 3852 } 3853 3854 if (sbi->s_mount_opt & EXT4_MOUNT_DAX) { 3855 if (ext4_has_feature_inline_data(sb)) { 3856 ext4_msg(sb, KERN_ERR, "Cannot use DAX on a filesystem" 3857 " that may contain inline data"); |
3845 sbi->s_mount_opt &= ~EXT4_MOUNT_DAX; | 3858 goto failed_mount; |
3846 } 3847 if (!bdev_dax_supported(sb->s_bdev, blocksize)) { 3848 ext4_msg(sb, KERN_ERR, | 3859 } 3860 if (!bdev_dax_supported(sb->s_bdev, blocksize)) { 3861 ext4_msg(sb, KERN_ERR, |
3849 "DAX unsupported by block device. Turning off DAX."); 3850 sbi->s_mount_opt &= ~EXT4_MOUNT_DAX; | 3862 "DAX unsupported by block device."); 3863 goto failed_mount; |
3851 } 3852 } 3853 3854 if (ext4_has_feature_encrypt(sb) && es->s_encryption_level) { 3855 ext4_msg(sb, KERN_ERR, "Unsupported encryption level %d", 3856 es->s_encryption_level); 3857 goto failed_mount; 3858 } --- 464 unchanged lines hidden (view full) --- 4323 goto failed_mount4; 4324 } 4325 4326 /* 4327 * The jbd2_journal_load will have done any necessary log recovery, 4328 * so we can safely mount the rest of the filesystem now. 4329 */ 4330 | 3864 } 3865 } 3866 3867 if (ext4_has_feature_encrypt(sb) && es->s_encryption_level) { 3868 ext4_msg(sb, KERN_ERR, "Unsupported encryption level %d", 3869 es->s_encryption_level); 3870 goto failed_mount; 3871 } --- 464 unchanged lines hidden (view full) --- 4336 goto failed_mount4; 4337 } 4338 4339 /* 4340 * The jbd2_journal_load will have done any necessary log recovery, 4341 * so we can safely mount the rest of the filesystem now. 4342 */ 4343 |
4331 root = ext4_iget(sb, EXT4_ROOT_INO); | 4344 root = ext4_iget(sb, EXT4_ROOT_INO, EXT4_IGET_SPECIAL); |
4332 if (IS_ERR(root)) { 4333 ext4_msg(sb, KERN_ERR, "get root inode failed"); 4334 ret = PTR_ERR(root); 4335 root = NULL; 4336 goto failed_mount4; 4337 } 4338 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { 4339 ext4_msg(sb, KERN_ERR, "corrupt root inode, run e2fsck"); --- 177 unchanged lines hidden (view full) --- 4517failed_mount4a: 4518 dput(sb->s_root); 4519 sb->s_root = NULL; 4520failed_mount4: 4521 ext4_msg(sb, KERN_ERR, "mount failed"); 4522 if (EXT4_SB(sb)->rsv_conversion_wq) 4523 destroy_workqueue(EXT4_SB(sb)->rsv_conversion_wq); 4524failed_mount_wq: | 4345 if (IS_ERR(root)) { 4346 ext4_msg(sb, KERN_ERR, "get root inode failed"); 4347 ret = PTR_ERR(root); 4348 root = NULL; 4349 goto failed_mount4; 4350 } 4351 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { 4352 ext4_msg(sb, KERN_ERR, "corrupt root inode, run e2fsck"); --- 177 unchanged lines hidden (view full) --- 4530failed_mount4a: 4531 dput(sb->s_root); 4532 sb->s_root = NULL; 4533failed_mount4: 4534 ext4_msg(sb, KERN_ERR, "mount failed"); 4535 if (EXT4_SB(sb)->rsv_conversion_wq) 4536 destroy_workqueue(EXT4_SB(sb)->rsv_conversion_wq); 4537failed_mount_wq: |
4525 if (sbi->s_ea_inode_cache) { 4526 ext4_xattr_destroy_cache(sbi->s_ea_inode_cache); 4527 sbi->s_ea_inode_cache = NULL; 4528 } 4529 if (sbi->s_ea_block_cache) { 4530 ext4_xattr_destroy_cache(sbi->s_ea_block_cache); 4531 sbi->s_ea_block_cache = NULL; 4532 } | 4538 ext4_xattr_destroy_cache(sbi->s_ea_inode_cache); 4539 sbi->s_ea_inode_cache = NULL; 4540 4541 ext4_xattr_destroy_cache(sbi->s_ea_block_cache); 4542 sbi->s_ea_block_cache = NULL; 4543 |
4533 if (sbi->s_journal) { 4534 jbd2_journal_destroy(sbi->s_journal); 4535 sbi->s_journal = NULL; 4536 } 4537failed_mount3a: 4538 ext4_es_unregister_shrinker(sbi); 4539failed_mount3: 4540 del_timer_sync(&sbi->s_err_report); --- 52 unchanged lines hidden (view full) --- 4593{ 4594 struct inode *journal_inode; 4595 4596 /* 4597 * Test for the existence of a valid inode on disk. Bad things 4598 * happen if we iget() an unused inode, as the subsequent iput() 4599 * will try to delete it. 4600 */ | 4544 if (sbi->s_journal) { 4545 jbd2_journal_destroy(sbi->s_journal); 4546 sbi->s_journal = NULL; 4547 } 4548failed_mount3a: 4549 ext4_es_unregister_shrinker(sbi); 4550failed_mount3: 4551 del_timer_sync(&sbi->s_err_report); --- 52 unchanged lines hidden (view full) --- 4604{ 4605 struct inode *journal_inode; 4606 4607 /* 4608 * Test for the existence of a valid inode on disk. Bad things 4609 * happen if we iget() an unused inode, as the subsequent iput() 4610 * will try to delete it. 4611 */ |
4601 journal_inode = ext4_iget(sb, journal_inum); | 4612 journal_inode = ext4_iget(sb, journal_inum, EXT4_IGET_SPECIAL); |
4602 if (IS_ERR(journal_inode)) { 4603 ext4_msg(sb, KERN_ERR, "no journal found"); 4604 return NULL; 4605 } 4606 if (!journal_inode->i_nlink) { 4607 make_bad_inode(journal_inode); 4608 iput(journal_inode); 4609 ext4_msg(sb, KERN_ERR, "journal inode is deleted"); --- 1065 unchanged lines hidden (view full) --- 5675 le32_to_cpu(EXT4_SB(sb)->s_es->s_prj_quota_inum) 5676 }; 5677 5678 BUG_ON(!ext4_has_feature_quota(sb)); 5679 5680 if (!qf_inums[type]) 5681 return -EPERM; 5682 | 4613 if (IS_ERR(journal_inode)) { 4614 ext4_msg(sb, KERN_ERR, "no journal found"); 4615 return NULL; 4616 } 4617 if (!journal_inode->i_nlink) { 4618 make_bad_inode(journal_inode); 4619 iput(journal_inode); 4620 ext4_msg(sb, KERN_ERR, "journal inode is deleted"); --- 1065 unchanged lines hidden (view full) --- 5686 le32_to_cpu(EXT4_SB(sb)->s_es->s_prj_quota_inum) 5687 }; 5688 5689 BUG_ON(!ext4_has_feature_quota(sb)); 5690 5691 if (!qf_inums[type]) 5692 return -EPERM; 5693 |
5683 qf_inode = ext4_iget(sb, qf_inums[type]); | 5694 qf_inode = ext4_iget(sb, qf_inums[type], EXT4_IGET_SPECIAL); |
5684 if (IS_ERR(qf_inode)) { 5685 ext4_error(sb, "Bad quota inode # %lu", qf_inums[type]); 5686 return PTR_ERR(qf_inode); 5687 } 5688 5689 /* Don't account quota for quota files to avoid recursion */ 5690 qf_inode->i_flags |= S_NOQUOTA; 5691 lockdep_set_quota_inode(qf_inode, I_DATA_SEM_QUOTA); 5692 err = dquot_enable(qf_inode, type, format_id, flags); | 5695 if (IS_ERR(qf_inode)) { 5696 ext4_error(sb, "Bad quota inode # %lu", qf_inums[type]); 5697 return PTR_ERR(qf_inode); 5698 } 5699 5700 /* Don't account quota for quota files to avoid recursion */ 5701 qf_inode->i_flags |= S_NOQUOTA; 5702 lockdep_set_quota_inode(qf_inode, I_DATA_SEM_QUOTA); 5703 err = dquot_enable(qf_inode, type, format_id, flags); |
5693 iput(qf_inode); | |
5694 if (err) 5695 lockdep_set_quota_inode(qf_inode, I_DATA_SEM_NORMAL); | 5704 if (err) 5705 lockdep_set_quota_inode(qf_inode, I_DATA_SEM_NORMAL); |
5706 iput(qf_inode); |
|
5696 5697 return err; 5698} 5699 5700/* Enable usage tracking for all quota types. */ 5701static int ext4_enable_quotas(struct super_block *sb) 5702{ 5703 int type, err = 0; --- 348 unchanged lines hidden --- | 5707 5708 return err; 5709} 5710 5711/* Enable usage tracking for all quota types. */ 5712static int ext4_enable_quotas(struct super_block *sb) 5713{ 5714 int type, err = 0; --- 348 unchanged lines hidden --- |