]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
f2fs: fix lock dependency in between dio_rwsem & i_mmap_sem
authorChao Yu <yuchao0@huawei.com>
Thu, 23 Nov 2017 15:26:52 +0000 (23:26 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Apr 2018 10:31:04 +0000 (12:31 +0200)
commite0870e5401eee3d7aa29506385b30f9e07edb8c3
tree2272e45dc594f632f7970becff345f6639c44168
parentbde6301dbf14b99c673db7d33431b5718eaf1623
f2fs: fix lock dependency in between dio_rwsem & i_mmap_sem

[ Upstream commit 21020812c9e1ab593367fad9ce579f842a0b406d ]

test/generic/208 reports a potential deadlock as below:

Chain exists of:
  &mm->mmap_sem --> &fi->i_mmap_sem --> &fi->dio_rwsem[WRITE]

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&fi->dio_rwsem[WRITE]);
                               lock(&fi->i_mmap_sem);
                               lock(&fi->dio_rwsem[WRITE]);
  lock(&mm->mmap_sem);

This patch changes the lock dependency as below in fallocate() to
fix this issue:
- dio_rwsem
 - i_mmap_sem

Fixes: bb06664a534b ("f2fs: avoid race in between GC and block exchange")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/f2fs/file.c