freebsd-nq/module/zfs
Brian Behlendorf 3ec3bc2167 OpenZFS 7793 - ztest fails assertion in dmu_tx_willuse_space
Reviewed by: Steve Gonczi <steve.gonczi@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>

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.
2017-03-07 09:51:59 -08:00
..
abd.c codebase style improvements for OpenZFS 6459 port 2017-01-22 13:25:40 -08:00
arc.c zfs_arc_num_sublists_per_state should be common to all multilists 2017-02-15 15:49:33 -08:00
blkptr.c DLPX-44812 integrate EP-220 large memory scalability 2016-11-29 14:34:27 -08:00
bplist.c Change KM_PUSHPAGE -> KM_SLEEP 2015-01-16 14:41:26 -08:00
bpobj.c panic in bpobj_space(): null pointer dereference 2017-02-09 10:19:12 -08:00
bptree.c OpenZFS 7082 - bptree_iterate() passes wrong args to zfs_dbgmsg() 2017-01-17 14:49:24 -08:00
bqueue.c Fix coverity defects: CID 147565-147567 2016-10-07 13:19:43 -07:00
dbuf_stats.c OpenZFS 6950 - ARC should cache compressed data 2016-09-13 09:58:33 -07:00
dbuf.c OpenZFS 7793 - ztest fails assertion in dmu_tx_willuse_space 2017-03-07 09:51:59 -08:00
ddt_zap.c Change KM_PUSHPAGE -> KM_SLEEP 2015-01-16 14:41:26 -08:00
ddt.c Cache ddt_get_dedup_dspace() value if there was no ddt changes 2016-12-02 16:59:35 -07:00
dmu_diff.c OpenZFS 6950 - ARC should cache compressed data 2016-09-13 09:58:33 -07:00
dmu_object.c Clean up by-dnode code in dmu_tx.c 2017-02-24 13:34:26 -08:00
dmu_objset.c OpenZFS 7793 - ztest fails assertion in dmu_tx_willuse_space 2017-03-07 09:51:59 -08:00
dmu_send.c OpenZFS 7247 - zfs receive of deduplicated stream fails 2017-02-04 09:10:24 -08:00
dmu_traverse.c Add TASKQID_INVALID 2016-11-02 12:14:45 -07:00
dmu_tx.c OpenZFS 7793 - ztest fails assertion in dmu_tx_willuse_space 2017-03-07 09:51:59 -08:00
dmu_zfetch.c Use cstyle -cpP in make cstyle check 2016-12-12 10:46:26 -08:00
dmu.c Add missing module_param for zfs_per_txg_dirty_frees_percent 2017-02-07 09:44:03 -08:00
dnode_sync.c OpenZFS 7580 - ztest failure in dbuf_read_impl 2017-01-28 12:11:09 -08:00
dnode.c OpenZFS 7793 - ztest fails assertion in dmu_tx_willuse_space 2017-03-07 09:51:59 -08:00
dsl_bookmark.c OpenZFS 1300 - filename normalization doesn't work for removes 2017-02-02 14:13:41 -08:00
dsl_dataset.c OpenZFS 7793 - ztest fails assertion in dmu_tx_willuse_space 2017-03-07 09:51:59 -08:00
dsl_deadlist.c panic in bpobj_space(): null pointer dereference 2017-02-09 10:19:12 -08:00
dsl_deleg.c Performance optimization of AVL tree comparator functions 2016-08-31 14:35:34 -07:00
dsl_destroy.c OpenZFS 7254 - ztest failed assertion in ztest_dataset_dirobj_verify: dirobjs + 1 == usedobjs 2017-01-27 11:43:42 -08:00
dsl_dir.c OpenZFS 7793 - ztest fails assertion in dmu_tx_willuse_space 2017-03-07 09:51:59 -08:00
dsl_pool.c OpenZFS 7199 - dsl_dataset_rollback_sync may try to free already free blocks 2017-02-24 11:05:33 -08:00
dsl_prop.c Fix dsl_props_set_sync_impl to work with nested nvlist 2016-12-20 18:46:59 -08:00
dsl_scan.c OpenZFS 7254 - ztest failed assertion in ztest_dataset_dirobj_verify: dirobjs + 1 == usedobjs 2017-01-27 11:43:42 -08:00
dsl_synctask.c Illumos 4951 - ZFS administrative commands should use reserved space 2015-05-04 09:41:10 -07:00
dsl_userhold.c OpenZFS 6314 - buffer overflow in dsl_dataset_name 2016-06-28 13:47:03 -07:00
edonr_zfs.c DLPX-44812 integrate EP-220 large memory scalability 2016-11-29 14:34:27 -08:00
fm.c Use cstyle -cpP in make cstyle check 2016-12-12 10:46:26 -08:00
gzip.c Use cstyle -cpP in make cstyle check 2016-12-12 10:46:26 -08:00
lz4.c Fix spelling 2017-01-03 11:31:18 -06:00
lzjb.c Change KM_PUSHPAGE -> KM_SLEEP 2015-01-16 14:41:26 -08:00
Makefile.in DLPX-44812 integrate EP-220 large memory scalability 2016-11-29 14:34:27 -08:00
metaslab.c OpenZFS 7072 - zfs fails to expand if lun added when os is in shutdown state 2017-02-01 13:14:02 -08:00
multilist.c zfs_arc_num_sublists_per_state should be common to all multilists 2017-02-15 15:49:33 -08:00
pathname.c Add pn_alloc()/pn_free() functions 2016-04-21 09:49:25 -07:00
policy.c codebase style improvements for OpenZFS 6459 port 2017-01-22 13:25:40 -08:00
range_tree.c Performance optimization of AVL tree comparator functions 2016-08-31 14:35:34 -07:00
refcount.c Linux 4.11 compat: avoid refcount_t name conflict 2017-02-28 16:10:18 -08:00
rrwlock.c Fix spelling 2017-01-03 11:31:18 -06:00
sa.c OpenZFS 6676 - Race between unique_insert() and unique_remove() causes ZFS fsid change 2017-01-26 14:43:28 -08:00
sha256.c DLPX-44812 integrate EP-220 large memory scalability 2016-11-29 14:34:27 -08:00
skein_zfs.c DLPX-44812 integrate EP-220 large memory scalability 2016-11-29 14:34:27 -08:00
spa_boot.c Add linux kernel module support 2010-08-31 13:41:58 -07:00
spa_config.c Fix spelling 2017-01-03 11:31:18 -06:00
spa_errlog.c Illumos 4914 - zfs on-disk bookmark structure should be named *_phys_t 2014-08-06 14:48:41 -07:00
spa_history.c Fix indefinite article 2016-08-11 11:23:49 -07:00
spa_misc.c OpenZFS 7793 - ztest fails assertion in dmu_tx_willuse_space 2017-03-07 09:51:59 -08:00
spa_stats.c Fix spelling 2017-01-03 11:31:18 -06:00
spa.c Fix incorrect spare vdev state after replacing 2017-02-23 10:32:15 -08:00
space_map.c OpenZFS 7303 - dynamic metaslab selection 2017-01-12 11:52:56 -08:00
space_reftree.c OpenZFS 6328 - Fix cstyle errors in zfs codebase 2017-01-12 09:42:11 -08:00
trace.c OpenZFS 6531 - Provide mechanism to artificially limit disk performance 2016-05-26 10:11:51 -07:00
txg.c Refactor txg history kstat 2016-12-02 16:57:49 -07:00
uberblock.c Illumos 5347 - idle pool may run itself out of space 2015-07-14 10:35:21 -07:00
unique.c Performance optimization of AVL tree comparator functions 2016-08-31 14:35:34 -07:00
vdev_cache.c DLPX-44812 integrate EP-220 large memory scalability 2016-11-29 14:34:27 -08:00
vdev_disk.c OpenZFS 7448 - ZFS doesn't notice when disk vdevs have no write cache 2017-02-04 09:23:50 -08:00
vdev_file.c Use a dedicated taskq for vdev_file 2016-12-21 10:47:15 -08:00
vdev_label.c OpenZFS 6328 - Fix cstyle errors in zfs codebase 2017-01-12 09:42:11 -08:00
vdev_mirror.c codebase style improvements for OpenZFS 6459 port 2017-01-22 13:25:40 -08:00
vdev_missing.c Illumos #5244 - zio pipeline callers should explicitly invoke next stage 2015-04-30 15:07:47 -07:00
vdev_queue.c Use cstyle -cpP in make cstyle check 2016-12-12 10:46:26 -08:00
vdev_raidz_math_aarch64_neon_common.h ABD raidz NEON support 2016-11-29 14:34:33 -08:00
vdev_raidz_math_aarch64_neon.c codebase style improvements for OpenZFS 6459 port 2017-01-22 13:25:40 -08:00
vdev_raidz_math_aarch64_neonx2.c ABD raidz NEON support 2016-11-29 14:34:33 -08:00
vdev_raidz_math_avx2.c ABD raidz avx512f support 2016-11-29 14:34:33 -08:00
vdev_raidz_math_avx512bw.c ABD: Adapt avx512bw raidz assembly 2016-12-15 17:31:33 -08:00
vdev_raidz_math_avx512f.c Use cstyle -cpP in make cstyle check 2016-12-12 10:46:26 -08:00
vdev_raidz_math_impl.h codebase style improvements for OpenZFS 6459 port 2017-01-22 13:25:40 -08:00
vdev_raidz_math_scalar.c ABD Vectorized raidz 2016-11-29 14:34:33 -08:00
vdev_raidz_math_sse2.c ABD raidz avx512f support 2016-11-29 14:34:33 -08:00
vdev_raidz_math_ssse3.c codebase style improvements for OpenZFS 6459 port 2017-01-22 13:25:40 -08:00
vdev_raidz_math.c codebase style improvements for OpenZFS 6459 port 2017-01-22 13:25:40 -08:00
vdev_raidz.c ABD style cleanups 2017-02-24 12:05:42 -08:00
vdev_root.c Illumos #3598 2013-10-31 14:58:04 -07:00
vdev.c OpenZFS 7072 - zfs fails to expand if lun added when os is in shutdown state 2017-02-01 13:14:02 -08:00
zap_leaf.c OpenZFS 1300 - filename normalization doesn't work for removes 2017-02-02 14:13:41 -08:00
zap_micro.c OpenZFS 7793 - ztest fails assertion in dmu_tx_willuse_space 2017-03-07 09:51:59 -08:00
zap.c OpenZFS 7793 - ztest fails assertion in dmu_tx_willuse_space 2017-03-07 09:51:59 -08:00
zfeature_common.c OpenZFS 6586 - Whitespace inconsistencies in the spa feature dependency arrays in zfeature_common.c 2017-01-17 14:46:28 -08:00
zfeature.c OpenZFS 6328 - Fix cstyle errors in zfs codebase 2017-01-12 09:42:11 -08:00
zfs_acl.c Fix unlinked file cannot do xattr operations 2016-11-04 10:46:40 -07:00
zfs_byteswap.c Add linux kernel module support 2010-08-31 13:41:58 -07:00
zfs_ctldir.c codebase style improvements for OpenZFS 6459 port 2017-01-22 13:25:40 -08:00
zfs_debug.c OpenZFS 7277 - zdb should be able to print zfs_dbgmsg's 2017-01-28 12:16:43 -08:00
zfs_dir.c OpenZFS 7812 - Remove gender specific language 2017-02-24 11:07:04 -08:00
zfs_fm.c Fix coverity defects: CID 147626, 147628 2016-11-08 14:28:17 -08:00
zfs_fuid.c Fix coverity defects 2016-09-21 18:09:00 -07:00
zfs_ioctl.c OpenZFS 7019 - zfsdev_ioctl skips secpolicy when FKIOCTL is set 2017-01-31 10:24:23 -08:00
zfs_log.c OpenZFS 6328 - Fix cstyle errors in zfs codebase 2017-01-12 09:42:11 -08:00
zfs_onexit.c zfsdev_getminor() should check for invalid file handles 2015-06-22 17:02:13 -07:00
zfs_replay.c OpenZFS 6328 - Fix cstyle errors in zfs codebase 2017-01-12 09:42:11 -08:00
zfs_rlock.c Fix spelling 2017-01-03 11:31:18 -06:00
zfs_sa.c Convert zio_buf_alloc() consumers 2016-11-30 16:18:20 -07:00
zfs_vfsops.c OpenZFS 7301 - zpool export -f should be able to interrupt file freeing 2017-01-27 11:46:39 -08:00
zfs_vnops.c Fix iput() calls within a tx 2017-02-08 17:28:22 -08:00
zfs_znode.c Use inode_set_flags when available 2016-12-16 13:54:51 -08:00
zil.c Fix spelling 2017-01-03 11:31:18 -06:00
zio_checksum.c Use fletcher_4 routines natively with abd_iterate_func() 2017-02-01 09:34:22 -08:00
zio_compress.c DLPX-44812 integrate EP-220 large memory scalability 2016-11-29 14:34:27 -08:00
zio_inject.c Compile zio.h and zio_impl.h mutual include 2016-12-01 16:36:25 -07:00
zio.c OpenZFS 7812 - Remove gender specific language 2017-02-24 11:07:04 -08:00
zle.c Update core ZFS code from build 121 to build 141. 2010-05-28 13:45:14 -07:00
zpl_ctldir.c Linux 4.9 compat: iops->rename() wants flags 2016-10-20 09:39:09 -07:00
zpl_export.c Use cstyle -cpP in make cstyle check 2016-12-12 10:46:26 -08:00
zpl_file.c Fix loop device becomes read-only 2017-03-06 09:20:20 -08:00
zpl_inode.c Fix off by one in zpl_lookup 2017-02-11 12:42:17 -08:00
zpl_super.c Fix memleak in zpl_parse_options 2016-05-31 16:04:26 -07:00
zpl_xattr.c Fix spelling 2017-01-03 11:31:18 -06:00
zrlock.c OpenZFS 3746 - ZRLs are racy 2017-01-23 10:35:58 -08:00
zvol.c Allow c99 code to compile 2017-02-08 09:27:48 -08:00