From: Chao Yu <chao2.yu@samsung.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] f2fs: introduce __f2fs_commit_super
Date: Tue, 15 Dec 2015 17:20:50 +0800 [thread overview]
Message-ID: <010601d13719$fb952260$f2bf6720$@samsung.com> (raw)
Introduce __f2fs_commit_super to include duplicated codes in
f2fs_commit_super for cleanup.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
fs/f2fs/super.c | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 2d4fed8..56a160a 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1201,14 +1201,13 @@ next:
return 0;
}
-int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
+int __f2fs_commit_super(struct f2fs_sb_info *sbi, int block)
{
struct f2fs_super_block *super = F2FS_RAW_SUPER(sbi);
struct buffer_head *bh;
int err;
- /* write back-up superblock first */
- bh = sb_getblk(sbi->sb, sbi->valid_super_block ? 0 : 1);
+ bh = sb_getblk(sbi->sb, block);
if (!bh)
return -EIO;
@@ -1222,23 +1221,22 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
err = __sync_dirty_buffer(bh, WRITE_FLUSH_FUA);
brelse(bh);
+ return err;
+}
+
+int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
+{
+ int err;
+
+ /* write back-up superblock first */
+ err = __f2fs_commit_super(sbi, sbi->valid_super_block ? 0 : 1);
+
/* if we are in recovery path, skip writing valid superblock */
if (recover || err)
return err;
- bh = sb_getblk(sbi->sb, sbi->valid_super_block);
- if (!bh)
- return -EIO;
-
/* write current valid superblock */
- lock_buffer(bh);
- memcpy(bh->b_data + F2FS_SUPER_OFFSET, super, sizeof(*super));
- set_buffer_uptodate(bh);
- set_buffer_dirty(bh);
- unlock_buffer(bh);
-
- err = __sync_dirty_buffer(bh, WRITE_FLUSH_FUA);
- brelse(bh);
+ err = __f2fs_commit_super(sbi, sbi->valid_super_block);
return err;
}
--
2.6.3
next reply other threads:[~2015-12-15 9:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-15 9:20 Chao Yu [this message]
2015-12-15 22:19 ` [PATCH 3/3] f2fs: introduce __f2fs_commit_super Jaegeuk Kim
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='010601d13719$fb952260$f2bf6720$@samsung.com' \
--to=chao2.yu@samsung.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--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