← Back to team overview

sts-sponsors team mailing list archive

[Merge] ~halves/ubuntu/+source/zfs-linux:lp1916486-groovy into ubuntu/+source/zfs-linux:ubuntu/groovy-devel

 

You have been requested to review the proposed merge of ~halves/ubuntu/+source/zfs-linux:lp1916486-groovy into ubuntu/+source/zfs-linux:ubuntu/groovy-devel.

For more details, see:
https://code.launchpad.net/~halves/ubuntu/+source/zfs-linux/+git/zfs-linux/+merge/398743



-- 
Your team STS Sponsors is requested to review the proposed merge of ~halves/ubuntu/+source/zfs-linux:lp1916486-groovy into ubuntu/+source/zfs-linux:ubuntu/groovy-devel.
diff --git a/debian/changelog b/debian/changelog
index e792d01..763135b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+zfs-linux (0.8.4-1ubuntu11.2) groovy; urgency=medium
+
+  * Fix race condition in zfs_iput_async (LP: #1916485)
+    - Upstream ZFS fix 43eaef6de817 ("Fix zrele race in zrele_async that can
+      cause hang")
+
+ -- Heitor Alves de Siqueira <halves@xxxxxxxxxxxxx>  Thu, 25 Feb 2021 19:53:32 +0000
+
 zfs-linux (0.8.4-1ubuntu11.1) groovy; urgency=medium
 
   [ Didier Roche ]
diff --git a/debian/patches/fix-iput-race-in-zfs_iput_async.patch b/debian/patches/fix-iput-race-in-zfs_iput_async.patch
new file mode 100644
index 0000000..8fbdb99
--- /dev/null
+++ b/debian/patches/fix-iput-race-in-zfs_iput_async.patch
@@ -0,0 +1,52 @@
+From 43eaef6de817dab3e098488f8e02a11fe57944d0 Mon Sep 17 00:00:00 2001
+From: Paul Dagnelie <paulcd2000@xxxxxxxxx>
+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 <behlendorf1@xxxxxxxx>
+Reviewed-by: Matthew Ahrens <mahrens@xxxxxxxxxxx>
+Signed-off-by: Paul Dagnelie <pcd@xxxxxxxxxxx>
+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
+@@ -996,11 +996,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);
++	}
+ }
+
+ /* ARGSUSED */
diff --git a/debian/patches/series b/debian/patches/series
index 1f3a531..900a7c7 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -23,3 +23,4 @@ git_fix_dependency_loop_encryption2.patch
 4620-zfs-vol-wait-fix-locked-encrypted-vols.patch
 4700-Fix-DKMS-build-on-arm64-with-PREEMPTION-and-BLK_CGRO.patch
 4702-Revert-Let-zfs-mount-all-tolerate-in-progress-mounts.patch
+fix-iput-race-in-zfs_iput_async.patch

Follow ups