diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 64e389285f54ee92ea1bb96e863c96c012e6e2d7..15c0006b12f1db995562186300b747d1d5277ca3 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -535,6 +535,17 @@ static int recover_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino) { struct inode *inode; struct node_info ni; + int err = acquire_orphan_inode(sbi); + + if (err) { + set_sbi_flag(sbi, SBI_NEED_FSCK); + f2fs_msg(sbi->sb, KERN_WARNING, + "%s: orphan failed (ino=%x), run fsck to fix.", + __func__, ino); + return err; + } + + __add_ino_entry(sbi, ino, ORPHAN_INO); inode = f2fs_iget_retry(sbi->sb, ino); if (IS_ERR(inode)) { @@ -555,17 +566,13 @@ static int recover_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino) /* ENOMEM was fully retried in f2fs_evict_inode. */ if (ni.blk_addr != NULL_ADDR) { - int err = acquire_orphan_inode(sbi); - - if (err) { - set_sbi_flag(sbi, SBI_NEED_FSCK); - f2fs_msg(sbi->sb, KERN_WARNING, - "%s: orphan failed (ino=%x), run fsck to fix.", - __func__, ino); - return err; - } - __add_ino_entry(sbi, ino, ORPHAN_INO); + set_sbi_flag(sbi, SBI_NEED_FSCK); + f2fs_msg(sbi->sb, KERN_WARNING, + "%s: orphan failed (ino=%x), run fsck to fix.", + __func__, ino); + return -EIO; } + __remove_ino_entry(sbi, ino, ORPHAN_INO); return 0; } diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 95986a9aa615da6d0c1c7057a8410b23afa887f0..e7bb153f81045023c60c0e59783b8a3058f9c004 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1893,6 +1893,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) sb->s_root = NULL; free_node_inode: mutex_lock(&sbi->umount_mutex); + release_ino_entry(sbi, true); f2fs_leave_shrinker(sbi); iput(sbi->node_inode); mutex_unlock(&sbi->umount_mutex);