From 0506e1bd6a6d5fafe7fc5e558aa1b75e456c2642 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Wed, 28 Mar 2018 09:03:22 +0800 Subject: [PATCH] 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 Signed-off-by: Bob Glossman Reviewed-on: https://review.whamcloud.com/31806 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Dmitry Eremin --- .../ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch | 13 +++++++++++++ ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series | 1 + ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series | 1 + ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series | 1 + ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp2.series | 1 + ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp3.series | 1 + .../series/ldiskfs-4.4.0-45-ubuntu14+16.series | 1 + .../series/ldiskfs-4.4.0-49-ubuntu14+16.series | 1 + .../series/ldiskfs-4.4.0-62-ubuntu14+16.series | 1 + .../series/ldiskfs-4.4.0-73-ubuntu14+16.series | 1 + 10 files changed, 22 insertions(+) create mode 100644 ldiskfs/kernel_patches/patches/rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch new file mode 100644 index 0000000..5abe23e --- /dev/null +++ b/ldiskfs/kernel_patches/patches/rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch @@ -0,0 +1,13 @@ +diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c +index 153dda7..63339a2 100644 +--- a/fs/ext4/inode.c ++++ b/fs/ext4/inode.c +@@ -3775,7 +3775,7 @@ int ext4_inode_attach_jinode(struct inode *inode) + if (ei->jinode || !EXT4_SB(inode->i_sb)->s_journal) + return 0; + +- jinode = jbd2_alloc_inode(GFP_KERNEL); ++ jinode = jbd2_alloc_inode(GFP_NOFS); + spin_lock(&inode->i_lock); + if (!ei->jinode) { + if (!jinode) { diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series index aa1627d..cee90e2 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series @@ -33,3 +33,4 @@ rhel7/ext4-fix-xattr-shifting-when-expanding-inodes.patch rhel7/ext4-cleanup-goto-next-group.patch rhel7/ext4-reduce-lock-contention-in-__ext4_new_inode.patch rhel7.2/ext4-preread-gd.patch +rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series index 6f7a0db..4e1e863 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series @@ -33,3 +33,4 @@ rhel7.2/ext4-dont-check-before-replay.patch rhel7/ext4-cleanup-goto-next-group.patch rhel7/ext4-reduce-lock-contention-in-__ext4_new_inode.patch rhel7.2/ext4-preread-gd.patch +rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series index d9f7d95..e845452 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series @@ -33,3 +33,4 @@ rhel7.4/ext4-dont-check-before-replay.patch rhel7/ext4-cleanup-goto-next-group.patch rhel7/ext4-reduce-lock-contention-in-__ext4_new_inode.patch rhel7.2/ext4-preread-gd.patch +rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp2.series b/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp2.series index 5261894..2c5fc63 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp2.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp2.series @@ -24,3 +24,4 @@ sles12sp2/ext4-attach-jinode-in-writepages.patch sles12sp2/ext4-dont-check-before-replay.patch rhel7.2/ext4-dont-check-in-ro.patch sles12sp2/ext4-fix-xattr-shifting-when-expanding-inodes.patch +rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp3.series b/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp3.series index 31308c1..1bbca1a 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp3.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp3.series @@ -24,3 +24,4 @@ sles12sp2/ext4-attach-jinode-in-writepages.patch sles12sp2/ext4-dont-check-before-replay.patch rhel7.2/ext4-dont-check-in-ro.patch sles12sp2/ext4-fix-xattr-shifting-when-expanding-inodes.patch +rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-45-ubuntu14+16.series b/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-45-ubuntu14+16.series index 5f65bd6..8b416d3 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-45-ubuntu14+16.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-45-ubuntu14+16.series @@ -21,3 +21,4 @@ sles12sp2/ext4-give-warning-with-dir-htree-growing.patch sles12sp2/ext4-mmp-brelse.patch rhel7/ext4-jcb-optimization.patch sles12sp2/ext4-attach-jinode-in-writepages.patch +rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-49-ubuntu14+16.series b/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-49-ubuntu14+16.series index cad26ef..6d9f4e0 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-49-ubuntu14+16.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-49-ubuntu14+16.series @@ -21,3 +21,4 @@ sles12sp2/ext4-give-warning-with-dir-htree-growing.patch sles12sp2/ext4-mmp-brelse.patch rhel7/ext4-jcb-optimization.patch sles12sp2/ext4-attach-jinode-in-writepages.patch +rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-62-ubuntu14+16.series b/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-62-ubuntu14+16.series index 8a99b95..7151e9a 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-62-ubuntu14+16.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-62-ubuntu14+16.series @@ -21,3 +21,4 @@ sles12sp2/ext4-give-warning-with-dir-htree-growing.patch sles12sp2/ext4-mmp-brelse.patch rhel7/ext4-jcb-optimization.patch sles12sp2/ext4-attach-jinode-in-writepages.patch +rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-73-ubuntu14+16.series b/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-73-ubuntu14+16.series index 294419e..88ebda5 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-73-ubuntu14+16.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-73-ubuntu14+16.series @@ -21,3 +21,4 @@ sles12sp2/ext4-give-warning-with-dir-htree-growing.patch sles12sp2/ext4-mmp-brelse.patch rhel7/ext4-jcb-optimization.patch sles12sp2/ext4-attach-jinode-in-writepages.patch +rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -- 1.8.3.1