aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ext4/super.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 6e4cac646345..1a5729d8f9ec 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -430,6 +430,12 @@ static void ext4_journal_commit_callback(journal_t *journal, transaction_t *txn)
430 spin_unlock(&sbi->s_md_lock); 430 spin_unlock(&sbi->s_md_lock);
431} 431}
432 432
433static bool system_going_down(void)
434{
435 return system_state == SYSTEM_HALT || system_state == SYSTEM_POWER_OFF
436 || system_state == SYSTEM_RESTART;
437}
438
433/* Deal with the reporting of failure conditions on a filesystem such as 439/* Deal with the reporting of failure conditions on a filesystem such as
434 * inconsistencies detected or read IO failures. 440 * inconsistencies detected or read IO failures.
435 * 441 *
@@ -460,7 +466,12 @@ static void ext4_handle_error(struct super_block *sb)
460 if (journal) 466 if (journal)
461 jbd2_journal_abort(journal, -EIO); 467 jbd2_journal_abort(journal, -EIO);
462 } 468 }
463 if (test_opt(sb, ERRORS_RO)) { 469 /*
470 * We force ERRORS_RO behavior when system is rebooting. Otherwise we
471 * could panic during 'reboot -f' as the underlying device got already
472 * disabled.
473 */
474 if (test_opt(sb, ERRORS_RO) || system_going_down()) {
464 ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); 475 ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only");
465 /* 476 /*
466 * Make sure updated value of ->s_mount_flags will be visible 477 * Make sure updated value of ->s_mount_flags will be visible
@@ -468,8 +479,7 @@ static void ext4_handle_error(struct super_block *sb)
468 */ 479 */
469 smp_wmb(); 480 smp_wmb();
470 sb->s_flags |= SB_RDONLY; 481 sb->s_flags |= SB_RDONLY;
471 } 482 } else if (test_opt(sb, ERRORS_PANIC)) {
472 if (test_opt(sb, ERRORS_PANIC)) {
473 if (EXT4_SB(sb)->s_journal && 483 if (EXT4_SB(sb)->s_journal &&
474 !(EXT4_SB(sb)->s_journal->j_flags & JBD2_REC_ERR)) 484 !(EXT4_SB(sb)->s_journal->j_flags & JBD2_REC_ERR))
475 return; 485 return;