Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6b0310fb authored by Eric Sandeen's avatar Eric Sandeen Committed by Theodore Ts'o
Browse files

ext4: don't return to userspace after freezing the fs with a mutex held



ext4_freeze() used jbd2_journal_lock_updates() which takes
the j_barrier mutex, and then returns to userspace.  The
kernel does not like this:

================================================
[ BUG: lock held when returning to user space! ]
------------------------------------------------
lvcreate/1075 is leaving the kernel with locks still held!
1 lock held by lvcreate/1075:
 #0:  (&journal->j_barrier){+.+...}, at: [<ffffffff811c6214>]
jbd2_journal_lock_updates+0xe1/0xf0

Use vfs_check_frozen() added to ext4_journal_start_sb() and
ext4_force_commit() instead.

Addresses-Red-Hat-Bugzilla: #568503

Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent 256a4535
Loading
Loading
Loading
Loading
+10 −10
Original line number Original line Diff line number Diff line
@@ -241,6 +241,7 @@ handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks)
	if (sb->s_flags & MS_RDONLY)
	if (sb->s_flags & MS_RDONLY)
		return ERR_PTR(-EROFS);
		return ERR_PTR(-EROFS);


	vfs_check_frozen(sb, SB_FREEZE_WRITE);
	/* Special case here: if the journal has aborted behind our
	/* Special case here: if the journal has aborted behind our
	 * backs (eg. EIO in the commit thread), then we still need to
	 * backs (eg. EIO in the commit thread), then we still need to
	 * take the FS itself readonly cleanly. */
	 * take the FS itself readonly cleanly. */
@@ -3485,8 +3486,10 @@ int ext4_force_commit(struct super_block *sb)
		return 0;
		return 0;


	journal = EXT4_SB(sb)->s_journal;
	journal = EXT4_SB(sb)->s_journal;
	if (journal)
	if (journal) {
		vfs_check_frozen(sb, SB_FREEZE_WRITE);
		ret = ext4_journal_force_commit(journal);
		ret = ext4_journal_force_commit(journal);
	}


	return ret;
	return ret;
}
}
@@ -3535,18 +3538,16 @@ static int ext4_freeze(struct super_block *sb)
	 * the journal.
	 * the journal.
	 */
	 */
	error = jbd2_journal_flush(journal);
	error = jbd2_journal_flush(journal);
	if (error < 0) {
	if (error < 0)
	out:
		goto out;
		jbd2_journal_unlock_updates(journal);
		return error;
	}


	/* Journal blocked and flushed, clear needs_recovery flag. */
	/* Journal blocked and flushed, clear needs_recovery flag. */
	EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
	EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
	error = ext4_commit_super(sb, 1);
	error = ext4_commit_super(sb, 1);
	if (error)
out:
		goto out;
	/* we rely on s_frozen to stop further updates */
	return 0;
	jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
	return error;
}
}


/*
/*
@@ -3563,7 +3564,6 @@ static int ext4_unfreeze(struct super_block *sb)
	EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
	EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
	ext4_commit_super(sb, 1);
	ext4_commit_super(sb, 1);
	unlock_super(sb);
	unlock_super(sb);
	jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
	return 0;
	return 0;
}
}