diff -Nru zfs-linux-0.7.5/debian/changelog zfs-linux-0.7.5/debian/changelog --- zfs-linux-0.7.5/debian/changelog 2020-08-18 09:10:41.000000000 +0000 +++ zfs-linux-0.7.5/debian/changelog 2021-02-25 17:20:20.000000000 +0000 @@ -1,3 +1,11 @@ +zfs-linux (0.7.5-1ubuntu16.11) bionic; urgency=medium + + * Fix race condition in zfs_iput_async (LP: #1916486) + - Upstream ZFS fix 43eaef6de817 ("Fix zrele race in zrele_async that can + cause hang") + + -- Heitor Alves de Siqueira Thu, 25 Feb 2021 17:20:20 +0000 + zfs-linux (0.7.5-1ubuntu16.10) bionic; urgency=medium * Fix zfs-dkms build on arm64 with PREEMPTION and BLK_CGROUP (LP: #1892001) diff -Nru zfs-linux-0.7.5/debian/patches/4800-fix-iput-race-in-zfs_iput_async.patch zfs-linux-0.7.5/debian/patches/4800-fix-iput-race-in-zfs_iput_async.patch --- zfs-linux-0.7.5/debian/patches/4800-fix-iput-race-in-zfs_iput_async.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/4800-fix-iput-race-in-zfs_iput_async.patch 2021-02-25 17:20:20.000000000 +0000 @@ -0,0 +1,52 @@ +From 43eaef6de817dab3e098488f8e02a11fe57944d0 Mon Sep 17 00:00:00 2001 +From: Paul Dagnelie +Date: Wed, 27 Jan 2021 21:29:58 -0800 +Subject: [PATCH] Fix zrele race in zrele_async that can cause hang + +There is a race condition in zfs_zrele_async when we are checking if +we would be the one to evict an inode. This can lead to a txg sync +deadlock. + +Instead of calling into iput directly, we attempt to perform the atomic +decrement ourselves, unless that would set the i_count value to zero. +In that case, we dispatch a call to iput to run later, to prevent a +deadlock from occurring. + +Reviewed-by: Brian Behlendorf +Reviewed-by: Matthew Ahrens +Signed-off-by: Paul Dagnelie +Closes #11527 +Closes #11530 + +Origin: backport, https://github.com/openzfs/zfs/commit/43eaef6de817 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1916486 +--- + module/zfs/zfs_vnops.c | 13 +++++++++++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +Index: zfs-linux/module/zfs/zfs_vnops.c +=================================================================== +--- zfs-linux.orig/module/zfs/zfs_vnops.c ++++ zfs-linux/module/zfs/zfs_vnops.c +@@ -958,11 +958,18 @@ zfs_iput_async(struct inode *ip) + ASSERT(atomic_read(&ip->i_count) > 0); + ASSERT(os != NULL); + +- if (atomic_read(&ip->i_count) == 1) ++ /* ++ * If decrementing the count would put us at 0, we can't do it inline ++ * here, because that would be synchronous. Instead, dispatch an iput ++ * to run later. ++ * ++ * For more information on the dangers of a synchronous iput, see the ++ * header comment of this file. ++ */ ++ if (!atomic_add_unless(&ip->i_count, -1, 1)) { + VERIFY(taskq_dispatch(dsl_pool_iput_taskq(dmu_objset_pool(os)), + (task_func_t *)iput, ip, TQ_SLEEP) != TASKQID_INVALID); +- else +- iput(ip); ++ } + } + + void diff -Nru zfs-linux-0.7.5/debian/patches/series zfs-linux-0.7.5/debian/patches/series --- zfs-linux-0.7.5/debian/patches/series 2020-08-18 09:10:41.000000000 +0000 +++ zfs-linux-0.7.5/debian/patches/series 2021-02-25 17:20:20.000000000 +0000 @@ -96,3 +96,4 @@ 3321-add-compat-check-disk-size-change.patch 3322-add-scrub-compat-fixes.patch 4700-Fix-DKMS-build-on-arm64-with-PREEMPTION-and-BLK_CGRO.patch +4800-fix-iput-race-in-zfs_iput_async.patch