2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* CDDL HEADER START
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the terms of the
|
|
|
|
* Common Development and Distribution License (the "License").
|
|
|
|
* You may not use this file except in compliance with the License.
|
|
|
|
*
|
|
|
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
|
|
* or http://www.opensolaris.org/os/licensing.
|
|
|
|
* See the License for the specific language governing permissions
|
|
|
|
* and limitations under the License.
|
|
|
|
*
|
|
|
|
* When distributing Covered Code, include this CDDL HEADER in each
|
|
|
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
|
|
* If applicable, add the following below this CDDL HEADER, with the
|
|
|
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
|
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
|
|
*
|
|
|
|
* CDDL HEADER END
|
|
|
|
*/
|
|
|
|
/*
|
2010-05-28 20:45:14 +00:00
|
|
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
2012-04-08 17:10:49 +00:00
|
|
|
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
|
OpenZFS 7004 - dmu_tx_hold_zap() does dnode_hold() 7x on same object
Using a benchmark which has 32 threads creating 2 million files in the
same directory, on a machine with 16 CPU cores, I observed poor
performance. I noticed that dmu_tx_hold_zap() was using about 30% of
all CPU, and doing dnode_hold() 7 times on the same object (the ZAP
object that is being held).
dmu_tx_hold_zap() keeps a hold on the dnode_t the entire time it is
running, in dmu_tx_hold_t:txh_dnode, so it would be nice to use the
dnode_t that we already have in hand, rather than repeatedly calling
dnode_hold(). To do this, we need to pass the dnode_t down through
all the intermediate calls that dmu_tx_hold_zap() makes, making these
routines take the dnode_t* rather than an objset_t* and a uint64_t
object number. In particular, the following routines will need to have
analogous *_by_dnode() variants created:
dmu_buf_hold_noread()
dmu_buf_hold()
zap_lookup()
zap_lookup_norm()
zap_count_write()
zap_lockdir()
zap_count_write()
This can improve performance on the benchmark described above by 100%,
from 30,000 file creations per second to 60,000. (This improvement is on
top of that provided by working around the object allocation issue. Peak
performance of ~90,000 creations per second was observed with 8 CPUs;
adding CPUs past that decreased performance due to lock contention.) The
CPU used by dmu_tx_hold_zap() was reduced by 88%, from 340 CPU-seconds
to 40 CPU-seconds.
Sponsored by: Intel Corp.
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
OpenZFS-issue: https://www.illumos.org/issues/7004
OpenZFS-commit: https://github.com/openzfs/openzfs/pull/109
Closes #4641
Closes #4972
2016-07-20 22:42:13 +00:00
|
|
|
* Copyright (c) 2012, 2016 by Delphix. All rights reserved.
|
2012-04-08 17:10:49 +00:00
|
|
|
*/
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
#include <sys/dmu.h>
|
|
|
|
#include <sys/dmu_impl.h>
|
|
|
|
#include <sys/dbuf.h>
|
|
|
|
#include <sys/dmu_tx.h>
|
|
|
|
#include <sys/dmu_objset.h>
|
|
|
|
#include <sys/dsl_dataset.h> /* for dsl_dataset_block_freeable() */
|
|
|
|
#include <sys/dsl_dir.h> /* for dsl_dir_tempreserve_*() */
|
|
|
|
#include <sys/dsl_pool.h>
|
|
|
|
#include <sys/zap_impl.h> /* for fzap_default_block_shift */
|
|
|
|
#include <sys/spa.h>
|
2010-05-28 20:45:14 +00:00
|
|
|
#include <sys/sa.h>
|
|
|
|
#include <sys/sa_impl.h>
|
2008-11-20 20:01:55 +00:00
|
|
|
#include <sys/zfs_context.h>
|
2010-05-28 20:45:14 +00:00
|
|
|
#include <sys/varargs.h>
|
2014-12-13 02:07:39 +00:00
|
|
|
#include <sys/trace_dmu.h>
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
typedef void (*dmu_tx_hold_func_t)(dmu_tx_t *tx, struct dnode *dn,
|
|
|
|
uint64_t arg1, uint64_t arg2);
|
|
|
|
|
2012-01-20 18:58:57 +00:00
|
|
|
dmu_tx_stats_t dmu_tx_stats = {
|
|
|
|
{ "dmu_tx_assigned", KSTAT_DATA_UINT64 },
|
|
|
|
{ "dmu_tx_delay", KSTAT_DATA_UINT64 },
|
|
|
|
{ "dmu_tx_error", KSTAT_DATA_UINT64 },
|
|
|
|
{ "dmu_tx_suspended", KSTAT_DATA_UINT64 },
|
|
|
|
{ "dmu_tx_group", KSTAT_DATA_UINT64 },
|
|
|
|
{ "dmu_tx_memory_reserve", KSTAT_DATA_UINT64 },
|
|
|
|
{ "dmu_tx_memory_reclaim", KSTAT_DATA_UINT64 },
|
|
|
|
{ "dmu_tx_dirty_throttle", KSTAT_DATA_UINT64 },
|
Illumos #4045 write throttle & i/o scheduler performance work
4045 zfs write throttle & i/o scheduler performance work
1. The ZFS i/o scheduler (vdev_queue.c) now divides i/os into 5 classes: sync
read, sync write, async read, async write, and scrub/resilver. The scheduler
issues a number of concurrent i/os from each class to the device. Once a class
has been selected, an i/o is selected from this class using either an elevator
algorithem (async, scrub classes) or FIFO (sync classes). The number of
concurrent async write i/os is tuned dynamically based on i/o load, to achieve
good sync i/o latency when there is not a high load of writes, and good write
throughput when there is. See the block comment in vdev_queue.c (reproduced
below) for more details.
2. The write throttle (dsl_pool_tempreserve_space() and
txg_constrain_throughput()) is rewritten to produce much more consistent delays
when under constant load. The new write throttle is based on the amount of
dirty data, rather than guesses about future performance of the system. When
there is a lot of dirty data, each transaction (e.g. write() syscall) will be
delayed by the same small amount. This eliminates the "brick wall of wait"
that the old write throttle could hit, causing all transactions to wait several
seconds until the next txg opens. One of the keys to the new write throttle is
decrementing the amount of dirty data as i/o completes, rather than at the end
of spa_sync(). Note that the write throttle is only applied once the i/o
scheduler is issuing the maximum number of outstanding async writes. See the
block comments in dsl_pool.c and above dmu_tx_delay() (reproduced below) for
more details.
This diff has several other effects, including:
* the commonly-tuned global variable zfs_vdev_max_pending has been removed;
use per-class zfs_vdev_*_max_active values or zfs_vdev_max_active instead.
* the size of each txg (meaning the amount of dirty data written, and thus the
time it takes to write out) is now controlled differently. There is no longer
an explicit time goal; the primary determinant is amount of dirty data.
Systems that are under light or medium load will now often see that a txg is
always syncing, but the impact to performance (e.g. read latency) is minimal.
Tune zfs_dirty_data_max and zfs_dirty_data_sync to control this.
* zio_taskq_batch_pct = 75 -- Only use 75% of all CPUs for compression,
checksum, etc. This improves latency by not allowing these CPU-intensive tasks
to consume all CPU (on machines with at least 4 CPU's; the percentage is
rounded up).
--matt
APPENDIX: problems with the current i/o scheduler
The current ZFS i/o scheduler (vdev_queue.c) is deadline based. The problem
with this is that if there are always i/os pending, then certain classes of
i/os can see very long delays.
For example, if there are always synchronous reads outstanding, then no async
writes will be serviced until they become "past due". One symptom of this
situation is that each pass of the txg sync takes at least several seconds
(typically 3 seconds).
If many i/os become "past due" (their deadline is in the past), then we must
service all of these overdue i/os before any new i/os. This happens when we
enqueue a batch of async writes for the txg sync, with deadlines 2.5 seconds in
the future. If we can't complete all the i/os in 2.5 seconds (e.g. because
there were always reads pending), then these i/os will become past due. Now we
must service all the "async" writes (which could be hundreds of megabytes)
before we service any reads, introducing considerable latency to synchronous
i/os (reads or ZIL writes).
Notes on porting to ZFS on Linux:
- zio_t gained new members io_physdone and io_phys_children. Because
object caches in the Linux port call the constructor only once at
allocation time, objects may contain residual data when retrieved
from the cache. Therefore zio_create() was updated to zero out the two
new fields.
- vdev_mirror_pending() relied on the depth of the per-vdev pending queue
(vq->vq_pending_tree) to select the least-busy leaf vdev to read from.
This tree has been replaced by vq->vq_active_tree which is now used
for the same purpose.
- vdev_queue_init() used the value of zfs_vdev_max_pending to determine
the number of vdev I/O buffers to pre-allocate. That global no longer
exists, so we instead use the sum of the *_max_active values for each of
the five I/O classes described above.
- The Illumos implementation of dmu_tx_delay() delays a transaction by
sleeping in condition variable embedded in the thread
(curthread->t_delay_cv). We do not have an equivalent CV to use in
Linux, so this change replaced the delay logic with a wrapper called
zfs_sleep_until(). This wrapper could be adopted upstream and in other
downstream ports to abstract away operating system-specific delay logic.
- These tunables are added as module parameters, and descriptions added
to the zfs-module-parameters.5 man page.
spa_asize_inflation
zfs_deadman_synctime_ms
zfs_vdev_max_active
zfs_vdev_async_write_active_min_dirty_percent
zfs_vdev_async_write_active_max_dirty_percent
zfs_vdev_async_read_max_active
zfs_vdev_async_read_min_active
zfs_vdev_async_write_max_active
zfs_vdev_async_write_min_active
zfs_vdev_scrub_max_active
zfs_vdev_scrub_min_active
zfs_vdev_sync_read_max_active
zfs_vdev_sync_read_min_active
zfs_vdev_sync_write_max_active
zfs_vdev_sync_write_min_active
zfs_dirty_data_max_percent
zfs_delay_min_dirty_percent
zfs_dirty_data_max_max_percent
zfs_dirty_data_max
zfs_dirty_data_max_max
zfs_dirty_data_sync
zfs_delay_scale
The latter four have type unsigned long, whereas they are uint64_t in
Illumos. This accommodates Linux's module_param() supported types, but
means they may overflow on 32-bit architectures.
The values zfs_dirty_data_max and zfs_dirty_data_max_max are the most
likely to overflow on 32-bit systems, since they express physical RAM
sizes in bytes. In fact, Illumos initializes zfs_dirty_data_max_max to
2^32 which does overflow. To resolve that, this port instead initializes
it in arc_init() to 25% of physical RAM, and adds the tunable
zfs_dirty_data_max_max_percent to override that percentage. While this
solution doesn't completely avoid the overflow issue, it should be a
reasonable default for most systems, and the minority of affected
systems can work around the issue by overriding the defaults.
- Fixed reversed logic in comment above zfs_delay_scale declaration.
- Clarified comments in vdev_queue.c regarding when per-queue minimums take
effect.
- Replaced dmu_tx_write_limit in the dmu_tx kstat file
with dmu_tx_dirty_delay and dmu_tx_dirty_over_max. The first counts
how many times a transaction has been delayed because the pool dirty
data has exceeded zfs_delay_min_dirty_percent. The latter counts how
many times the pool dirty data has exceeded zfs_dirty_data_max (which
we expect to never happen).
- The original patch would have regressed the bug fixed in
zfsonlinux/zfs@c418410, which prevented users from setting the
zfs_vdev_aggregation_limit tuning larger than SPA_MAXBLOCKSIZE.
A similar fix is added to vdev_queue_aggregate().
- In vdev_queue_io_to_issue(), dynamically allocate 'zio_t search' on the
heap instead of the stack. In Linux we can't afford such large
structures on the stack.
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Ned Bass <bass6@llnl.gov>
Reviewed by: Brendan Gregg <brendan.gregg@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
References:
http://www.illumos.org/issues/4045
illumos/illumos-gate@69962b5647e4a8b9b14998733b765925381b727e
Ported-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1913
2013-08-29 03:01:20 +00:00
|
|
|
{ "dmu_tx_dirty_delay", KSTAT_DATA_UINT64 },
|
|
|
|
{ "dmu_tx_dirty_over_max", KSTAT_DATA_UINT64 },
|
2012-01-20 18:58:57 +00:00
|
|
|
{ "dmu_tx_quota", KSTAT_DATA_UINT64 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static kstat_t *dmu_tx_ksp;
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
dmu_tx_t *
|
|
|
|
dmu_tx_create_dd(dsl_dir_t *dd)
|
|
|
|
{
|
2014-11-21 00:09:39 +00:00
|
|
|
dmu_tx_t *tx = kmem_zalloc(sizeof (dmu_tx_t), KM_SLEEP);
|
2008-11-20 20:01:55 +00:00
|
|
|
tx->tx_dir = dd;
|
2013-08-28 11:45:09 +00:00
|
|
|
if (dd != NULL)
|
2008-11-20 20:01:55 +00:00
|
|
|
tx->tx_pool = dd->dd_pool;
|
|
|
|
list_create(&tx->tx_holds, sizeof (dmu_tx_hold_t),
|
|
|
|
offsetof(dmu_tx_hold_t, txh_node));
|
2010-05-28 20:45:14 +00:00
|
|
|
list_create(&tx->tx_callbacks, sizeof (dmu_tx_callback_t),
|
|
|
|
offsetof(dmu_tx_callback_t, dcb_node));
|
Illumos #4045 write throttle & i/o scheduler performance work
4045 zfs write throttle & i/o scheduler performance work
1. The ZFS i/o scheduler (vdev_queue.c) now divides i/os into 5 classes: sync
read, sync write, async read, async write, and scrub/resilver. The scheduler
issues a number of concurrent i/os from each class to the device. Once a class
has been selected, an i/o is selected from this class using either an elevator
algorithem (async, scrub classes) or FIFO (sync classes). The number of
concurrent async write i/os is tuned dynamically based on i/o load, to achieve
good sync i/o latency when there is not a high load of writes, and good write
throughput when there is. See the block comment in vdev_queue.c (reproduced
below) for more details.
2. The write throttle (dsl_pool_tempreserve_space() and
txg_constrain_throughput()) is rewritten to produce much more consistent delays
when under constant load. The new write throttle is based on the amount of
dirty data, rather than guesses about future performance of the system. When
there is a lot of dirty data, each transaction (e.g. write() syscall) will be
delayed by the same small amount. This eliminates the "brick wall of wait"
that the old write throttle could hit, causing all transactions to wait several
seconds until the next txg opens. One of the keys to the new write throttle is
decrementing the amount of dirty data as i/o completes, rather than at the end
of spa_sync(). Note that the write throttle is only applied once the i/o
scheduler is issuing the maximum number of outstanding async writes. See the
block comments in dsl_pool.c and above dmu_tx_delay() (reproduced below) for
more details.
This diff has several other effects, including:
* the commonly-tuned global variable zfs_vdev_max_pending has been removed;
use per-class zfs_vdev_*_max_active values or zfs_vdev_max_active instead.
* the size of each txg (meaning the amount of dirty data written, and thus the
time it takes to write out) is now controlled differently. There is no longer
an explicit time goal; the primary determinant is amount of dirty data.
Systems that are under light or medium load will now often see that a txg is
always syncing, but the impact to performance (e.g. read latency) is minimal.
Tune zfs_dirty_data_max and zfs_dirty_data_sync to control this.
* zio_taskq_batch_pct = 75 -- Only use 75% of all CPUs for compression,
checksum, etc. This improves latency by not allowing these CPU-intensive tasks
to consume all CPU (on machines with at least 4 CPU's; the percentage is
rounded up).
--matt
APPENDIX: problems with the current i/o scheduler
The current ZFS i/o scheduler (vdev_queue.c) is deadline based. The problem
with this is that if there are always i/os pending, then certain classes of
i/os can see very long delays.
For example, if there are always synchronous reads outstanding, then no async
writes will be serviced until they become "past due". One symptom of this
situation is that each pass of the txg sync takes at least several seconds
(typically 3 seconds).
If many i/os become "past due" (their deadline is in the past), then we must
service all of these overdue i/os before any new i/os. This happens when we
enqueue a batch of async writes for the txg sync, with deadlines 2.5 seconds in
the future. If we can't complete all the i/os in 2.5 seconds (e.g. because
there were always reads pending), then these i/os will become past due. Now we
must service all the "async" writes (which could be hundreds of megabytes)
before we service any reads, introducing considerable latency to synchronous
i/os (reads or ZIL writes).
Notes on porting to ZFS on Linux:
- zio_t gained new members io_physdone and io_phys_children. Because
object caches in the Linux port call the constructor only once at
allocation time, objects may contain residual data when retrieved
from the cache. Therefore zio_create() was updated to zero out the two
new fields.
- vdev_mirror_pending() relied on the depth of the per-vdev pending queue
(vq->vq_pending_tree) to select the least-busy leaf vdev to read from.
This tree has been replaced by vq->vq_active_tree which is now used
for the same purpose.
- vdev_queue_init() used the value of zfs_vdev_max_pending to determine
the number of vdev I/O buffers to pre-allocate. That global no longer
exists, so we instead use the sum of the *_max_active values for each of
the five I/O classes described above.
- The Illumos implementation of dmu_tx_delay() delays a transaction by
sleeping in condition variable embedded in the thread
(curthread->t_delay_cv). We do not have an equivalent CV to use in
Linux, so this change replaced the delay logic with a wrapper called
zfs_sleep_until(). This wrapper could be adopted upstream and in other
downstream ports to abstract away operating system-specific delay logic.
- These tunables are added as module parameters, and descriptions added
to the zfs-module-parameters.5 man page.
spa_asize_inflation
zfs_deadman_synctime_ms
zfs_vdev_max_active
zfs_vdev_async_write_active_min_dirty_percent
zfs_vdev_async_write_active_max_dirty_percent
zfs_vdev_async_read_max_active
zfs_vdev_async_read_min_active
zfs_vdev_async_write_max_active
zfs_vdev_async_write_min_active
zfs_vdev_scrub_max_active
zfs_vdev_scrub_min_active
zfs_vdev_sync_read_max_active
zfs_vdev_sync_read_min_active
zfs_vdev_sync_write_max_active
zfs_vdev_sync_write_min_active
zfs_dirty_data_max_percent
zfs_delay_min_dirty_percent
zfs_dirty_data_max_max_percent
zfs_dirty_data_max
zfs_dirty_data_max_max
zfs_dirty_data_sync
zfs_delay_scale
The latter four have type unsigned long, whereas they are uint64_t in
Illumos. This accommodates Linux's module_param() supported types, but
means they may overflow on 32-bit architectures.
The values zfs_dirty_data_max and zfs_dirty_data_max_max are the most
likely to overflow on 32-bit systems, since they express physical RAM
sizes in bytes. In fact, Illumos initializes zfs_dirty_data_max_max to
2^32 which does overflow. To resolve that, this port instead initializes
it in arc_init() to 25% of physical RAM, and adds the tunable
zfs_dirty_data_max_max_percent to override that percentage. While this
solution doesn't completely avoid the overflow issue, it should be a
reasonable default for most systems, and the minority of affected
systems can work around the issue by overriding the defaults.
- Fixed reversed logic in comment above zfs_delay_scale declaration.
- Clarified comments in vdev_queue.c regarding when per-queue minimums take
effect.
- Replaced dmu_tx_write_limit in the dmu_tx kstat file
with dmu_tx_dirty_delay and dmu_tx_dirty_over_max. The first counts
how many times a transaction has been delayed because the pool dirty
data has exceeded zfs_delay_min_dirty_percent. The latter counts how
many times the pool dirty data has exceeded zfs_dirty_data_max (which
we expect to never happen).
- The original patch would have regressed the bug fixed in
zfsonlinux/zfs@c418410, which prevented users from setting the
zfs_vdev_aggregation_limit tuning larger than SPA_MAXBLOCKSIZE.
A similar fix is added to vdev_queue_aggregate().
- In vdev_queue_io_to_issue(), dynamically allocate 'zio_t search' on the
heap instead of the stack. In Linux we can't afford such large
structures on the stack.
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Ned Bass <bass6@llnl.gov>
Reviewed by: Brendan Gregg <brendan.gregg@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
References:
http://www.illumos.org/issues/4045
illumos/illumos-gate@69962b5647e4a8b9b14998733b765925381b727e
Ported-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1913
2013-08-29 03:01:20 +00:00
|
|
|
tx->tx_start = gethrtime();
|
2012-03-20 23:00:17 +00:00
|
|
|
#ifdef DEBUG_DMU_TX
|
2008-11-20 20:01:55 +00:00
|
|
|
refcount_create(&tx->tx_space_written);
|
|
|
|
refcount_create(&tx->tx_space_freed);
|
|
|
|
#endif
|
|
|
|
return (tx);
|
|
|
|
}
|
|
|
|
|
|
|
|
dmu_tx_t *
|
|
|
|
dmu_tx_create(objset_t *os)
|
|
|
|
{
|
2010-05-28 20:45:14 +00:00
|
|
|
dmu_tx_t *tx = dmu_tx_create_dd(os->os_dsl_dataset->ds_dir);
|
2008-11-20 20:01:55 +00:00
|
|
|
tx->tx_objset = os;
|
2010-05-28 20:45:14 +00:00
|
|
|
tx->tx_lastsnap_txg = dsl_dataset_prev_snap_txg(os->os_dsl_dataset);
|
2008-11-20 20:01:55 +00:00
|
|
|
return (tx);
|
|
|
|
}
|
|
|
|
|
|
|
|
dmu_tx_t *
|
|
|
|
dmu_tx_create_assigned(struct dsl_pool *dp, uint64_t txg)
|
|
|
|
{
|
|
|
|
dmu_tx_t *tx = dmu_tx_create_dd(NULL);
|
|
|
|
|
|
|
|
ASSERT3U(txg, <=, dp->dp_tx.tx_open_txg);
|
|
|
|
tx->tx_pool = dp;
|
|
|
|
tx->tx_txg = txg;
|
|
|
|
tx->tx_anyobj = TRUE;
|
|
|
|
|
|
|
|
return (tx);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
dmu_tx_is_syncing(dmu_tx_t *tx)
|
|
|
|
{
|
|
|
|
return (tx->tx_anyobj);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
dmu_tx_private_ok(dmu_tx_t *tx)
|
|
|
|
{
|
|
|
|
return (tx->tx_anyobj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static dmu_tx_hold_t *
|
2017-01-13 22:58:41 +00:00
|
|
|
dmu_tx_hold_dnode_impl(dmu_tx_t *tx, dnode_t *dn, enum dmu_tx_hold_type type,
|
|
|
|
uint64_t arg1, uint64_t arg2)
|
2008-11-20 20:01:55 +00:00
|
|
|
{
|
|
|
|
dmu_tx_hold_t *txh;
|
|
|
|
|
2017-01-13 22:58:41 +00:00
|
|
|
if (dn != NULL) {
|
|
|
|
refcount_add(&dn->dn_holds, tx);
|
|
|
|
if (tx->tx_txg != 0) {
|
2008-11-20 20:01:55 +00:00
|
|
|
mutex_enter(&dn->dn_mtx);
|
|
|
|
/*
|
|
|
|
* dn->dn_assigned_txg == tx->tx_txg doesn't pose a
|
|
|
|
* problem, but there's no way for it to happen (for
|
|
|
|
* now, at least).
|
|
|
|
*/
|
|
|
|
ASSERT(dn->dn_assigned_txg == 0);
|
|
|
|
dn->dn_assigned_txg = tx->tx_txg;
|
|
|
|
(void) refcount_add(&dn->dn_tx_holds, tx);
|
|
|
|
mutex_exit(&dn->dn_mtx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-21 00:09:39 +00:00
|
|
|
txh = kmem_zalloc(sizeof (dmu_tx_hold_t), KM_SLEEP);
|
2008-11-20 20:01:55 +00:00
|
|
|
txh->txh_tx = tx;
|
|
|
|
txh->txh_dnode = dn;
|
2017-01-23 17:36:24 +00:00
|
|
|
refcount_create(&txh->txh_space_towrite);
|
|
|
|
refcount_create(&txh->txh_space_tofree);
|
|
|
|
refcount_create(&txh->txh_space_tooverwrite);
|
|
|
|
refcount_create(&txh->txh_space_tounref);
|
|
|
|
refcount_create(&txh->txh_memory_tohold);
|
|
|
|
refcount_create(&txh->txh_fudge);
|
2012-03-20 23:00:17 +00:00
|
|
|
#ifdef DEBUG_DMU_TX
|
2008-11-20 20:01:55 +00:00
|
|
|
txh->txh_type = type;
|
|
|
|
txh->txh_arg1 = arg1;
|
|
|
|
txh->txh_arg2 = arg2;
|
|
|
|
#endif
|
|
|
|
list_insert_tail(&tx->tx_holds, txh);
|
|
|
|
|
|
|
|
return (txh);
|
|
|
|
}
|
|
|
|
|
2017-01-13 22:58:41 +00:00
|
|
|
static dmu_tx_hold_t *
|
|
|
|
dmu_tx_hold_object_impl(dmu_tx_t *tx, objset_t *os, uint64_t object,
|
|
|
|
enum dmu_tx_hold_type type, uint64_t arg1, uint64_t arg2)
|
|
|
|
{
|
|
|
|
dnode_t *dn = NULL;
|
|
|
|
dmu_tx_hold_t *txh;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (object != DMU_NEW_OBJECT) {
|
|
|
|
err = dnode_hold(os, object, FTAG, &dn);
|
|
|
|
if (err) {
|
|
|
|
tx->tx_err = err;
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
txh = dmu_tx_hold_dnode_impl(tx, dn, type, arg1, arg2);
|
|
|
|
if (dn != NULL)
|
|
|
|
dnode_rele(dn, FTAG);
|
|
|
|
return (txh);
|
|
|
|
}
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
void
|
2017-01-13 22:58:41 +00:00
|
|
|
dmu_tx_add_new_object(dmu_tx_t *tx, objset_t *os, dnode_t *dn)
|
2008-11-20 20:01:55 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* If we're syncing, they can manipulate any object anyhow, and
|
|
|
|
* the hold on the dnode_t can cause problems.
|
|
|
|
*/
|
2017-01-13 22:58:41 +00:00
|
|
|
if (!dmu_tx_is_syncing(tx))
|
|
|
|
(void) dmu_tx_hold_dnode_impl(tx, dn, THT_NEWOBJECT, 0, 0);
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
dmu_tx_check_ioerr(zio_t *zio, dnode_t *dn, int level, uint64_t blkid)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
dmu_buf_impl_t *db;
|
|
|
|
|
|
|
|
rw_enter(&dn->dn_struct_rwlock, RW_READER);
|
|
|
|
db = dbuf_hold_level(dn, level, blkid, FTAG);
|
|
|
|
rw_exit(&dn->dn_struct_rwlock);
|
|
|
|
if (db == NULL)
|
2013-03-08 18:41:28 +00:00
|
|
|
return (SET_ERROR(EIO));
|
2008-11-20 20:01:55 +00:00
|
|
|
err = dbuf_read(db, zio, DB_RF_CANFAIL | DB_RF_NOPREFETCH);
|
|
|
|
dbuf_rele(db, FTAG);
|
|
|
|
return (err);
|
|
|
|
}
|
|
|
|
|
2009-07-02 22:44:48 +00:00
|
|
|
static void
|
2010-05-28 20:45:14 +00:00
|
|
|
dmu_tx_count_twig(dmu_tx_hold_t *txh, dnode_t *dn, dmu_buf_impl_t *db,
|
|
|
|
int level, uint64_t blkid, boolean_t freeable, uint64_t *history)
|
2009-07-02 22:44:48 +00:00
|
|
|
{
|
2010-05-28 20:45:14 +00:00
|
|
|
objset_t *os = dn->dn_objset;
|
|
|
|
dsl_dataset_t *ds = os->os_dsl_dataset;
|
|
|
|
int epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
|
|
|
|
dmu_buf_impl_t *parent = NULL;
|
|
|
|
blkptr_t *bp = NULL;
|
|
|
|
uint64_t space;
|
|
|
|
|
|
|
|
if (level >= dn->dn_nlevels || history[level] == blkid)
|
2009-07-02 22:44:48 +00:00
|
|
|
return;
|
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
history[level] = blkid;
|
2009-07-02 22:44:48 +00:00
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
space = (level == 0) ? dn->dn_datablksz : (1ULL << dn->dn_indblkshift);
|
|
|
|
|
|
|
|
if (db == NULL || db == dn->dn_dbuf) {
|
|
|
|
ASSERT(level != 0);
|
|
|
|
db = NULL;
|
|
|
|
} else {
|
2010-08-26 21:24:34 +00:00
|
|
|
ASSERT(DB_DNODE(db) == dn);
|
2010-05-28 20:45:14 +00:00
|
|
|
ASSERT(db->db_level == level);
|
|
|
|
ASSERT(db->db.db_size == space);
|
|
|
|
ASSERT(db->db_blkid == blkid);
|
|
|
|
bp = db->db_blkptr;
|
|
|
|
parent = db->db_parent;
|
2009-07-02 22:44:48 +00:00
|
|
|
}
|
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
freeable = (bp && (freeable ||
|
|
|
|
dsl_dataset_block_freeable(ds, bp, bp->blk_birth)));
|
2009-07-02 22:44:48 +00:00
|
|
|
|
2017-01-23 17:36:24 +00:00
|
|
|
if (freeable) {
|
|
|
|
(void) refcount_add_many(&txh->txh_space_tooverwrite,
|
|
|
|
space, FTAG);
|
|
|
|
} else {
|
|
|
|
(void) refcount_add_many(&txh->txh_space_towrite,
|
|
|
|
space, FTAG);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bp) {
|
|
|
|
(void) refcount_add_many(&txh->txh_space_tounref,
|
|
|
|
bp_get_dsize(os->os_spa, bp), FTAG);
|
|
|
|
}
|
2010-05-28 20:45:14 +00:00
|
|
|
|
|
|
|
dmu_tx_count_twig(txh, dn, parent, level + 1,
|
|
|
|
blkid >> epbs, freeable, history);
|
2009-07-02 22:44:48 +00:00
|
|
|
}
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/* ARGSUSED */
|
|
|
|
static void
|
|
|
|
dmu_tx_count_write(dmu_tx_hold_t *txh, uint64_t off, uint64_t len)
|
|
|
|
{
|
|
|
|
dnode_t *dn = txh->txh_dnode;
|
|
|
|
uint64_t start, end, i;
|
|
|
|
int min_bs, max_bs, min_ibs, max_ibs, epbs, bits;
|
|
|
|
int err = 0;
|
2010-08-26 16:52:39 +00:00
|
|
|
int l;
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
min_bs = SPA_MINBLOCKSHIFT;
|
2014-11-03 20:15:08 +00:00
|
|
|
max_bs = highbit64(txh->txh_tx->tx_objset->os_recordsize) - 1;
|
2008-11-20 20:01:55 +00:00
|
|
|
min_ibs = DN_MIN_INDBLKSHIFT;
|
|
|
|
max_ibs = DN_MAX_INDBLKSHIFT;
|
|
|
|
|
|
|
|
if (dn) {
|
2010-05-28 20:45:14 +00:00
|
|
|
uint64_t history[DN_MAX_LEVELS];
|
2009-07-02 22:44:48 +00:00
|
|
|
int nlvls = dn->dn_nlevels;
|
|
|
|
int delta;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For i/o error checking, read the first and last level-0
|
|
|
|
* blocks (if they are not aligned), and all the level-1 blocks.
|
|
|
|
*/
|
2008-11-20 20:01:55 +00:00
|
|
|
if (dn->dn_maxblkid == 0) {
|
2009-07-02 22:44:48 +00:00
|
|
|
delta = dn->dn_datablksz;
|
|
|
|
start = (off < dn->dn_datablksz) ? 0 : 1;
|
|
|
|
end = (off+len <= dn->dn_datablksz) ? 0 : 1;
|
|
|
|
if (start == 0 && (off > 0 || len < dn->dn_datablksz)) {
|
2008-12-03 20:09:06 +00:00
|
|
|
err = dmu_tx_check_ioerr(NULL, dn, 0, 0);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
2009-07-02 22:44:48 +00:00
|
|
|
delta -= off;
|
2008-12-03 20:09:06 +00:00
|
|
|
}
|
2008-11-20 20:01:55 +00:00
|
|
|
} else {
|
|
|
|
zio_t *zio = zio_root(dn->dn_objset->os_spa,
|
|
|
|
NULL, NULL, ZIO_FLAG_CANFAIL);
|
|
|
|
|
|
|
|
/* first level-0 block */
|
|
|
|
start = off >> dn->dn_datablkshift;
|
|
|
|
if (P2PHASE(off, dn->dn_datablksz) ||
|
|
|
|
len < dn->dn_datablksz) {
|
|
|
|
err = dmu_tx_check_ioerr(zio, dn, 0, start);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* last level-0 block */
|
|
|
|
end = (off+len-1) >> dn->dn_datablkshift;
|
2008-12-03 20:09:06 +00:00
|
|
|
if (end != start && end <= dn->dn_maxblkid &&
|
2008-11-20 20:01:55 +00:00
|
|
|
P2PHASE(off+len, dn->dn_datablksz)) {
|
|
|
|
err = dmu_tx_check_ioerr(zio, dn, 0, end);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* level-1 blocks */
|
2009-07-02 22:44:48 +00:00
|
|
|
if (nlvls > 1) {
|
|
|
|
int shft = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
|
|
|
|
for (i = (start>>shft)+1; i < end>>shft; i++) {
|
2008-11-20 20:01:55 +00:00
|
|
|
err = dmu_tx_check_ioerr(zio, dn, 1, i);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
err = zio_wait(zio);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
2009-07-02 22:44:48 +00:00
|
|
|
delta = P2NPHASE(off, dn->dn_datablksz);
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
|
2013-04-10 23:58:22 +00:00
|
|
|
min_ibs = max_ibs = dn->dn_indblkshift;
|
2009-07-02 22:44:48 +00:00
|
|
|
if (dn->dn_maxblkid > 0) {
|
|
|
|
/*
|
|
|
|
* The blocksize can't change,
|
|
|
|
* so we can make a more precise estimate.
|
|
|
|
*/
|
|
|
|
ASSERT(dn->dn_datablkshift != 0);
|
2008-11-20 20:01:55 +00:00
|
|
|
min_bs = max_bs = dn->dn_datablkshift;
|
2014-11-03 20:15:08 +00:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* The blocksize can increase up to the recordsize,
|
|
|
|
* or if it is already more than the recordsize,
|
|
|
|
* up to the next power of 2.
|
|
|
|
*/
|
|
|
|
min_bs = highbit64(dn->dn_datablksz - 1);
|
|
|
|
max_bs = MAX(max_bs, highbit64(dn->dn_datablksz - 1));
|
2009-07-02 22:44:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this write is not off the end of the file
|
|
|
|
* we need to account for overwrites/unref.
|
|
|
|
*/
|
2010-05-28 20:45:14 +00:00
|
|
|
if (start <= dn->dn_maxblkid) {
|
2010-08-26 16:52:39 +00:00
|
|
|
for (l = 0; l < DN_MAX_LEVELS; l++)
|
2010-05-28 20:45:14 +00:00
|
|
|
history[l] = -1ULL;
|
|
|
|
}
|
2009-07-02 22:44:48 +00:00
|
|
|
while (start <= dn->dn_maxblkid) {
|
|
|
|
dmu_buf_impl_t *db;
|
|
|
|
|
|
|
|
rw_enter(&dn->dn_struct_rwlock, RW_READER);
|
2015-12-22 01:31:57 +00:00
|
|
|
err = dbuf_hold_impl(dn, 0, start,
|
|
|
|
FALSE, FALSE, FTAG, &db);
|
2009-07-02 22:44:48 +00:00
|
|
|
rw_exit(&dn->dn_struct_rwlock);
|
2010-05-28 20:45:14 +00:00
|
|
|
|
|
|
|
if (err) {
|
|
|
|
txh->txh_tx->tx_err = err;
|
|
|
|
return;
|
2009-07-02 22:44:48 +00:00
|
|
|
}
|
2010-05-28 20:45:14 +00:00
|
|
|
|
|
|
|
dmu_tx_count_twig(txh, dn, db, 0, start, B_FALSE,
|
|
|
|
history);
|
2009-07-02 22:44:48 +00:00
|
|
|
dbuf_rele(db, FTAG);
|
|
|
|
if (++start > end) {
|
|
|
|
/*
|
|
|
|
* Account for new indirects appearing
|
|
|
|
* before this IO gets assigned into a txg.
|
|
|
|
*/
|
|
|
|
bits = 64 - min_bs;
|
|
|
|
epbs = min_ibs - SPA_BLKPTRSHIFT;
|
|
|
|
for (bits -= epbs * (nlvls - 1);
|
2017-01-23 17:36:24 +00:00
|
|
|
bits >= 0; bits -= epbs) {
|
|
|
|
(void) refcount_add_many(
|
|
|
|
&txh->txh_fudge,
|
|
|
|
1ULL << max_ibs, FTAG);
|
|
|
|
}
|
2009-07-02 22:44:48 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
off += delta;
|
|
|
|
if (len >= delta)
|
|
|
|
len -= delta;
|
|
|
|
delta = dn->dn_datablksz;
|
|
|
|
}
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 'end' is the last thing we will access, not one past.
|
|
|
|
* This way we won't overflow when accessing the last byte.
|
|
|
|
*/
|
|
|
|
start = P2ALIGN(off, 1ULL << max_bs);
|
|
|
|
end = P2ROUNDUP(off + len, 1ULL << max_bs) - 1;
|
2017-01-23 17:36:24 +00:00
|
|
|
(void) refcount_add_many(&txh->txh_space_towrite,
|
|
|
|
end - start + 1, FTAG);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
start >>= min_bs;
|
|
|
|
end >>= min_bs;
|
|
|
|
|
|
|
|
epbs = min_ibs - SPA_BLKPTRSHIFT;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The object contains at most 2^(64 - min_bs) blocks,
|
|
|
|
* and each indirect level maps 2^epbs.
|
|
|
|
*/
|
|
|
|
for (bits = 64 - min_bs; bits >= 0; bits -= epbs) {
|
|
|
|
start >>= epbs;
|
|
|
|
end >>= epbs;
|
2009-07-02 22:44:48 +00:00
|
|
|
ASSERT3U(end, >=, start);
|
2017-01-23 17:36:24 +00:00
|
|
|
(void) refcount_add_many(&txh->txh_space_towrite,
|
|
|
|
(end - start + 1) << max_ibs, FTAG);
|
2009-07-02 22:44:48 +00:00
|
|
|
if (start != 0) {
|
|
|
|
/*
|
|
|
|
* We also need a new blkid=0 indirect block
|
|
|
|
* to reference any existing file data.
|
|
|
|
*/
|
2017-01-23 17:36:24 +00:00
|
|
|
(void) refcount_add_many(&txh->txh_space_towrite,
|
|
|
|
1ULL << max_ibs, FTAG);
|
2009-07-02 22:44:48 +00:00
|
|
|
}
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2017-01-23 17:36:24 +00:00
|
|
|
if (refcount_count(&txh->txh_space_towrite) +
|
|
|
|
refcount_count(&txh->txh_space_tooverwrite) >
|
2009-07-02 22:44:48 +00:00
|
|
|
2 * DMU_MAX_ACCESS)
|
2013-03-08 18:41:28 +00:00
|
|
|
err = SET_ERROR(EFBIG);
|
2009-07-02 22:44:48 +00:00
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
if (err)
|
|
|
|
txh->txh_tx->tx_err = err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dmu_tx_count_dnode(dmu_tx_hold_t *txh)
|
|
|
|
{
|
|
|
|
dnode_t *dn = txh->txh_dnode;
|
2010-08-26 21:24:34 +00:00
|
|
|
dnode_t *mdn = DMU_META_DNODE(txh->txh_tx->tx_objset);
|
2008-11-20 20:01:55 +00:00
|
|
|
uint64_t space = mdn->dn_datablksz +
|
2016-10-13 21:25:05 +00:00
|
|
|
((uint64_t)(mdn->dn_nlevels-1) << mdn->dn_indblkshift);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
if (dn && dn->dn_dbuf->db_blkptr &&
|
|
|
|
dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset,
|
2010-05-28 20:45:14 +00:00
|
|
|
dn->dn_dbuf->db_blkptr, dn->dn_dbuf->db_blkptr->blk_birth)) {
|
2017-01-23 17:36:24 +00:00
|
|
|
(void) refcount_add_many(&txh->txh_space_tooverwrite,
|
|
|
|
space, FTAG);
|
|
|
|
(void) refcount_add_many(&txh->txh_space_tounref, space, FTAG);
|
2008-11-20 20:01:55 +00:00
|
|
|
} else {
|
2017-01-23 17:36:24 +00:00
|
|
|
(void) refcount_add_many(&txh->txh_space_towrite, space, FTAG);
|
|
|
|
if (dn && dn->dn_dbuf->db_blkptr) {
|
|
|
|
(void) refcount_add_many(&txh->txh_space_tounref,
|
|
|
|
space, FTAG);
|
|
|
|
}
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dmu_tx_hold_write(dmu_tx_t *tx, uint64_t object, uint64_t off, int len)
|
|
|
|
{
|
|
|
|
dmu_tx_hold_t *txh;
|
|
|
|
|
|
|
|
ASSERT(tx->tx_txg == 0);
|
2015-03-23 17:10:19 +00:00
|
|
|
ASSERT(len <= DMU_MAX_ACCESS);
|
2008-11-20 20:01:55 +00:00
|
|
|
ASSERT(len == 0 || UINT64_MAX - off >= len - 1);
|
|
|
|
|
|
|
|
txh = dmu_tx_hold_object_impl(tx, tx->tx_objset,
|
|
|
|
object, THT_WRITE, off, len);
|
|
|
|
if (txh == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
dmu_tx_count_write(txh, off, len);
|
|
|
|
dmu_tx_count_dnode(txh);
|
|
|
|
}
|
|
|
|
|
2017-01-13 22:58:41 +00:00
|
|
|
void
|
|
|
|
dmu_tx_hold_write_by_dnode(dmu_tx_t *tx, dnode_t *dn, uint64_t off, int len)
|
|
|
|
{
|
|
|
|
dmu_tx_hold_t *txh;
|
|
|
|
|
|
|
|
ASSERT(tx->tx_txg == 0);
|
|
|
|
ASSERT(len <= DMU_MAX_ACCESS);
|
|
|
|
ASSERT(len == 0 || UINT64_MAX - off >= len - 1);
|
|
|
|
|
|
|
|
txh = dmu_tx_hold_dnode_impl(tx, dn, THT_WRITE, off, len);
|
|
|
|
if (txh == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
dmu_tx_count_write(txh, off, len);
|
|
|
|
dmu_tx_count_dnode(txh);
|
|
|
|
}
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
static void
|
|
|
|
dmu_tx_count_free(dmu_tx_hold_t *txh, uint64_t off, uint64_t len)
|
|
|
|
{
|
2008-12-03 20:09:06 +00:00
|
|
|
uint64_t blkid, nblks, lastblk;
|
|
|
|
uint64_t space = 0, unref = 0, skipped = 0;
|
2008-11-20 20:01:55 +00:00
|
|
|
dnode_t *dn = txh->txh_dnode;
|
|
|
|
dsl_dataset_t *ds = dn->dn_objset->os_dsl_dataset;
|
|
|
|
spa_t *spa = txh->txh_tx->tx_pool->dp_spa;
|
2008-12-03 20:09:06 +00:00
|
|
|
int epbs;
|
2013-01-14 18:26:31 +00:00
|
|
|
uint64_t l0span = 0, nl1blks = 0;
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2008-12-03 20:09:06 +00:00
|
|
|
if (dn->dn_nlevels == 0)
|
2008-11-20 20:01:55 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
2008-12-03 20:09:06 +00:00
|
|
|
* The struct_rwlock protects us against dn_nlevels
|
2008-11-20 20:01:55 +00:00
|
|
|
* changing, in case (against all odds) we manage to dirty &
|
|
|
|
* sync out the changes after we check for being dirty.
|
2010-05-28 20:45:14 +00:00
|
|
|
* Also, dbuf_hold_impl() wants us to have the struct_rwlock.
|
2008-11-20 20:01:55 +00:00
|
|
|
*/
|
|
|
|
rw_enter(&dn->dn_struct_rwlock, RW_READER);
|
2008-12-03 20:09:06 +00:00
|
|
|
epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
|
|
|
|
if (dn->dn_maxblkid == 0) {
|
2008-11-20 20:01:55 +00:00
|
|
|
if (off == 0 && len >= dn->dn_datablksz) {
|
|
|
|
blkid = 0;
|
|
|
|
nblks = 1;
|
|
|
|
} else {
|
|
|
|
rw_exit(&dn->dn_struct_rwlock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
blkid = off >> dn->dn_datablkshift;
|
2008-12-03 20:09:06 +00:00
|
|
|
nblks = (len + dn->dn_datablksz - 1) >> dn->dn_datablkshift;
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2013-08-07 18:32:46 +00:00
|
|
|
if (blkid > dn->dn_maxblkid) {
|
2008-11-20 20:01:55 +00:00
|
|
|
rw_exit(&dn->dn_struct_rwlock);
|
|
|
|
return;
|
|
|
|
}
|
2008-12-03 20:09:06 +00:00
|
|
|
if (blkid + nblks > dn->dn_maxblkid)
|
2013-08-07 18:32:46 +00:00
|
|
|
nblks = dn->dn_maxblkid - blkid + 1;
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
}
|
2013-01-14 18:26:31 +00:00
|
|
|
l0span = nblks; /* save for later use to calc level > 1 overhead */
|
2008-12-03 20:09:06 +00:00
|
|
|
if (dn->dn_nlevels == 1) {
|
2008-11-20 20:01:55 +00:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < nblks; i++) {
|
|
|
|
blkptr_t *bp = dn->dn_phys->dn_blkptr;
|
2008-12-03 20:09:06 +00:00
|
|
|
ASSERT3U(blkid + i, <, dn->dn_nblkptr);
|
2008-11-20 20:01:55 +00:00
|
|
|
bp += blkid + i;
|
2010-05-28 20:45:14 +00:00
|
|
|
if (dsl_dataset_block_freeable(ds, bp, bp->blk_birth)) {
|
2008-11-20 20:01:55 +00:00
|
|
|
dprintf_bp(bp, "can free old%s", "");
|
2010-05-28 20:45:14 +00:00
|
|
|
space += bp_get_dsize(spa, bp);
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
unref += BP_GET_ASIZE(bp);
|
|
|
|
}
|
2013-01-14 18:26:31 +00:00
|
|
|
nl1blks = 1;
|
2008-11-20 20:01:55 +00:00
|
|
|
nblks = 0;
|
|
|
|
}
|
|
|
|
|
2008-12-03 20:09:06 +00:00
|
|
|
lastblk = blkid + nblks - 1;
|
2008-11-20 20:01:55 +00:00
|
|
|
while (nblks) {
|
|
|
|
dmu_buf_impl_t *dbuf;
|
2008-12-03 20:09:06 +00:00
|
|
|
uint64_t ibyte, new_blkid;
|
|
|
|
int epb = 1 << epbs;
|
|
|
|
int err, i, blkoff, tochk;
|
|
|
|
blkptr_t *bp;
|
|
|
|
|
|
|
|
ibyte = blkid << dn->dn_datablkshift;
|
|
|
|
err = dnode_next_offset(dn,
|
|
|
|
DNODE_FIND_HAVELOCK, &ibyte, 2, 1, 0);
|
|
|
|
new_blkid = ibyte >> dn->dn_datablkshift;
|
|
|
|
if (err == ESRCH) {
|
|
|
|
skipped += (lastblk >> epbs) - (blkid >> epbs) + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (err) {
|
|
|
|
txh->txh_tx->tx_err = err;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (new_blkid > lastblk) {
|
|
|
|
skipped += (lastblk >> epbs) - (blkid >> epbs) + 1;
|
|
|
|
break;
|
|
|
|
}
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2008-12-03 20:09:06 +00:00
|
|
|
if (new_blkid > blkid) {
|
|
|
|
ASSERT((new_blkid >> epbs) > (blkid >> epbs));
|
|
|
|
skipped += (new_blkid >> epbs) - (blkid >> epbs) - 1;
|
|
|
|
nblks -= new_blkid - blkid;
|
|
|
|
blkid = new_blkid;
|
|
|
|
}
|
|
|
|
blkoff = P2PHASE(blkid, epb);
|
|
|
|
tochk = MIN(epb - blkoff, nblks);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2015-12-22 01:31:57 +00:00
|
|
|
err = dbuf_hold_impl(dn, 1, blkid >> epbs,
|
|
|
|
FALSE, FALSE, FTAG, &dbuf);
|
2010-05-28 20:45:14 +00:00
|
|
|
if (err) {
|
|
|
|
txh->txh_tx->tx_err = err;
|
2008-12-03 20:09:06 +00:00
|
|
|
break;
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
2010-05-28 20:45:14 +00:00
|
|
|
|
2017-01-23 17:36:24 +00:00
|
|
|
(void) refcount_add_many(&txh->txh_memory_tohold,
|
|
|
|
dbuf->db.db_size, FTAG);
|
2010-05-28 20:45:14 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't check memory_tohold against DMU_MAX_ACCESS because
|
|
|
|
* memory_tohold is an over-estimation (especially the >L1
|
|
|
|
* indirect blocks), so it could fail. Callers should have
|
|
|
|
* already verified that they will not be holding too much
|
|
|
|
* memory.
|
|
|
|
*/
|
|
|
|
|
2008-12-03 20:09:06 +00:00
|
|
|
err = dbuf_read(dbuf, NULL, DB_RF_HAVESTRUCT | DB_RF_CANFAIL);
|
|
|
|
if (err != 0) {
|
2008-11-20 20:01:55 +00:00
|
|
|
txh->txh_tx->tx_err = err;
|
2008-12-03 20:09:06 +00:00
|
|
|
dbuf_rele(dbuf, FTAG);
|
2008-11-20 20:01:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-12-03 20:09:06 +00:00
|
|
|
bp = dbuf->db.db_data;
|
|
|
|
bp += blkoff;
|
|
|
|
|
|
|
|
for (i = 0; i < tochk; i++) {
|
2010-05-28 20:45:14 +00:00
|
|
|
if (dsl_dataset_block_freeable(ds, &bp[i],
|
|
|
|
bp[i].blk_birth)) {
|
2008-12-03 20:09:06 +00:00
|
|
|
dprintf_bp(&bp[i], "can free old%s", "");
|
2010-05-28 20:45:14 +00:00
|
|
|
space += bp_get_dsize(spa, &bp[i]);
|
2008-12-03 20:09:06 +00:00
|
|
|
}
|
|
|
|
unref += BP_GET_ASIZE(bp);
|
|
|
|
}
|
|
|
|
dbuf_rele(dbuf, FTAG);
|
|
|
|
|
2013-01-14 18:26:31 +00:00
|
|
|
++nl1blks;
|
2008-11-20 20:01:55 +00:00
|
|
|
blkid += tochk;
|
|
|
|
nblks -= tochk;
|
|
|
|
}
|
|
|
|
rw_exit(&dn->dn_struct_rwlock);
|
|
|
|
|
2013-01-14 18:26:31 +00:00
|
|
|
/*
|
|
|
|
* Add in memory requirements of higher-level indirects.
|
|
|
|
* This assumes a worst-possible scenario for dn_nlevels and a
|
|
|
|
* worst-possible distribution of l1-blocks over the region to free.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
uint64_t blkcnt = 1 + ((l0span >> epbs) >> epbs);
|
|
|
|
int level = 2;
|
|
|
|
/*
|
|
|
|
* Here we don't use DN_MAX_LEVEL, but calculate it with the
|
|
|
|
* given datablkshift and indblkshift. This makes the
|
|
|
|
* difference between 19 and 8 on large files.
|
|
|
|
*/
|
|
|
|
int maxlevel = 2 + (DN_MAX_OFFSET_SHIFT - dn->dn_datablkshift) /
|
|
|
|
(dn->dn_indblkshift - SPA_BLKPTRSHIFT);
|
|
|
|
|
|
|
|
while (level++ < maxlevel) {
|
2017-01-23 17:36:24 +00:00
|
|
|
(void) refcount_add_many(&txh->txh_memory_tohold,
|
|
|
|
MAX(MIN(blkcnt, nl1blks), 1) << dn->dn_indblkshift,
|
|
|
|
FTAG);
|
2013-01-14 18:26:31 +00:00
|
|
|
blkcnt = 1 + (blkcnt >> epbs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-03 20:09:06 +00:00
|
|
|
/* account for new level 1 indirect blocks that might show up */
|
|
|
|
if (skipped > 0) {
|
2017-01-23 17:36:24 +00:00
|
|
|
(void) refcount_add_many(&txh->txh_fudge,
|
|
|
|
skipped << dn->dn_indblkshift, FTAG);
|
2008-12-03 20:09:06 +00:00
|
|
|
skipped = MIN(skipped, DMU_MAX_DELETEBLKCNT >> epbs);
|
2017-01-23 17:36:24 +00:00
|
|
|
(void) refcount_add_many(&txh->txh_memory_tohold,
|
|
|
|
skipped << dn->dn_indblkshift, FTAG);
|
2008-12-03 20:09:06 +00:00
|
|
|
}
|
2017-01-23 17:36:24 +00:00
|
|
|
(void) refcount_add_many(&txh->txh_space_tofree, space, FTAG);
|
|
|
|
(void) refcount_add_many(&txh->txh_space_tounref, unref, FTAG);
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
|
2014-07-07 19:49:36 +00:00
|
|
|
/*
|
|
|
|
* This function marks the transaction as being a "net free". The end
|
|
|
|
* result is that refquotas will be disabled for this transaction, and
|
|
|
|
* this transaction will be able to use half of the pool space overhead
|
|
|
|
* (see dsl_pool_adjustedsize()). Therefore this function should only
|
|
|
|
* be called for transactions that we expect will not cause a net increase
|
|
|
|
* in the amount of space used (but it's OK if that is occasionally not true).
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
dmu_tx_mark_netfree(dmu_tx_t *tx)
|
|
|
|
{
|
|
|
|
dmu_tx_hold_t *txh;
|
|
|
|
|
|
|
|
txh = dmu_tx_hold_object_impl(tx, tx->tx_objset,
|
|
|
|
DMU_NEW_OBJECT, THT_FREE, 0, 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pretend that this operation will free 1GB of space. This
|
|
|
|
* should be large enough to cancel out the largest write.
|
|
|
|
* We don't want to use something like UINT64_MAX, because that would
|
|
|
|
* cause overflows when doing math with these values (e.g. in
|
|
|
|
* dmu_tx_try_assign()).
|
|
|
|
*/
|
2017-01-23 17:36:24 +00:00
|
|
|
(void) refcount_add_many(&txh->txh_space_tofree,
|
|
|
|
1024 * 1024 * 1024, FTAG);
|
|
|
|
(void) refcount_add_many(&txh->txh_space_tounref,
|
|
|
|
1024 * 1024 * 1024, FTAG);
|
2014-07-07 19:49:36 +00:00
|
|
|
}
|
|
|
|
|
2017-01-13 22:58:41 +00:00
|
|
|
static void
|
|
|
|
dmu_tx_hold_free_impl(dmu_tx_hold_t *txh, uint64_t off, uint64_t len)
|
2008-11-20 20:01:55 +00:00
|
|
|
{
|
2017-01-13 22:58:41 +00:00
|
|
|
dmu_tx_t *tx;
|
2008-11-20 20:01:55 +00:00
|
|
|
dnode_t *dn;
|
2013-07-29 18:58:53 +00:00
|
|
|
int err;
|
2008-11-20 20:01:55 +00:00
|
|
|
zio_t *zio;
|
|
|
|
|
2017-01-13 22:58:41 +00:00
|
|
|
tx = txh->txh_tx;
|
2008-11-20 20:01:55 +00:00
|
|
|
ASSERT(tx->tx_txg == 0);
|
|
|
|
|
|
|
|
dn = txh->txh_dnode;
|
Illumos #4045 write throttle & i/o scheduler performance work
4045 zfs write throttle & i/o scheduler performance work
1. The ZFS i/o scheduler (vdev_queue.c) now divides i/os into 5 classes: sync
read, sync write, async read, async write, and scrub/resilver. The scheduler
issues a number of concurrent i/os from each class to the device. Once a class
has been selected, an i/o is selected from this class using either an elevator
algorithem (async, scrub classes) or FIFO (sync classes). The number of
concurrent async write i/os is tuned dynamically based on i/o load, to achieve
good sync i/o latency when there is not a high load of writes, and good write
throughput when there is. See the block comment in vdev_queue.c (reproduced
below) for more details.
2. The write throttle (dsl_pool_tempreserve_space() and
txg_constrain_throughput()) is rewritten to produce much more consistent delays
when under constant load. The new write throttle is based on the amount of
dirty data, rather than guesses about future performance of the system. When
there is a lot of dirty data, each transaction (e.g. write() syscall) will be
delayed by the same small amount. This eliminates the "brick wall of wait"
that the old write throttle could hit, causing all transactions to wait several
seconds until the next txg opens. One of the keys to the new write throttle is
decrementing the amount of dirty data as i/o completes, rather than at the end
of spa_sync(). Note that the write throttle is only applied once the i/o
scheduler is issuing the maximum number of outstanding async writes. See the
block comments in dsl_pool.c and above dmu_tx_delay() (reproduced below) for
more details.
This diff has several other effects, including:
* the commonly-tuned global variable zfs_vdev_max_pending has been removed;
use per-class zfs_vdev_*_max_active values or zfs_vdev_max_active instead.
* the size of each txg (meaning the amount of dirty data written, and thus the
time it takes to write out) is now controlled differently. There is no longer
an explicit time goal; the primary determinant is amount of dirty data.
Systems that are under light or medium load will now often see that a txg is
always syncing, but the impact to performance (e.g. read latency) is minimal.
Tune zfs_dirty_data_max and zfs_dirty_data_sync to control this.
* zio_taskq_batch_pct = 75 -- Only use 75% of all CPUs for compression,
checksum, etc. This improves latency by not allowing these CPU-intensive tasks
to consume all CPU (on machines with at least 4 CPU's; the percentage is
rounded up).
--matt
APPENDIX: problems with the current i/o scheduler
The current ZFS i/o scheduler (vdev_queue.c) is deadline based. The problem
with this is that if there are always i/os pending, then certain classes of
i/os can see very long delays.
For example, if there are always synchronous reads outstanding, then no async
writes will be serviced until they become "past due". One symptom of this
situation is that each pass of the txg sync takes at least several seconds
(typically 3 seconds).
If many i/os become "past due" (their deadline is in the past), then we must
service all of these overdue i/os before any new i/os. This happens when we
enqueue a batch of async writes for the txg sync, with deadlines 2.5 seconds in
the future. If we can't complete all the i/os in 2.5 seconds (e.g. because
there were always reads pending), then these i/os will become past due. Now we
must service all the "async" writes (which could be hundreds of megabytes)
before we service any reads, introducing considerable latency to synchronous
i/os (reads or ZIL writes).
Notes on porting to ZFS on Linux:
- zio_t gained new members io_physdone and io_phys_children. Because
object caches in the Linux port call the constructor only once at
allocation time, objects may contain residual data when retrieved
from the cache. Therefore zio_create() was updated to zero out the two
new fields.
- vdev_mirror_pending() relied on the depth of the per-vdev pending queue
(vq->vq_pending_tree) to select the least-busy leaf vdev to read from.
This tree has been replaced by vq->vq_active_tree which is now used
for the same purpose.
- vdev_queue_init() used the value of zfs_vdev_max_pending to determine
the number of vdev I/O buffers to pre-allocate. That global no longer
exists, so we instead use the sum of the *_max_active values for each of
the five I/O classes described above.
- The Illumos implementation of dmu_tx_delay() delays a transaction by
sleeping in condition variable embedded in the thread
(curthread->t_delay_cv). We do not have an equivalent CV to use in
Linux, so this change replaced the delay logic with a wrapper called
zfs_sleep_until(). This wrapper could be adopted upstream and in other
downstream ports to abstract away operating system-specific delay logic.
- These tunables are added as module parameters, and descriptions added
to the zfs-module-parameters.5 man page.
spa_asize_inflation
zfs_deadman_synctime_ms
zfs_vdev_max_active
zfs_vdev_async_write_active_min_dirty_percent
zfs_vdev_async_write_active_max_dirty_percent
zfs_vdev_async_read_max_active
zfs_vdev_async_read_min_active
zfs_vdev_async_write_max_active
zfs_vdev_async_write_min_active
zfs_vdev_scrub_max_active
zfs_vdev_scrub_min_active
zfs_vdev_sync_read_max_active
zfs_vdev_sync_read_min_active
zfs_vdev_sync_write_max_active
zfs_vdev_sync_write_min_active
zfs_dirty_data_max_percent
zfs_delay_min_dirty_percent
zfs_dirty_data_max_max_percent
zfs_dirty_data_max
zfs_dirty_data_max_max
zfs_dirty_data_sync
zfs_delay_scale
The latter four have type unsigned long, whereas they are uint64_t in
Illumos. This accommodates Linux's module_param() supported types, but
means they may overflow on 32-bit architectures.
The values zfs_dirty_data_max and zfs_dirty_data_max_max are the most
likely to overflow on 32-bit systems, since they express physical RAM
sizes in bytes. In fact, Illumos initializes zfs_dirty_data_max_max to
2^32 which does overflow. To resolve that, this port instead initializes
it in arc_init() to 25% of physical RAM, and adds the tunable
zfs_dirty_data_max_max_percent to override that percentage. While this
solution doesn't completely avoid the overflow issue, it should be a
reasonable default for most systems, and the minority of affected
systems can work around the issue by overriding the defaults.
- Fixed reversed logic in comment above zfs_delay_scale declaration.
- Clarified comments in vdev_queue.c regarding when per-queue minimums take
effect.
- Replaced dmu_tx_write_limit in the dmu_tx kstat file
with dmu_tx_dirty_delay and dmu_tx_dirty_over_max. The first counts
how many times a transaction has been delayed because the pool dirty
data has exceeded zfs_delay_min_dirty_percent. The latter counts how
many times the pool dirty data has exceeded zfs_dirty_data_max (which
we expect to never happen).
- The original patch would have regressed the bug fixed in
zfsonlinux/zfs@c418410, which prevented users from setting the
zfs_vdev_aggregation_limit tuning larger than SPA_MAXBLOCKSIZE.
A similar fix is added to vdev_queue_aggregate().
- In vdev_queue_io_to_issue(), dynamically allocate 'zio_t search' on the
heap instead of the stack. In Linux we can't afford such large
structures on the stack.
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Ned Bass <bass6@llnl.gov>
Reviewed by: Brendan Gregg <brendan.gregg@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
References:
http://www.illumos.org/issues/4045
illumos/illumos-gate@69962b5647e4a8b9b14998733b765925381b727e
Ported-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1913
2013-08-29 03:01:20 +00:00
|
|
|
dmu_tx_count_dnode(txh);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
if (off >= (dn->dn_maxblkid+1) * dn->dn_datablksz)
|
|
|
|
return;
|
|
|
|
if (len == DMU_OBJECT_END)
|
|
|
|
len = (dn->dn_maxblkid+1) * dn->dn_datablksz - off;
|
|
|
|
|
2013-07-29 18:58:53 +00:00
|
|
|
dmu_tx_count_dnode(txh);
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/*
|
2013-07-29 18:58:53 +00:00
|
|
|
* For i/o error checking, we read the first and last level-0
|
|
|
|
* blocks if they are not aligned, and all the level-1 blocks.
|
|
|
|
*
|
|
|
|
* Note: dbuf_free_range() assumes that we have not instantiated
|
|
|
|
* any level-0 dbufs that will be completely freed. Therefore we must
|
|
|
|
* exercise care to not read or count the first and last blocks
|
|
|
|
* if they are blocksize-aligned.
|
|
|
|
*/
|
|
|
|
if (dn->dn_datablkshift == 0) {
|
2013-08-21 04:11:52 +00:00
|
|
|
if (off != 0 || len < dn->dn_datablksz)
|
2013-08-30 09:19:35 +00:00
|
|
|
dmu_tx_count_write(txh, 0, dn->dn_datablksz);
|
2013-07-29 18:58:53 +00:00
|
|
|
} else {
|
|
|
|
/* first block will be modified if it is not aligned */
|
|
|
|
if (!IS_P2ALIGNED(off, 1 << dn->dn_datablkshift))
|
|
|
|
dmu_tx_count_write(txh, off, 1);
|
|
|
|
/* last block will be modified if it is not aligned */
|
|
|
|
if (!IS_P2ALIGNED(off + len, 1 << dn->dn_datablkshift))
|
|
|
|
dmu_tx_count_write(txh, off+len, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check level-1 blocks.
|
2008-11-20 20:01:55 +00:00
|
|
|
*/
|
|
|
|
if (dn->dn_nlevels > 1) {
|
2013-07-29 18:58:53 +00:00
|
|
|
int shift = dn->dn_datablkshift + dn->dn_indblkshift -
|
2008-11-20 20:01:55 +00:00
|
|
|
SPA_BLKPTRSHIFT;
|
2013-07-29 18:58:53 +00:00
|
|
|
uint64_t start = off >> shift;
|
|
|
|
uint64_t end = (off + len) >> shift;
|
|
|
|
uint64_t i;
|
|
|
|
|
|
|
|
ASSERT(dn->dn_indblkshift != 0);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2014-01-31 15:52:11 +00:00
|
|
|
/*
|
|
|
|
* dnode_reallocate() can result in an object with indirect
|
|
|
|
* blocks having an odd data block size. In this case,
|
|
|
|
* just check the single block.
|
|
|
|
*/
|
|
|
|
if (dn->dn_datablkshift == 0)
|
|
|
|
start = end = 0;
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
zio = zio_root(tx->tx_pool->dp_spa,
|
|
|
|
NULL, NULL, ZIO_FLAG_CANFAIL);
|
|
|
|
for (i = start; i <= end; i++) {
|
|
|
|
uint64_t ibyte = i << shift;
|
2008-12-03 20:09:06 +00:00
|
|
|
err = dnode_next_offset(dn, 0, &ibyte, 2, 1, 0);
|
2008-11-20 20:01:55 +00:00
|
|
|
i = ibyte >> shift;
|
2015-07-02 16:23:20 +00:00
|
|
|
if (err == ESRCH || i > end)
|
2008-11-20 20:01:55 +00:00
|
|
|
break;
|
|
|
|
if (err) {
|
|
|
|
tx->tx_err = err;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = dmu_tx_check_ioerr(zio, dn, 1, i);
|
|
|
|
if (err) {
|
|
|
|
tx->tx_err = err;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err = zio_wait(zio);
|
|
|
|
if (err) {
|
|
|
|
tx->tx_err = err;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dmu_tx_count_free(txh, off, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-01-13 22:58:41 +00:00
|
|
|
dmu_tx_hold_free(dmu_tx_t *tx, uint64_t object, uint64_t off, uint64_t len)
|
|
|
|
{
|
|
|
|
dmu_tx_hold_t *txh;
|
|
|
|
|
|
|
|
txh = dmu_tx_hold_object_impl(tx, tx->tx_objset,
|
|
|
|
object, THT_FREE, off, len);
|
|
|
|
if (txh == NULL)
|
|
|
|
return;
|
|
|
|
(void) dmu_tx_hold_free_impl(txh, off, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dmu_tx_hold_free_by_dnode(dmu_tx_t *tx, dnode_t *dn, uint64_t off, uint64_t len)
|
2008-11-20 20:01:55 +00:00
|
|
|
{
|
|
|
|
dmu_tx_hold_t *txh;
|
2017-01-13 22:58:41 +00:00
|
|
|
|
|
|
|
txh = dmu_tx_hold_dnode_impl(tx, dn, THT_FREE, off, len);
|
|
|
|
if (txh == NULL)
|
|
|
|
return;
|
|
|
|
(void) dmu_tx_hold_free_impl(txh, off, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dmu_tx_hold_zap_impl(dmu_tx_hold_t *txh, int add, const char *name)
|
|
|
|
{
|
|
|
|
dmu_tx_t *tx = txh->txh_tx;
|
2008-11-20 20:01:55 +00:00
|
|
|
dnode_t *dn;
|
2017-01-23 17:36:24 +00:00
|
|
|
int err;
|
|
|
|
int epbs;
|
2015-04-01 15:14:34 +00:00
|
|
|
dsl_dataset_phys_t *ds_phys;
|
2017-01-23 17:36:24 +00:00
|
|
|
int lvl;
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
ASSERT(tx->tx_txg == 0);
|
|
|
|
|
|
|
|
dn = txh->txh_dnode;
|
|
|
|
|
|
|
|
dmu_tx_count_dnode(txh);
|
|
|
|
|
|
|
|
if (dn == NULL) {
|
|
|
|
/*
|
|
|
|
* We will be able to fit a new object's entries into one leaf
|
|
|
|
* block. So there will be at most 2 blocks total,
|
|
|
|
* including the header block.
|
|
|
|
*/
|
2016-11-07 22:54:32 +00:00
|
|
|
dmu_tx_count_write(txh, 0, 2ULL << fzap_default_block_shift);
|
2008-11-20 20:01:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-12-13 23:24:15 +00:00
|
|
|
ASSERT3U(DMU_OT_BYTESWAP(dn->dn_type), ==, DMU_BSWAP_ZAP);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
if (dn->dn_maxblkid == 0 && !add) {
|
2012-04-08 17:10:49 +00:00
|
|
|
blkptr_t *bp;
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* If there is only one block (i.e. this is a micro-zap)
|
|
|
|
* and we are not adding anything, the accounting is simple.
|
|
|
|
*/
|
|
|
|
err = dmu_tx_check_ioerr(NULL, dn, 0, 0);
|
|
|
|
if (err) {
|
|
|
|
tx->tx_err = err;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use max block size here, since we don't know how much
|
|
|
|
* the size will change between now and the dbuf dirty call.
|
|
|
|
*/
|
2012-04-08 17:10:49 +00:00
|
|
|
bp = &dn->dn_phys->dn_blkptr[0];
|
2008-11-20 20:01:55 +00:00
|
|
|
if (dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset,
|
2017-01-23 17:36:24 +00:00
|
|
|
bp, bp->blk_birth)) {
|
|
|
|
(void) refcount_add_many(&txh->txh_space_tooverwrite,
|
|
|
|
MZAP_MAX_BLKSZ, FTAG);
|
|
|
|
} else {
|
|
|
|
(void) refcount_add_many(&txh->txh_space_towrite,
|
|
|
|
MZAP_MAX_BLKSZ, FTAG);
|
|
|
|
}
|
|
|
|
if (!BP_IS_HOLE(bp)) {
|
|
|
|
(void) refcount_add_many(&txh->txh_space_tounref,
|
|
|
|
MZAP_MAX_BLKSZ, FTAG);
|
|
|
|
}
|
2008-11-20 20:01:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dn->dn_maxblkid > 0 && name) {
|
|
|
|
/*
|
|
|
|
* access the name in this fat-zap so that we'll check
|
|
|
|
* for i/o errors to the leaf blocks, etc.
|
|
|
|
*/
|
OpenZFS 7004 - dmu_tx_hold_zap() does dnode_hold() 7x on same object
Using a benchmark which has 32 threads creating 2 million files in the
same directory, on a machine with 16 CPU cores, I observed poor
performance. I noticed that dmu_tx_hold_zap() was using about 30% of
all CPU, and doing dnode_hold() 7 times on the same object (the ZAP
object that is being held).
dmu_tx_hold_zap() keeps a hold on the dnode_t the entire time it is
running, in dmu_tx_hold_t:txh_dnode, so it would be nice to use the
dnode_t that we already have in hand, rather than repeatedly calling
dnode_hold(). To do this, we need to pass the dnode_t down through
all the intermediate calls that dmu_tx_hold_zap() makes, making these
routines take the dnode_t* rather than an objset_t* and a uint64_t
object number. In particular, the following routines will need to have
analogous *_by_dnode() variants created:
dmu_buf_hold_noread()
dmu_buf_hold()
zap_lookup()
zap_lookup_norm()
zap_count_write()
zap_lockdir()
zap_count_write()
This can improve performance on the benchmark described above by 100%,
from 30,000 file creations per second to 60,000. (This improvement is on
top of that provided by working around the object allocation issue. Peak
performance of ~90,000 creations per second was observed with 8 CPUs;
adding CPUs past that decreased performance due to lock contention.) The
CPU used by dmu_tx_hold_zap() was reduced by 88%, from 340 CPU-seconds
to 40 CPU-seconds.
Sponsored by: Intel Corp.
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
OpenZFS-issue: https://www.illumos.org/issues/7004
OpenZFS-commit: https://github.com/openzfs/openzfs/pull/109
Closes #4641
Closes #4972
2016-07-20 22:42:13 +00:00
|
|
|
err = zap_lookup_by_dnode(dn, name, 8, 0, NULL);
|
2008-11-20 20:01:55 +00:00
|
|
|
if (err == EIO) {
|
|
|
|
tx->tx_err = err;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
OpenZFS 7004 - dmu_tx_hold_zap() does dnode_hold() 7x on same object
Using a benchmark which has 32 threads creating 2 million files in the
same directory, on a machine with 16 CPU cores, I observed poor
performance. I noticed that dmu_tx_hold_zap() was using about 30% of
all CPU, and doing dnode_hold() 7 times on the same object (the ZAP
object that is being held).
dmu_tx_hold_zap() keeps a hold on the dnode_t the entire time it is
running, in dmu_tx_hold_t:txh_dnode, so it would be nice to use the
dnode_t that we already have in hand, rather than repeatedly calling
dnode_hold(). To do this, we need to pass the dnode_t down through
all the intermediate calls that dmu_tx_hold_zap() makes, making these
routines take the dnode_t* rather than an objset_t* and a uint64_t
object number. In particular, the following routines will need to have
analogous *_by_dnode() variants created:
dmu_buf_hold_noread()
dmu_buf_hold()
zap_lookup()
zap_lookup_norm()
zap_count_write()
zap_lockdir()
zap_count_write()
This can improve performance on the benchmark described above by 100%,
from 30,000 file creations per second to 60,000. (This improvement is on
top of that provided by working around the object allocation issue. Peak
performance of ~90,000 creations per second was observed with 8 CPUs;
adding CPUs past that decreased performance due to lock contention.) The
CPU used by dmu_tx_hold_zap() was reduced by 88%, from 340 CPU-seconds
to 40 CPU-seconds.
Sponsored by: Intel Corp.
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
OpenZFS-issue: https://www.illumos.org/issues/7004
OpenZFS-commit: https://github.com/openzfs/openzfs/pull/109
Closes #4641
Closes #4972
2016-07-20 22:42:13 +00:00
|
|
|
err = zap_count_write_by_dnode(dn, name, add,
|
2009-08-18 18:43:27 +00:00
|
|
|
&txh->txh_space_towrite, &txh->txh_space_tooverwrite);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the modified blocks are scattered to the four winds,
|
2017-01-23 17:36:24 +00:00
|
|
|
* we'll have to modify an indirect twig for each. We can make
|
|
|
|
* modifications at up to 3 locations:
|
|
|
|
* - header block at the beginning of the object
|
|
|
|
* - target leaf block
|
|
|
|
* - end of the object, where we might need to write:
|
|
|
|
* - a new leaf block if the target block needs to be split
|
|
|
|
* - the new pointer table, if it is growing
|
|
|
|
* - the new cookie table, if it is growing
|
2008-11-20 20:01:55 +00:00
|
|
|
*/
|
|
|
|
epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
|
2017-01-23 17:36:24 +00:00
|
|
|
ds_phys =
|
|
|
|
dsl_dataset_phys(dn->dn_objset->os_dsl_dataset);
|
|
|
|
for (lvl = 1; lvl < dn->dn_nlevels; lvl++) {
|
|
|
|
uint64_t num_indirects = 1 + (dn->dn_maxblkid >> (epbs * lvl));
|
|
|
|
uint64_t spc = MIN(3, num_indirects) << dn->dn_indblkshift;
|
|
|
|
if (ds_phys->ds_prev_snap_obj != 0) {
|
|
|
|
(void) refcount_add_many(&txh->txh_space_towrite,
|
|
|
|
spc, FTAG);
|
|
|
|
} else {
|
|
|
|
(void) refcount_add_many(&txh->txh_space_tooverwrite,
|
|
|
|
spc, FTAG);
|
|
|
|
}
|
|
|
|
}
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
|
2017-01-13 22:58:41 +00:00
|
|
|
void
|
|
|
|
dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t object, int add, const char *name)
|
|
|
|
{
|
|
|
|
dmu_tx_hold_t *txh;
|
|
|
|
|
|
|
|
ASSERT(tx->tx_txg == 0);
|
|
|
|
|
|
|
|
txh = dmu_tx_hold_object_impl(tx, tx->tx_objset,
|
|
|
|
object, THT_ZAP, add, (uintptr_t)name);
|
|
|
|
if (txh == NULL)
|
|
|
|
return;
|
|
|
|
dmu_tx_hold_zap_impl(txh, add, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dmu_tx_hold_zap_by_dnode(dmu_tx_t *tx, dnode_t *dn, int add, const char *name)
|
|
|
|
{
|
|
|
|
dmu_tx_hold_t *txh;
|
|
|
|
|
|
|
|
ASSERT(tx->tx_txg == 0);
|
|
|
|
ASSERT(dn != NULL);
|
|
|
|
|
|
|
|
txh = dmu_tx_hold_dnode_impl(tx, dn, THT_ZAP, add, (uintptr_t)name);
|
|
|
|
if (txh == NULL)
|
|
|
|
return;
|
|
|
|
dmu_tx_hold_zap_impl(txh, add, name);
|
|
|
|
}
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
void
|
|
|
|
dmu_tx_hold_bonus(dmu_tx_t *tx, uint64_t object)
|
|
|
|
{
|
|
|
|
dmu_tx_hold_t *txh;
|
|
|
|
|
|
|
|
ASSERT(tx->tx_txg == 0);
|
|
|
|
|
|
|
|
txh = dmu_tx_hold_object_impl(tx, tx->tx_objset,
|
|
|
|
object, THT_BONUS, 0, 0);
|
|
|
|
if (txh)
|
|
|
|
dmu_tx_count_dnode(txh);
|
|
|
|
}
|
|
|
|
|
2017-01-13 22:58:41 +00:00
|
|
|
void
|
|
|
|
dmu_tx_hold_bonus_by_dnode(dmu_tx_t *tx, dnode_t *dn)
|
|
|
|
{
|
|
|
|
dmu_tx_hold_t *txh;
|
|
|
|
|
|
|
|
ASSERT(tx->tx_txg == 0);
|
|
|
|
|
|
|
|
txh = dmu_tx_hold_dnode_impl(tx, dn, THT_BONUS, 0, 0);
|
|
|
|
if (txh)
|
|
|
|
dmu_tx_count_dnode(txh);
|
|
|
|
}
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
void
|
|
|
|
dmu_tx_hold_space(dmu_tx_t *tx, uint64_t space)
|
|
|
|
{
|
|
|
|
dmu_tx_hold_t *txh;
|
2013-07-23 17:32:57 +00:00
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
ASSERT(tx->tx_txg == 0);
|
|
|
|
|
|
|
|
txh = dmu_tx_hold_object_impl(tx, tx->tx_objset,
|
|
|
|
DMU_NEW_OBJECT, THT_SPACE, space, 0);
|
2013-07-23 17:32:57 +00:00
|
|
|
if (txh)
|
2017-01-23 17:36:24 +00:00
|
|
|
(void) refcount_add_many(&txh->txh_space_towrite, space, FTAG);
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
dmu_tx_holds(dmu_tx_t *tx, uint64_t object)
|
|
|
|
{
|
|
|
|
dmu_tx_hold_t *txh;
|
|
|
|
int holds = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* By asserting that the tx is assigned, we're counting the
|
|
|
|
* number of dn_tx_holds, which is the same as the number of
|
|
|
|
* dn_holds. Otherwise, we'd be counting dn_holds, but
|
|
|
|
* dn_tx_holds could be 0.
|
|
|
|
*/
|
|
|
|
ASSERT(tx->tx_txg != 0);
|
|
|
|
|
|
|
|
/* if (tx->tx_anyobj == TRUE) */
|
|
|
|
/* return (0); */
|
|
|
|
|
|
|
|
for (txh = list_head(&tx->tx_holds); txh;
|
|
|
|
txh = list_next(&tx->tx_holds, txh)) {
|
|
|
|
if (txh->txh_dnode && txh->txh_dnode->dn_object == object)
|
|
|
|
holds++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (holds);
|
|
|
|
}
|
|
|
|
|
2012-03-20 23:00:17 +00:00
|
|
|
#ifdef DEBUG_DMU_TX
|
2008-11-20 20:01:55 +00:00
|
|
|
void
|
|
|
|
dmu_tx_dirty_buf(dmu_tx_t *tx, dmu_buf_impl_t *db)
|
|
|
|
{
|
|
|
|
dmu_tx_hold_t *txh;
|
|
|
|
int match_object = FALSE, match_offset = FALSE;
|
2010-08-26 21:24:34 +00:00
|
|
|
dnode_t *dn;
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2010-08-26 21:24:34 +00:00
|
|
|
DB_DNODE_ENTER(db);
|
|
|
|
dn = DB_DNODE(db);
|
2012-03-12 19:38:00 +00:00
|
|
|
ASSERT(dn != NULL);
|
2008-11-20 20:01:55 +00:00
|
|
|
ASSERT(tx->tx_txg != 0);
|
2010-05-28 20:45:14 +00:00
|
|
|
ASSERT(tx->tx_objset == NULL || dn->dn_objset == tx->tx_objset);
|
2008-11-20 20:01:55 +00:00
|
|
|
ASSERT3U(dn->dn_object, ==, db->db.db_object);
|
|
|
|
|
2010-08-26 21:24:34 +00:00
|
|
|
if (tx->tx_anyobj) {
|
|
|
|
DB_DNODE_EXIT(db);
|
2008-11-20 20:01:55 +00:00
|
|
|
return;
|
2010-08-26 21:24:34 +00:00
|
|
|
}
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
/* XXX No checking on the meta dnode for now */
|
2010-08-26 21:24:34 +00:00
|
|
|
if (db->db.db_object == DMU_META_DNODE_OBJECT) {
|
|
|
|
DB_DNODE_EXIT(db);
|
2008-11-20 20:01:55 +00:00
|
|
|
return;
|
2010-08-26 21:24:34 +00:00
|
|
|
}
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
for (txh = list_head(&tx->tx_holds); txh;
|
|
|
|
txh = list_next(&tx->tx_holds, txh)) {
|
2012-03-12 19:38:00 +00:00
|
|
|
ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg);
|
2008-11-20 20:01:55 +00:00
|
|
|
if (txh->txh_dnode == dn && txh->txh_type != THT_NEWOBJECT)
|
|
|
|
match_object = TRUE;
|
|
|
|
if (txh->txh_dnode == NULL || txh->txh_dnode == dn) {
|
|
|
|
int datablkshift = dn->dn_datablkshift ?
|
|
|
|
dn->dn_datablkshift : SPA_MAXBLOCKSHIFT;
|
|
|
|
int epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
|
|
|
|
int shift = datablkshift + epbs * db->db_level;
|
|
|
|
uint64_t beginblk = shift >= 64 ? 0 :
|
|
|
|
(txh->txh_arg1 >> shift);
|
|
|
|
uint64_t endblk = shift >= 64 ? 0 :
|
|
|
|
((txh->txh_arg1 + txh->txh_arg2 - 1) >> shift);
|
|
|
|
uint64_t blkid = db->db_blkid;
|
|
|
|
|
|
|
|
/* XXX txh_arg2 better not be zero... */
|
|
|
|
|
|
|
|
dprintf("found txh type %x beginblk=%llx endblk=%llx\n",
|
|
|
|
txh->txh_type, beginblk, endblk);
|
|
|
|
|
|
|
|
switch (txh->txh_type) {
|
|
|
|
case THT_WRITE:
|
|
|
|
if (blkid >= beginblk && blkid <= endblk)
|
|
|
|
match_offset = TRUE;
|
|
|
|
/*
|
|
|
|
* We will let this hold work for the bonus
|
2010-05-28 20:45:14 +00:00
|
|
|
* or spill buffer so that we don't need to
|
|
|
|
* hold it when creating a new object.
|
2008-11-20 20:01:55 +00:00
|
|
|
*/
|
2010-05-28 20:45:14 +00:00
|
|
|
if (blkid == DMU_BONUS_BLKID ||
|
|
|
|
blkid == DMU_SPILL_BLKID)
|
2008-11-20 20:01:55 +00:00
|
|
|
match_offset = TRUE;
|
|
|
|
/*
|
|
|
|
* They might have to increase nlevels,
|
|
|
|
* thus dirtying the new TLIBs. Or the
|
|
|
|
* might have to change the block size,
|
|
|
|
* thus dirying the new lvl=0 blk=0.
|
|
|
|
*/
|
|
|
|
if (blkid == 0)
|
|
|
|
match_offset = TRUE;
|
|
|
|
break;
|
|
|
|
case THT_FREE:
|
2008-12-03 20:09:06 +00:00
|
|
|
/*
|
|
|
|
* We will dirty all the level 1 blocks in
|
|
|
|
* the free range and perhaps the first and
|
|
|
|
* last level 0 block.
|
|
|
|
*/
|
|
|
|
if (blkid >= beginblk && (blkid <= endblk ||
|
|
|
|
txh->txh_arg2 == DMU_OBJECT_END))
|
2008-11-20 20:01:55 +00:00
|
|
|
match_offset = TRUE;
|
|
|
|
break;
|
2010-05-28 20:45:14 +00:00
|
|
|
case THT_SPILL:
|
|
|
|
if (blkid == DMU_SPILL_BLKID)
|
|
|
|
match_offset = TRUE;
|
|
|
|
break;
|
2008-11-20 20:01:55 +00:00
|
|
|
case THT_BONUS:
|
2010-05-28 20:45:14 +00:00
|
|
|
if (blkid == DMU_BONUS_BLKID)
|
2008-11-20 20:01:55 +00:00
|
|
|
match_offset = TRUE;
|
|
|
|
break;
|
|
|
|
case THT_ZAP:
|
|
|
|
match_offset = TRUE;
|
|
|
|
break;
|
|
|
|
case THT_NEWOBJECT:
|
|
|
|
match_object = TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
2015-02-27 20:53:35 +00:00
|
|
|
cmn_err(CE_PANIC, "bad txh_type %d",
|
|
|
|
txh->txh_type);
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
}
|
2010-08-26 21:24:34 +00:00
|
|
|
if (match_object && match_offset) {
|
|
|
|
DB_DNODE_EXIT(db);
|
2008-11-20 20:01:55 +00:00
|
|
|
return;
|
2010-08-26 21:24:34 +00:00
|
|
|
}
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
2010-08-26 21:24:34 +00:00
|
|
|
DB_DNODE_EXIT(db);
|
2008-11-20 20:01:55 +00:00
|
|
|
panic("dirtying dbuf obj=%llx lvl=%u blkid=%llx but not tx_held\n",
|
|
|
|
(u_longlong_t)db->db.db_object, db->db_level,
|
|
|
|
(u_longlong_t)db->db_blkid);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
Illumos #4045 write throttle & i/o scheduler performance work
4045 zfs write throttle & i/o scheduler performance work
1. The ZFS i/o scheduler (vdev_queue.c) now divides i/os into 5 classes: sync
read, sync write, async read, async write, and scrub/resilver. The scheduler
issues a number of concurrent i/os from each class to the device. Once a class
has been selected, an i/o is selected from this class using either an elevator
algorithem (async, scrub classes) or FIFO (sync classes). The number of
concurrent async write i/os is tuned dynamically based on i/o load, to achieve
good sync i/o latency when there is not a high load of writes, and good write
throughput when there is. See the block comment in vdev_queue.c (reproduced
below) for more details.
2. The write throttle (dsl_pool_tempreserve_space() and
txg_constrain_throughput()) is rewritten to produce much more consistent delays
when under constant load. The new write throttle is based on the amount of
dirty data, rather than guesses about future performance of the system. When
there is a lot of dirty data, each transaction (e.g. write() syscall) will be
delayed by the same small amount. This eliminates the "brick wall of wait"
that the old write throttle could hit, causing all transactions to wait several
seconds until the next txg opens. One of the keys to the new write throttle is
decrementing the amount of dirty data as i/o completes, rather than at the end
of spa_sync(). Note that the write throttle is only applied once the i/o
scheduler is issuing the maximum number of outstanding async writes. See the
block comments in dsl_pool.c and above dmu_tx_delay() (reproduced below) for
more details.
This diff has several other effects, including:
* the commonly-tuned global variable zfs_vdev_max_pending has been removed;
use per-class zfs_vdev_*_max_active values or zfs_vdev_max_active instead.
* the size of each txg (meaning the amount of dirty data written, and thus the
time it takes to write out) is now controlled differently. There is no longer
an explicit time goal; the primary determinant is amount of dirty data.
Systems that are under light or medium load will now often see that a txg is
always syncing, but the impact to performance (e.g. read latency) is minimal.
Tune zfs_dirty_data_max and zfs_dirty_data_sync to control this.
* zio_taskq_batch_pct = 75 -- Only use 75% of all CPUs for compression,
checksum, etc. This improves latency by not allowing these CPU-intensive tasks
to consume all CPU (on machines with at least 4 CPU's; the percentage is
rounded up).
--matt
APPENDIX: problems with the current i/o scheduler
The current ZFS i/o scheduler (vdev_queue.c) is deadline based. The problem
with this is that if there are always i/os pending, then certain classes of
i/os can see very long delays.
For example, if there are always synchronous reads outstanding, then no async
writes will be serviced until they become "past due". One symptom of this
situation is that each pass of the txg sync takes at least several seconds
(typically 3 seconds).
If many i/os become "past due" (their deadline is in the past), then we must
service all of these overdue i/os before any new i/os. This happens when we
enqueue a batch of async writes for the txg sync, with deadlines 2.5 seconds in
the future. If we can't complete all the i/os in 2.5 seconds (e.g. because
there were always reads pending), then these i/os will become past due. Now we
must service all the "async" writes (which could be hundreds of megabytes)
before we service any reads, introducing considerable latency to synchronous
i/os (reads or ZIL writes).
Notes on porting to ZFS on Linux:
- zio_t gained new members io_physdone and io_phys_children. Because
object caches in the Linux port call the constructor only once at
allocation time, objects may contain residual data when retrieved
from the cache. Therefore zio_create() was updated to zero out the two
new fields.
- vdev_mirror_pending() relied on the depth of the per-vdev pending queue
(vq->vq_pending_tree) to select the least-busy leaf vdev to read from.
This tree has been replaced by vq->vq_active_tree which is now used
for the same purpose.
- vdev_queue_init() used the value of zfs_vdev_max_pending to determine
the number of vdev I/O buffers to pre-allocate. That global no longer
exists, so we instead use the sum of the *_max_active values for each of
the five I/O classes described above.
- The Illumos implementation of dmu_tx_delay() delays a transaction by
sleeping in condition variable embedded in the thread
(curthread->t_delay_cv). We do not have an equivalent CV to use in
Linux, so this change replaced the delay logic with a wrapper called
zfs_sleep_until(). This wrapper could be adopted upstream and in other
downstream ports to abstract away operating system-specific delay logic.
- These tunables are added as module parameters, and descriptions added
to the zfs-module-parameters.5 man page.
spa_asize_inflation
zfs_deadman_synctime_ms
zfs_vdev_max_active
zfs_vdev_async_write_active_min_dirty_percent
zfs_vdev_async_write_active_max_dirty_percent
zfs_vdev_async_read_max_active
zfs_vdev_async_read_min_active
zfs_vdev_async_write_max_active
zfs_vdev_async_write_min_active
zfs_vdev_scrub_max_active
zfs_vdev_scrub_min_active
zfs_vdev_sync_read_max_active
zfs_vdev_sync_read_min_active
zfs_vdev_sync_write_max_active
zfs_vdev_sync_write_min_active
zfs_dirty_data_max_percent
zfs_delay_min_dirty_percent
zfs_dirty_data_max_max_percent
zfs_dirty_data_max
zfs_dirty_data_max_max
zfs_dirty_data_sync
zfs_delay_scale
The latter four have type unsigned long, whereas they are uint64_t in
Illumos. This accommodates Linux's module_param() supported types, but
means they may overflow on 32-bit architectures.
The values zfs_dirty_data_max and zfs_dirty_data_max_max are the most
likely to overflow on 32-bit systems, since they express physical RAM
sizes in bytes. In fact, Illumos initializes zfs_dirty_data_max_max to
2^32 which does overflow. To resolve that, this port instead initializes
it in arc_init() to 25% of physical RAM, and adds the tunable
zfs_dirty_data_max_max_percent to override that percentage. While this
solution doesn't completely avoid the overflow issue, it should be a
reasonable default for most systems, and the minority of affected
systems can work around the issue by overriding the defaults.
- Fixed reversed logic in comment above zfs_delay_scale declaration.
- Clarified comments in vdev_queue.c regarding when per-queue minimums take
effect.
- Replaced dmu_tx_write_limit in the dmu_tx kstat file
with dmu_tx_dirty_delay and dmu_tx_dirty_over_max. The first counts
how many times a transaction has been delayed because the pool dirty
data has exceeded zfs_delay_min_dirty_percent. The latter counts how
many times the pool dirty data has exceeded zfs_dirty_data_max (which
we expect to never happen).
- The original patch would have regressed the bug fixed in
zfsonlinux/zfs@c418410, which prevented users from setting the
zfs_vdev_aggregation_limit tuning larger than SPA_MAXBLOCKSIZE.
A similar fix is added to vdev_queue_aggregate().
- In vdev_queue_io_to_issue(), dynamically allocate 'zio_t search' on the
heap instead of the stack. In Linux we can't afford such large
structures on the stack.
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Ned Bass <bass6@llnl.gov>
Reviewed by: Brendan Gregg <brendan.gregg@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
References:
http://www.illumos.org/issues/4045
illumos/illumos-gate@69962b5647e4a8b9b14998733b765925381b727e
Ported-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1913
2013-08-29 03:01:20 +00:00
|
|
|
/*
|
|
|
|
* If we can't do 10 iops, something is wrong. Let us go ahead
|
|
|
|
* and hit zfs_dirty_data_max.
|
|
|
|
*/
|
|
|
|
hrtime_t zfs_delay_max_ns = 100 * MICROSEC; /* 100 milliseconds */
|
|
|
|
int zfs_delay_resolution_ns = 100 * 1000; /* 100 microseconds */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We delay transactions when we've determined that the backend storage
|
|
|
|
* isn't able to accommodate the rate of incoming writes.
|
|
|
|
*
|
|
|
|
* If there is already a transaction waiting, we delay relative to when
|
|
|
|
* that transaction finishes waiting. This way the calculated min_time
|
|
|
|
* is independent of the number of threads concurrently executing
|
|
|
|
* transactions.
|
|
|
|
*
|
|
|
|
* If we are the only waiter, wait relative to when the transaction
|
|
|
|
* started, rather than the current time. This credits the transaction for
|
|
|
|
* "time already served", e.g. reading indirect blocks.
|
|
|
|
*
|
|
|
|
* The minimum time for a transaction to take is calculated as:
|
|
|
|
* min_time = scale * (dirty - min) / (max - dirty)
|
|
|
|
* min_time is then capped at zfs_delay_max_ns.
|
|
|
|
*
|
|
|
|
* The delay has two degrees of freedom that can be adjusted via tunables.
|
|
|
|
* The percentage of dirty data at which we start to delay is defined by
|
|
|
|
* zfs_delay_min_dirty_percent. This should typically be at or above
|
|
|
|
* zfs_vdev_async_write_active_max_dirty_percent so that we only start to
|
|
|
|
* delay after writing at full speed has failed to keep up with the incoming
|
|
|
|
* write rate. The scale of the curve is defined by zfs_delay_scale. Roughly
|
|
|
|
* speaking, this variable determines the amount of delay at the midpoint of
|
|
|
|
* the curve.
|
|
|
|
*
|
|
|
|
* delay
|
|
|
|
* 10ms +-------------------------------------------------------------*+
|
|
|
|
* | *|
|
|
|
|
* 9ms + *+
|
|
|
|
* | *|
|
|
|
|
* 8ms + *+
|
|
|
|
* | * |
|
|
|
|
* 7ms + * +
|
|
|
|
* | * |
|
|
|
|
* 6ms + * +
|
|
|
|
* | * |
|
|
|
|
* 5ms + * +
|
|
|
|
* | * |
|
|
|
|
* 4ms + * +
|
|
|
|
* | * |
|
|
|
|
* 3ms + * +
|
|
|
|
* | * |
|
|
|
|
* 2ms + (midpoint) * +
|
|
|
|
* | | ** |
|
|
|
|
* 1ms + v *** +
|
|
|
|
* | zfs_delay_scale ----------> ******** |
|
|
|
|
* 0 +-------------------------------------*********----------------+
|
|
|
|
* 0% <- zfs_dirty_data_max -> 100%
|
|
|
|
*
|
|
|
|
* Note that since the delay is added to the outstanding time remaining on the
|
|
|
|
* most recent transaction, the delay is effectively the inverse of IOPS.
|
|
|
|
* Here the midpoint of 500us translates to 2000 IOPS. The shape of the curve
|
|
|
|
* was chosen such that small changes in the amount of accumulated dirty data
|
|
|
|
* in the first 3/4 of the curve yield relatively small differences in the
|
|
|
|
* amount of delay.
|
|
|
|
*
|
|
|
|
* The effects can be easier to understand when the amount of delay is
|
|
|
|
* represented on a log scale:
|
|
|
|
*
|
|
|
|
* delay
|
|
|
|
* 100ms +-------------------------------------------------------------++
|
|
|
|
* + +
|
|
|
|
* | |
|
|
|
|
* + *+
|
|
|
|
* 10ms + *+
|
|
|
|
* + ** +
|
|
|
|
* | (midpoint) ** |
|
|
|
|
* + | ** +
|
|
|
|
* 1ms + v **** +
|
|
|
|
* + zfs_delay_scale ----------> ***** +
|
|
|
|
* | **** |
|
|
|
|
* + **** +
|
|
|
|
* 100us + ** +
|
|
|
|
* + * +
|
|
|
|
* | * |
|
|
|
|
* + * +
|
|
|
|
* 10us + * +
|
|
|
|
* + +
|
|
|
|
* | |
|
|
|
|
* + +
|
|
|
|
* +--------------------------------------------------------------+
|
|
|
|
* 0% <- zfs_dirty_data_max -> 100%
|
|
|
|
*
|
|
|
|
* Note here that only as the amount of dirty data approaches its limit does
|
|
|
|
* the delay start to increase rapidly. The goal of a properly tuned system
|
|
|
|
* should be to keep the amount of dirty data out of that range by first
|
|
|
|
* ensuring that the appropriate limits are set for the I/O scheduler to reach
|
|
|
|
* optimal throughput on the backend storage, and then by changing the value
|
|
|
|
* of zfs_delay_scale to increase the steepness of the curve.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
dmu_tx_delay(dmu_tx_t *tx, uint64_t dirty)
|
|
|
|
{
|
|
|
|
dsl_pool_t *dp = tx->tx_pool;
|
|
|
|
uint64_t delay_min_bytes =
|
|
|
|
zfs_dirty_data_max * zfs_delay_min_dirty_percent / 100;
|
|
|
|
hrtime_t wakeup, min_tx_time, now;
|
|
|
|
|
|
|
|
if (dirty <= delay_min_bytes)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The caller has already waited until we are under the max.
|
|
|
|
* We make them pass us the amount of dirty data so we don't
|
|
|
|
* have to handle the case of it being >= the max, which could
|
|
|
|
* cause a divide-by-zero if it's == the max.
|
|
|
|
*/
|
|
|
|
ASSERT3U(dirty, <, zfs_dirty_data_max);
|
|
|
|
|
|
|
|
now = gethrtime();
|
|
|
|
min_tx_time = zfs_delay_scale *
|
|
|
|
(dirty - delay_min_bytes) / (zfs_dirty_data_max - dirty);
|
|
|
|
min_tx_time = MIN(min_tx_time, zfs_delay_max_ns);
|
|
|
|
if (now > tx->tx_start + min_tx_time)
|
|
|
|
return;
|
|
|
|
|
|
|
|
DTRACE_PROBE3(delay__mintime, dmu_tx_t *, tx, uint64_t, dirty,
|
|
|
|
uint64_t, min_tx_time);
|
|
|
|
|
|
|
|
mutex_enter(&dp->dp_lock);
|
|
|
|
wakeup = MAX(tx->tx_start + min_tx_time,
|
|
|
|
dp->dp_last_wakeup + min_tx_time);
|
|
|
|
dp->dp_last_wakeup = wakeup;
|
|
|
|
mutex_exit(&dp->dp_lock);
|
|
|
|
|
|
|
|
zfs_sleep_until(wakeup);
|
|
|
|
}
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
static int
|
2013-09-04 12:00:57 +00:00
|
|
|
dmu_tx_try_assign(dmu_tx_t *tx, txg_how_t txg_how)
|
2008-11-20 20:01:55 +00:00
|
|
|
{
|
|
|
|
dmu_tx_hold_t *txh;
|
|
|
|
spa_t *spa = tx->tx_pool->dp_spa;
|
2008-12-03 20:09:06 +00:00
|
|
|
uint64_t memory, asize, fsize, usize;
|
|
|
|
uint64_t towrite, tofree, tooverwrite, tounref, tohold, fudge;
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2013-05-10 21:17:03 +00:00
|
|
|
ASSERT0(tx->tx_txg);
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2012-01-20 18:58:57 +00:00
|
|
|
if (tx->tx_err) {
|
|
|
|
DMU_TX_STAT_BUMP(dmu_tx_error);
|
2008-11-20 20:01:55 +00:00
|
|
|
return (tx->tx_err);
|
2012-01-20 18:58:57 +00:00
|
|
|
}
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2008-12-03 20:09:06 +00:00
|
|
|
if (spa_suspended(spa)) {
|
2012-01-20 18:58:57 +00:00
|
|
|
DMU_TX_STAT_BUMP(dmu_tx_suspended);
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
/*
|
|
|
|
* If the user has indicated a blocking failure mode
|
|
|
|
* then return ERESTART which will block in dmu_tx_wait().
|
|
|
|
* Otherwise, return EIO so that an error can get
|
|
|
|
* propagated back to the VOP calls.
|
|
|
|
*
|
|
|
|
* Note that we always honor the txg_how flag regardless
|
|
|
|
* of the failuremode setting.
|
|
|
|
*/
|
|
|
|
if (spa_get_failmode(spa) == ZIO_FAILURE_MODE_CONTINUE &&
|
|
|
|
txg_how != TXG_WAIT)
|
2013-03-08 18:41:28 +00:00
|
|
|
return (SET_ERROR(EIO));
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2013-03-08 18:41:28 +00:00
|
|
|
return (SET_ERROR(ERESTART));
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
|
Illumos #4045 write throttle & i/o scheduler performance work
4045 zfs write throttle & i/o scheduler performance work
1. The ZFS i/o scheduler (vdev_queue.c) now divides i/os into 5 classes: sync
read, sync write, async read, async write, and scrub/resilver. The scheduler
issues a number of concurrent i/os from each class to the device. Once a class
has been selected, an i/o is selected from this class using either an elevator
algorithem (async, scrub classes) or FIFO (sync classes). The number of
concurrent async write i/os is tuned dynamically based on i/o load, to achieve
good sync i/o latency when there is not a high load of writes, and good write
throughput when there is. See the block comment in vdev_queue.c (reproduced
below) for more details.
2. The write throttle (dsl_pool_tempreserve_space() and
txg_constrain_throughput()) is rewritten to produce much more consistent delays
when under constant load. The new write throttle is based on the amount of
dirty data, rather than guesses about future performance of the system. When
there is a lot of dirty data, each transaction (e.g. write() syscall) will be
delayed by the same small amount. This eliminates the "brick wall of wait"
that the old write throttle could hit, causing all transactions to wait several
seconds until the next txg opens. One of the keys to the new write throttle is
decrementing the amount of dirty data as i/o completes, rather than at the end
of spa_sync(). Note that the write throttle is only applied once the i/o
scheduler is issuing the maximum number of outstanding async writes. See the
block comments in dsl_pool.c and above dmu_tx_delay() (reproduced below) for
more details.
This diff has several other effects, including:
* the commonly-tuned global variable zfs_vdev_max_pending has been removed;
use per-class zfs_vdev_*_max_active values or zfs_vdev_max_active instead.
* the size of each txg (meaning the amount of dirty data written, and thus the
time it takes to write out) is now controlled differently. There is no longer
an explicit time goal; the primary determinant is amount of dirty data.
Systems that are under light or medium load will now often see that a txg is
always syncing, but the impact to performance (e.g. read latency) is minimal.
Tune zfs_dirty_data_max and zfs_dirty_data_sync to control this.
* zio_taskq_batch_pct = 75 -- Only use 75% of all CPUs for compression,
checksum, etc. This improves latency by not allowing these CPU-intensive tasks
to consume all CPU (on machines with at least 4 CPU's; the percentage is
rounded up).
--matt
APPENDIX: problems with the current i/o scheduler
The current ZFS i/o scheduler (vdev_queue.c) is deadline based. The problem
with this is that if there are always i/os pending, then certain classes of
i/os can see very long delays.
For example, if there are always synchronous reads outstanding, then no async
writes will be serviced until they become "past due". One symptom of this
situation is that each pass of the txg sync takes at least several seconds
(typically 3 seconds).
If many i/os become "past due" (their deadline is in the past), then we must
service all of these overdue i/os before any new i/os. This happens when we
enqueue a batch of async writes for the txg sync, with deadlines 2.5 seconds in
the future. If we can't complete all the i/os in 2.5 seconds (e.g. because
there were always reads pending), then these i/os will become past due. Now we
must service all the "async" writes (which could be hundreds of megabytes)
before we service any reads, introducing considerable latency to synchronous
i/os (reads or ZIL writes).
Notes on porting to ZFS on Linux:
- zio_t gained new members io_physdone and io_phys_children. Because
object caches in the Linux port call the constructor only once at
allocation time, objects may contain residual data when retrieved
from the cache. Therefore zio_create() was updated to zero out the two
new fields.
- vdev_mirror_pending() relied on the depth of the per-vdev pending queue
(vq->vq_pending_tree) to select the least-busy leaf vdev to read from.
This tree has been replaced by vq->vq_active_tree which is now used
for the same purpose.
- vdev_queue_init() used the value of zfs_vdev_max_pending to determine
the number of vdev I/O buffers to pre-allocate. That global no longer
exists, so we instead use the sum of the *_max_active values for each of
the five I/O classes described above.
- The Illumos implementation of dmu_tx_delay() delays a transaction by
sleeping in condition variable embedded in the thread
(curthread->t_delay_cv). We do not have an equivalent CV to use in
Linux, so this change replaced the delay logic with a wrapper called
zfs_sleep_until(). This wrapper could be adopted upstream and in other
downstream ports to abstract away operating system-specific delay logic.
- These tunables are added as module parameters, and descriptions added
to the zfs-module-parameters.5 man page.
spa_asize_inflation
zfs_deadman_synctime_ms
zfs_vdev_max_active
zfs_vdev_async_write_active_min_dirty_percent
zfs_vdev_async_write_active_max_dirty_percent
zfs_vdev_async_read_max_active
zfs_vdev_async_read_min_active
zfs_vdev_async_write_max_active
zfs_vdev_async_write_min_active
zfs_vdev_scrub_max_active
zfs_vdev_scrub_min_active
zfs_vdev_sync_read_max_active
zfs_vdev_sync_read_min_active
zfs_vdev_sync_write_max_active
zfs_vdev_sync_write_min_active
zfs_dirty_data_max_percent
zfs_delay_min_dirty_percent
zfs_dirty_data_max_max_percent
zfs_dirty_data_max
zfs_dirty_data_max_max
zfs_dirty_data_sync
zfs_delay_scale
The latter four have type unsigned long, whereas they are uint64_t in
Illumos. This accommodates Linux's module_param() supported types, but
means they may overflow on 32-bit architectures.
The values zfs_dirty_data_max and zfs_dirty_data_max_max are the most
likely to overflow on 32-bit systems, since they express physical RAM
sizes in bytes. In fact, Illumos initializes zfs_dirty_data_max_max to
2^32 which does overflow. To resolve that, this port instead initializes
it in arc_init() to 25% of physical RAM, and adds the tunable
zfs_dirty_data_max_max_percent to override that percentage. While this
solution doesn't completely avoid the overflow issue, it should be a
reasonable default for most systems, and the minority of affected
systems can work around the issue by overriding the defaults.
- Fixed reversed logic in comment above zfs_delay_scale declaration.
- Clarified comments in vdev_queue.c regarding when per-queue minimums take
effect.
- Replaced dmu_tx_write_limit in the dmu_tx kstat file
with dmu_tx_dirty_delay and dmu_tx_dirty_over_max. The first counts
how many times a transaction has been delayed because the pool dirty
data has exceeded zfs_delay_min_dirty_percent. The latter counts how
many times the pool dirty data has exceeded zfs_dirty_data_max (which
we expect to never happen).
- The original patch would have regressed the bug fixed in
zfsonlinux/zfs@c418410, which prevented users from setting the
zfs_vdev_aggregation_limit tuning larger than SPA_MAXBLOCKSIZE.
A similar fix is added to vdev_queue_aggregate().
- In vdev_queue_io_to_issue(), dynamically allocate 'zio_t search' on the
heap instead of the stack. In Linux we can't afford such large
structures on the stack.
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Ned Bass <bass6@llnl.gov>
Reviewed by: Brendan Gregg <brendan.gregg@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
References:
http://www.illumos.org/issues/4045
illumos/illumos-gate@69962b5647e4a8b9b14998733b765925381b727e
Ported-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1913
2013-08-29 03:01:20 +00:00
|
|
|
if (!tx->tx_waited &&
|
|
|
|
dsl_pool_need_dirty_delay(tx->tx_pool)) {
|
|
|
|
tx->tx_wait_dirty = B_TRUE;
|
|
|
|
DMU_TX_STAT_BUMP(dmu_tx_dirty_delay);
|
|
|
|
return (ERESTART);
|
|
|
|
}
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
tx->tx_txg = txg_hold_open(tx->tx_pool, &tx->tx_txgh);
|
|
|
|
tx->tx_needassign_txh = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NB: No error returns are allowed after txg_hold_open, but
|
|
|
|
* before processing the dnode holds, due to the
|
|
|
|
* dmu_tx_unassign() logic.
|
|
|
|
*/
|
|
|
|
|
2008-12-03 20:09:06 +00:00
|
|
|
towrite = tofree = tooverwrite = tounref = tohold = fudge = 0;
|
2008-11-20 20:01:55 +00:00
|
|
|
for (txh = list_head(&tx->tx_holds); txh;
|
|
|
|
txh = list_next(&tx->tx_holds, txh)) {
|
|
|
|
dnode_t *dn = txh->txh_dnode;
|
|
|
|
if (dn != NULL) {
|
|
|
|
mutex_enter(&dn->dn_mtx);
|
|
|
|
if (dn->dn_assigned_txg == tx->tx_txg - 1) {
|
|
|
|
mutex_exit(&dn->dn_mtx);
|
|
|
|
tx->tx_needassign_txh = txh;
|
2012-01-20 18:58:57 +00:00
|
|
|
DMU_TX_STAT_BUMP(dmu_tx_group);
|
2013-03-08 18:41:28 +00:00
|
|
|
return (SET_ERROR(ERESTART));
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
if (dn->dn_assigned_txg == 0)
|
|
|
|
dn->dn_assigned_txg = tx->tx_txg;
|
|
|
|
ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg);
|
|
|
|
(void) refcount_add(&dn->dn_tx_holds, tx);
|
|
|
|
mutex_exit(&dn->dn_mtx);
|
|
|
|
}
|
2017-01-23 17:36:24 +00:00
|
|
|
towrite += refcount_count(&txh->txh_space_towrite);
|
|
|
|
tofree += refcount_count(&txh->txh_space_tofree);
|
|
|
|
tooverwrite += refcount_count(&txh->txh_space_tooverwrite);
|
|
|
|
tounref += refcount_count(&txh->txh_space_tounref);
|
|
|
|
tohold += refcount_count(&txh->txh_memory_tohold);
|
|
|
|
fudge += refcount_count(&txh->txh_fudge);
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If a snapshot has been taken since we made our estimates,
|
|
|
|
* assume that we won't be able to free or overwrite anything.
|
|
|
|
*/
|
|
|
|
if (tx->tx_objset &&
|
2010-05-28 20:45:14 +00:00
|
|
|
dsl_dataset_prev_snap_txg(tx->tx_objset->os_dsl_dataset) >
|
2008-11-20 20:01:55 +00:00
|
|
|
tx->tx_lastsnap_txg) {
|
|
|
|
towrite += tooverwrite;
|
|
|
|
tooverwrite = tofree = 0;
|
|
|
|
}
|
|
|
|
|
2008-12-03 20:09:06 +00:00
|
|
|
/* needed allocation: worst-case estimate of write space */
|
|
|
|
asize = spa_get_asize(tx->tx_pool->dp_spa, towrite + tooverwrite);
|
|
|
|
/* freed space estimate: worst-case overwrite + free estimate */
|
2008-11-20 20:01:55 +00:00
|
|
|
fsize = spa_get_asize(tx->tx_pool->dp_spa, tooverwrite) + tofree;
|
2008-12-03 20:09:06 +00:00
|
|
|
/* convert unrefd space to worst-case estimate */
|
2008-11-20 20:01:55 +00:00
|
|
|
usize = spa_get_asize(tx->tx_pool->dp_spa, tounref);
|
2008-12-03 20:09:06 +00:00
|
|
|
/* calculate memory footprint estimate */
|
|
|
|
memory = towrite + tooverwrite + tohold;
|
2008-11-20 20:01:55 +00:00
|
|
|
|
2012-03-20 23:00:17 +00:00
|
|
|
#ifdef DEBUG_DMU_TX
|
2008-12-03 20:09:06 +00:00
|
|
|
/*
|
|
|
|
* Add in 'tohold' to account for our dirty holds on this memory
|
|
|
|
* XXX - the "fudge" factor is to account for skipped blocks that
|
|
|
|
* we missed because dnode_next_offset() misses in-core-only blocks.
|
|
|
|
*/
|
|
|
|
tx->tx_space_towrite = asize +
|
|
|
|
spa_get_asize(tx->tx_pool->dp_spa, tohold + fudge);
|
2008-11-20 20:01:55 +00:00
|
|
|
tx->tx_space_tofree = tofree;
|
|
|
|
tx->tx_space_tooverwrite = tooverwrite;
|
|
|
|
tx->tx_space_tounref = tounref;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (tx->tx_dir && asize != 0) {
|
2008-12-03 20:09:06 +00:00
|
|
|
int err = dsl_dir_tempreserve_space(tx->tx_dir, memory,
|
|
|
|
asize, fsize, usize, &tx->tx_tempreserve_cookie, tx);
|
2008-11-20 20:01:55 +00:00
|
|
|
if (err)
|
|
|
|
return (err);
|
|
|
|
}
|
|
|
|
|
2012-01-20 18:58:57 +00:00
|
|
|
DMU_TX_STAT_BUMP(dmu_tx_assigned);
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dmu_tx_unassign(dmu_tx_t *tx)
|
|
|
|
{
|
|
|
|
dmu_tx_hold_t *txh;
|
|
|
|
|
|
|
|
if (tx->tx_txg == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
txg_rele_to_quiesce(&tx->tx_txgh);
|
|
|
|
|
2013-06-11 17:12:34 +00:00
|
|
|
/*
|
|
|
|
* Walk the transaction's hold list, removing the hold on the
|
|
|
|
* associated dnode, and notifying waiters if the refcount drops to 0.
|
|
|
|
*/
|
2016-11-01 17:20:24 +00:00
|
|
|
for (txh = list_head(&tx->tx_holds);
|
|
|
|
txh && txh != tx->tx_needassign_txh;
|
2008-11-20 20:01:55 +00:00
|
|
|
txh = list_next(&tx->tx_holds, txh)) {
|
|
|
|
dnode_t *dn = txh->txh_dnode;
|
|
|
|
|
|
|
|
if (dn == NULL)
|
|
|
|
continue;
|
|
|
|
mutex_enter(&dn->dn_mtx);
|
|
|
|
ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg);
|
|
|
|
|
|
|
|
if (refcount_remove(&dn->dn_tx_holds, tx) == 0) {
|
|
|
|
dn->dn_assigned_txg = 0;
|
|
|
|
cv_broadcast(&dn->dn_notxholds);
|
|
|
|
}
|
|
|
|
mutex_exit(&dn->dn_mtx);
|
|
|
|
}
|
|
|
|
|
|
|
|
txg_rele_to_sync(&tx->tx_txgh);
|
|
|
|
|
|
|
|
tx->tx_lasttried_txg = tx->tx_txg;
|
|
|
|
tx->tx_txg = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assign tx to a transaction group. txg_how can be one of:
|
|
|
|
*
|
|
|
|
* (1) TXG_WAIT. If the current open txg is full, waits until there's
|
|
|
|
* a new one. This should be used when you're not holding locks.
|
2013-09-04 12:00:57 +00:00
|
|
|
* It will only fail if we're truly out of space (or over quota).
|
2008-11-20 20:01:55 +00:00
|
|
|
*
|
|
|
|
* (2) TXG_NOWAIT. If we can't assign into the current open txg without
|
|
|
|
* blocking, returns immediately with ERESTART. This should be used
|
|
|
|
* whenever you're holding locks. On an ERESTART error, the caller
|
|
|
|
* should drop locks, do a dmu_tx_wait(tx), and try again.
|
Illumos #4045 write throttle & i/o scheduler performance work
4045 zfs write throttle & i/o scheduler performance work
1. The ZFS i/o scheduler (vdev_queue.c) now divides i/os into 5 classes: sync
read, sync write, async read, async write, and scrub/resilver. The scheduler
issues a number of concurrent i/os from each class to the device. Once a class
has been selected, an i/o is selected from this class using either an elevator
algorithem (async, scrub classes) or FIFO (sync classes). The number of
concurrent async write i/os is tuned dynamically based on i/o load, to achieve
good sync i/o latency when there is not a high load of writes, and good write
throughput when there is. See the block comment in vdev_queue.c (reproduced
below) for more details.
2. The write throttle (dsl_pool_tempreserve_space() and
txg_constrain_throughput()) is rewritten to produce much more consistent delays
when under constant load. The new write throttle is based on the amount of
dirty data, rather than guesses about future performance of the system. When
there is a lot of dirty data, each transaction (e.g. write() syscall) will be
delayed by the same small amount. This eliminates the "brick wall of wait"
that the old write throttle could hit, causing all transactions to wait several
seconds until the next txg opens. One of the keys to the new write throttle is
decrementing the amount of dirty data as i/o completes, rather than at the end
of spa_sync(). Note that the write throttle is only applied once the i/o
scheduler is issuing the maximum number of outstanding async writes. See the
block comments in dsl_pool.c and above dmu_tx_delay() (reproduced below) for
more details.
This diff has several other effects, including:
* the commonly-tuned global variable zfs_vdev_max_pending has been removed;
use per-class zfs_vdev_*_max_active values or zfs_vdev_max_active instead.
* the size of each txg (meaning the amount of dirty data written, and thus the
time it takes to write out) is now controlled differently. There is no longer
an explicit time goal; the primary determinant is amount of dirty data.
Systems that are under light or medium load will now often see that a txg is
always syncing, but the impact to performance (e.g. read latency) is minimal.
Tune zfs_dirty_data_max and zfs_dirty_data_sync to control this.
* zio_taskq_batch_pct = 75 -- Only use 75% of all CPUs for compression,
checksum, etc. This improves latency by not allowing these CPU-intensive tasks
to consume all CPU (on machines with at least 4 CPU's; the percentage is
rounded up).
--matt
APPENDIX: problems with the current i/o scheduler
The current ZFS i/o scheduler (vdev_queue.c) is deadline based. The problem
with this is that if there are always i/os pending, then certain classes of
i/os can see very long delays.
For example, if there are always synchronous reads outstanding, then no async
writes will be serviced until they become "past due". One symptom of this
situation is that each pass of the txg sync takes at least several seconds
(typically 3 seconds).
If many i/os become "past due" (their deadline is in the past), then we must
service all of these overdue i/os before any new i/os. This happens when we
enqueue a batch of async writes for the txg sync, with deadlines 2.5 seconds in
the future. If we can't complete all the i/os in 2.5 seconds (e.g. because
there were always reads pending), then these i/os will become past due. Now we
must service all the "async" writes (which could be hundreds of megabytes)
before we service any reads, introducing considerable latency to synchronous
i/os (reads or ZIL writes).
Notes on porting to ZFS on Linux:
- zio_t gained new members io_physdone and io_phys_children. Because
object caches in the Linux port call the constructor only once at
allocation time, objects may contain residual data when retrieved
from the cache. Therefore zio_create() was updated to zero out the two
new fields.
- vdev_mirror_pending() relied on the depth of the per-vdev pending queue
(vq->vq_pending_tree) to select the least-busy leaf vdev to read from.
This tree has been replaced by vq->vq_active_tree which is now used
for the same purpose.
- vdev_queue_init() used the value of zfs_vdev_max_pending to determine
the number of vdev I/O buffers to pre-allocate. That global no longer
exists, so we instead use the sum of the *_max_active values for each of
the five I/O classes described above.
- The Illumos implementation of dmu_tx_delay() delays a transaction by
sleeping in condition variable embedded in the thread
(curthread->t_delay_cv). We do not have an equivalent CV to use in
Linux, so this change replaced the delay logic with a wrapper called
zfs_sleep_until(). This wrapper could be adopted upstream and in other
downstream ports to abstract away operating system-specific delay logic.
- These tunables are added as module parameters, and descriptions added
to the zfs-module-parameters.5 man page.
spa_asize_inflation
zfs_deadman_synctime_ms
zfs_vdev_max_active
zfs_vdev_async_write_active_min_dirty_percent
zfs_vdev_async_write_active_max_dirty_percent
zfs_vdev_async_read_max_active
zfs_vdev_async_read_min_active
zfs_vdev_async_write_max_active
zfs_vdev_async_write_min_active
zfs_vdev_scrub_max_active
zfs_vdev_scrub_min_active
zfs_vdev_sync_read_max_active
zfs_vdev_sync_read_min_active
zfs_vdev_sync_write_max_active
zfs_vdev_sync_write_min_active
zfs_dirty_data_max_percent
zfs_delay_min_dirty_percent
zfs_dirty_data_max_max_percent
zfs_dirty_data_max
zfs_dirty_data_max_max
zfs_dirty_data_sync
zfs_delay_scale
The latter four have type unsigned long, whereas they are uint64_t in
Illumos. This accommodates Linux's module_param() supported types, but
means they may overflow on 32-bit architectures.
The values zfs_dirty_data_max and zfs_dirty_data_max_max are the most
likely to overflow on 32-bit systems, since they express physical RAM
sizes in bytes. In fact, Illumos initializes zfs_dirty_data_max_max to
2^32 which does overflow. To resolve that, this port instead initializes
it in arc_init() to 25% of physical RAM, and adds the tunable
zfs_dirty_data_max_max_percent to override that percentage. While this
solution doesn't completely avoid the overflow issue, it should be a
reasonable default for most systems, and the minority of affected
systems can work around the issue by overriding the defaults.
- Fixed reversed logic in comment above zfs_delay_scale declaration.
- Clarified comments in vdev_queue.c regarding when per-queue minimums take
effect.
- Replaced dmu_tx_write_limit in the dmu_tx kstat file
with dmu_tx_dirty_delay and dmu_tx_dirty_over_max. The first counts
how many times a transaction has been delayed because the pool dirty
data has exceeded zfs_delay_min_dirty_percent. The latter counts how
many times the pool dirty data has exceeded zfs_dirty_data_max (which
we expect to never happen).
- The original patch would have regressed the bug fixed in
zfsonlinux/zfs@c418410, which prevented users from setting the
zfs_vdev_aggregation_limit tuning larger than SPA_MAXBLOCKSIZE.
A similar fix is added to vdev_queue_aggregate().
- In vdev_queue_io_to_issue(), dynamically allocate 'zio_t search' on the
heap instead of the stack. In Linux we can't afford such large
structures on the stack.
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Ned Bass <bass6@llnl.gov>
Reviewed by: Brendan Gregg <brendan.gregg@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
References:
http://www.illumos.org/issues/4045
illumos/illumos-gate@69962b5647e4a8b9b14998733b765925381b727e
Ported-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1913
2013-08-29 03:01:20 +00:00
|
|
|
*
|
|
|
|
* (3) TXG_WAITED. Like TXG_NOWAIT, but indicates that dmu_tx_wait()
|
|
|
|
* has already been called on behalf of this operation (though
|
|
|
|
* most likely on a different tx).
|
2008-11-20 20:01:55 +00:00
|
|
|
*/
|
|
|
|
int
|
2013-09-04 12:00:57 +00:00
|
|
|
dmu_tx_assign(dmu_tx_t *tx, txg_how_t txg_how)
|
2008-11-20 20:01:55 +00:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
ASSERT(tx->tx_txg == 0);
|
Illumos #4045 write throttle & i/o scheduler performance work
4045 zfs write throttle & i/o scheduler performance work
1. The ZFS i/o scheduler (vdev_queue.c) now divides i/os into 5 classes: sync
read, sync write, async read, async write, and scrub/resilver. The scheduler
issues a number of concurrent i/os from each class to the device. Once a class
has been selected, an i/o is selected from this class using either an elevator
algorithem (async, scrub classes) or FIFO (sync classes). The number of
concurrent async write i/os is tuned dynamically based on i/o load, to achieve
good sync i/o latency when there is not a high load of writes, and good write
throughput when there is. See the block comment in vdev_queue.c (reproduced
below) for more details.
2. The write throttle (dsl_pool_tempreserve_space() and
txg_constrain_throughput()) is rewritten to produce much more consistent delays
when under constant load. The new write throttle is based on the amount of
dirty data, rather than guesses about future performance of the system. When
there is a lot of dirty data, each transaction (e.g. write() syscall) will be
delayed by the same small amount. This eliminates the "brick wall of wait"
that the old write throttle could hit, causing all transactions to wait several
seconds until the next txg opens. One of the keys to the new write throttle is
decrementing the amount of dirty data as i/o completes, rather than at the end
of spa_sync(). Note that the write throttle is only applied once the i/o
scheduler is issuing the maximum number of outstanding async writes. See the
block comments in dsl_pool.c and above dmu_tx_delay() (reproduced below) for
more details.
This diff has several other effects, including:
* the commonly-tuned global variable zfs_vdev_max_pending has been removed;
use per-class zfs_vdev_*_max_active values or zfs_vdev_max_active instead.
* the size of each txg (meaning the amount of dirty data written, and thus the
time it takes to write out) is now controlled differently. There is no longer
an explicit time goal; the primary determinant is amount of dirty data.
Systems that are under light or medium load will now often see that a txg is
always syncing, but the impact to performance (e.g. read latency) is minimal.
Tune zfs_dirty_data_max and zfs_dirty_data_sync to control this.
* zio_taskq_batch_pct = 75 -- Only use 75% of all CPUs for compression,
checksum, etc. This improves latency by not allowing these CPU-intensive tasks
to consume all CPU (on machines with at least 4 CPU's; the percentage is
rounded up).
--matt
APPENDIX: problems with the current i/o scheduler
The current ZFS i/o scheduler (vdev_queue.c) is deadline based. The problem
with this is that if there are always i/os pending, then certain classes of
i/os can see very long delays.
For example, if there are always synchronous reads outstanding, then no async
writes will be serviced until they become "past due". One symptom of this
situation is that each pass of the txg sync takes at least several seconds
(typically 3 seconds).
If many i/os become "past due" (their deadline is in the past), then we must
service all of these overdue i/os before any new i/os. This happens when we
enqueue a batch of async writes for the txg sync, with deadlines 2.5 seconds in
the future. If we can't complete all the i/os in 2.5 seconds (e.g. because
there were always reads pending), then these i/os will become past due. Now we
must service all the "async" writes (which could be hundreds of megabytes)
before we service any reads, introducing considerable latency to synchronous
i/os (reads or ZIL writes).
Notes on porting to ZFS on Linux:
- zio_t gained new members io_physdone and io_phys_children. Because
object caches in the Linux port call the constructor only once at
allocation time, objects may contain residual data when retrieved
from the cache. Therefore zio_create() was updated to zero out the two
new fields.
- vdev_mirror_pending() relied on the depth of the per-vdev pending queue
(vq->vq_pending_tree) to select the least-busy leaf vdev to read from.
This tree has been replaced by vq->vq_active_tree which is now used
for the same purpose.
- vdev_queue_init() used the value of zfs_vdev_max_pending to determine
the number of vdev I/O buffers to pre-allocate. That global no longer
exists, so we instead use the sum of the *_max_active values for each of
the five I/O classes described above.
- The Illumos implementation of dmu_tx_delay() delays a transaction by
sleeping in condition variable embedded in the thread
(curthread->t_delay_cv). We do not have an equivalent CV to use in
Linux, so this change replaced the delay logic with a wrapper called
zfs_sleep_until(). This wrapper could be adopted upstream and in other
downstream ports to abstract away operating system-specific delay logic.
- These tunables are added as module parameters, and descriptions added
to the zfs-module-parameters.5 man page.
spa_asize_inflation
zfs_deadman_synctime_ms
zfs_vdev_max_active
zfs_vdev_async_write_active_min_dirty_percent
zfs_vdev_async_write_active_max_dirty_percent
zfs_vdev_async_read_max_active
zfs_vdev_async_read_min_active
zfs_vdev_async_write_max_active
zfs_vdev_async_write_min_active
zfs_vdev_scrub_max_active
zfs_vdev_scrub_min_active
zfs_vdev_sync_read_max_active
zfs_vdev_sync_read_min_active
zfs_vdev_sync_write_max_active
zfs_vdev_sync_write_min_active
zfs_dirty_data_max_percent
zfs_delay_min_dirty_percent
zfs_dirty_data_max_max_percent
zfs_dirty_data_max
zfs_dirty_data_max_max
zfs_dirty_data_sync
zfs_delay_scale
The latter four have type unsigned long, whereas they are uint64_t in
Illumos. This accommodates Linux's module_param() supported types, but
means they may overflow on 32-bit architectures.
The values zfs_dirty_data_max and zfs_dirty_data_max_max are the most
likely to overflow on 32-bit systems, since they express physical RAM
sizes in bytes. In fact, Illumos initializes zfs_dirty_data_max_max to
2^32 which does overflow. To resolve that, this port instead initializes
it in arc_init() to 25% of physical RAM, and adds the tunable
zfs_dirty_data_max_max_percent to override that percentage. While this
solution doesn't completely avoid the overflow issue, it should be a
reasonable default for most systems, and the minority of affected
systems can work around the issue by overriding the defaults.
- Fixed reversed logic in comment above zfs_delay_scale declaration.
- Clarified comments in vdev_queue.c regarding when per-queue minimums take
effect.
- Replaced dmu_tx_write_limit in the dmu_tx kstat file
with dmu_tx_dirty_delay and dmu_tx_dirty_over_max. The first counts
how many times a transaction has been delayed because the pool dirty
data has exceeded zfs_delay_min_dirty_percent. The latter counts how
many times the pool dirty data has exceeded zfs_dirty_data_max (which
we expect to never happen).
- The original patch would have regressed the bug fixed in
zfsonlinux/zfs@c418410, which prevented users from setting the
zfs_vdev_aggregation_limit tuning larger than SPA_MAXBLOCKSIZE.
A similar fix is added to vdev_queue_aggregate().
- In vdev_queue_io_to_issue(), dynamically allocate 'zio_t search' on the
heap instead of the stack. In Linux we can't afford such large
structures on the stack.
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Ned Bass <bass6@llnl.gov>
Reviewed by: Brendan Gregg <brendan.gregg@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
References:
http://www.illumos.org/issues/4045
illumos/illumos-gate@69962b5647e4a8b9b14998733b765925381b727e
Ported-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1913
2013-08-29 03:01:20 +00:00
|
|
|
ASSERT(txg_how == TXG_WAIT || txg_how == TXG_NOWAIT ||
|
|
|
|
txg_how == TXG_WAITED);
|
2008-11-20 20:01:55 +00:00
|
|
|
ASSERT(!dsl_pool_sync_context(tx->tx_pool));
|
|
|
|
|
Illumos #4045 write throttle & i/o scheduler performance work
4045 zfs write throttle & i/o scheduler performance work
1. The ZFS i/o scheduler (vdev_queue.c) now divides i/os into 5 classes: sync
read, sync write, async read, async write, and scrub/resilver. The scheduler
issues a number of concurrent i/os from each class to the device. Once a class
has been selected, an i/o is selected from this class using either an elevator
algorithem (async, scrub classes) or FIFO (sync classes). The number of
concurrent async write i/os is tuned dynamically based on i/o load, to achieve
good sync i/o latency when there is not a high load of writes, and good write
throughput when there is. See the block comment in vdev_queue.c (reproduced
below) for more details.
2. The write throttle (dsl_pool_tempreserve_space() and
txg_constrain_throughput()) is rewritten to produce much more consistent delays
when under constant load. The new write throttle is based on the amount of
dirty data, rather than guesses about future performance of the system. When
there is a lot of dirty data, each transaction (e.g. write() syscall) will be
delayed by the same small amount. This eliminates the "brick wall of wait"
that the old write throttle could hit, causing all transactions to wait several
seconds until the next txg opens. One of the keys to the new write throttle is
decrementing the amount of dirty data as i/o completes, rather than at the end
of spa_sync(). Note that the write throttle is only applied once the i/o
scheduler is issuing the maximum number of outstanding async writes. See the
block comments in dsl_pool.c and above dmu_tx_delay() (reproduced below) for
more details.
This diff has several other effects, including:
* the commonly-tuned global variable zfs_vdev_max_pending has been removed;
use per-class zfs_vdev_*_max_active values or zfs_vdev_max_active instead.
* the size of each txg (meaning the amount of dirty data written, and thus the
time it takes to write out) is now controlled differently. There is no longer
an explicit time goal; the primary determinant is amount of dirty data.
Systems that are under light or medium load will now often see that a txg is
always syncing, but the impact to performance (e.g. read latency) is minimal.
Tune zfs_dirty_data_max and zfs_dirty_data_sync to control this.
* zio_taskq_batch_pct = 75 -- Only use 75% of all CPUs for compression,
checksum, etc. This improves latency by not allowing these CPU-intensive tasks
to consume all CPU (on machines with at least 4 CPU's; the percentage is
rounded up).
--matt
APPENDIX: problems with the current i/o scheduler
The current ZFS i/o scheduler (vdev_queue.c) is deadline based. The problem
with this is that if there are always i/os pending, then certain classes of
i/os can see very long delays.
For example, if there are always synchronous reads outstanding, then no async
writes will be serviced until they become "past due". One symptom of this
situation is that each pass of the txg sync takes at least several seconds
(typically 3 seconds).
If many i/os become "past due" (their deadline is in the past), then we must
service all of these overdue i/os before any new i/os. This happens when we
enqueue a batch of async writes for the txg sync, with deadlines 2.5 seconds in
the future. If we can't complete all the i/os in 2.5 seconds (e.g. because
there were always reads pending), then these i/os will become past due. Now we
must service all the "async" writes (which could be hundreds of megabytes)
before we service any reads, introducing considerable latency to synchronous
i/os (reads or ZIL writes).
Notes on porting to ZFS on Linux:
- zio_t gained new members io_physdone and io_phys_children. Because
object caches in the Linux port call the constructor only once at
allocation time, objects may contain residual data when retrieved
from the cache. Therefore zio_create() was updated to zero out the two
new fields.
- vdev_mirror_pending() relied on the depth of the per-vdev pending queue
(vq->vq_pending_tree) to select the least-busy leaf vdev to read from.
This tree has been replaced by vq->vq_active_tree which is now used
for the same purpose.
- vdev_queue_init() used the value of zfs_vdev_max_pending to determine
the number of vdev I/O buffers to pre-allocate. That global no longer
exists, so we instead use the sum of the *_max_active values for each of
the five I/O classes described above.
- The Illumos implementation of dmu_tx_delay() delays a transaction by
sleeping in condition variable embedded in the thread
(curthread->t_delay_cv). We do not have an equivalent CV to use in
Linux, so this change replaced the delay logic with a wrapper called
zfs_sleep_until(). This wrapper could be adopted upstream and in other
downstream ports to abstract away operating system-specific delay logic.
- These tunables are added as module parameters, and descriptions added
to the zfs-module-parameters.5 man page.
spa_asize_inflation
zfs_deadman_synctime_ms
zfs_vdev_max_active
zfs_vdev_async_write_active_min_dirty_percent
zfs_vdev_async_write_active_max_dirty_percent
zfs_vdev_async_read_max_active
zfs_vdev_async_read_min_active
zfs_vdev_async_write_max_active
zfs_vdev_async_write_min_active
zfs_vdev_scrub_max_active
zfs_vdev_scrub_min_active
zfs_vdev_sync_read_max_active
zfs_vdev_sync_read_min_active
zfs_vdev_sync_write_max_active
zfs_vdev_sync_write_min_active
zfs_dirty_data_max_percent
zfs_delay_min_dirty_percent
zfs_dirty_data_max_max_percent
zfs_dirty_data_max
zfs_dirty_data_max_max
zfs_dirty_data_sync
zfs_delay_scale
The latter four have type unsigned long, whereas they are uint64_t in
Illumos. This accommodates Linux's module_param() supported types, but
means they may overflow on 32-bit architectures.
The values zfs_dirty_data_max and zfs_dirty_data_max_max are the most
likely to overflow on 32-bit systems, since they express physical RAM
sizes in bytes. In fact, Illumos initializes zfs_dirty_data_max_max to
2^32 which does overflow. To resolve that, this port instead initializes
it in arc_init() to 25% of physical RAM, and adds the tunable
zfs_dirty_data_max_max_percent to override that percentage. While this
solution doesn't completely avoid the overflow issue, it should be a
reasonable default for most systems, and the minority of affected
systems can work around the issue by overriding the defaults.
- Fixed reversed logic in comment above zfs_delay_scale declaration.
- Clarified comments in vdev_queue.c regarding when per-queue minimums take
effect.
- Replaced dmu_tx_write_limit in the dmu_tx kstat file
with dmu_tx_dirty_delay and dmu_tx_dirty_over_max. The first counts
how many times a transaction has been delayed because the pool dirty
data has exceeded zfs_delay_min_dirty_percent. The latter counts how
many times the pool dirty data has exceeded zfs_dirty_data_max (which
we expect to never happen).
- The original patch would have regressed the bug fixed in
zfsonlinux/zfs@c418410, which prevented users from setting the
zfs_vdev_aggregation_limit tuning larger than SPA_MAXBLOCKSIZE.
A similar fix is added to vdev_queue_aggregate().
- In vdev_queue_io_to_issue(), dynamically allocate 'zio_t search' on the
heap instead of the stack. In Linux we can't afford such large
structures on the stack.
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Ned Bass <bass6@llnl.gov>
Reviewed by: Brendan Gregg <brendan.gregg@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
References:
http://www.illumos.org/issues/4045
illumos/illumos-gate@69962b5647e4a8b9b14998733b765925381b727e
Ported-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1913
2013-08-29 03:01:20 +00:00
|
|
|
if (txg_how == TXG_WAITED)
|
|
|
|
tx->tx_waited = B_TRUE;
|
|
|
|
|
2013-09-04 12:00:57 +00:00
|
|
|
/* If we might wait, we must not hold the config lock. */
|
|
|
|
ASSERT(txg_how != TXG_WAIT || !dsl_pool_config_held(tx->tx_pool));
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
while ((err = dmu_tx_try_assign(tx, txg_how)) != 0) {
|
|
|
|
dmu_tx_unassign(tx);
|
|
|
|
|
|
|
|
if (err != ERESTART || txg_how != TXG_WAIT)
|
|
|
|
return (err);
|
|
|
|
|
|
|
|
dmu_tx_wait(tx);
|
|
|
|
}
|
|
|
|
|
|
|
|
txg_rele_to_quiesce(&tx->tx_txgh);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dmu_tx_wait(dmu_tx_t *tx)
|
|
|
|
{
|
|
|
|
spa_t *spa = tx->tx_pool->dp_spa;
|
Illumos #4045 write throttle & i/o scheduler performance work
4045 zfs write throttle & i/o scheduler performance work
1. The ZFS i/o scheduler (vdev_queue.c) now divides i/os into 5 classes: sync
read, sync write, async read, async write, and scrub/resilver. The scheduler
issues a number of concurrent i/os from each class to the device. Once a class
has been selected, an i/o is selected from this class using either an elevator
algorithem (async, scrub classes) or FIFO (sync classes). The number of
concurrent async write i/os is tuned dynamically based on i/o load, to achieve
good sync i/o latency when there is not a high load of writes, and good write
throughput when there is. See the block comment in vdev_queue.c (reproduced
below) for more details.
2. The write throttle (dsl_pool_tempreserve_space() and
txg_constrain_throughput()) is rewritten to produce much more consistent delays
when under constant load. The new write throttle is based on the amount of
dirty data, rather than guesses about future performance of the system. When
there is a lot of dirty data, each transaction (e.g. write() syscall) will be
delayed by the same small amount. This eliminates the "brick wall of wait"
that the old write throttle could hit, causing all transactions to wait several
seconds until the next txg opens. One of the keys to the new write throttle is
decrementing the amount of dirty data as i/o completes, rather than at the end
of spa_sync(). Note that the write throttle is only applied once the i/o
scheduler is issuing the maximum number of outstanding async writes. See the
block comments in dsl_pool.c and above dmu_tx_delay() (reproduced below) for
more details.
This diff has several other effects, including:
* the commonly-tuned global variable zfs_vdev_max_pending has been removed;
use per-class zfs_vdev_*_max_active values or zfs_vdev_max_active instead.
* the size of each txg (meaning the amount of dirty data written, and thus the
time it takes to write out) is now controlled differently. There is no longer
an explicit time goal; the primary determinant is amount of dirty data.
Systems that are under light or medium load will now often see that a txg is
always syncing, but the impact to performance (e.g. read latency) is minimal.
Tune zfs_dirty_data_max and zfs_dirty_data_sync to control this.
* zio_taskq_batch_pct = 75 -- Only use 75% of all CPUs for compression,
checksum, etc. This improves latency by not allowing these CPU-intensive tasks
to consume all CPU (on machines with at least 4 CPU's; the percentage is
rounded up).
--matt
APPENDIX: problems with the current i/o scheduler
The current ZFS i/o scheduler (vdev_queue.c) is deadline based. The problem
with this is that if there are always i/os pending, then certain classes of
i/os can see very long delays.
For example, if there are always synchronous reads outstanding, then no async
writes will be serviced until they become "past due". One symptom of this
situation is that each pass of the txg sync takes at least several seconds
(typically 3 seconds).
If many i/os become "past due" (their deadline is in the past), then we must
service all of these overdue i/os before any new i/os. This happens when we
enqueue a batch of async writes for the txg sync, with deadlines 2.5 seconds in
the future. If we can't complete all the i/os in 2.5 seconds (e.g. because
there were always reads pending), then these i/os will become past due. Now we
must service all the "async" writes (which could be hundreds of megabytes)
before we service any reads, introducing considerable latency to synchronous
i/os (reads or ZIL writes).
Notes on porting to ZFS on Linux:
- zio_t gained new members io_physdone and io_phys_children. Because
object caches in the Linux port call the constructor only once at
allocation time, objects may contain residual data when retrieved
from the cache. Therefore zio_create() was updated to zero out the two
new fields.
- vdev_mirror_pending() relied on the depth of the per-vdev pending queue
(vq->vq_pending_tree) to select the least-busy leaf vdev to read from.
This tree has been replaced by vq->vq_active_tree which is now used
for the same purpose.
- vdev_queue_init() used the value of zfs_vdev_max_pending to determine
the number of vdev I/O buffers to pre-allocate. That global no longer
exists, so we instead use the sum of the *_max_active values for each of
the five I/O classes described above.
- The Illumos implementation of dmu_tx_delay() delays a transaction by
sleeping in condition variable embedded in the thread
(curthread->t_delay_cv). We do not have an equivalent CV to use in
Linux, so this change replaced the delay logic with a wrapper called
zfs_sleep_until(). This wrapper could be adopted upstream and in other
downstream ports to abstract away operating system-specific delay logic.
- These tunables are added as module parameters, and descriptions added
to the zfs-module-parameters.5 man page.
spa_asize_inflation
zfs_deadman_synctime_ms
zfs_vdev_max_active
zfs_vdev_async_write_active_min_dirty_percent
zfs_vdev_async_write_active_max_dirty_percent
zfs_vdev_async_read_max_active
zfs_vdev_async_read_min_active
zfs_vdev_async_write_max_active
zfs_vdev_async_write_min_active
zfs_vdev_scrub_max_active
zfs_vdev_scrub_min_active
zfs_vdev_sync_read_max_active
zfs_vdev_sync_read_min_active
zfs_vdev_sync_write_max_active
zfs_vdev_sync_write_min_active
zfs_dirty_data_max_percent
zfs_delay_min_dirty_percent
zfs_dirty_data_max_max_percent
zfs_dirty_data_max
zfs_dirty_data_max_max
zfs_dirty_data_sync
zfs_delay_scale
The latter four have type unsigned long, whereas they are uint64_t in
Illumos. This accommodates Linux's module_param() supported types, but
means they may overflow on 32-bit architectures.
The values zfs_dirty_data_max and zfs_dirty_data_max_max are the most
likely to overflow on 32-bit systems, since they express physical RAM
sizes in bytes. In fact, Illumos initializes zfs_dirty_data_max_max to
2^32 which does overflow. To resolve that, this port instead initializes
it in arc_init() to 25% of physical RAM, and adds the tunable
zfs_dirty_data_max_max_percent to override that percentage. While this
solution doesn't completely avoid the overflow issue, it should be a
reasonable default for most systems, and the minority of affected
systems can work around the issue by overriding the defaults.
- Fixed reversed logic in comment above zfs_delay_scale declaration.
- Clarified comments in vdev_queue.c regarding when per-queue minimums take
effect.
- Replaced dmu_tx_write_limit in the dmu_tx kstat file
with dmu_tx_dirty_delay and dmu_tx_dirty_over_max. The first counts
how many times a transaction has been delayed because the pool dirty
data has exceeded zfs_delay_min_dirty_percent. The latter counts how
many times the pool dirty data has exceeded zfs_dirty_data_max (which
we expect to never happen).
- The original patch would have regressed the bug fixed in
zfsonlinux/zfs@c418410, which prevented users from setting the
zfs_vdev_aggregation_limit tuning larger than SPA_MAXBLOCKSIZE.
A similar fix is added to vdev_queue_aggregate().
- In vdev_queue_io_to_issue(), dynamically allocate 'zio_t search' on the
heap instead of the stack. In Linux we can't afford such large
structures on the stack.
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Ned Bass <bass6@llnl.gov>
Reviewed by: Brendan Gregg <brendan.gregg@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
References:
http://www.illumos.org/issues/4045
illumos/illumos-gate@69962b5647e4a8b9b14998733b765925381b727e
Ported-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1913
2013-08-29 03:01:20 +00:00
|
|
|
dsl_pool_t *dp = tx->tx_pool;
|
Improve reporting of tx assignment wait times
Some callers of dmu_tx_assign() use the TXG_NOWAIT flag and call
dmu_tx_wait() themselves before retrying if the assignment fails.
The wait times for such callers are not accounted for in the
dmu_tx_assign kstat histogram, because the histogram only records
time spent in dmu_tx_assign(). This change moves the histogram
update to dmu_tx_wait() to properly account for all time spent there.
One downside of this approach is that it is possible to call
dmu_tx_wait() multiple times before successfully assigning a
transaction, in which case the cumulative wait time would not be
recorded. However, this case should not often arise in practice,
because most callers currently use one of these forms:
dmu_tx_assign(tx, TXG_WAIT);
dmu_tx_assign(tx, waited ? TXG_WAITED : TXG_NOWAIT);
The first form should make just one call to dmu_tx_delay() inside of
dmu_tx_assign(). The second form retries with TXG_WAITED if the first
assignment fails and incurs a delay, in which case no further waiting
is performed. Therefore transaction delays normally occur in one
call to dmu_tx_wait() so the histogram should be fairly accurate.
Another possible downside of this approach is that the histogram will
no longer record overhead outside of dmu_tx_wait() such as in
dmu_tx_try_assign(). While I'm not aware of any reason for concern on
this point, it is conceivable that lock contention, long list
traversal, etc. could cause assignment delays that would not be
reflected in the histogram. Therefore the histogram should strictly
be used for visibility in to the normal delay mechanisms and not as a
profiling tool for code performance.
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1915
2014-02-28 23:07:00 +00:00
|
|
|
hrtime_t before;
|
2008-11-20 20:01:55 +00:00
|
|
|
|
|
|
|
ASSERT(tx->tx_txg == 0);
|
2013-09-04 12:00:57 +00:00
|
|
|
ASSERT(!dsl_pool_config_held(tx->tx_pool));
|
2008-11-20 20:01:55 +00:00
|
|
|
|
Improve reporting of tx assignment wait times
Some callers of dmu_tx_assign() use the TXG_NOWAIT flag and call
dmu_tx_wait() themselves before retrying if the assignment fails.
The wait times for such callers are not accounted for in the
dmu_tx_assign kstat histogram, because the histogram only records
time spent in dmu_tx_assign(). This change moves the histogram
update to dmu_tx_wait() to properly account for all time spent there.
One downside of this approach is that it is possible to call
dmu_tx_wait() multiple times before successfully assigning a
transaction, in which case the cumulative wait time would not be
recorded. However, this case should not often arise in practice,
because most callers currently use one of these forms:
dmu_tx_assign(tx, TXG_WAIT);
dmu_tx_assign(tx, waited ? TXG_WAITED : TXG_NOWAIT);
The first form should make just one call to dmu_tx_delay() inside of
dmu_tx_assign(). The second form retries with TXG_WAITED if the first
assignment fails and incurs a delay, in which case no further waiting
is performed. Therefore transaction delays normally occur in one
call to dmu_tx_wait() so the histogram should be fairly accurate.
Another possible downside of this approach is that the histogram will
no longer record overhead outside of dmu_tx_wait() such as in
dmu_tx_try_assign(). While I'm not aware of any reason for concern on
this point, it is conceivable that lock contention, long list
traversal, etc. could cause assignment delays that would not be
reflected in the histogram. Therefore the histogram should strictly
be used for visibility in to the normal delay mechanisms and not as a
profiling tool for code performance.
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1915
2014-02-28 23:07:00 +00:00
|
|
|
before = gethrtime();
|
|
|
|
|
Illumos #4045 write throttle & i/o scheduler performance work
4045 zfs write throttle & i/o scheduler performance work
1. The ZFS i/o scheduler (vdev_queue.c) now divides i/os into 5 classes: sync
read, sync write, async read, async write, and scrub/resilver. The scheduler
issues a number of concurrent i/os from each class to the device. Once a class
has been selected, an i/o is selected from this class using either an elevator
algorithem (async, scrub classes) or FIFO (sync classes). The number of
concurrent async write i/os is tuned dynamically based on i/o load, to achieve
good sync i/o latency when there is not a high load of writes, and good write
throughput when there is. See the block comment in vdev_queue.c (reproduced
below) for more details.
2. The write throttle (dsl_pool_tempreserve_space() and
txg_constrain_throughput()) is rewritten to produce much more consistent delays
when under constant load. The new write throttle is based on the amount of
dirty data, rather than guesses about future performance of the system. When
there is a lot of dirty data, each transaction (e.g. write() syscall) will be
delayed by the same small amount. This eliminates the "brick wall of wait"
that the old write throttle could hit, causing all transactions to wait several
seconds until the next txg opens. One of the keys to the new write throttle is
decrementing the amount of dirty data as i/o completes, rather than at the end
of spa_sync(). Note that the write throttle is only applied once the i/o
scheduler is issuing the maximum number of outstanding async writes. See the
block comments in dsl_pool.c and above dmu_tx_delay() (reproduced below) for
more details.
This diff has several other effects, including:
* the commonly-tuned global variable zfs_vdev_max_pending has been removed;
use per-class zfs_vdev_*_max_active values or zfs_vdev_max_active instead.
* the size of each txg (meaning the amount of dirty data written, and thus the
time it takes to write out) is now controlled differently. There is no longer
an explicit time goal; the primary determinant is amount of dirty data.
Systems that are under light or medium load will now often see that a txg is
always syncing, but the impact to performance (e.g. read latency) is minimal.
Tune zfs_dirty_data_max and zfs_dirty_data_sync to control this.
* zio_taskq_batch_pct = 75 -- Only use 75% of all CPUs for compression,
checksum, etc. This improves latency by not allowing these CPU-intensive tasks
to consume all CPU (on machines with at least 4 CPU's; the percentage is
rounded up).
--matt
APPENDIX: problems with the current i/o scheduler
The current ZFS i/o scheduler (vdev_queue.c) is deadline based. The problem
with this is that if there are always i/os pending, then certain classes of
i/os can see very long delays.
For example, if there are always synchronous reads outstanding, then no async
writes will be serviced until they become "past due". One symptom of this
situation is that each pass of the txg sync takes at least several seconds
(typically 3 seconds).
If many i/os become "past due" (their deadline is in the past), then we must
service all of these overdue i/os before any new i/os. This happens when we
enqueue a batch of async writes for the txg sync, with deadlines 2.5 seconds in
the future. If we can't complete all the i/os in 2.5 seconds (e.g. because
there were always reads pending), then these i/os will become past due. Now we
must service all the "async" writes (which could be hundreds of megabytes)
before we service any reads, introducing considerable latency to synchronous
i/os (reads or ZIL writes).
Notes on porting to ZFS on Linux:
- zio_t gained new members io_physdone and io_phys_children. Because
object caches in the Linux port call the constructor only once at
allocation time, objects may contain residual data when retrieved
from the cache. Therefore zio_create() was updated to zero out the two
new fields.
- vdev_mirror_pending() relied on the depth of the per-vdev pending queue
(vq->vq_pending_tree) to select the least-busy leaf vdev to read from.
This tree has been replaced by vq->vq_active_tree which is now used
for the same purpose.
- vdev_queue_init() used the value of zfs_vdev_max_pending to determine
the number of vdev I/O buffers to pre-allocate. That global no longer
exists, so we instead use the sum of the *_max_active values for each of
the five I/O classes described above.
- The Illumos implementation of dmu_tx_delay() delays a transaction by
sleeping in condition variable embedded in the thread
(curthread->t_delay_cv). We do not have an equivalent CV to use in
Linux, so this change replaced the delay logic with a wrapper called
zfs_sleep_until(). This wrapper could be adopted upstream and in other
downstream ports to abstract away operating system-specific delay logic.
- These tunables are added as module parameters, and descriptions added
to the zfs-module-parameters.5 man page.
spa_asize_inflation
zfs_deadman_synctime_ms
zfs_vdev_max_active
zfs_vdev_async_write_active_min_dirty_percent
zfs_vdev_async_write_active_max_dirty_percent
zfs_vdev_async_read_max_active
zfs_vdev_async_read_min_active
zfs_vdev_async_write_max_active
zfs_vdev_async_write_min_active
zfs_vdev_scrub_max_active
zfs_vdev_scrub_min_active
zfs_vdev_sync_read_max_active
zfs_vdev_sync_read_min_active
zfs_vdev_sync_write_max_active
zfs_vdev_sync_write_min_active
zfs_dirty_data_max_percent
zfs_delay_min_dirty_percent
zfs_dirty_data_max_max_percent
zfs_dirty_data_max
zfs_dirty_data_max_max
zfs_dirty_data_sync
zfs_delay_scale
The latter four have type unsigned long, whereas they are uint64_t in
Illumos. This accommodates Linux's module_param() supported types, but
means they may overflow on 32-bit architectures.
The values zfs_dirty_data_max and zfs_dirty_data_max_max are the most
likely to overflow on 32-bit systems, since they express physical RAM
sizes in bytes. In fact, Illumos initializes zfs_dirty_data_max_max to
2^32 which does overflow. To resolve that, this port instead initializes
it in arc_init() to 25% of physical RAM, and adds the tunable
zfs_dirty_data_max_max_percent to override that percentage. While this
solution doesn't completely avoid the overflow issue, it should be a
reasonable default for most systems, and the minority of affected
systems can work around the issue by overriding the defaults.
- Fixed reversed logic in comment above zfs_delay_scale declaration.
- Clarified comments in vdev_queue.c regarding when per-queue minimums take
effect.
- Replaced dmu_tx_write_limit in the dmu_tx kstat file
with dmu_tx_dirty_delay and dmu_tx_dirty_over_max. The first counts
how many times a transaction has been delayed because the pool dirty
data has exceeded zfs_delay_min_dirty_percent. The latter counts how
many times the pool dirty data has exceeded zfs_dirty_data_max (which
we expect to never happen).
- The original patch would have regressed the bug fixed in
zfsonlinux/zfs@c418410, which prevented users from setting the
zfs_vdev_aggregation_limit tuning larger than SPA_MAXBLOCKSIZE.
A similar fix is added to vdev_queue_aggregate().
- In vdev_queue_io_to_issue(), dynamically allocate 'zio_t search' on the
heap instead of the stack. In Linux we can't afford such large
structures on the stack.
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Ned Bass <bass6@llnl.gov>
Reviewed by: Brendan Gregg <brendan.gregg@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
References:
http://www.illumos.org/issues/4045
illumos/illumos-gate@69962b5647e4a8b9b14998733b765925381b727e
Ported-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1913
2013-08-29 03:01:20 +00:00
|
|
|
if (tx->tx_wait_dirty) {
|
|
|
|
uint64_t dirty;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dmu_tx_try_assign() has determined that we need to wait
|
|
|
|
* because we've consumed much or all of the dirty buffer
|
|
|
|
* space.
|
|
|
|
*/
|
|
|
|
mutex_enter(&dp->dp_lock);
|
|
|
|
if (dp->dp_dirty_total >= zfs_dirty_data_max)
|
|
|
|
DMU_TX_STAT_BUMP(dmu_tx_dirty_over_max);
|
|
|
|
while (dp->dp_dirty_total >= zfs_dirty_data_max)
|
|
|
|
cv_wait(&dp->dp_spaceavail_cv, &dp->dp_lock);
|
|
|
|
dirty = dp->dp_dirty_total;
|
|
|
|
mutex_exit(&dp->dp_lock);
|
|
|
|
|
|
|
|
dmu_tx_delay(tx, dirty);
|
|
|
|
|
|
|
|
tx->tx_wait_dirty = B_FALSE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note: setting tx_waited only has effect if the caller
|
|
|
|
* used TX_WAIT. Otherwise they are going to destroy
|
|
|
|
* this tx and try again. The common case, zfs_write(),
|
|
|
|
* uses TX_WAIT.
|
|
|
|
*/
|
|
|
|
tx->tx_waited = B_TRUE;
|
|
|
|
} else if (spa_suspended(spa) || tx->tx_lasttried_txg == 0) {
|
|
|
|
/*
|
|
|
|
* If the pool is suspended we need to wait until it
|
|
|
|
* is resumed. Note that it's possible that the pool
|
|
|
|
* has become active after this thread has tried to
|
|
|
|
* obtain a tx. If that's the case then tx_lasttried_txg
|
|
|
|
* would not have been set.
|
|
|
|
*/
|
|
|
|
txg_wait_synced(dp, spa_last_synced_txg(spa) + 1);
|
2008-11-20 20:01:55 +00:00
|
|
|
} else if (tx->tx_needassign_txh) {
|
|
|
|
dnode_t *dn = tx->tx_needassign_txh->txh_dnode;
|
|
|
|
|
|
|
|
mutex_enter(&dn->dn_mtx);
|
|
|
|
while (dn->dn_assigned_txg == tx->tx_lasttried_txg - 1)
|
|
|
|
cv_wait(&dn->dn_notxholds, &dn->dn_mtx);
|
|
|
|
mutex_exit(&dn->dn_mtx);
|
|
|
|
tx->tx_needassign_txh = NULL;
|
|
|
|
} else {
|
Illumos #4045 write throttle & i/o scheduler performance work
4045 zfs write throttle & i/o scheduler performance work
1. The ZFS i/o scheduler (vdev_queue.c) now divides i/os into 5 classes: sync
read, sync write, async read, async write, and scrub/resilver. The scheduler
issues a number of concurrent i/os from each class to the device. Once a class
has been selected, an i/o is selected from this class using either an elevator
algorithem (async, scrub classes) or FIFO (sync classes). The number of
concurrent async write i/os is tuned dynamically based on i/o load, to achieve
good sync i/o latency when there is not a high load of writes, and good write
throughput when there is. See the block comment in vdev_queue.c (reproduced
below) for more details.
2. The write throttle (dsl_pool_tempreserve_space() and
txg_constrain_throughput()) is rewritten to produce much more consistent delays
when under constant load. The new write throttle is based on the amount of
dirty data, rather than guesses about future performance of the system. When
there is a lot of dirty data, each transaction (e.g. write() syscall) will be
delayed by the same small amount. This eliminates the "brick wall of wait"
that the old write throttle could hit, causing all transactions to wait several
seconds until the next txg opens. One of the keys to the new write throttle is
decrementing the amount of dirty data as i/o completes, rather than at the end
of spa_sync(). Note that the write throttle is only applied once the i/o
scheduler is issuing the maximum number of outstanding async writes. See the
block comments in dsl_pool.c and above dmu_tx_delay() (reproduced below) for
more details.
This diff has several other effects, including:
* the commonly-tuned global variable zfs_vdev_max_pending has been removed;
use per-class zfs_vdev_*_max_active values or zfs_vdev_max_active instead.
* the size of each txg (meaning the amount of dirty data written, and thus the
time it takes to write out) is now controlled differently. There is no longer
an explicit time goal; the primary determinant is amount of dirty data.
Systems that are under light or medium load will now often see that a txg is
always syncing, but the impact to performance (e.g. read latency) is minimal.
Tune zfs_dirty_data_max and zfs_dirty_data_sync to control this.
* zio_taskq_batch_pct = 75 -- Only use 75% of all CPUs for compression,
checksum, etc. This improves latency by not allowing these CPU-intensive tasks
to consume all CPU (on machines with at least 4 CPU's; the percentage is
rounded up).
--matt
APPENDIX: problems with the current i/o scheduler
The current ZFS i/o scheduler (vdev_queue.c) is deadline based. The problem
with this is that if there are always i/os pending, then certain classes of
i/os can see very long delays.
For example, if there are always synchronous reads outstanding, then no async
writes will be serviced until they become "past due". One symptom of this
situation is that each pass of the txg sync takes at least several seconds
(typically 3 seconds).
If many i/os become "past due" (their deadline is in the past), then we must
service all of these overdue i/os before any new i/os. This happens when we
enqueue a batch of async writes for the txg sync, with deadlines 2.5 seconds in
the future. If we can't complete all the i/os in 2.5 seconds (e.g. because
there were always reads pending), then these i/os will become past due. Now we
must service all the "async" writes (which could be hundreds of megabytes)
before we service any reads, introducing considerable latency to synchronous
i/os (reads or ZIL writes).
Notes on porting to ZFS on Linux:
- zio_t gained new members io_physdone and io_phys_children. Because
object caches in the Linux port call the constructor only once at
allocation time, objects may contain residual data when retrieved
from the cache. Therefore zio_create() was updated to zero out the two
new fields.
- vdev_mirror_pending() relied on the depth of the per-vdev pending queue
(vq->vq_pending_tree) to select the least-busy leaf vdev to read from.
This tree has been replaced by vq->vq_active_tree which is now used
for the same purpose.
- vdev_queue_init() used the value of zfs_vdev_max_pending to determine
the number of vdev I/O buffers to pre-allocate. That global no longer
exists, so we instead use the sum of the *_max_active values for each of
the five I/O classes described above.
- The Illumos implementation of dmu_tx_delay() delays a transaction by
sleeping in condition variable embedded in the thread
(curthread->t_delay_cv). We do not have an equivalent CV to use in
Linux, so this change replaced the delay logic with a wrapper called
zfs_sleep_until(). This wrapper could be adopted upstream and in other
downstream ports to abstract away operating system-specific delay logic.
- These tunables are added as module parameters, and descriptions added
to the zfs-module-parameters.5 man page.
spa_asize_inflation
zfs_deadman_synctime_ms
zfs_vdev_max_active
zfs_vdev_async_write_active_min_dirty_percent
zfs_vdev_async_write_active_max_dirty_percent
zfs_vdev_async_read_max_active
zfs_vdev_async_read_min_active
zfs_vdev_async_write_max_active
zfs_vdev_async_write_min_active
zfs_vdev_scrub_max_active
zfs_vdev_scrub_min_active
zfs_vdev_sync_read_max_active
zfs_vdev_sync_read_min_active
zfs_vdev_sync_write_max_active
zfs_vdev_sync_write_min_active
zfs_dirty_data_max_percent
zfs_delay_min_dirty_percent
zfs_dirty_data_max_max_percent
zfs_dirty_data_max
zfs_dirty_data_max_max
zfs_dirty_data_sync
zfs_delay_scale
The latter four have type unsigned long, whereas they are uint64_t in
Illumos. This accommodates Linux's module_param() supported types, but
means they may overflow on 32-bit architectures.
The values zfs_dirty_data_max and zfs_dirty_data_max_max are the most
likely to overflow on 32-bit systems, since they express physical RAM
sizes in bytes. In fact, Illumos initializes zfs_dirty_data_max_max to
2^32 which does overflow. To resolve that, this port instead initializes
it in arc_init() to 25% of physical RAM, and adds the tunable
zfs_dirty_data_max_max_percent to override that percentage. While this
solution doesn't completely avoid the overflow issue, it should be a
reasonable default for most systems, and the minority of affected
systems can work around the issue by overriding the defaults.
- Fixed reversed logic in comment above zfs_delay_scale declaration.
- Clarified comments in vdev_queue.c regarding when per-queue minimums take
effect.
- Replaced dmu_tx_write_limit in the dmu_tx kstat file
with dmu_tx_dirty_delay and dmu_tx_dirty_over_max. The first counts
how many times a transaction has been delayed because the pool dirty
data has exceeded zfs_delay_min_dirty_percent. The latter counts how
many times the pool dirty data has exceeded zfs_dirty_data_max (which
we expect to never happen).
- The original patch would have regressed the bug fixed in
zfsonlinux/zfs@c418410, which prevented users from setting the
zfs_vdev_aggregation_limit tuning larger than SPA_MAXBLOCKSIZE.
A similar fix is added to vdev_queue_aggregate().
- In vdev_queue_io_to_issue(), dynamically allocate 'zio_t search' on the
heap instead of the stack. In Linux we can't afford such large
structures on the stack.
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: Ned Bass <bass6@llnl.gov>
Reviewed by: Brendan Gregg <brendan.gregg@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>
References:
http://www.illumos.org/issues/4045
illumos/illumos-gate@69962b5647e4a8b9b14998733b765925381b727e
Ported-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1913
2013-08-29 03:01:20 +00:00
|
|
|
/*
|
|
|
|
* A dnode is assigned to the quiescing txg. Wait for its
|
|
|
|
* transaction to complete.
|
|
|
|
*/
|
2008-11-20 20:01:55 +00:00
|
|
|
txg_wait_open(tx->tx_pool, tx->tx_lasttried_txg + 1);
|
|
|
|
}
|
Improve reporting of tx assignment wait times
Some callers of dmu_tx_assign() use the TXG_NOWAIT flag and call
dmu_tx_wait() themselves before retrying if the assignment fails.
The wait times for such callers are not accounted for in the
dmu_tx_assign kstat histogram, because the histogram only records
time spent in dmu_tx_assign(). This change moves the histogram
update to dmu_tx_wait() to properly account for all time spent there.
One downside of this approach is that it is possible to call
dmu_tx_wait() multiple times before successfully assigning a
transaction, in which case the cumulative wait time would not be
recorded. However, this case should not often arise in practice,
because most callers currently use one of these forms:
dmu_tx_assign(tx, TXG_WAIT);
dmu_tx_assign(tx, waited ? TXG_WAITED : TXG_NOWAIT);
The first form should make just one call to dmu_tx_delay() inside of
dmu_tx_assign(). The second form retries with TXG_WAITED if the first
assignment fails and incurs a delay, in which case no further waiting
is performed. Therefore transaction delays normally occur in one
call to dmu_tx_wait() so the histogram should be fairly accurate.
Another possible downside of this approach is that the histogram will
no longer record overhead outside of dmu_tx_wait() such as in
dmu_tx_try_assign(). While I'm not aware of any reason for concern on
this point, it is conceivable that lock contention, long list
traversal, etc. could cause assignment delays that would not be
reflected in the histogram. Therefore the histogram should strictly
be used for visibility in to the normal delay mechanisms and not as a
profiling tool for code performance.
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1915
2014-02-28 23:07:00 +00:00
|
|
|
|
|
|
|
spa_tx_assign_add_nsecs(spa, gethrtime() - before);
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dmu_tx_willuse_space(dmu_tx_t *tx, int64_t delta)
|
|
|
|
{
|
2012-03-20 23:00:17 +00:00
|
|
|
#ifdef DEBUG_DMU_TX
|
2008-11-20 20:01:55 +00:00
|
|
|
if (tx->tx_dir == NULL || delta == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (delta > 0) {
|
|
|
|
ASSERT3U(refcount_count(&tx->tx_space_written) + delta, <=,
|
|
|
|
tx->tx_space_towrite);
|
|
|
|
(void) refcount_add_many(&tx->tx_space_written, delta, NULL);
|
|
|
|
} else {
|
|
|
|
(void) refcount_add_many(&tx->tx_space_freed, -delta, NULL);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-01-23 17:36:24 +00:00
|
|
|
static void
|
|
|
|
dmu_tx_destroy(dmu_tx_t *tx)
|
|
|
|
{
|
|
|
|
dmu_tx_hold_t *txh;
|
|
|
|
|
|
|
|
while ((txh = list_head(&tx->tx_holds)) != NULL) {
|
|
|
|
dnode_t *dn = txh->txh_dnode;
|
|
|
|
|
|
|
|
list_remove(&tx->tx_holds, txh);
|
|
|
|
refcount_destroy_many(&txh->txh_space_towrite,
|
|
|
|
refcount_count(&txh->txh_space_towrite));
|
|
|
|
refcount_destroy_many(&txh->txh_space_tofree,
|
|
|
|
refcount_count(&txh->txh_space_tofree));
|
|
|
|
refcount_destroy_many(&txh->txh_space_tooverwrite,
|
|
|
|
refcount_count(&txh->txh_space_tooverwrite));
|
|
|
|
refcount_destroy_many(&txh->txh_space_tounref,
|
|
|
|
refcount_count(&txh->txh_space_tounref));
|
|
|
|
refcount_destroy_many(&txh->txh_memory_tohold,
|
|
|
|
refcount_count(&txh->txh_memory_tohold));
|
|
|
|
refcount_destroy_many(&txh->txh_fudge,
|
|
|
|
refcount_count(&txh->txh_fudge));
|
|
|
|
kmem_free(txh, sizeof (dmu_tx_hold_t));
|
|
|
|
if (dn != NULL)
|
|
|
|
dnode_rele(dn, tx);
|
|
|
|
}
|
|
|
|
|
|
|
|
list_destroy(&tx->tx_callbacks);
|
|
|
|
list_destroy(&tx->tx_holds);
|
|
|
|
#ifdef DEBUG_DMU_TX
|
|
|
|
refcount_destroy_many(&tx->tx_space_written,
|
|
|
|
refcount_count(&tx->tx_space_written));
|
|
|
|
refcount_destroy_many(&tx->tx_space_freed,
|
|
|
|
refcount_count(&tx->tx_space_freed));
|
|
|
|
#endif
|
|
|
|
kmem_free(tx, sizeof (dmu_tx_t));
|
|
|
|
}
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
void
|
|
|
|
dmu_tx_commit(dmu_tx_t *tx)
|
|
|
|
{
|
|
|
|
dmu_tx_hold_t *txh;
|
|
|
|
|
|
|
|
ASSERT(tx->tx_txg != 0);
|
|
|
|
|
2013-06-11 17:12:34 +00:00
|
|
|
/*
|
|
|
|
* Go through the transaction's hold list and remove holds on
|
|
|
|
* associated dnodes, notifying waiters if no holds remain.
|
|
|
|
*/
|
2017-01-23 17:36:24 +00:00
|
|
|
for (txh = list_head(&tx->tx_holds); txh != NULL;
|
|
|
|
txh = list_next(&tx->tx_holds, txh)) {
|
2008-11-20 20:01:55 +00:00
|
|
|
dnode_t *dn = txh->txh_dnode;
|
|
|
|
|
|
|
|
if (dn == NULL)
|
|
|
|
continue;
|
2017-01-23 17:36:24 +00:00
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
mutex_enter(&dn->dn_mtx);
|
|
|
|
ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg);
|
|
|
|
|
|
|
|
if (refcount_remove(&dn->dn_tx_holds, tx) == 0) {
|
|
|
|
dn->dn_assigned_txg = 0;
|
|
|
|
cv_broadcast(&dn->dn_notxholds);
|
|
|
|
}
|
|
|
|
mutex_exit(&dn->dn_mtx);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tx->tx_tempreserve_cookie)
|
|
|
|
dsl_dir_tempreserve_clear(tx->tx_tempreserve_cookie, tx);
|
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
if (!list_is_empty(&tx->tx_callbacks))
|
|
|
|
txg_register_callbacks(&tx->tx_txgh, &tx->tx_callbacks);
|
|
|
|
|
2008-11-20 20:01:55 +00:00
|
|
|
if (tx->tx_anyobj == FALSE)
|
|
|
|
txg_rele_to_sync(&tx->tx_txgh);
|
2010-05-28 20:45:14 +00:00
|
|
|
|
2012-03-20 23:00:17 +00:00
|
|
|
#ifdef DEBUG_DMU_TX
|
2008-11-20 20:01:55 +00:00
|
|
|
dprintf("towrite=%llu written=%llu tofree=%llu freed=%llu\n",
|
|
|
|
tx->tx_space_towrite, refcount_count(&tx->tx_space_written),
|
|
|
|
tx->tx_space_tofree, refcount_count(&tx->tx_space_freed));
|
|
|
|
#endif
|
2017-01-23 17:36:24 +00:00
|
|
|
dmu_tx_destroy(tx);
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dmu_tx_abort(dmu_tx_t *tx)
|
|
|
|
{
|
|
|
|
ASSERT(tx->tx_txg == 0);
|
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
/*
|
|
|
|
* Call any registered callbacks with an error code.
|
|
|
|
*/
|
|
|
|
if (!list_is_empty(&tx->tx_callbacks))
|
|
|
|
dmu_tx_do_callbacks(&tx->tx_callbacks, ECANCELED);
|
|
|
|
|
2017-01-23 17:36:24 +00:00
|
|
|
dmu_tx_destroy(tx);
|
2008-11-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t
|
|
|
|
dmu_tx_get_txg(dmu_tx_t *tx)
|
|
|
|
{
|
|
|
|
ASSERT(tx->tx_txg != 0);
|
|
|
|
return (tx->tx_txg);
|
|
|
|
}
|
2010-05-28 20:45:14 +00:00
|
|
|
|
2013-09-04 12:00:57 +00:00
|
|
|
dsl_pool_t *
|
|
|
|
dmu_tx_pool(dmu_tx_t *tx)
|
|
|
|
{
|
|
|
|
ASSERT(tx->tx_pool != NULL);
|
|
|
|
return (tx->tx_pool);
|
|
|
|
}
|
|
|
|
|
2010-05-28 20:45:14 +00:00
|
|
|
void
|
|
|
|
dmu_tx_callback_register(dmu_tx_t *tx, dmu_tx_callback_func_t *func, void *data)
|
|
|
|
{
|
|
|
|
dmu_tx_callback_t *dcb;
|
|
|
|
|
2014-11-21 00:09:39 +00:00
|
|
|
dcb = kmem_alloc(sizeof (dmu_tx_callback_t), KM_SLEEP);
|
2010-05-28 20:45:14 +00:00
|
|
|
|
|
|
|
dcb->dcb_func = func;
|
|
|
|
dcb->dcb_data = data;
|
|
|
|
|
|
|
|
list_insert_tail(&tx->tx_callbacks, dcb);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call all the commit callbacks on a list, with a given error code.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
dmu_tx_do_callbacks(list_t *cb_list, int error)
|
|
|
|
{
|
|
|
|
dmu_tx_callback_t *dcb;
|
|
|
|
|
2017-01-23 17:36:24 +00:00
|
|
|
while ((dcb = list_head(cb_list)) != NULL) {
|
2010-05-28 20:45:14 +00:00
|
|
|
list_remove(cb_list, dcb);
|
|
|
|
dcb->dcb_func(dcb->dcb_data, error);
|
|
|
|
kmem_free(dcb, sizeof (dmu_tx_callback_t));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interface to hold a bunch of attributes.
|
|
|
|
* used for creating new files.
|
|
|
|
* attrsize is the total size of all attributes
|
|
|
|
* to be added during object creation
|
|
|
|
*
|
|
|
|
* For updating/adding a single attribute dmu_tx_hold_sa() should be used.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* hold necessary attribute name for attribute registration.
|
|
|
|
* should be a very rare case where this is needed. If it does
|
|
|
|
* happen it would only happen on the first write to the file system.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
dmu_tx_sa_registration_hold(sa_os_t *sa, dmu_tx_t *tx)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!sa->sa_need_attr_registration)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i != sa->sa_num_attrs; i++) {
|
|
|
|
if (!sa->sa_attr_table[i].sa_registered) {
|
|
|
|
if (sa->sa_reg_attr_obj)
|
|
|
|
dmu_tx_hold_zap(tx, sa->sa_reg_attr_obj,
|
|
|
|
B_TRUE, sa->sa_attr_table[i].sa_name);
|
|
|
|
else
|
|
|
|
dmu_tx_hold_zap(tx, DMU_NEW_OBJECT,
|
|
|
|
B_TRUE, sa->sa_attr_table[i].sa_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
dmu_tx_hold_spill(dmu_tx_t *tx, uint64_t object)
|
|
|
|
{
|
|
|
|
dnode_t *dn;
|
|
|
|
dmu_tx_hold_t *txh;
|
|
|
|
|
|
|
|
txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, object,
|
|
|
|
THT_SPILL, 0, 0);
|
2013-07-23 17:32:57 +00:00
|
|
|
if (txh == NULL)
|
|
|
|
return;
|
2010-05-28 20:45:14 +00:00
|
|
|
|
|
|
|
dn = txh->txh_dnode;
|
|
|
|
|
|
|
|
if (dn == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* If blkptr doesn't exist then add space to towrite */
|
2012-04-08 17:10:49 +00:00
|
|
|
if (!(dn->dn_phys->dn_flags & DNODE_FLAG_SPILL_BLKPTR)) {
|
2017-01-23 17:36:24 +00:00
|
|
|
(void) refcount_add_many(&txh->txh_space_towrite,
|
|
|
|
SPA_OLD_MAXBLOCKSIZE, FTAG);
|
2010-05-28 20:45:14 +00:00
|
|
|
} else {
|
2012-04-08 17:10:49 +00:00
|
|
|
blkptr_t *bp;
|
|
|
|
|
Implement large_dnode pool feature
Justification
-------------
This feature adds support for variable length dnodes. Our motivation is
to eliminate the overhead associated with using spill blocks. Spill
blocks are used to store system attribute data (i.e. file metadata) that
does not fit in the dnode's bonus buffer. By allowing a larger bonus
buffer area the use of a spill block can be avoided. Spill blocks
potentially incur an additional read I/O for every dnode in a dnode
block. As a worst case example, reading 32 dnodes from a 16k dnode block
and all of the spill blocks could issue 33 separate reads. Now suppose
those dnodes have size 1024 and therefore don't need spill blocks. Then
the worst case number of blocks read is reduced to from 33 to two--one
per dnode block. In practice spill blocks may tend to be co-located on
disk with the dnode blocks so the reduction in I/O would not be this
drastic. In a badly fragmented pool, however, the improvement could be
significant.
ZFS-on-Linux systems that make heavy use of extended attributes would
benefit from this feature. In particular, ZFS-on-Linux supports the
xattr=sa dataset property which allows file extended attribute data
to be stored in the dnode bonus buffer as an alternative to the
traditional directory-based format. Workloads such as SELinux and the
Lustre distributed filesystem often store enough xattr data to force
spill bocks when xattr=sa is in effect. Large dnodes may therefore
provide a performance benefit to such systems.
Other use cases that may benefit from this feature include files with
large ACLs and symbolic links with long target names. Furthermore,
this feature may be desirable on other platforms in case future
applications or features are developed that could make use of a
larger bonus buffer area.
Implementation
--------------
The size of a dnode may be a multiple of 512 bytes up to the size of
a dnode block (currently 16384 bytes). A dn_extra_slots field was
added to the current on-disk dnode_phys_t structure to describe the
size of the physical dnode on disk. The 8 bits for this field were
taken from the zero filled dn_pad2 field. The field represents how
many "extra" dnode_phys_t slots a dnode consumes in its dnode block.
This convention results in a value of 0 for 512 byte dnodes which
preserves on-disk format compatibility with older software.
Similarly, the in-memory dnode_t structure has a new dn_num_slots field
to represent the total number of dnode_phys_t slots consumed on disk.
Thus dn->dn_num_slots is 1 greater than the corresponding
dnp->dn_extra_slots. This difference in convention was adopted
because, unlike on-disk structures, backward compatibility is not a
concern for in-memory objects, so we used a more natural way to
represent size for a dnode_t.
The default size for newly created dnodes is determined by the value of
a new "dnodesize" dataset property. By default the property is set to
"legacy" which is compatible with older software. Setting the property
to "auto" will allow the filesystem to choose the most suitable dnode
size. Currently this just sets the default dnode size to 1k, but future
code improvements could dynamically choose a size based on observed
workload patterns. Dnodes of varying sizes can coexist within the same
dataset and even within the same dnode block. For example, to enable
automatically-sized dnodes, run
# zfs set dnodesize=auto tank/fish
The user can also specify literal values for the dnodesize property.
These are currently limited to powers of two from 1k to 16k. The
power-of-2 limitation is only for simplicity of the user interface.
Internally the implementation can handle any multiple of 512 up to 16k,
and consumers of the DMU API can specify any legal dnode value.
The size of a new dnode is determined at object allocation time and
stored as a new field in the znode in-memory structure. New DMU
interfaces are added to allow the consumer to specify the dnode size
that a newly allocated object should use. Existing interfaces are
unchanged to avoid having to update every call site and to preserve
compatibility with external consumers such as Lustre. The new
interfaces names are given below. The versions of these functions that
don't take a dnodesize parameter now just call the _dnsize() versions
with a dnodesize of 0, which means use the legacy dnode size.
New DMU interfaces:
dmu_object_alloc_dnsize()
dmu_object_claim_dnsize()
dmu_object_reclaim_dnsize()
New ZAP interfaces:
zap_create_dnsize()
zap_create_norm_dnsize()
zap_create_flags_dnsize()
zap_create_claim_norm_dnsize()
zap_create_link_dnsize()
The constant DN_MAX_BONUSLEN is renamed to DN_OLD_MAX_BONUSLEN. The
spa_maxdnodesize() function should be used to determine the maximum
bonus length for a pool.
These are a few noteworthy changes to key functions:
* The prototype for dnode_hold_impl() now takes a "slots" parameter.
When the DNODE_MUST_BE_FREE flag is set, this parameter is used to
ensure the hole at the specified object offset is large enough to
hold the dnode being created. The slots parameter is also used
to ensure a dnode does not span multiple dnode blocks. In both of
these cases, if a failure occurs, ENOSPC is returned. Keep in mind,
these failure cases are only possible when using DNODE_MUST_BE_FREE.
If the DNODE_MUST_BE_ALLOCATED flag is set, "slots" must be 0.
dnode_hold_impl() will check if the requested dnode is already
consumed as an extra dnode slot by an large dnode, in which case
it returns ENOENT.
* The function dmu_object_alloc() advances to the next dnode block
if dnode_hold_impl() returns an error for a requested object.
This is because the beginning of the next dnode block is the only
location it can safely assume to either be a hole or a valid
starting point for a dnode.
* dnode_next_offset_level() and other functions that iterate
through dnode blocks may no longer use a simple array indexing
scheme. These now use the current dnode's dn_num_slots field to
advance to the next dnode in the block. This is to ensure we
properly skip the current dnode's bonus area and don't interpret it
as a valid dnode.
zdb
---
The zdb command was updated to display a dnode's size under the
"dnsize" column when the object is dumped.
For ZIL create log records, zdb will now display the slot count for
the object.
ztest
-----
Ztest chooses a random dnodesize for every newly created object. The
random distribution is more heavily weighted toward small dnodes to
better simulate real-world datasets.
Unused bonus buffer space is filled with non-zero values computed from
the object number, dataset id, offset, and generation number. This
helps ensure that the dnode traversal code properly skips the interior
regions of large dnodes, and that these interior regions are not
overwritten by data belonging to other dnodes. A new test visits each
object in a dataset. It verifies that the actual dnode size matches what
was stored in the ztest block tag when it was created. It also verifies
that the unused bonus buffer space is filled with the expected data
patterns.
ZFS Test Suite
--------------
Added six new large dnode-specific tests, and integrated the dnodesize
property into existing tests for zfs allow and send/recv.
Send/Receive
------------
ZFS send streams for datasets containing large dnodes cannot be received
on pools that don't support the large_dnode feature. A send stream with
large dnodes sets a DMU_BACKUP_FEATURE_LARGE_DNODE flag which will be
unrecognized by an incompatible receiving pool so that the zfs receive
will fail gracefully.
While not implemented here, it may be possible to generate a
backward-compatible send stream from a dataset containing large
dnodes. The implementation may be tricky, however, because the send
object record for a large dnode would need to be resized to a 512
byte dnode, possibly kicking in a spill block in the process. This
means we would need to construct a new SA layout and possibly
register it in the SA layout object. The SA layout is normally just
sent as an ordinary object record. But if we are constructing new
layouts while generating the send stream we'd have to build the SA
layout object dynamically and send it at the end of the stream.
For sending and receiving between pools that do support large dnodes,
the drr_object send record type is extended with a new field to store
the dnode slot count. This field was repurposed from unused padding
in the structure.
ZIL Replay
----------
The dnode slot count is stored in the uppermost 8 bits of the lr_foid
field. The bits were unused as the object id is currently capped at
48 bits.
Resizing Dnodes
---------------
It should be possible to resize a dnode when it is dirtied if the
current dnodesize dataset property differs from the dnode's size, but
this functionality is not currently implemented. Clearly a dnode can
only grow if there are sufficient contiguous unused slots in the
dnode block, but it should always be possible to shrink a dnode.
Growing dnodes may be useful to reduce fragmentation in a pool with
many spill blocks in use. Shrinking dnodes may be useful to allow
sending a dataset to a pool that doesn't support the large_dnode
feature.
Feature Reference Counting
--------------------------
The reference count for the large_dnode pool feature tracks the
number of datasets that have ever contained a dnode of size larger
than 512 bytes. The first time a large dnode is created in a dataset
the dataset is converted to an extensible dataset. This is a one-way
operation and the only way to decrement the feature count is to
destroy the dataset, even if the dataset no longer contains any large
dnodes. The complexity of reference counting on a per-dnode basis was
too high, so we chose to track it on a per-dataset basis similarly to
the large_block feature.
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3542
2016-03-17 01:25:34 +00:00
|
|
|
bp = DN_SPILL_BLKPTR(dn->dn_phys);
|
2010-05-28 20:45:14 +00:00
|
|
|
if (dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset,
|
2017-01-23 17:36:24 +00:00
|
|
|
bp, bp->blk_birth)) {
|
|
|
|
(void) refcount_add_many(&txh->txh_space_tooverwrite,
|
|
|
|
SPA_OLD_MAXBLOCKSIZE, FTAG);
|
|
|
|
} else {
|
|
|
|
(void) refcount_add_many(&txh->txh_space_towrite,
|
|
|
|
SPA_OLD_MAXBLOCKSIZE, FTAG);
|
|
|
|
}
|
|
|
|
if (!BP_IS_HOLE(bp)) {
|
|
|
|
(void) refcount_add_many(&txh->txh_space_tounref,
|
|
|
|
SPA_OLD_MAXBLOCKSIZE, FTAG);
|
|
|
|
}
|
2010-05-28 20:45:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dmu_tx_hold_sa_create(dmu_tx_t *tx, int attrsize)
|
|
|
|
{
|
|
|
|
sa_os_t *sa = tx->tx_objset->os_sa;
|
|
|
|
|
|
|
|
dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT);
|
|
|
|
|
|
|
|
if (tx->tx_objset->os_sa->sa_master_obj == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (tx->tx_objset->os_sa->sa_layout_attr_obj)
|
|
|
|
dmu_tx_hold_zap(tx, sa->sa_layout_attr_obj, B_TRUE, NULL);
|
|
|
|
else {
|
|
|
|
dmu_tx_hold_zap(tx, sa->sa_master_obj, B_TRUE, SA_LAYOUTS);
|
|
|
|
dmu_tx_hold_zap(tx, sa->sa_master_obj, B_TRUE, SA_REGISTRY);
|
|
|
|
dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, B_TRUE, NULL);
|
|
|
|
dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, B_TRUE, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
dmu_tx_sa_registration_hold(sa, tx);
|
|
|
|
|
Implement large_dnode pool feature
Justification
-------------
This feature adds support for variable length dnodes. Our motivation is
to eliminate the overhead associated with using spill blocks. Spill
blocks are used to store system attribute data (i.e. file metadata) that
does not fit in the dnode's bonus buffer. By allowing a larger bonus
buffer area the use of a spill block can be avoided. Spill blocks
potentially incur an additional read I/O for every dnode in a dnode
block. As a worst case example, reading 32 dnodes from a 16k dnode block
and all of the spill blocks could issue 33 separate reads. Now suppose
those dnodes have size 1024 and therefore don't need spill blocks. Then
the worst case number of blocks read is reduced to from 33 to two--one
per dnode block. In practice spill blocks may tend to be co-located on
disk with the dnode blocks so the reduction in I/O would not be this
drastic. In a badly fragmented pool, however, the improvement could be
significant.
ZFS-on-Linux systems that make heavy use of extended attributes would
benefit from this feature. In particular, ZFS-on-Linux supports the
xattr=sa dataset property which allows file extended attribute data
to be stored in the dnode bonus buffer as an alternative to the
traditional directory-based format. Workloads such as SELinux and the
Lustre distributed filesystem often store enough xattr data to force
spill bocks when xattr=sa is in effect. Large dnodes may therefore
provide a performance benefit to such systems.
Other use cases that may benefit from this feature include files with
large ACLs and symbolic links with long target names. Furthermore,
this feature may be desirable on other platforms in case future
applications or features are developed that could make use of a
larger bonus buffer area.
Implementation
--------------
The size of a dnode may be a multiple of 512 bytes up to the size of
a dnode block (currently 16384 bytes). A dn_extra_slots field was
added to the current on-disk dnode_phys_t structure to describe the
size of the physical dnode on disk. The 8 bits for this field were
taken from the zero filled dn_pad2 field. The field represents how
many "extra" dnode_phys_t slots a dnode consumes in its dnode block.
This convention results in a value of 0 for 512 byte dnodes which
preserves on-disk format compatibility with older software.
Similarly, the in-memory dnode_t structure has a new dn_num_slots field
to represent the total number of dnode_phys_t slots consumed on disk.
Thus dn->dn_num_slots is 1 greater than the corresponding
dnp->dn_extra_slots. This difference in convention was adopted
because, unlike on-disk structures, backward compatibility is not a
concern for in-memory objects, so we used a more natural way to
represent size for a dnode_t.
The default size for newly created dnodes is determined by the value of
a new "dnodesize" dataset property. By default the property is set to
"legacy" which is compatible with older software. Setting the property
to "auto" will allow the filesystem to choose the most suitable dnode
size. Currently this just sets the default dnode size to 1k, but future
code improvements could dynamically choose a size based on observed
workload patterns. Dnodes of varying sizes can coexist within the same
dataset and even within the same dnode block. For example, to enable
automatically-sized dnodes, run
# zfs set dnodesize=auto tank/fish
The user can also specify literal values for the dnodesize property.
These are currently limited to powers of two from 1k to 16k. The
power-of-2 limitation is only for simplicity of the user interface.
Internally the implementation can handle any multiple of 512 up to 16k,
and consumers of the DMU API can specify any legal dnode value.
The size of a new dnode is determined at object allocation time and
stored as a new field in the znode in-memory structure. New DMU
interfaces are added to allow the consumer to specify the dnode size
that a newly allocated object should use. Existing interfaces are
unchanged to avoid having to update every call site and to preserve
compatibility with external consumers such as Lustre. The new
interfaces names are given below. The versions of these functions that
don't take a dnodesize parameter now just call the _dnsize() versions
with a dnodesize of 0, which means use the legacy dnode size.
New DMU interfaces:
dmu_object_alloc_dnsize()
dmu_object_claim_dnsize()
dmu_object_reclaim_dnsize()
New ZAP interfaces:
zap_create_dnsize()
zap_create_norm_dnsize()
zap_create_flags_dnsize()
zap_create_claim_norm_dnsize()
zap_create_link_dnsize()
The constant DN_MAX_BONUSLEN is renamed to DN_OLD_MAX_BONUSLEN. The
spa_maxdnodesize() function should be used to determine the maximum
bonus length for a pool.
These are a few noteworthy changes to key functions:
* The prototype for dnode_hold_impl() now takes a "slots" parameter.
When the DNODE_MUST_BE_FREE flag is set, this parameter is used to
ensure the hole at the specified object offset is large enough to
hold the dnode being created. The slots parameter is also used
to ensure a dnode does not span multiple dnode blocks. In both of
these cases, if a failure occurs, ENOSPC is returned. Keep in mind,
these failure cases are only possible when using DNODE_MUST_BE_FREE.
If the DNODE_MUST_BE_ALLOCATED flag is set, "slots" must be 0.
dnode_hold_impl() will check if the requested dnode is already
consumed as an extra dnode slot by an large dnode, in which case
it returns ENOENT.
* The function dmu_object_alloc() advances to the next dnode block
if dnode_hold_impl() returns an error for a requested object.
This is because the beginning of the next dnode block is the only
location it can safely assume to either be a hole or a valid
starting point for a dnode.
* dnode_next_offset_level() and other functions that iterate
through dnode blocks may no longer use a simple array indexing
scheme. These now use the current dnode's dn_num_slots field to
advance to the next dnode in the block. This is to ensure we
properly skip the current dnode's bonus area and don't interpret it
as a valid dnode.
zdb
---
The zdb command was updated to display a dnode's size under the
"dnsize" column when the object is dumped.
For ZIL create log records, zdb will now display the slot count for
the object.
ztest
-----
Ztest chooses a random dnodesize for every newly created object. The
random distribution is more heavily weighted toward small dnodes to
better simulate real-world datasets.
Unused bonus buffer space is filled with non-zero values computed from
the object number, dataset id, offset, and generation number. This
helps ensure that the dnode traversal code properly skips the interior
regions of large dnodes, and that these interior regions are not
overwritten by data belonging to other dnodes. A new test visits each
object in a dataset. It verifies that the actual dnode size matches what
was stored in the ztest block tag when it was created. It also verifies
that the unused bonus buffer space is filled with the expected data
patterns.
ZFS Test Suite
--------------
Added six new large dnode-specific tests, and integrated the dnodesize
property into existing tests for zfs allow and send/recv.
Send/Receive
------------
ZFS send streams for datasets containing large dnodes cannot be received
on pools that don't support the large_dnode feature. A send stream with
large dnodes sets a DMU_BACKUP_FEATURE_LARGE_DNODE flag which will be
unrecognized by an incompatible receiving pool so that the zfs receive
will fail gracefully.
While not implemented here, it may be possible to generate a
backward-compatible send stream from a dataset containing large
dnodes. The implementation may be tricky, however, because the send
object record for a large dnode would need to be resized to a 512
byte dnode, possibly kicking in a spill block in the process. This
means we would need to construct a new SA layout and possibly
register it in the SA layout object. The SA layout is normally just
sent as an ordinary object record. But if we are constructing new
layouts while generating the send stream we'd have to build the SA
layout object dynamically and send it at the end of the stream.
For sending and receiving between pools that do support large dnodes,
the drr_object send record type is extended with a new field to store
the dnode slot count. This field was repurposed from unused padding
in the structure.
ZIL Replay
----------
The dnode slot count is stored in the uppermost 8 bits of the lr_foid
field. The bits were unused as the object id is currently capped at
48 bits.
Resizing Dnodes
---------------
It should be possible to resize a dnode when it is dirtied if the
current dnodesize dataset property differs from the dnode's size, but
this functionality is not currently implemented. Clearly a dnode can
only grow if there are sufficient contiguous unused slots in the
dnode block, but it should always be possible to shrink a dnode.
Growing dnodes may be useful to reduce fragmentation in a pool with
many spill blocks in use. Shrinking dnodes may be useful to allow
sending a dataset to a pool that doesn't support the large_dnode
feature.
Feature Reference Counting
--------------------------
The reference count for the large_dnode pool feature tracks the
number of datasets that have ever contained a dnode of size larger
than 512 bytes. The first time a large dnode is created in a dataset
the dataset is converted to an extensible dataset. This is a one-way
operation and the only way to decrement the feature count is to
destroy the dataset, even if the dataset no longer contains any large
dnodes. The complexity of reference counting on a per-dnode basis was
too high, so we chose to track it on a per-dataset basis similarly to
the large_block feature.
Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3542
2016-03-17 01:25:34 +00:00
|
|
|
if (attrsize <= DN_OLD_MAX_BONUSLEN && !sa->sa_force_spill)
|
2010-05-28 20:45:14 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
(void) dmu_tx_hold_object_impl(tx, tx->tx_objset, DMU_NEW_OBJECT,
|
|
|
|
THT_SPILL, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hold SA attribute
|
|
|
|
*
|
|
|
|
* dmu_tx_hold_sa(dmu_tx_t *tx, sa_handle_t *, attribute, add, size)
|
|
|
|
*
|
|
|
|
* variable_size is the total size of all variable sized attributes
|
|
|
|
* passed to this function. It is not the total size of all
|
|
|
|
* variable size attributes that *may* exist on this object.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
dmu_tx_hold_sa(dmu_tx_t *tx, sa_handle_t *hdl, boolean_t may_grow)
|
|
|
|
{
|
|
|
|
uint64_t object;
|
|
|
|
sa_os_t *sa = tx->tx_objset->os_sa;
|
|
|
|
|
|
|
|
ASSERT(hdl != NULL);
|
|
|
|
|
|
|
|
object = sa_handle_object(hdl);
|
|
|
|
|
|
|
|
dmu_tx_hold_bonus(tx, object);
|
|
|
|
|
|
|
|
if (tx->tx_objset->os_sa->sa_master_obj == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (tx->tx_objset->os_sa->sa_reg_attr_obj == 0 ||
|
|
|
|
tx->tx_objset->os_sa->sa_layout_attr_obj == 0) {
|
|
|
|
dmu_tx_hold_zap(tx, sa->sa_master_obj, B_TRUE, SA_LAYOUTS);
|
|
|
|
dmu_tx_hold_zap(tx, sa->sa_master_obj, B_TRUE, SA_REGISTRY);
|
|
|
|
dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, B_TRUE, NULL);
|
|
|
|
dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, B_TRUE, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
dmu_tx_sa_registration_hold(sa, tx);
|
|
|
|
|
|
|
|
if (may_grow && tx->tx_objset->os_sa->sa_layout_attr_obj)
|
|
|
|
dmu_tx_hold_zap(tx, sa->sa_layout_attr_obj, B_TRUE, NULL);
|
|
|
|
|
2010-08-26 21:24:34 +00:00
|
|
|
if (sa->sa_force_spill || may_grow || hdl->sa_spill) {
|
2010-05-28 20:45:14 +00:00
|
|
|
ASSERT(tx->tx_txg == 0);
|
|
|
|
dmu_tx_hold_spill(tx, object);
|
2010-08-26 21:24:34 +00:00
|
|
|
} else {
|
|
|
|
dmu_buf_impl_t *db = (dmu_buf_impl_t *)hdl->sa_bonus;
|
|
|
|
dnode_t *dn;
|
|
|
|
|
|
|
|
DB_DNODE_ENTER(db);
|
|
|
|
dn = DB_DNODE(db);
|
|
|
|
if (dn->dn_have_spill) {
|
|
|
|
ASSERT(tx->tx_txg == 0);
|
|
|
|
dmu_tx_hold_spill(tx, object);
|
|
|
|
}
|
|
|
|
DB_DNODE_EXIT(db);
|
2010-05-28 20:45:14 +00:00
|
|
|
}
|
|
|
|
}
|
2010-08-26 18:49:16 +00:00
|
|
|
|
2012-01-20 18:58:57 +00:00
|
|
|
void
|
|
|
|
dmu_tx_init(void)
|
|
|
|
{
|
|
|
|
dmu_tx_ksp = kstat_create("zfs", 0, "dmu_tx", "misc",
|
|
|
|
KSTAT_TYPE_NAMED, sizeof (dmu_tx_stats) / sizeof (kstat_named_t),
|
|
|
|
KSTAT_FLAG_VIRTUAL);
|
|
|
|
|
|
|
|
if (dmu_tx_ksp != NULL) {
|
|
|
|
dmu_tx_ksp->ks_data = &dmu_tx_stats;
|
|
|
|
kstat_install(dmu_tx_ksp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dmu_tx_fini(void)
|
|
|
|
{
|
|
|
|
if (dmu_tx_ksp != NULL) {
|
|
|
|
kstat_delete(dmu_tx_ksp);
|
|
|
|
dmu_tx_ksp = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-26 18:49:16 +00:00
|
|
|
#if defined(_KERNEL) && defined(HAVE_SPL)
|
|
|
|
EXPORT_SYMBOL(dmu_tx_create);
|
|
|
|
EXPORT_SYMBOL(dmu_tx_hold_write);
|
2017-01-13 22:58:41 +00:00
|
|
|
EXPORT_SYMBOL(dmu_tx_hold_write_by_dnode);
|
2010-08-26 18:49:16 +00:00
|
|
|
EXPORT_SYMBOL(dmu_tx_hold_free);
|
2017-01-13 22:58:41 +00:00
|
|
|
EXPORT_SYMBOL(dmu_tx_hold_free_by_dnode);
|
2010-08-26 18:49:16 +00:00
|
|
|
EXPORT_SYMBOL(dmu_tx_hold_zap);
|
2017-01-13 22:58:41 +00:00
|
|
|
EXPORT_SYMBOL(dmu_tx_hold_zap_by_dnode);
|
2010-08-26 18:49:16 +00:00
|
|
|
EXPORT_SYMBOL(dmu_tx_hold_bonus);
|
2017-01-13 22:58:41 +00:00
|
|
|
EXPORT_SYMBOL(dmu_tx_hold_bonus_by_dnode);
|
2010-08-26 18:49:16 +00:00
|
|
|
EXPORT_SYMBOL(dmu_tx_abort);
|
|
|
|
EXPORT_SYMBOL(dmu_tx_assign);
|
|
|
|
EXPORT_SYMBOL(dmu_tx_wait);
|
|
|
|
EXPORT_SYMBOL(dmu_tx_commit);
|
|
|
|
EXPORT_SYMBOL(dmu_tx_get_txg);
|
|
|
|
EXPORT_SYMBOL(dmu_tx_callback_register);
|
|
|
|
EXPORT_SYMBOL(dmu_tx_do_callbacks);
|
|
|
|
EXPORT_SYMBOL(dmu_tx_hold_spill);
|
|
|
|
EXPORT_SYMBOL(dmu_tx_hold_sa_create);
|
|
|
|
EXPORT_SYMBOL(dmu_tx_hold_sa);
|
|
|
|
#endif
|