]> granicus.if.org Git - zfs/commit
deadlock between mm_sem and tx assign in zfs_write() and page fault
authorilbsmart <wgqimut@gmail.com>
Tue, 16 Oct 2018 18:11:24 +0000 (02:11 +0800)
committerTony Hutter <hutter2@llnl.gov>
Fri, 22 Feb 2019 17:47:34 +0000 (09:47 -0800)
commit98bb45e27ae80145a6ce028df90fccdb23f8901d
treeb31587f2fa3d09b09dad7227f81a04ab2c6c73b7
parent44f463824bc78df2d23dd049c3ef57ddaf464feb
deadlock between mm_sem and tx assign in zfs_write() and page fault

The bug time sequence:
1. thread #1, `zfs_write` assign a txg "n".
2. In a same process, thread #2, mmap page fault (which means the
   `mm_sem` is hold) occurred, `zfs_dirty_inode` open a txg failed,
   and wait previous txg "n" completed.
3. thread #1 call `uiomove` to write, however page fault is occurred
   in `uiomove`, which means it need `mm_sem`, but `mm_sem` is hold by
   thread #2, so it stuck and can't complete,  then txg "n" will
   not complete.

So thread #1 and thread #2 are deadlocked.

Reviewed-by: Chunwei Chen <tuxoko@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Signed-off-by: Grady Wong <grady.w@xtaotech.com>
Closes #7939
include/sys/uio_impl.h
module/zcommon/zfs_uio.c
module/zfs/zfs_vnops.c
tests/zfs-tests/cmd/mmapwrite/mmapwrite.c
tests/zfs-tests/tests/functional/mmap/mmap_write_001_pos.ksh