f2fs: fix double lock in handle_failed_inode
authorChao Yu <chao2.yu@samsung.com>
Thu, 16 Jul 2015 10:19:02 +0000 (18:19 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 5 Aug 2015 15:08:09 +0000 (08:08 -0700)
commit55f57d2c4259a9a4048cf4629a2c6ba53729188d
tree00308a663bd758c81f7c9bcc90d66b8dc7f52f0d
parentecbaa4068f88f96a8ffde37d532e618508394b53
f2fs: fix double lock in handle_failed_inode

In handle_failed_inode, there is a potential deadlock which can happen
in below call path:

- f2fs_create
 - f2fs_lock_op   down_read(cp_rwsem)
 - f2fs_add_link
  - __f2fs_add_link
   - init_inode_metadata
    - f2fs_init_security    failed
    - truncate_blocks    failed
 - handle_failed_inode
  - f2fs_truncate
   - truncate_blocks(..,true)
- write_checkpoint
 - block_operations
  - f2fs_lock_all  down_write(cp_rwsem)
    - f2fs_lock_op   down_read(cp_rwsem)

So in this path, we pass parameter to f2fs_truncate to make sure
cp_rwsem in truncate_blocks will not be locked again.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/inode.c
fs/f2fs/super.c