summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2015-12-16 13:19:35 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2015-12-16 08:58:07 -0800
commitb3980910f746d885111db7252f664600de2a5ea3 (patch)
treedba6cc120ad1d3f970affc661e584cf4ce9d2688 /fs
parent55d1cdb25a815ba92a917ae579c27cc3ffb9a57d (diff)
downloadop-kernel-dev-b3980910f746d885111db7252f664600de2a5ea3.zip
op-kernel-dev-b3980910f746d885111db7252f664600de2a5ea3.tar.gz
f2fs: introduce __f2fs_commit_super
Introduce __f2fs_commit_super to include duplicated codes in f2fs_commit_super for cleanup. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/f2fs/super.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 8c8b467..bc1a8cd 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1187,14 +1187,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;
@@ -1208,25 +1207,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);
-
- return err;
+ return __f2fs_commit_super(sbi, sbi->valid_super_block);
}
static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
OpenPOWER on IntegriCloud