]> git.baikalelectronics.ru Git - kernel.git/commit
f2fs: fix to release inode correctly
authorChao Yu <chao2.yu@samsung.com>
Mon, 24 Aug 2015 09:40:45 +0000 (17:40 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 24 Aug 2015 23:35:59 +0000 (16:35 -0700)
commitb3a944d5944b1e8b2612d1df60f837eae226ec9c
tree64c4092d02d04f7705a69e49174a0b1742ca34a1
parent274343d1d7a7fd754f8369f1fec46dee1f3c9e19
f2fs: fix to release inode correctly

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: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/inode.c
fs/f2fs/node.c