linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH 2/3] f2fs: refactor f2fs_commit_super
Date: Mon,  7 Dec 2015 14:53:24 -0800	[thread overview]
Message-ID: <1449528805-89661-2-git-send-email-jaegeuk@kernel.org> (raw)
In-Reply-To: <1449528805-89661-1-git-send-email-jaegeuk@kernel.org>

Previously, f2fs_commit_super hacks the bh->blocknr to write the broken
alternate superblock.
Instead of it, we should use the correct logic to retrieve its buffer head
with locking it appropriately.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/super.c | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index bd7e9c6..dbf16ad 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1099,27 +1099,35 @@ out:
 int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
 {
 	struct buffer_head *sbh = sbi->raw_super_buf;
-	sector_t block = sbh->b_blocknr;
+	struct buffer_head *bh;
 	int err;
 
 	/* write back-up superblock first */
-	sbh->b_blocknr = block ? 0 : 1;
-	mark_buffer_dirty(sbh);
-	err = sync_dirty_buffer(sbh);
+	bh = sb_getblk(sbi->sb, sbh->b_blocknr ? 0 : 1);
+	if (!bh)
+		return -EIO;
 
-	sbh->b_blocknr = block;
+	lock_buffer(bh);
+	memcpy(bh->b_data, sbh->b_data, sbh->b_size);
+	WARN_ON(sbh->b_size != F2FS_BLKSIZE);
+	set_buffer_uptodate(bh);
+	set_buffer_dirty(bh);
+	unlock_buffer(bh);
+
+	/* it's rare case, we can do fua all the time */
+	err = __sync_dirty_buffer(bh, WRITE_FLUSH_FUA);
+	brelse(bh);
 
 	/* if we are in recovery path, skip writing valid superblock */
 	if (recover || err)
-		goto out;
+		return err;
 
 	/* write current valid superblock */
-	mark_buffer_dirty(sbh);
-	err = sync_dirty_buffer(sbh);
-out:
-	clear_buffer_write_io_error(sbh);
-	set_buffer_uptodate(sbh);
-	return err;
+	lock_buffer(sbh);
+	set_buffer_dirty(sbh);
+	unlock_buffer(sbh);
+
+	return __sync_dirty_buffer(sbh, WRITE_FLUSH_FUA);
 }
 
 static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
-- 
2.4.9 (Apple Git-60)


------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140

  reply	other threads:[~2015-12-07 22:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-07 22:53 [PATCH 1/3] f2fs: enhance the bit operation for SSR Jaegeuk Kim
2015-12-07 22:53 ` Jaegeuk Kim [this message]
2015-12-09  6:08   ` [f2fs-dev] [PATCH 2/3] f2fs: refactor f2fs_commit_super Chao Yu
2015-12-07 22:53 ` [PATCH 3/3] f2fs: use lock_buffer when changing superblock Jaegeuk Kim
2015-12-09  6:10   ` [f2fs-dev] " Chao Yu
2015-12-09 17:54     ` [PATCH 3/3 v2] " Jaegeuk Kim
2015-12-09  6:06 ` [PATCH 1/3] f2fs: enhance the bit operation for SSR Chao Yu

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=1449528805-89661-2-git-send-email-jaegeuk@kernel.org \
    --to=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).