/* LVM calls this function before a (read-only) snapshot is created. This gives us a chance to flush the journal completely and mark the fs clean.  */
static int ext4_freeze(struct super_block *sb)
/* LVM calls this function before a (read-only) snapshot is created. This gives us a chance to flush the journal completely and mark the fs clean.  */
static int ext4_freeze(struct super_block *sb)
{
	int error = 0;
	journal_t *journal;
	if (sb->s_flags & MS_RDONLY)
		return 0;
	journal = EXT4_SB(sb)->s_journal;
	jbd2_journal_lock_updates(journal);
	error = jbd2_journal_flush(journal);
	if (error < 0) {
	out:
		jbd2_journal_unlock_updates(journal);
		return error;
	}
	EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
	error = ext4_commit_super(sb, 1);
	if (error)
		goto out;
	return 0;
}