Skip to content

Commit bb04457

Browse files
committed
ext4: support freezing ext2 (nojournal) file systems
Through an oversight, when we added nojournal support to ext4, we didn't add support to allow file system freezing. This is relatively easy to add, so let's do it. Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reported-by: Dexuan Cui <decui@microsoft.com>
1 parent bda3253 commit bb04457

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

‎fs/ext4/super.c‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,8 @@ static const struct super_operations ext4_nojournal_sops = {
11311131
.drop_inode = ext4_drop_inode,
11321132
.evict_inode = ext4_evict_inode,
11331133
.sync_fs = ext4_sync_fs,
1134+
.freeze_fs = ext4_freeze,
1135+
.unfreeze_fs = ext4_unfreeze,
11341136
.put_super = ext4_put_super,
11351137
.statfs = ext4_statfs,
11361138
.remount_fs = ext4_remount,
@@ -4758,23 +4760,26 @@ static int ext4_freeze(struct super_block *sb)
47584760

47594761
journal = EXT4_SB(sb)->s_journal;
47604762

4761-
/* Now we set up the journal barrier. */
4762-
jbd2_journal_lock_updates(journal);
4763+
if (journal) {
4764+
/* Now we set up the journal barrier. */
4765+
jbd2_journal_lock_updates(journal);
47634766

4764-
/*
4765-
* Don't clear the needs_recovery flag if we failed to flush
4766-
* the journal.
4767-
*/
4768-
error = jbd2_journal_flush(journal);
4769-
if (error < 0)
4770-
goto out;
4767+
/*
4768+
* Don't clear the needs_recovery flag if we failed to
4769+
* flush the journal.
4770+
*/
4771+
error = jbd2_journal_flush(journal);
4772+
if (error < 0)
4773+
goto out;
4774+
}
47714775

47724776
/* Journal blocked and flushed, clear needs_recovery flag. */
47734777
EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
47744778
error = ext4_commit_super(sb, 1);
47754779
out:
4776-
/* we rely on upper layer to stop further updates */
4777-
jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
4780+
if (journal)
4781+
/* we rely on upper layer to stop further updates */
4782+
jbd2_journal_unlock_updates(journal);
47784783
return error;
47794784
}
47804785

0 commit comments

Comments
 (0)