Commit b3980910 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: introduce __f2fs_commit_super

Introduce __f2fs_commit_super to include duplicated codes in
f2fs_commit_super for cleanup.
Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 55d1cdb2
...@@ -1187,14 +1187,13 @@ static int read_raw_super_block(struct super_block *sb, ...@@ -1187,14 +1187,13 @@ static int read_raw_super_block(struct super_block *sb,
return 0; 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 f2fs_super_block *super = F2FS_RAW_SUPER(sbi);
struct buffer_head *bh; struct buffer_head *bh;
int err; int err;
/* write back-up superblock first */ bh = sb_getblk(sbi->sb, block);
bh = sb_getblk(sbi->sb, sbi->valid_super_block ? 0 : 1);
if (!bh) if (!bh)
return -EIO; return -EIO;
...@@ -1208,25 +1207,22 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover) ...@@ -1208,25 +1207,22 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
err = __sync_dirty_buffer(bh, WRITE_FLUSH_FUA); err = __sync_dirty_buffer(bh, WRITE_FLUSH_FUA);
brelse(bh); 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 we are in recovery path, skip writing valid superblock */
if (recover || err) if (recover || err)
return err; return err;
bh = sb_getblk(sbi->sb, sbi->valid_super_block);
if (!bh)
return -EIO;
/* write current valid superblock */ /* write current valid superblock */
lock_buffer(bh); return __f2fs_commit_super(sbi, sbi->valid_super_block);
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);
return err;
} }
static int f2fs_fill_super(struct super_block *sb, void *data, int silent) static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment