public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Yongqiang Yang <xiaoqiangnk@gmail.com>
To: jack@suse.cz
Cc: linux-ext4@vger.kernel.org, Yongqiang Yang <xiaoqiangnk@gmail.com>
Subject: [RESEND PATCH 2/2] ext3: flush journal only when journal mode is changed from journaled
Date: Tue, 15 Nov 2011 16:04:49 +0800	[thread overview]
Message-ID: <1321344289-13125-1-git-send-email-xiaoqiangnk@gmail.com> (raw)

To prevent data from corruption during repaly, we need to flush journal
before changing journal mode from journaled.  However flushing journal is
not needed when changing journal to journaled.

Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
---
 fs/ext3/inode.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 04da6ac..5577358 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -3546,7 +3546,6 @@ int ext3_change_inode_journal_flag(struct inode *inode, int val)
 		return -EROFS;
 
 	journal_lock_updates(journal);
-	journal_flush(journal);
 
 	/*
 	 * OK, there are no updates running now, and all cached data is
@@ -3556,10 +3555,12 @@ int ext3_change_inode_journal_flag(struct inode *inode, int val)
 	 * the inode's in-core data-journaling state flag now.
 	 */
 
-	if (val)
+	if (val) {
 		EXT3_I(inode)->i_flags |= EXT3_JOURNAL_DATA_FL;
-	else
+	} else {
+		journal_flush(journal);
 		EXT3_I(inode)->i_flags &= ~EXT3_JOURNAL_DATA_FL;
+	}
 	ext3_set_aops(inode);
 
 	journal_unlock_updates(journal);
-- 
1.7.5.1


             reply	other threads:[~2011-11-15 10:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-15  8:04 Yongqiang Yang [this message]
2011-11-15 13:33 ` [RESEND PATCH 2/2] ext3: flush journal only when journal mode is changed from journaled Jan Kara
2011-11-15 13:57   ` Yongqiang Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1321344289-13125-1-git-send-email-xiaoqiangnk@gmail.com \
    --to=xiaoqiangnk@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox