super.c (c4cf5f61982e35348f522464010445efcc0aeb60) | super.c (4ba3fcdde7e36af93610ceb3cc38365b14539865) |
---|---|
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) --- 1160 unchanged lines hidden (view full) --- 1169 /* 1170 * Unregister sysfs before destroying jbd2 journal. 1171 * Since we could still access attr_journal_task attribute via sysfs 1172 * path which could have sbi->s_journal->j_task as NULL 1173 */ 1174 ext4_unregister_sysfs(sb); 1175 1176 if (sbi->s_journal) { | 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) --- 1160 unchanged lines hidden (view full) --- 1169 /* 1170 * Unregister sysfs before destroying jbd2 journal. 1171 * Since we could still access attr_journal_task attribute via sysfs 1172 * path which could have sbi->s_journal->j_task as NULL 1173 */ 1174 ext4_unregister_sysfs(sb); 1175 1176 if (sbi->s_journal) { |
1177 jbd2_journal_unregister_shrinker(sbi->s_journal); |
|
1177 aborted = is_journal_aborted(sbi->s_journal); 1178 err = jbd2_journal_destroy(sbi->s_journal); 1179 sbi->s_journal = NULL; 1180 if ((err < 0) && !aborted) { 1181 ext4_abort(sb, -err, "Couldn't clean up the journal"); 1182 } 1183 } 1184 --- 55 unchanged lines hidden (view full) --- 1240 } 1241 1242 ext4_xattr_destroy_cache(sbi->s_ea_inode_cache); 1243 sbi->s_ea_inode_cache = NULL; 1244 1245 ext4_xattr_destroy_cache(sbi->s_ea_block_cache); 1246 sbi->s_ea_block_cache = NULL; 1247 | 1178 aborted = is_journal_aborted(sbi->s_journal); 1179 err = jbd2_journal_destroy(sbi->s_journal); 1180 sbi->s_journal = NULL; 1181 if ((err < 0) && !aborted) { 1182 ext4_abort(sb, -err, "Couldn't clean up the journal"); 1183 } 1184 } 1185 --- 55 unchanged lines hidden (view full) --- 1241 } 1242 1243 ext4_xattr_destroy_cache(sbi->s_ea_inode_cache); 1244 sbi->s_ea_inode_cache = NULL; 1245 1246 ext4_xattr_destroy_cache(sbi->s_ea_block_cache); 1247 sbi->s_ea_block_cache = NULL; 1248 |
1248 if (sbi->s_mmp_tsk) 1249 kthread_stop(sbi->s_mmp_tsk); | 1249 ext4_stop_mmpd(sbi); 1250 |
1250 brelse(sbi->s_sbh); 1251 sb->s_fs_info = NULL; 1252 /* 1253 * Now that we are completely done shutting down the 1254 * superblock, we need to actually destroy the kobject. 1255 */ 1256 kobject_put(&sbi->s_kobj); 1257 wait_for_completion(&sbi->s_kobj_unregister); --- 1838 unchanged lines hidden (view full) --- 3096 ext4_msg(sb, KERN_DEBUG, 3097 "%s: truncating inode %lu to %lld bytes", 3098 __func__, inode->i_ino, inode->i_size); 3099 jbd_debug(2, "truncating inode %lu to %lld bytes\n", 3100 inode->i_ino, inode->i_size); 3101 inode_lock(inode); 3102 truncate_inode_pages(inode->i_mapping, inode->i_size); 3103 ret = ext4_truncate(inode); | 1251 brelse(sbi->s_sbh); 1252 sb->s_fs_info = NULL; 1253 /* 1254 * Now that we are completely done shutting down the 1255 * superblock, we need to actually destroy the kobject. 1256 */ 1257 kobject_put(&sbi->s_kobj); 1258 wait_for_completion(&sbi->s_kobj_unregister); --- 1838 unchanged lines hidden (view full) --- 3097 ext4_msg(sb, KERN_DEBUG, 3098 "%s: truncating inode %lu to %lld bytes", 3099 __func__, inode->i_ino, inode->i_size); 3100 jbd_debug(2, "truncating inode %lu to %lld bytes\n", 3101 inode->i_ino, inode->i_size); 3102 inode_lock(inode); 3103 truncate_inode_pages(inode->i_mapping, inode->i_size); 3104 ret = ext4_truncate(inode); |
3104 if (ret) | 3105 if (ret) { 3106 /* 3107 * We need to clean up the in-core orphan list 3108 * manually if ext4_truncate() failed to get a 3109 * transaction handle. 3110 */ 3111 ext4_orphan_del(NULL, inode); |
3105 ext4_std_error(inode->i_sb, ret); | 3112 ext4_std_error(inode->i_sb, ret); |
3113 } |
|
3106 inode_unlock(inode); 3107 nr_truncates++; 3108 } else { 3109 if (test_opt(sb, DEBUG)) 3110 ext4_msg(sb, KERN_DEBUG, 3111 "%s: deleting unreferenced inode %lu", 3112 __func__, inode->i_ino); 3113 jbd_debug(2, "deleting unreferenced inode %lu\n", --- 1939 unchanged lines hidden (view full) --- 5053 goto failed_mount6; 5054 } 5055 5056 if (ext4_has_feature_flex_bg(sb)) 5057 if (!ext4_fill_flex_info(sb)) { 5058 ext4_msg(sb, KERN_ERR, 5059 "unable to initialize " 5060 "flex_bg meta info!"); | 3114 inode_unlock(inode); 3115 nr_truncates++; 3116 } else { 3117 if (test_opt(sb, DEBUG)) 3118 ext4_msg(sb, KERN_DEBUG, 3119 "%s: deleting unreferenced inode %lu", 3120 __func__, inode->i_ino); 3121 jbd_debug(2, "deleting unreferenced inode %lu\n", --- 1939 unchanged lines hidden (view full) --- 5061 goto failed_mount6; 5062 } 5063 5064 if (ext4_has_feature_flex_bg(sb)) 5065 if (!ext4_fill_flex_info(sb)) { 5066 ext4_msg(sb, KERN_ERR, 5067 "unable to initialize " 5068 "flex_bg meta info!"); |
5069 ret = -ENOMEM; |
|
5061 goto failed_mount6; 5062 } 5063 5064 err = ext4_register_li_request(sb, first_not_zeroed); 5065 if (err) 5066 goto failed_mount6; 5067 5068 err = ext4_register_sysfs(sb); --- 104 unchanged lines hidden (view full) --- 5173failed_mount_wq: 5174 ext4_xattr_destroy_cache(sbi->s_ea_inode_cache); 5175 sbi->s_ea_inode_cache = NULL; 5176 5177 ext4_xattr_destroy_cache(sbi->s_ea_block_cache); 5178 sbi->s_ea_block_cache = NULL; 5179 5180 if (sbi->s_journal) { | 5070 goto failed_mount6; 5071 } 5072 5073 err = ext4_register_li_request(sb, first_not_zeroed); 5074 if (err) 5075 goto failed_mount6; 5076 5077 err = ext4_register_sysfs(sb); --- 104 unchanged lines hidden (view full) --- 5182failed_mount_wq: 5183 ext4_xattr_destroy_cache(sbi->s_ea_inode_cache); 5184 sbi->s_ea_inode_cache = NULL; 5185 5186 ext4_xattr_destroy_cache(sbi->s_ea_block_cache); 5187 sbi->s_ea_block_cache = NULL; 5188 5189 if (sbi->s_journal) { |
5190 jbd2_journal_unregister_shrinker(sbi->s_journal); |
|
5181 jbd2_journal_destroy(sbi->s_journal); 5182 sbi->s_journal = NULL; 5183 } 5184failed_mount3a: 5185 ext4_es_unregister_shrinker(sbi); 5186failed_mount3: 5187 flush_work(&sbi->s_error_work); 5188 del_timer_sync(&sbi->s_err_report); | 5191 jbd2_journal_destroy(sbi->s_journal); 5192 sbi->s_journal = NULL; 5193 } 5194failed_mount3a: 5195 ext4_es_unregister_shrinker(sbi); 5196failed_mount3: 5197 flush_work(&sbi->s_error_work); 5198 del_timer_sync(&sbi->s_err_report); |
5189 if (sbi->s_mmp_tsk) 5190 kthread_stop(sbi->s_mmp_tsk); | 5199 ext4_stop_mmpd(sbi); |
5191failed_mount2: 5192 rcu_read_lock(); 5193 group_desc = rcu_dereference(sbi->s_group_desc); 5194 for (i = 0; i < db_count; i++) 5195 brelse(group_desc[i]); 5196 kvfree(group_desc); 5197 rcu_read_unlock(); 5198failed_mount: --- 300 unchanged lines hidden (view full) --- 5499 if (!really_read_only && journal_devnum && 5500 journal_devnum != le32_to_cpu(es->s_journal_dev)) { 5501 es->s_journal_dev = cpu_to_le32(journal_devnum); 5502 5503 /* Make sure we flush the recovery flag to disk. */ 5504 ext4_commit_super(sb); 5505 } 5506 | 5200failed_mount2: 5201 rcu_read_lock(); 5202 group_desc = rcu_dereference(sbi->s_group_desc); 5203 for (i = 0; i < db_count; i++) 5204 brelse(group_desc[i]); 5205 kvfree(group_desc); 5206 rcu_read_unlock(); 5207failed_mount: --- 300 unchanged lines hidden (view full) --- 5508 if (!really_read_only && journal_devnum && 5509 journal_devnum != le32_to_cpu(es->s_journal_dev)) { 5510 es->s_journal_dev = cpu_to_le32(journal_devnum); 5511 5512 /* Make sure we flush the recovery flag to disk. */ 5513 ext4_commit_super(sb); 5514 } 5515 |
5516 err = jbd2_journal_register_shrinker(journal); 5517 if (err) { 5518 EXT4_SB(sb)->s_journal = NULL; 5519 goto err_out; 5520 } 5521 |
|
5507 return 0; 5508 5509err_out: 5510 jbd2_journal_destroy(journal); 5511 return err; 5512} 5513 5514/* Copy state of EXT4_SB(sb) into buffer for on-disk superblock */ --- 126 unchanged lines hidden (view full) --- 5641 if (journal != NULL) { 5642 ext4_error(sb, "Journal got removed while the fs was " 5643 "mounted!"); 5644 return -EFSCORRUPTED; 5645 } 5646 return 0; 5647 } 5648 jbd2_journal_lock_updates(journal); | 5522 return 0; 5523 5524err_out: 5525 jbd2_journal_destroy(journal); 5526 return err; 5527} 5528 5529/* Copy state of EXT4_SB(sb) into buffer for on-disk superblock */ --- 126 unchanged lines hidden (view full) --- 5656 if (journal != NULL) { 5657 ext4_error(sb, "Journal got removed while the fs was " 5658 "mounted!"); 5659 return -EFSCORRUPTED; 5660 } 5661 return 0; 5662 } 5663 jbd2_journal_lock_updates(journal); |
5649 err = jbd2_journal_flush(journal); | 5664 err = jbd2_journal_flush(journal, 0); |
5650 if (err < 0) 5651 goto out; 5652 5653 if (ext4_has_feature_journal_needs_recovery(sb) && sb_rdonly(sb)) { 5654 ext4_clear_feature_journal_needs_recovery(sb); 5655 ext4_commit_super(sb); 5656 } 5657out: --- 125 unchanged lines hidden (view full) --- 5783 if (journal) { 5784 /* Now we set up the journal barrier. */ 5785 jbd2_journal_lock_updates(journal); 5786 5787 /* 5788 * Don't clear the needs_recovery flag if we failed to 5789 * flush the journal. 5790 */ | 5665 if (err < 0) 5666 goto out; 5667 5668 if (ext4_has_feature_journal_needs_recovery(sb) && sb_rdonly(sb)) { 5669 ext4_clear_feature_journal_needs_recovery(sb); 5670 ext4_commit_super(sb); 5671 } 5672out: --- 125 unchanged lines hidden (view full) --- 5798 if (journal) { 5799 /* Now we set up the journal barrier. */ 5800 jbd2_journal_lock_updates(journal); 5801 5802 /* 5803 * Don't clear the needs_recovery flag if we failed to 5804 * flush the journal. 5805 */ |
5791 error = jbd2_journal_flush(journal); | 5806 error = jbd2_journal_flush(journal, 0); |
5792 if (error < 0) 5793 goto out; 5794 5795 /* Journal blocked and flushed, clear needs_recovery flag. */ 5796 ext4_clear_feature_journal_needs_recovery(sb); 5797 } 5798 5799 error = ext4_commit_super(sb); --- 184 unchanged lines hidden (view full) --- 5984 5985 if (sbi->s_journal) { 5986 /* 5987 * We let remount-ro finish even if marking fs 5988 * as clean failed... 5989 */ 5990 ext4_mark_recovery_complete(sb, es); 5991 } | 5807 if (error < 0) 5808 goto out; 5809 5810 /* Journal blocked and flushed, clear needs_recovery flag. */ 5811 ext4_clear_feature_journal_needs_recovery(sb); 5812 } 5813 5814 error = ext4_commit_super(sb); --- 184 unchanged lines hidden (view full) --- 5999 6000 if (sbi->s_journal) { 6001 /* 6002 * We let remount-ro finish even if marking fs 6003 * as clean failed... 6004 */ 6005 ext4_mark_recovery_complete(sb, es); 6006 } |
5992 if (sbi->s_mmp_tsk) 5993 kthread_stop(sbi->s_mmp_tsk); | 6007 ext4_stop_mmpd(sbi); |
5994 } else { 5995 /* Make sure we can mount this feature set readwrite */ 5996 if (ext4_has_feature_readonly(sb) || 5997 !ext4_feature_set_ok(sb, 0)) { 5998 err = -EROFS; 5999 goto restore_opts; 6000 } 6001 /* --- 376 unchanged lines hidden (view full) --- 6378 */ 6379 if (EXT4_SB(sb)->s_journal && 6380 ext4_should_journal_data(d_inode(path->dentry))) { 6381 /* 6382 * We don't need to lock updates but journal_flush() could 6383 * otherwise be livelocked... 6384 */ 6385 jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); | 6008 } else { 6009 /* Make sure we can mount this feature set readwrite */ 6010 if (ext4_has_feature_readonly(sb) || 6011 !ext4_feature_set_ok(sb, 0)) { 6012 err = -EROFS; 6013 goto restore_opts; 6014 } 6015 /* --- 376 unchanged lines hidden (view full) --- 6392 */ 6393 if (EXT4_SB(sb)->s_journal && 6394 ext4_should_journal_data(d_inode(path->dentry))) { 6395 /* 6396 * We don't need to lock updates but journal_flush() could 6397 * otherwise be livelocked... 6398 */ 6399 jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); |
6386 err = jbd2_journal_flush(EXT4_SB(sb)->s_journal); | 6400 err = jbd2_journal_flush(EXT4_SB(sb)->s_journal, 0); |
6387 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); 6388 if (err) 6389 return err; 6390 } 6391 6392 lockdep_set_quota_inode(path->dentry->d_inode, I_DATA_SEM_QUOTA); 6393 err = dquot_quota_on(sb, type, format_id, path); 6394 if (err) { --- 415 unchanged lines hidden --- | 6401 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); 6402 if (err) 6403 return err; 6404 } 6405 6406 lockdep_set_quota_inode(path->dentry->d_inode, I_DATA_SEM_QUOTA); 6407 err = dquot_quota_on(sb, type, format_id, path); 6408 if (err) { --- 415 unchanged lines hidden --- |