• Chao Yu's avatar
    f2fs: fix to release inode correctly · 13ec7297
    Chao Yu authored
    In following call stack, if unfortunately we lose all chances to truncate
    inode page in remove_inode_page, eventually we will add the nid allocated
    previously into free nid cache, this nid is with NID_NEW status and with
    NEW_ADDR in its blkaddr pointer:
    
     - f2fs_create
      - f2fs_add_link
       - __f2fs_add_link
        - init_inode_metadata
         - new_inode_page
          - new_node_page
           - set_node_addr(, NEW_ADDR)
         - f2fs_init_acl   failed
         - remove_inode_page  failed
      - handle_failed_inode
       - remove_inode_page  failed
       - iput
        - f2fs_evict_inode
         - remove_inode_page  failed
         - alloc_nid_failed   cache a nid with valid blkaddr: NEW_ADDR
    
    This may not only cause resource leak of previous inode, but also may cause
    incorrect use of the previous blkaddr which is located in NO.nid node entry
    when this nid is reused by others.
    
    This patch tries to add this inode to orphan list if we fail to truncate
    inode, so that we can obtain a second chance to release it in orphan
    recovery flow.
    Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
    Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
    13ec7297
inode.c 11.5 KB