Whamcloud - gitweb
LU-10859 ldiskfs: fix deadlock with heavy memory preassure 06/31806/3
authorWang Shilong <wshilong@ddn.com>
Wed, 28 Mar 2018 01:03:22 +0000 (09:03 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 9 Apr 2018 19:51:34 +0000 (19:51 +0000)
commit0506e1bd6a6d5fafe7fc5e558aa1b75e456c2642
tree671bbb5825f6114fd64679898a75ef8b3d171af1
parentc2b788e7bfc387739a5f2e661920f0140cbc9eee
LU-10859 ldiskfs: fix deadlock with heavy memory preassure

On one Customer site, we hit following deadlock:

Thread 1:
ofd_object_punch
 osd_punch
  ldiskfs_truncate
   ldiskfs_inode_attach_jinode
     ...
     do_try_to_free_pages
      lu_cache_shrink
       mutex_lock -->try to hold @lu_sites_guard

kswapd thread2:
kthread
 shrink_slab
  lu_cache_shrink
    mutex_lock ---->hold already.
     ...
     dqget
      ldiskfs_acquire_dquot
       jbd2__journal_start-->blocked to wait for more credits.

Thread3:
kthread
 kjournald2
  jbd2_journal_commit_transaction-->blocked to wait Thread2 finished,
 since Thread1 add a handle into transaction.

So deadlock happens because of Thread1 wait Thread2, Thread2 wait Thread3..
but Thread3 wait Thread1....

This problem still exists even we have switched @lu_sites_guard
into a read/write lock, sine we hold write lock at lu_cahce_shrink().

Fixed the problem by making ldiskfs_inode_attach_jinode() use
GFP_NOFS.

Test-Parameters: testgroup=review-ldiskfs \
mdtfilesystemtype=ldiskfs ostfilesystemtype=ldiskfs

Change-Id: I0ab143fc0cdb8e1b0c490c2c25e8af483c491a81
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Signed-off-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-on: https://review.whamcloud.com/31806
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
ldiskfs/kernel_patches/patches/rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch [new file with mode: 0644]
ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series
ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series
ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series
ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp2.series
ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp3.series
ldiskfs/kernel_patches/series/ldiskfs-4.4.0-45-ubuntu14+16.series
ldiskfs/kernel_patches/series/ldiskfs-4.4.0-49-ubuntu14+16.series
ldiskfs/kernel_patches/series/ldiskfs-4.4.0-62-ubuntu14+16.series
ldiskfs/kernel_patches/series/ldiskfs-4.4.0-73-ubuntu14+16.series