From 3ec3bc2167352df525c10c99cf24cb24952c2786 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Tue, 7 Mar 2017 09:51:59 -0800 Subject: OpenZFS 7793 - ztest fails assertion in dmu_tx_willuse_space MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed by: Steve Gonczi Reviewed by: George Wilson Reviewed by: Pavel Zakharov Ported-by: Brian Behlendorf Background information: This assertion about tx_space_* verifies that we are not dirtying more stuff than we thought we would. We “need” to know how much we will dirty so that we can check if we should fail this transaction with ENOSPC/EDQUOT, in dmu_tx_assign(). While the transaction is open (i.e. between dmu_tx_assign() and dmu_tx_commit() — typically less than a millisecond), we call dbuf_dirty() on the exact blocks that will be modified. Once this happens, the temporary accounting in tx_space_* is unnecessary, because we know exactly what blocks are newly dirtied; we call dnode_willuse_space() to track this more exact accounting. The fundamental problem causing this bug is that dmu_tx_hold_*() relies on the current state in the DMU (e.g. dn_nlevels) to predict how much will be dirtied by this transaction, but this state can change before we actually perform the transaction (i.e. call dbuf_dirty()). This bug will be fixed by removing the assertion that the tx_space_* accounting is perfectly accurate (i.e. we never dirty more than was predicted by dmu_tx_hold_*()). By removing the requirement that this accounting be perfectly accurate, we can also vastly simplify it, e.g. removing most of the logic in dmu_tx_count_*(). The new tx space accounting will be very approximate, and may be more or less than what is actually dirtied. It will still be used to determine if this transaction will put us over quota. Transactions that are marked by dmu_tx_mark_netfree() will be excepted from this check. We won’t make an attempt to determine how much space will be freed by the transaction — this was rarely accurate enough to determine if a transaction should be permitted when we are over quota, which is why dmu_tx_mark_netfree() was introduced in 2014. We also won’t attempt to give “credit” when overwriting existing blocks, if those blocks may be freed. This allows us to remove the do_free_accounting logic in dbuf_dirty(), and associated routines. This logic attempted to predict what will be on disk when this txg syncs, to know if the overwritten block will be freed (i.e. exists, and has no snapshots). OpenZFS-issue: https://www.illumos.org/issues/7793 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/3704e0a Upstream bugs: DLPX-32883a Closes #5804 Porting notes: - DNODE_SIZE replaced with DNODE_MIN_SIZE in dmu_tx_count_dnode(), Using the default dnode size would be slightly better. - DEBUG_DMU_TX wrappers and configure option removed. - Resolved _by_dnode() conflicts these changes have not yet been applied to OpenZFS. --- config/zfs-build.m4 | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) (limited to 'config/zfs-build.m4') diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index 8b969da36..6c5f13240 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -37,29 +37,6 @@ AC_DEFUN([ZFS_AC_DEBUG], [ AC_MSG_RESULT([$enable_debug]) ]) -AC_DEFUN([ZFS_AC_DEBUG_DMU_TX], [ - AC_ARG_ENABLE([debug-dmu-tx], - [AS_HELP_STRING([--enable-debug-dmu-tx], - [Enable dmu tx validation @<:@default=no@:>@])], - [], - [enable_debug_dmu_tx=no]) - - AS_IF([test "x$enable_debug_dmu_tx" = xyes], - [ - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_DMU_TX" - DEBUG_DMU_TX="_with_debug_dmu_tx" - AC_DEFINE([DEBUG_DMU_TX], [1], - [Define to 1 to enabled dmu tx validation]) - ], - [ - DEBUG_DMU_TX="_without_debug_dmu_tx" - ]) - - AC_SUBST(DEBUG_DMU_TX) - AC_MSG_CHECKING([whether dmu tx validation is enabled]) - AC_MSG_RESULT([$enable_debug_dmu_tx]) -]) - AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [ ZFS_AC_CONFIG_ALWAYS_NO_UNUSED_BUT_SET_VARIABLE ZFS_AC_CONFIG_ALWAYS_NO_BOOL_COMPARE @@ -140,7 +117,7 @@ AC_DEFUN([ZFS_AC_RPM], [ AC_MSG_RESULT([$HAVE_RPMBUILD]) ]) - RPM_DEFINE_COMMON='--define "$(DEBUG_ZFS) 1" --define "$(DEBUG_DMU_TX) 1"' + RPM_DEFINE_COMMON='--define "$(DEBUG_ZFS) 1"' RPM_DEFINE_UTIL='--define "_dracutdir $(dracutdir)" --define "_udevdir $(udevdir)" --define "_udevruledir $(udevruledir)" --define "_initconfdir $(DEFAULT_INITCONF_DIR)" $(DEFINE_INITRAMFS)' RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)" --define "require_spldir $(SPL)" --define "require_splobj $(SPL_OBJ)" --define "ksrc $(LINUX)" --define "kobj $(LINUX_OBJ)"' RPM_DEFINE_DKMS= -- cgit v1.2.3