]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
f2fs: handle error in recover_orphan_inode
authorJaegeuk Kim <jaegeuk@kernel.org>
Mon, 12 Sep 2016 22:08:37 +0000 (15:08 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 15 Sep 2016 20:50:24 +0000 (13:50 -0700)
This patch enhances the error path in recover_orphan_inode.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/checkpoint.c

index b80dd379b3beecda8302e191ae66edeb28d116eb..df56a43f982ea69890a4d1ba47a4b0b4e5ea6b01 100644 (file)
@@ -531,8 +531,9 @@ void remove_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
 static int recover_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
 {
        struct inode *inode;
+       struct node_info ni;
 
-       inode = f2fs_iget(sbi->sb, ino);
+       inode = f2fs_iget_retry(sbi->sb, ino);
        if (IS_ERR(inode)) {
                /*
                 * there should be a bug that we can't find the entry
@@ -546,6 +547,22 @@ static int recover_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
 
        /* truncate all the data during iput */
        iput(inode);
+
+       get_node_info(sbi, ino, &ni);
+
+       /* 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);
+       }
        return 0;
 }