diff mbox

[2/3] ext4: support freezing ext2 (nojournal) file systems

Message ID 1411071989-4974-2-git-send-email-tytso@mit.edu
State Accepted, archived
Headers show

Commit Message

Theodore Ts'o Sept. 18, 2014, 8:26 p.m. UTC
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>
---
 fs/ext4/super.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

Comments

Andreas Dilger Sept. 18, 2014, 8:46 p.m. UTC | #1
On Sep 18, 2014, at 2:26 PM, Theodore Ts'o <tytso@mit.edu> wrote:
> 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>
> ---
> fs/ext4/super.c | 27 ++++++++++++++++-----------
> 1 file changed, 16 insertions(+), 11 deletions(-)
> 
> @@ -4758,23 +4760,26 @@ static int ext4_freeze(struct super_block *sb)
> 
> 	journal = EXT4_SB(sb)->s_journal;
[snip]
> 	/* Journal blocked and flushed, clear needs_recovery flag. */
> 	EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
> 	error = ext4_commit_super(sb, 1);
> out:
> -	/* we rely on upper layer to stop further updates */
> -	jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
> +	if (journal)
> +		/* we rely on upper layer to stop further updates */
> +		jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);

This could use "journal" directly instead of "EXT4_SB(sb)->s_journal"

Cheers, Andreas
Theodore Ts'o Sept. 18, 2014, 9:13 p.m. UTC | #2
On Thu, Sep 18, 2014 at 02:46:34PM -0600, Andreas Dilger wrote:
> > +	if (journal)
> > +		/* we rely on upper layer to stop further updates */
> > +		jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
> 
> This could use "journal" directly instead of "EXT4_SB(sb)->s_journal"

Good point, done.

				- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jan Kara Sept. 23, 2014, 12:33 p.m. UTC | #3
On Thu 18-09-14 16:26:28, Ted Tso wrote:
> 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>
  Looks good. You can add:
Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ext4/super.c | 27 ++++++++++++++++-----------
>  1 file changed, 16 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 4770c98..921d5b4 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -1131,6 +1131,8 @@ static const struct super_operations ext4_nojournal_sops = {
>  	.drop_inode	= ext4_drop_inode,
>  	.evict_inode	= ext4_evict_inode,
>  	.sync_fs	= ext4_sync_fs,
> +	.freeze_fs	= ext4_freeze,
> +	.unfreeze_fs	= ext4_unfreeze,
>  	.put_super	= ext4_put_super,
>  	.statfs		= ext4_statfs,
>  	.remount_fs	= ext4_remount,
> @@ -4758,23 +4760,26 @@ static int ext4_freeze(struct super_block *sb)
>  
>  	journal = EXT4_SB(sb)->s_journal;
>  
> -	/* Now we set up the journal barrier. */
> -	jbd2_journal_lock_updates(journal);
> +	if (journal) {
> +		/* Now we set up the journal barrier. */
> +		jbd2_journal_lock_updates(journal);
>  
> -	/*
> -	 * Don't clear the needs_recovery flag if we failed to flush
> -	 * the journal.
> -	 */
> -	error = jbd2_journal_flush(journal);
> -	if (error < 0)
> -		goto out;
> +		/*
> +		 * Don't clear the needs_recovery flag if we failed to
> +		 * flush the journal.
> +		 */
> +		error = jbd2_journal_flush(journal);
> +		if (error < 0)
> +			goto out;
> +	}
>  
>  	/* Journal blocked and flushed, clear needs_recovery flag. */
>  	EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
>  	error = ext4_commit_super(sb, 1);
>  out:
> -	/* we rely on upper layer to stop further updates */
> -	jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
> +	if (journal)
> +		/* we rely on upper layer to stop further updates */
> +		jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
>  	return error;
>  }
>  
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 4770c98..921d5b4 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1131,6 +1131,8 @@  static const struct super_operations ext4_nojournal_sops = {
 	.drop_inode	= ext4_drop_inode,
 	.evict_inode	= ext4_evict_inode,
 	.sync_fs	= ext4_sync_fs,
+	.freeze_fs	= ext4_freeze,
+	.unfreeze_fs	= ext4_unfreeze,
 	.put_super	= ext4_put_super,
 	.statfs		= ext4_statfs,
 	.remount_fs	= ext4_remount,
@@ -4758,23 +4760,26 @@  static int ext4_freeze(struct super_block *sb)
 
 	journal = EXT4_SB(sb)->s_journal;
 
-	/* Now we set up the journal barrier. */
-	jbd2_journal_lock_updates(journal);
+	if (journal) {
+		/* Now we set up the journal barrier. */
+		jbd2_journal_lock_updates(journal);
 
-	/*
-	 * Don't clear the needs_recovery flag if we failed to flush
-	 * the journal.
-	 */
-	error = jbd2_journal_flush(journal);
-	if (error < 0)
-		goto out;
+		/*
+		 * Don't clear the needs_recovery flag if we failed to
+		 * flush the journal.
+		 */
+		error = jbd2_journal_flush(journal);
+		if (error < 0)
+			goto out;
+	}
 
 	/* Journal blocked and flushed, clear needs_recovery flag. */
 	EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
 	error = ext4_commit_super(sb, 1);
 out:
-	/* we rely on upper layer to stop further updates */
-	jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
+	if (journal)
+		/* we rely on upper layer to stop further updates */
+		jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
 	return error;
 }