/*
* super.c
*/
-int f2fs_commit_super(struct f2fs_sb_info *);
+int f2fs_commit_super(struct f2fs_sb_info *, bool);
int f2fs_sync_fs(struct super_block *, int);
extern __printf(3, 4)
void f2fs_msg(struct super_block *, const char *, const char *, ...);
/* update superblock with uuid */
generate_random_uuid(sbi->raw_super->encrypt_pw_salt);
- err = f2fs_commit_super(sbi);
+ err = f2fs_commit_super(sbi, false);
mnt_drop_write_file(filp);
if (err) {
return 0;
}
-int f2fs_commit_super(struct f2fs_sb_info *sbi)
+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;
err = sync_dirty_buffer(sbh);
sbh->b_blocknr = block;
- if (err)
+
+ /* if we are in recovery path, skip writing valid superblock */
+ if (recover || err)
goto out;
/* write current valid superblock */
/* recover broken superblock */
if (recovery && !f2fs_readonly(sb) && !bdev_read_only(sb->s_bdev)) {
f2fs_msg(sb, KERN_INFO, "Recover invalid superblock");
- f2fs_commit_super(sbi);
+ f2fs_commit_super(sbi, true);
}
return 0;