commit:     a64fff9b8106dec5affc6a9e82bb9cbbb1fe6fec
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Apr 16 03:57:14 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Apr 16 04:00:11 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a64fff9b

sys-fs/zfs-kmod: revert patch causing SEEK_HOLE corruption (again)

This reverts commit 4b3133e671b958fa2c915a4faf57812820124a7b upstream.

See #14753 - possible corruption again, very similar symptoms to the
nightmare that was #11900 and same area of code.

We can safely revert it as it's an optimisation rather than a bugfix
in itself.

Keen Gentoo users may remember the following commits (in Gentoo):
- 8e5626dc90e4e6166c2e296371b6ff5a9d13a8c4
- 9fb275f656de639e25acc9497b70b4cae593d35d
- 95c250a3f3986b2bc2091dd3981ff1e1d3de0c73

Bug: https://github.com/openzfs/zfs/issues/14753
Bug: https://github.com/openzfs/zfs/issues/11900
Signed-off-by: Sam James <sam <AT> gentoo.org>

 profiles/package.mask                              |  5 ++
 ...IOC_COUNT_FILLED-does-unnecessary-txg_wai.patch | 67 ++++++++++++++++++++++
 ...mod-2.1.10.ebuild => zfs-kmod-2.1.10-r1.ebuild} |  5 ++
 3 files changed, 77 insertions(+)

diff --git a/profiles/package.mask b/profiles/package.mask
index d2367486b2b3..0f9d33d0dd71 100644
--- a/profiles/package.mask
+++ b/profiles/package.mask
@@ -33,6 +33,11 @@
 
 #--- END OF EXAMPLES ---
 
+# Sam James <s...@gentoo.org> (2023-04-16)
+# SEEK_HOLE issues causing corruption with (sparse?) copies again.
+# See https://github.com/openzfs/zfs/issues/14753.
+=sys-fs/zfs-kmod-2.1.10
+
 # Sam James <s...@gentoo.org> (2023-04-16)
 # OpenRC is broken with this version, but the issue is on OpenRC's side
 # and needs to be fixed there. bug #904277

diff --git 
a/sys-fs/zfs-kmod/files/2.1.10-Revert-ZFS_IOC_COUNT_FILLED-does-unnecessary-txg_wai.patch
 
b/sys-fs/zfs-kmod/files/2.1.10-Revert-ZFS_IOC_COUNT_FILLED-does-unnecessary-txg_wai.patch
new file mode 100644
index 000000000000..150d1b5145d9
--- /dev/null
+++ 
b/sys-fs/zfs-kmod/files/2.1.10-Revert-ZFS_IOC_COUNT_FILLED-does-unnecessary-txg_wai.patch
@@ -0,0 +1,67 @@
+From ac6b8f40981cb9328c22a3485e1a4b060ea89b1e Mon Sep 17 00:00:00 2001
+From: Sam James <s...@gentoo.org>
+Date: Sun, 16 Apr 2023 04:49:04 +0100
+Subject: [PATCH] Revert "ZFS_IOC_COUNT_FILLED does unnecessary
+ txg_wait_synced()"
+
+This reverts commit 4b3133e671b958fa2c915a4faf57812820124a7b.
+
+See #14753 - possible corruption again, very similar symptoms to the
+nightmare that was #11900 and same area of code.
+
+We can safely revert it as it's an optimisation rather than a bugfix
+in itself.
+
+Bug: https://github.com/openzfs/zfs/issues/14753
+Bug: https://github.com/openzfs/zfs/issues/11900
+Signed-off-by: Sam James <s...@gentoo.org>
+--- a/module/zfs/dnode.c
++++ b/module/zfs/dnode.c
+@@ -1773,29 +1773,20 @@ dnode_try_claim(objset_t *os, uint64_t object, int 
slots)
+ }
+ 
+ /*
+- * Checks if the dnode might contain any uncommitted changes to data blocks.
+- * Dirty metadata (e.g. bonus buffer) does not count.
++ * Checks if the dnode contains any uncommitted dirty records.
+  */
+ boolean_t
+ dnode_is_dirty(dnode_t *dn)
+ {
+       mutex_enter(&dn->dn_mtx);
++
+       for (int i = 0; i < TXG_SIZE; i++) {
+-              list_t *list = &dn->dn_dirty_records[i];
+-              for (dbuf_dirty_record_t *dr = list_head(list);
+-                  dr != NULL; dr = list_next(list, dr)) {
+-                      if (dr->dr_dbuf == NULL ||
+-                          (dr->dr_dbuf->db_blkid != DMU_BONUS_BLKID &&
+-                          dr->dr_dbuf->db_blkid != DMU_SPILL_BLKID)) {
+-                              mutex_exit(&dn->dn_mtx);
+-                              return (B_TRUE);
+-                      }
+-              }
+-              if (dn->dn_free_ranges[i] != NULL) {
++              if (multilist_link_active(&dn->dn_dirty_link[i])) {
+                       mutex_exit(&dn->dn_mtx);
+                       return (B_TRUE);
+               }
+       }
++
+       mutex_exit(&dn->dn_mtx);
+ 
+       return (B_FALSE);
+@@ -2667,9 +2658,7 @@ dnode_next_offset(dnode_t *dn, int flags, uint64_t 
*offset,
+               rw_enter(&dn->dn_struct_rwlock, RW_READER);
+ 
+       if (dn->dn_phys->dn_nlevels == 0) {
+-              if (!(flags & DNODE_FIND_HOLE)) {
+-                      error = SET_ERROR(ESRCH);
+-              }
++              error = SET_ERROR(ESRCH);
+               goto out;
+       }
+ 
+-- 
+2.40.0
+

diff --git a/sys-fs/zfs-kmod/zfs-kmod-2.1.10.ebuild 
b/sys-fs/zfs-kmod/zfs-kmod-2.1.10-r1.ebuild
similarity index 97%
rename from sys-fs/zfs-kmod/zfs-kmod-2.1.10.ebuild
rename to sys-fs/zfs-kmod/zfs-kmod-2.1.10-r1.ebuild
index 8f9eaa5b452c..bd0070f85ad1 100644
--- a/sys-fs/zfs-kmod/zfs-kmod-2.1.10.ebuild
+++ b/sys-fs/zfs-kmod/zfs-kmod-2.1.10-r1.ebuild
@@ -60,6 +60,11 @@ RESTRICT="debug? ( strip ) test"
 
 DOCS=( AUTHORS COPYRIGHT META README.md )
 
+PATCHES=(
+       # https://github.com/openzfs/zfs/issues/14753
+       
"${FILESDIR}"/2.1.10-Revert-ZFS_IOC_COUNT_FILLED-does-unnecessary-txg_wai.patch
+)
+
 pkg_pretend() {
        use rootfs || return 0
 

Reply via email to