Commit 680c105f authored by Jaegeuk Kim's avatar Jaegeuk Kim Committed by Stefan Bader

f2fs: give -EINVAL for norecovery and rw mount

BugLink: https://bugs.launchpad.net/bugs/1818797

commit 6781eabb upstream.

Once detecting something to recover, f2fs should stop mounting, given norecovery
and rw mount options.
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent e8607399
...@@ -1867,7 +1867,7 @@ void build_gc_manager(struct f2fs_sb_info *); ...@@ -1867,7 +1867,7 @@ void build_gc_manager(struct f2fs_sb_info *);
/* /*
* recovery.c * recovery.c
*/ */
int recover_fsync_data(struct f2fs_sb_info *); int recover_fsync_data(struct f2fs_sb_info *, bool);
bool space_for_roll_forward(struct f2fs_sb_info *); bool space_for_roll_forward(struct f2fs_sb_info *);
/* /*
......
...@@ -524,12 +524,13 @@ static int recover_data(struct f2fs_sb_info *sbi, struct list_head *head) ...@@ -524,12 +524,13 @@ static int recover_data(struct f2fs_sb_info *sbi, struct list_head *head)
return err; return err;
} }
int recover_fsync_data(struct f2fs_sb_info *sbi) int recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
{ {
struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_WARM_NODE); struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_WARM_NODE);
struct list_head inode_list; struct list_head inode_list;
block_t blkaddr; block_t blkaddr;
int err; int err;
int ret = 0;
bool need_writecp = false; bool need_writecp = false;
fsync_entry_slab = f2fs_kmem_cache_create("f2fs_fsync_inode_entry", fsync_entry_slab = f2fs_kmem_cache_create("f2fs_fsync_inode_entry",
...@@ -546,11 +547,13 @@ int recover_fsync_data(struct f2fs_sb_info *sbi) ...@@ -546,11 +547,13 @@ int recover_fsync_data(struct f2fs_sb_info *sbi)
/* step #1: find fsynced inode numbers */ /* step #1: find fsynced inode numbers */
err = find_fsync_dnodes(sbi, &inode_list); err = find_fsync_dnodes(sbi, &inode_list);
if (err) if (err || list_empty(&inode_list))
goto out; goto out;
if (list_empty(&inode_list)) if (check_only) {
ret = 1;
goto out; goto out;
}
need_writecp = true; need_writecp = true;
...@@ -598,5 +601,5 @@ int recover_fsync_data(struct f2fs_sb_info *sbi) ...@@ -598,5 +601,5 @@ int recover_fsync_data(struct f2fs_sb_info *sbi)
} else { } else {
mutex_unlock(&sbi->cp_mutex); mutex_unlock(&sbi->cp_mutex);
} }
return err; return ret ? ret: err;
} }
...@@ -1457,14 +1457,24 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1457,14 +1457,24 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
if (need_fsck) if (need_fsck)
set_sbi_flag(sbi, SBI_NEED_FSCK); set_sbi_flag(sbi, SBI_NEED_FSCK);
err = recover_fsync_data(sbi); err = recover_fsync_data(sbi, false);
if (err) { if (err < 0) {
need_fsck = true; need_fsck = true;
f2fs_msg(sb, KERN_ERR, f2fs_msg(sb, KERN_ERR,
"Cannot recover all fsync data errno=%ld", err); "Cannot recover all fsync data errno=%ld", err);
goto free_kobj; goto free_kobj;
} }
} else {
err = recover_fsync_data(sbi, true);
if (!f2fs_readonly(sb) && err > 0) {
err = -EINVAL;
f2fs_msg(sb, KERN_ERR,
"Need to recover fsync data");
goto free_kobj;
}
} }
/* recover_fsync_data() cleared this already */ /* recover_fsync_data() cleared this already */
clear_sbi_flag(sbi, SBI_POR_DOING); clear_sbi_flag(sbi, SBI_POR_DOING);
......
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