2008-11-20 23:01:55 +03: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
|
2022-07-12 00:16:13 +03:00
|
|
|
* or https://opensource.org/licenses/CDDL-1.0.
|
2008-11-20 23:01:55 +03:00
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
/*
|
2009-02-18 23:51:31 +03:00
|
|
|
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
2008-11-20 23:01:55 +03:00
|
|
|
* Use is subject to license terms.
|
|
|
|
*/
|
2013-03-08 22:41:28 +04:00
|
|
|
/*
|
2016-07-22 18:52:49 +03:00
|
|
|
* Copyright (c) 2013, 2016 by Delphix. All rights reserved.
|
2013-03-08 22:41:28 +04:00
|
|
|
*/
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
#include <sys/zfs_context.h>
|
|
|
|
#include <sys/spa.h>
|
|
|
|
#include <sys/vdev_impl.h>
|
|
|
|
#include <sys/zio.h>
|
|
|
|
#include <sys/kstat.h>
|
2016-07-22 18:52:49 +03:00
|
|
|
#include <sys/abd.h>
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Virtual device read-ahead caching.
|
|
|
|
*
|
|
|
|
* This file implements a simple LRU read-ahead cache. When the DMU reads
|
|
|
|
* a given block, it will often want other, nearby blocks soon thereafter.
|
|
|
|
* We take advantage of this by reading a larger disk region and caching
|
|
|
|
* the result. In the best case, this can turn 128 back-to-back 512-byte
|
|
|
|
* reads into a single 64k read followed by 127 cache hits; this reduces
|
|
|
|
* latency dramatically. In the worst case, it can turn an isolated 512-byte
|
|
|
|
* read into a 64k read, which doesn't affect latency all that much but is
|
|
|
|
* terribly wasteful of bandwidth. A more intelligent version of the cache
|
|
|
|
* could keep track of access patterns and not do read-ahead unless it sees
|
|
|
|
* at least two temporally close I/Os to the same region. Currently, only
|
2019-09-03 03:56:41 +03:00
|
|
|
* metadata I/O is inflated. A further enhancement could take advantage of
|
2008-11-20 23:01:55 +03:00
|
|
|
* more semantic information about the I/O. And it could use something
|
|
|
|
* faster than an AVL tree; that was chosen solely for convenience.
|
|
|
|
*
|
|
|
|
* There are five cache operations: allocate, fill, read, write, evict.
|
|
|
|
*
|
|
|
|
* (1) Allocate. This reserves a cache entry for the specified region.
|
|
|
|
* We separate the allocate and fill operations so that multiple threads
|
|
|
|
* don't generate I/O for the same cache miss.
|
|
|
|
*
|
|
|
|
* (2) Fill. When the I/O for a cache miss completes, the fill routine
|
|
|
|
* places the data in the previously allocated cache entry.
|
|
|
|
*
|
|
|
|
* (3) Read. Read data from the cache.
|
|
|
|
*
|
|
|
|
* (4) Write. Update cache contents after write completion.
|
|
|
|
*
|
|
|
|
* (5) Evict. When allocating a new entry, we evict the oldest (LRU) entry
|
|
|
|
* if the total cache size exceeds zfs_vdev_cache_size.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These tunables are for performance analysis.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* All i/os smaller than zfs_vdev_cache_max will be turned into
|
|
|
|
* 1<<zfs_vdev_cache_bshift byte reads by the vdev_cache (aka software
|
|
|
|
* track buffer). At most zfs_vdev_cache_size bytes will be kept in each
|
|
|
|
* vdev's vdev_cache.
|
2011-04-22 11:49:41 +04:00
|
|
|
*
|
|
|
|
* TODO: Note that with the current ZFS code, it turns out that the
|
|
|
|
* vdev cache is not helpful, and in some cases actually harmful. It
|
|
|
|
* is better if we disable this. Once some time has passed, we should
|
|
|
|
* actually remove this to simplify the code. For now we just disable
|
|
|
|
* it by setting the zfs_vdev_cache_size to zero. Note that Solaris 11
|
|
|
|
* has made these same changes.
|
2008-11-20 23:01:55 +03:00
|
|
|
*/
|
Cleanup: Specify unsignedness on things that should not be signed
In #13871, zfs_vdev_aggregation_limit_non_rotating and
zfs_vdev_aggregation_limit being signed was pointed out as a possible
reason not to eliminate an unnecessary MAX(unsigned, 0) since the
unsigned value was assigned from them.
There is no reason for these module parameters to be signed and upon
inspection, it was found that there are a number of other module
parameters that are signed, but should not be, so we make them unsigned.
Making them unsigned made it clear that some other variables in the code
should also be unsigned, so we also make those unsigned. This prevents
users from setting negative values that could potentially cause bad
behaviors. It also makes the code slightly easier to understand.
Mostly module parameters that deal with timeouts, limits, bitshifts and
percentages are made unsigned by this. Any that are boolean are left
signed, since whether booleans should be considered signed or unsigned
does not matter.
Making zfs_arc_lotsfree_percent unsigned caused a
`zfs_arc_lotsfree_percent >= 0` check to become redundant, so it was
removed. Removing the check was also necessary to prevent a compiler
error from -Werror=type-limits.
Several end of line comments had to be moved to their own lines because
replacing int with uint_t caused us to exceed the 80 character limit
enforced by cstyle.pl.
The following were kept signed because they are passed to
taskq_create(), which expects signed values and modifying the
OpenSolaris/Illumos DDI is out of scope of this patch:
* metaslab_load_pct
* zfs_sync_taskq_batch_pct
* zfs_zil_clean_taskq_nthr_pct
* zfs_zil_clean_taskq_minalloc
* zfs_zil_clean_taskq_maxalloc
* zfs_arc_prune_task_threads
Also, negative values in those parameters was found to be harmless.
The following were left signed because either negative values make
sense, or more analysis was needed to determine whether negative values
should be disallowed:
* zfs_metaslab_switch_threshold
* zfs_pd_bytes_max
* zfs_livelist_min_percent_shared
zfs_multihost_history was made static to be consistent with other
parameters.
A number of module parameters were marked as signed, but in reality
referenced unsigned variables. upgrade_errlog_limit is one of the
numerous examples. In the case of zfs_vdev_async_read_max_active, it was
already uint32_t, but zdb had an extern int declaration for it.
Interestingly, the documentation in zfs.4 was right for
upgrade_errlog_limit despite the module parameter being wrongly marked,
while the documentation for zfs_vdev_async_read_max_active (and friends)
was wrong. It was also wrong for zstd_abort_size, which was unsigned,
but was documented as signed.
Also, the documentation in zfs.4 incorrectly described the following
parameters as ulong when they were int:
* zfs_arc_meta_adjust_restarts
* zfs_override_estimate_recordsize
They are now uint_t as of this patch and thus the man page has been
updated to describe them as uint.
dbuf_state_index was left alone since it does nothing and perhaps should
be removed in another patch.
If any module parameters were missed, they were not found by `grep -r
'ZFS_MODULE_PARAM' | grep ', INT'`. I did find a few that grep missed,
but only because they were in files that had hits.
This patch intentionally did not attempt to address whether some of
these module parameters should be elevated to 64-bit parameters, because
the length of a long on 32-bit is 32-bit.
Lastly, it was pointed out during review that uint_t is a better match
for these variables than uint32_t because FreeBSD kernel parameter
definitions are designed for uint_t, whose bit width can change in
future memory models. As a result, we change the existing parameters
that are uint32_t to use uint_t.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Neal Gompa <ngompa@datto.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13875
2022-09-28 02:42:41 +03:00
|
|
|
static uint_t zfs_vdev_cache_max = 1 << 14; /* 16KB */
|
|
|
|
static uint_t zfs_vdev_cache_size = 0;
|
|
|
|
static uint_t zfs_vdev_cache_bshift = 16;
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
#define VCBS (1 << zfs_vdev_cache_bshift) /* 64KB */
|
|
|
|
|
2022-01-21 19:07:15 +03:00
|
|
|
static kstat_t *vdc_ksp = NULL;
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
typedef struct vdc_stats {
|
|
|
|
kstat_named_t vdc_stat_delegations;
|
|
|
|
kstat_named_t vdc_stat_hits;
|
|
|
|
kstat_named_t vdc_stat_misses;
|
|
|
|
} vdc_stats_t;
|
|
|
|
|
|
|
|
static vdc_stats_t vdc_stats = {
|
|
|
|
{ "delegations", KSTAT_DATA_UINT64 },
|
|
|
|
{ "hits", KSTAT_DATA_UINT64 },
|
|
|
|
{ "misses", KSTAT_DATA_UINT64 }
|
|
|
|
};
|
|
|
|
|
2016-01-14 03:37:41 +03:00
|
|
|
#define VDCSTAT_BUMP(stat) atomic_inc_64(&vdc_stats.stat.value.ui64);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2016-08-27 21:12:53 +03:00
|
|
|
static inline int
|
2008-11-20 23:01:55 +03:00
|
|
|
vdev_cache_offset_compare(const void *a1, const void *a2)
|
|
|
|
{
|
2016-08-27 21:12:53 +03:00
|
|
|
const vdev_cache_entry_t *ve1 = (const vdev_cache_entry_t *)a1;
|
|
|
|
const vdev_cache_entry_t *ve2 = (const vdev_cache_entry_t *)a2;
|
2008-11-20 23:01:55 +03:00
|
|
|
|
Reduce loaded range tree memory usage
This patch implements a new tree structure for ZFS, and uses it to
store range trees more efficiently.
The new structure is approximately a B-tree, though there are some
small differences from the usual characterizations. The tree has core
nodes and leaf nodes; each contain data elements, which the elements
in the core nodes acting as separators between its children. The
difference between core and leaf nodes is that the core nodes have an
array of children, while leaf nodes don't. Every node in the tree may
be only partially full; in most cases, they are all at least 50% full
(in terms of element count) except for the root node, which can be
less full. Underfull nodes will steal from their neighbors or merge to
remain full enough, while overfull nodes will split in two. The data
elements are contained in tree-controlled buffers; they are copied
into these on insertion, and overwritten on deletion. This means that
the elements are not independently allocated, which reduces overhead,
but also means they can't be shared between trees (and also that
pointers to them are only valid until a side-effectful tree operation
occurs). The overhead varies based on how dense the tree is, but is
usually on the order of about 50% of the element size; the per-node
overheads are very small, and so don't make a significant difference.
The trees can accept arbitrary records; they accept a size and a
comparator to allow them to be used for a variety of purposes.
The new trees replace the AVL trees used in the range trees today.
Currently, the range_seg_t structure contains three 8 byte integers
of payload and two 24 byte avl_tree_node_ts to handle its storage in
both an offset-sorted tree and a size-sorted tree (total size: 64
bytes). In the new model, the range seg structures are usually two 4
byte integers, but a separate one needs to exist for the size-sorted
and offset-sorted tree. Between the raw size, the 50% overhead, and
the double storage, the new btrees are expected to use 8*1.5*2 = 24
bytes per record, or 33.3% as much memory as the AVL trees (this is
for the purposes of storing metaslab range trees; for other purposes,
like scrubs, they use ~50% as much memory).
We reduced the size of the payload in the range segments by teaching
range trees about starting offsets and shifts; since metaslabs have a
fixed starting offset, and they all operate in terms of disk sectors,
we can store the ranges using 4-byte integers as long as the size of
the metaslab divided by the sector size is less than 2^32. For 512-byte
sectors, this is a 2^41 (or 2TB) metaslab, which with the default
settings corresponds to a 256PB disk. 4k sector disks can handle
metaslabs up to 2^46 bytes, or 2^63 byte disks. Since we do not
anticipate disks of this size in the near future, there should be
almost no cases where metaslabs need 64-byte integers to store their
ranges. We do still have the capability to store 64-byte integer ranges
to account for cases where we are storing per-vdev (or per-dnode) trees,
which could reasonably go above the limits discussed. We also do not
store fill information in the compact version of the node, since it
is only used for sorted scrub.
We also optimized the metaslab loading process in various other ways
to offset some inefficiencies in the btree model. While individual
operations (find, insert, remove_from) are faster for the btree than
they are for the avl tree, remove usually requires a find operation,
while in the AVL tree model the element itself suffices. Some clever
changes actually caused an overall speedup in metaslab loading; we use
approximately 40% less cpu to load metaslabs in our tests on Illumos.
Another memory and performance optimization was achieved by changing
what is stored in the size-sorted trees. When a disk is heavily
fragmented, the df algorithm used by default in ZFS will almost always
find a number of small regions in its initial cursor-based search; it
will usually only fall back to the size-sorted tree to find larger
regions. If we increase the size of the cursor-based search slightly,
and don't store segments that are smaller than a tunable size floor
in the size-sorted tree, we can further cut memory usage down to
below 20% of what the AVL trees store. This also results in further
reductions in CPU time spent loading metaslabs.
The 16KiB size floor was chosen because it results in substantial memory
usage reduction while not usually resulting in situations where we can't
find an appropriate chunk with the cursor and are forced to use an
oversized chunk from the size-sorted tree. In addition, even if we do
have to use an oversized chunk from the size-sorted tree, the chunk
would be too small to use for ZIL allocations, so it isn't as big of a
loss as it might otherwise be. And often, more small allocations will
follow the initial one, and the cursor search will now find the
remainder of the chunk we didn't use all of and use it for subsequent
allocations. Practical testing has shown little or no change in
fragmentation as a result of this change.
If the size-sorted tree becomes empty while the offset sorted one still
has entries, it will load all the entries from the offset sorted tree
and disregard the size floor until it is unloaded again. This operation
occurs rarely with the default setting, only on incredibly thoroughly
fragmented pools.
There are some other small changes to zdb to teach it to handle btrees,
but nothing major.
Reviewed-by: George Wilson <gwilson@delphix.com>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed by: Sebastien Roy seb@delphix.com
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Closes #9181
2019-10-09 20:36:03 +03:00
|
|
|
return (TREE_CMP(ve1->ve_offset, ve2->ve_offset));
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
vdev_cache_lastused_compare(const void *a1, const void *a2)
|
|
|
|
{
|
2016-08-27 21:12:53 +03:00
|
|
|
const vdev_cache_entry_t *ve1 = (const vdev_cache_entry_t *)a1;
|
|
|
|
const vdev_cache_entry_t *ve2 = (const vdev_cache_entry_t *)a2;
|
2008-11-20 23:01:55 +03:00
|
|
|
|
Reduce loaded range tree memory usage
This patch implements a new tree structure for ZFS, and uses it to
store range trees more efficiently.
The new structure is approximately a B-tree, though there are some
small differences from the usual characterizations. The tree has core
nodes and leaf nodes; each contain data elements, which the elements
in the core nodes acting as separators between its children. The
difference between core and leaf nodes is that the core nodes have an
array of children, while leaf nodes don't. Every node in the tree may
be only partially full; in most cases, they are all at least 50% full
(in terms of element count) except for the root node, which can be
less full. Underfull nodes will steal from their neighbors or merge to
remain full enough, while overfull nodes will split in two. The data
elements are contained in tree-controlled buffers; they are copied
into these on insertion, and overwritten on deletion. This means that
the elements are not independently allocated, which reduces overhead,
but also means they can't be shared between trees (and also that
pointers to them are only valid until a side-effectful tree operation
occurs). The overhead varies based on how dense the tree is, but is
usually on the order of about 50% of the element size; the per-node
overheads are very small, and so don't make a significant difference.
The trees can accept arbitrary records; they accept a size and a
comparator to allow them to be used for a variety of purposes.
The new trees replace the AVL trees used in the range trees today.
Currently, the range_seg_t structure contains three 8 byte integers
of payload and two 24 byte avl_tree_node_ts to handle its storage in
both an offset-sorted tree and a size-sorted tree (total size: 64
bytes). In the new model, the range seg structures are usually two 4
byte integers, but a separate one needs to exist for the size-sorted
and offset-sorted tree. Between the raw size, the 50% overhead, and
the double storage, the new btrees are expected to use 8*1.5*2 = 24
bytes per record, or 33.3% as much memory as the AVL trees (this is
for the purposes of storing metaslab range trees; for other purposes,
like scrubs, they use ~50% as much memory).
We reduced the size of the payload in the range segments by teaching
range trees about starting offsets and shifts; since metaslabs have a
fixed starting offset, and they all operate in terms of disk sectors,
we can store the ranges using 4-byte integers as long as the size of
the metaslab divided by the sector size is less than 2^32. For 512-byte
sectors, this is a 2^41 (or 2TB) metaslab, which with the default
settings corresponds to a 256PB disk. 4k sector disks can handle
metaslabs up to 2^46 bytes, or 2^63 byte disks. Since we do not
anticipate disks of this size in the near future, there should be
almost no cases where metaslabs need 64-byte integers to store their
ranges. We do still have the capability to store 64-byte integer ranges
to account for cases where we are storing per-vdev (or per-dnode) trees,
which could reasonably go above the limits discussed. We also do not
store fill information in the compact version of the node, since it
is only used for sorted scrub.
We also optimized the metaslab loading process in various other ways
to offset some inefficiencies in the btree model. While individual
operations (find, insert, remove_from) are faster for the btree than
they are for the avl tree, remove usually requires a find operation,
while in the AVL tree model the element itself suffices. Some clever
changes actually caused an overall speedup in metaslab loading; we use
approximately 40% less cpu to load metaslabs in our tests on Illumos.
Another memory and performance optimization was achieved by changing
what is stored in the size-sorted trees. When a disk is heavily
fragmented, the df algorithm used by default in ZFS will almost always
find a number of small regions in its initial cursor-based search; it
will usually only fall back to the size-sorted tree to find larger
regions. If we increase the size of the cursor-based search slightly,
and don't store segments that are smaller than a tunable size floor
in the size-sorted tree, we can further cut memory usage down to
below 20% of what the AVL trees store. This also results in further
reductions in CPU time spent loading metaslabs.
The 16KiB size floor was chosen because it results in substantial memory
usage reduction while not usually resulting in situations where we can't
find an appropriate chunk with the cursor and are forced to use an
oversized chunk from the size-sorted tree. In addition, even if we do
have to use an oversized chunk from the size-sorted tree, the chunk
would be too small to use for ZIL allocations, so it isn't as big of a
loss as it might otherwise be. And often, more small allocations will
follow the initial one, and the cursor search will now find the
remainder of the chunk we didn't use all of and use it for subsequent
allocations. Practical testing has shown little or no change in
fragmentation as a result of this change.
If the size-sorted tree becomes empty while the offset sorted one still
has entries, it will load all the entries from the offset sorted tree
and disregard the size floor until it is unloaded again. This operation
occurs rarely with the default setting, only on incredibly thoroughly
fragmented pools.
There are some other small changes to zdb to teach it to handle btrees,
but nothing major.
Reviewed-by: George Wilson <gwilson@delphix.com>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed by: Sebastien Roy seb@delphix.com
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Closes #9181
2019-10-09 20:36:03 +03:00
|
|
|
int cmp = TREE_CMP(ve1->ve_lastused, ve2->ve_lastused);
|
2016-08-27 21:12:53 +03:00
|
|
|
if (likely(cmp))
|
|
|
|
return (cmp);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Among equally old entries, sort by offset to ensure uniqueness.
|
|
|
|
*/
|
|
|
|
return (vdev_cache_offset_compare(a1, a2));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Evict the specified entry from the cache.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
vdev_cache_evict(vdev_cache_t *vc, vdev_cache_entry_t *ve)
|
|
|
|
{
|
|
|
|
ASSERT(MUTEX_HELD(&vc->vc_lock));
|
2016-07-22 18:52:49 +03:00
|
|
|
ASSERT3P(ve->ve_fill_io, ==, NULL);
|
|
|
|
ASSERT3P(ve->ve_abd, !=, NULL);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
avl_remove(&vc->vc_lastused_tree, ve);
|
|
|
|
avl_remove(&vc->vc_offset_tree, ve);
|
2016-07-22 18:52:49 +03:00
|
|
|
abd_free(ve->ve_abd);
|
2008-11-20 23:01:55 +03:00
|
|
|
kmem_free(ve, sizeof (vdev_cache_entry_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate an entry in the cache. At the point we don't have the data,
|
|
|
|
* we're just creating a placeholder so that multiple threads don't all
|
|
|
|
* go off and read the same blocks.
|
|
|
|
*/
|
|
|
|
static vdev_cache_entry_t *
|
|
|
|
vdev_cache_allocate(zio_t *zio)
|
|
|
|
{
|
|
|
|
vdev_cache_t *vc = &zio->io_vd->vdev_cache;
|
|
|
|
uint64_t offset = P2ALIGN(zio->io_offset, VCBS);
|
|
|
|
vdev_cache_entry_t *ve;
|
|
|
|
|
|
|
|
ASSERT(MUTEX_HELD(&vc->vc_lock));
|
|
|
|
|
|
|
|
if (zfs_vdev_cache_size == 0)
|
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If adding a new entry would exceed the cache size,
|
|
|
|
* evict the oldest entry (LRU).
|
|
|
|
*/
|
|
|
|
if ((avl_numnodes(&vc->vc_lastused_tree) << zfs_vdev_cache_bshift) >
|
|
|
|
zfs_vdev_cache_size) {
|
|
|
|
ve = avl_first(&vc->vc_lastused_tree);
|
2008-12-03 23:09:06 +03:00
|
|
|
if (ve->ve_fill_io != NULL)
|
2008-11-20 23:01:55 +03:00
|
|
|
return (NULL);
|
2016-07-22 18:52:49 +03:00
|
|
|
ASSERT3U(ve->ve_hits, !=, 0);
|
2008-11-20 23:01:55 +03:00
|
|
|
vdev_cache_evict(vc, ve);
|
|
|
|
}
|
|
|
|
|
2014-11-21 03:09:39 +03:00
|
|
|
ve = kmem_zalloc(sizeof (vdev_cache_entry_t), KM_SLEEP);
|
2008-11-20 23:01:55 +03:00
|
|
|
ve->ve_offset = offset;
|
2010-05-29 00:45:14 +04:00
|
|
|
ve->ve_lastused = ddi_get_lbolt();
|
2016-07-22 18:52:49 +03:00
|
|
|
ve->ve_abd = abd_alloc_for_io(VCBS, B_TRUE);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
avl_add(&vc->vc_offset_tree, ve);
|
|
|
|
avl_add(&vc->vc_lastused_tree, ve);
|
|
|
|
|
|
|
|
return (ve);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vdev_cache_hit(vdev_cache_t *vc, vdev_cache_entry_t *ve, zio_t *zio)
|
|
|
|
{
|
|
|
|
uint64_t cache_phase = P2PHASE(zio->io_offset, VCBS);
|
|
|
|
|
|
|
|
ASSERT(MUTEX_HELD(&vc->vc_lock));
|
2016-07-22 18:52:49 +03:00
|
|
|
ASSERT3P(ve->ve_fill_io, ==, NULL);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2010-05-29 00:45:14 +04:00
|
|
|
if (ve->ve_lastused != ddi_get_lbolt()) {
|
2008-11-20 23:01:55 +03:00
|
|
|
avl_remove(&vc->vc_lastused_tree, ve);
|
2010-05-29 00:45:14 +04:00
|
|
|
ve->ve_lastused = ddi_get_lbolt();
|
2008-11-20 23:01:55 +03:00
|
|
|
avl_add(&vc->vc_lastused_tree, ve);
|
|
|
|
}
|
|
|
|
|
|
|
|
ve->ve_hits++;
|
2016-07-22 18:52:49 +03:00
|
|
|
abd_copy_off(zio->io_abd, ve->ve_abd, 0, cache_phase, zio->io_size);
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill a previously allocated cache entry with data.
|
|
|
|
*/
|
|
|
|
static void
|
2009-02-18 23:51:31 +03:00
|
|
|
vdev_cache_fill(zio_t *fio)
|
2008-11-20 23:01:55 +03:00
|
|
|
{
|
2009-02-18 23:51:31 +03:00
|
|
|
vdev_t *vd = fio->io_vd;
|
2008-11-20 23:01:55 +03:00
|
|
|
vdev_cache_t *vc = &vd->vdev_cache;
|
2009-02-18 23:51:31 +03:00
|
|
|
vdev_cache_entry_t *ve = fio->io_private;
|
|
|
|
zio_t *pio;
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2016-07-22 18:52:49 +03:00
|
|
|
ASSERT3U(fio->io_size, ==, VCBS);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add data to the cache.
|
|
|
|
*/
|
|
|
|
mutex_enter(&vc->vc_lock);
|
|
|
|
|
2016-07-22 18:52:49 +03:00
|
|
|
ASSERT3P(ve->ve_fill_io, ==, fio);
|
|
|
|
ASSERT3U(ve->ve_offset, ==, fio->io_offset);
|
|
|
|
ASSERT3P(ve->ve_abd, ==, fio->io_abd);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
ve->ve_fill_io = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Even if this cache line was invalidated by a missed write update,
|
|
|
|
* any reads that were queued up before the missed update are still
|
|
|
|
* valid, so we can satisfy them from this line before we evict it.
|
|
|
|
*/
|
2017-11-04 23:25:13 +03:00
|
|
|
zio_link_t *zl = NULL;
|
2016-10-14 03:59:18 +03:00
|
|
|
while ((pio = zio_walk_parents(fio, &zl)) != NULL)
|
2009-02-18 23:51:31 +03:00
|
|
|
vdev_cache_hit(vc, ve, pio);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2009-02-18 23:51:31 +03:00
|
|
|
if (fio->io_error || ve->ve_missed_update)
|
2008-11-20 23:01:55 +03:00
|
|
|
vdev_cache_evict(vc, ve);
|
|
|
|
|
|
|
|
mutex_exit(&vc->vc_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2013-12-09 22:37:51 +04:00
|
|
|
* Read data from the cache. Returns B_TRUE cache hit, B_FALSE on miss.
|
2008-11-20 23:01:55 +03:00
|
|
|
*/
|
2013-12-09 22:37:51 +04:00
|
|
|
boolean_t
|
2008-11-20 23:01:55 +03:00
|
|
|
vdev_cache_read(zio_t *zio)
|
|
|
|
{
|
|
|
|
vdev_cache_t *vc = &zio->io_vd->vdev_cache;
|
2021-11-30 21:32:38 +03:00
|
|
|
vdev_cache_entry_t *ve, ve_search;
|
2008-11-20 23:01:55 +03:00
|
|
|
uint64_t cache_offset = P2ALIGN(zio->io_offset, VCBS);
|
|
|
|
zio_t *fio;
|
2019-12-05 23:37:00 +03:00
|
|
|
uint64_t cache_phase __maybe_unused = P2PHASE(zio->io_offset, VCBS);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2016-07-22 18:52:49 +03:00
|
|
|
ASSERT3U(zio->io_type, ==, ZIO_TYPE_READ);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2021-11-30 21:32:38 +03:00
|
|
|
if (zfs_vdev_cache_size == 0)
|
|
|
|
return (B_FALSE);
|
|
|
|
|
2008-11-20 23:01:55 +03:00
|
|
|
if (zio->io_flags & ZIO_FLAG_DONT_CACHE)
|
2013-12-09 22:37:51 +04:00
|
|
|
return (B_FALSE);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
if (zio->io_size > zfs_vdev_cache_max)
|
2013-12-09 22:37:51 +04:00
|
|
|
return (B_FALSE);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the I/O straddles two or more cache blocks, don't cache it.
|
|
|
|
*/
|
2008-12-03 23:09:06 +03:00
|
|
|
if (P2BOUNDARY(zio->io_offset, zio->io_size, VCBS))
|
2013-12-09 22:37:51 +04:00
|
|
|
return (B_FALSE);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
2016-07-22 18:52:49 +03:00
|
|
|
ASSERT3U(cache_phase + zio->io_size, <=, VCBS);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
mutex_enter(&vc->vc_lock);
|
|
|
|
|
2021-11-30 21:32:38 +03:00
|
|
|
ve_search.ve_offset = cache_offset;
|
|
|
|
ve = avl_find(&vc->vc_offset_tree, &ve_search, NULL);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
if (ve != NULL) {
|
|
|
|
if (ve->ve_missed_update) {
|
|
|
|
mutex_exit(&vc->vc_lock);
|
2013-12-09 22:37:51 +04:00
|
|
|
return (B_FALSE);
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((fio = ve->ve_fill_io) != NULL) {
|
|
|
|
zio_vdev_io_bypass(zio);
|
2009-02-18 23:51:31 +03:00
|
|
|
zio_add_child(zio, fio);
|
2008-11-20 23:01:55 +03:00
|
|
|
mutex_exit(&vc->vc_lock);
|
|
|
|
VDCSTAT_BUMP(vdc_stat_delegations);
|
2013-12-09 22:37:51 +04:00
|
|
|
return (B_TRUE);
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
vdev_cache_hit(vc, ve, zio);
|
|
|
|
zio_vdev_io_bypass(zio);
|
|
|
|
|
|
|
|
mutex_exit(&vc->vc_lock);
|
|
|
|
VDCSTAT_BUMP(vdc_stat_hits);
|
2013-12-09 22:37:51 +04:00
|
|
|
return (B_TRUE);
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ve = vdev_cache_allocate(zio);
|
|
|
|
|
|
|
|
if (ve == NULL) {
|
|
|
|
mutex_exit(&vc->vc_lock);
|
2013-12-09 22:37:51 +04:00
|
|
|
return (B_FALSE);
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
|
2008-12-03 23:09:06 +03:00
|
|
|
fio = zio_vdev_delegated_io(zio->io_vd, cache_offset,
|
2016-07-22 18:52:49 +03:00
|
|
|
ve->ve_abd, VCBS, ZIO_TYPE_READ, ZIO_PRIORITY_NOW,
|
2008-12-03 23:09:06 +03:00
|
|
|
ZIO_FLAG_DONT_CACHE, vdev_cache_fill, ve);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
ve->ve_fill_io = fio;
|
|
|
|
zio_vdev_io_bypass(zio);
|
2009-02-18 23:51:31 +03:00
|
|
|
zio_add_child(zio, fio);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
mutex_exit(&vc->vc_lock);
|
|
|
|
zio_nowait(fio);
|
|
|
|
VDCSTAT_BUMP(vdc_stat_misses);
|
|
|
|
|
2013-12-09 22:37:51 +04:00
|
|
|
return (B_TRUE);
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update cache contents upon write completion.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
vdev_cache_write(zio_t *zio)
|
|
|
|
{
|
|
|
|
vdev_cache_t *vc = &zio->io_vd->vdev_cache;
|
|
|
|
vdev_cache_entry_t *ve, ve_search;
|
|
|
|
uint64_t io_start = zio->io_offset;
|
|
|
|
uint64_t io_end = io_start + zio->io_size;
|
|
|
|
uint64_t min_offset = P2ALIGN(io_start, VCBS);
|
|
|
|
uint64_t max_offset = P2ROUNDUP(io_end, VCBS);
|
|
|
|
avl_index_t where;
|
|
|
|
|
2016-07-22 18:52:49 +03:00
|
|
|
ASSERT3U(zio->io_type, ==, ZIO_TYPE_WRITE);
|
2008-11-20 23:01:55 +03:00
|
|
|
|
|
|
|
mutex_enter(&vc->vc_lock);
|
|
|
|
|
|
|
|
ve_search.ve_offset = min_offset;
|
|
|
|
ve = avl_find(&vc->vc_offset_tree, &ve_search, &where);
|
|
|
|
|
|
|
|
if (ve == NULL)
|
|
|
|
ve = avl_nearest(&vc->vc_offset_tree, where, AVL_AFTER);
|
|
|
|
|
|
|
|
while (ve != NULL && ve->ve_offset < max_offset) {
|
|
|
|
uint64_t start = MAX(ve->ve_offset, io_start);
|
|
|
|
uint64_t end = MIN(ve->ve_offset + VCBS, io_end);
|
|
|
|
|
|
|
|
if (ve->ve_fill_io != NULL) {
|
|
|
|
ve->ve_missed_update = 1;
|
|
|
|
} else {
|
2017-03-28 21:06:22 +03:00
|
|
|
abd_copy_off(ve->ve_abd, zio->io_abd,
|
|
|
|
start - ve->ve_offset, start - io_start,
|
|
|
|
end - start);
|
2008-11-20 23:01:55 +03:00
|
|
|
}
|
|
|
|
ve = AVL_NEXT(&vc->vc_offset_tree, ve);
|
|
|
|
}
|
|
|
|
mutex_exit(&vc->vc_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vdev_cache_purge(vdev_t *vd)
|
|
|
|
{
|
|
|
|
vdev_cache_t *vc = &vd->vdev_cache;
|
|
|
|
vdev_cache_entry_t *ve;
|
|
|
|
|
|
|
|
mutex_enter(&vc->vc_lock);
|
|
|
|
while ((ve = avl_first(&vc->vc_offset_tree)) != NULL)
|
|
|
|
vdev_cache_evict(vc, ve);
|
|
|
|
mutex_exit(&vc->vc_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vdev_cache_init(vdev_t *vd)
|
|
|
|
{
|
|
|
|
vdev_cache_t *vc = &vd->vdev_cache;
|
|
|
|
|
|
|
|
mutex_init(&vc->vc_lock, NULL, MUTEX_DEFAULT, NULL);
|
|
|
|
|
|
|
|
avl_create(&vc->vc_offset_tree, vdev_cache_offset_compare,
|
|
|
|
sizeof (vdev_cache_entry_t),
|
|
|
|
offsetof(struct vdev_cache_entry, ve_offset_node));
|
|
|
|
|
|
|
|
avl_create(&vc->vc_lastused_tree, vdev_cache_lastused_compare,
|
|
|
|
sizeof (vdev_cache_entry_t),
|
|
|
|
offsetof(struct vdev_cache_entry, ve_lastused_node));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vdev_cache_fini(vdev_t *vd)
|
|
|
|
{
|
|
|
|
vdev_cache_t *vc = &vd->vdev_cache;
|
|
|
|
|
|
|
|
vdev_cache_purge(vd);
|
|
|
|
|
|
|
|
avl_destroy(&vc->vc_offset_tree);
|
|
|
|
avl_destroy(&vc->vc_lastused_tree);
|
|
|
|
|
|
|
|
mutex_destroy(&vc->vc_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vdev_cache_stat_init(void)
|
|
|
|
{
|
|
|
|
vdc_ksp = kstat_create("zfs", 0, "vdev_cache_stats", "misc",
|
|
|
|
KSTAT_TYPE_NAMED, sizeof (vdc_stats) / sizeof (kstat_named_t),
|
|
|
|
KSTAT_FLAG_VIRTUAL);
|
|
|
|
if (vdc_ksp != NULL) {
|
|
|
|
vdc_ksp->ks_data = &vdc_stats;
|
|
|
|
kstat_install(vdc_ksp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vdev_cache_stat_fini(void)
|
|
|
|
{
|
|
|
|
if (vdc_ksp != NULL) {
|
|
|
|
kstat_delete(vdc_ksp);
|
|
|
|
vdc_ksp = NULL;
|
|
|
|
}
|
|
|
|
}
|
2011-05-04 02:09:28 +04:00
|
|
|
|
Cleanup: Specify unsignedness on things that should not be signed
In #13871, zfs_vdev_aggregation_limit_non_rotating and
zfs_vdev_aggregation_limit being signed was pointed out as a possible
reason not to eliminate an unnecessary MAX(unsigned, 0) since the
unsigned value was assigned from them.
There is no reason for these module parameters to be signed and upon
inspection, it was found that there are a number of other module
parameters that are signed, but should not be, so we make them unsigned.
Making them unsigned made it clear that some other variables in the code
should also be unsigned, so we also make those unsigned. This prevents
users from setting negative values that could potentially cause bad
behaviors. It also makes the code slightly easier to understand.
Mostly module parameters that deal with timeouts, limits, bitshifts and
percentages are made unsigned by this. Any that are boolean are left
signed, since whether booleans should be considered signed or unsigned
does not matter.
Making zfs_arc_lotsfree_percent unsigned caused a
`zfs_arc_lotsfree_percent >= 0` check to become redundant, so it was
removed. Removing the check was also necessary to prevent a compiler
error from -Werror=type-limits.
Several end of line comments had to be moved to their own lines because
replacing int with uint_t caused us to exceed the 80 character limit
enforced by cstyle.pl.
The following were kept signed because they are passed to
taskq_create(), which expects signed values and modifying the
OpenSolaris/Illumos DDI is out of scope of this patch:
* metaslab_load_pct
* zfs_sync_taskq_batch_pct
* zfs_zil_clean_taskq_nthr_pct
* zfs_zil_clean_taskq_minalloc
* zfs_zil_clean_taskq_maxalloc
* zfs_arc_prune_task_threads
Also, negative values in those parameters was found to be harmless.
The following were left signed because either negative values make
sense, or more analysis was needed to determine whether negative values
should be disallowed:
* zfs_metaslab_switch_threshold
* zfs_pd_bytes_max
* zfs_livelist_min_percent_shared
zfs_multihost_history was made static to be consistent with other
parameters.
A number of module parameters were marked as signed, but in reality
referenced unsigned variables. upgrade_errlog_limit is one of the
numerous examples. In the case of zfs_vdev_async_read_max_active, it was
already uint32_t, but zdb had an extern int declaration for it.
Interestingly, the documentation in zfs.4 was right for
upgrade_errlog_limit despite the module parameter being wrongly marked,
while the documentation for zfs_vdev_async_read_max_active (and friends)
was wrong. It was also wrong for zstd_abort_size, which was unsigned,
but was documented as signed.
Also, the documentation in zfs.4 incorrectly described the following
parameters as ulong when they were int:
* zfs_arc_meta_adjust_restarts
* zfs_override_estimate_recordsize
They are now uint_t as of this patch and thus the man page has been
updated to describe them as uint.
dbuf_state_index was left alone since it does nothing and perhaps should
be removed in another patch.
If any module parameters were missed, they were not found by `grep -r
'ZFS_MODULE_PARAM' | grep ', INT'`. I did find a few that grep missed,
but only because they were in files that had hits.
This patch intentionally did not attempt to address whether some of
these module parameters should be elevated to 64-bit parameters, because
the length of a long on 32-bit is 32-bit.
Lastly, it was pointed out during review that uint_t is a better match
for these variables than uint32_t because FreeBSD kernel parameter
definitions are designed for uint_t, whose bit width can change in
future memory models. As a result, we change the existing parameters
that are uint32_t to use uint_t.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Neal Gompa <ngompa@datto.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13875
2022-09-28 02:42:41 +03:00
|
|
|
ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, cache_max, UINT, ZMOD_RW,
|
2019-09-06 00:49:49 +03:00
|
|
|
"Inflate reads small than max");
|
2011-05-04 02:09:28 +04:00
|
|
|
|
Cleanup: Specify unsignedness on things that should not be signed
In #13871, zfs_vdev_aggregation_limit_non_rotating and
zfs_vdev_aggregation_limit being signed was pointed out as a possible
reason not to eliminate an unnecessary MAX(unsigned, 0) since the
unsigned value was assigned from them.
There is no reason for these module parameters to be signed and upon
inspection, it was found that there are a number of other module
parameters that are signed, but should not be, so we make them unsigned.
Making them unsigned made it clear that some other variables in the code
should also be unsigned, so we also make those unsigned. This prevents
users from setting negative values that could potentially cause bad
behaviors. It also makes the code slightly easier to understand.
Mostly module parameters that deal with timeouts, limits, bitshifts and
percentages are made unsigned by this. Any that are boolean are left
signed, since whether booleans should be considered signed or unsigned
does not matter.
Making zfs_arc_lotsfree_percent unsigned caused a
`zfs_arc_lotsfree_percent >= 0` check to become redundant, so it was
removed. Removing the check was also necessary to prevent a compiler
error from -Werror=type-limits.
Several end of line comments had to be moved to their own lines because
replacing int with uint_t caused us to exceed the 80 character limit
enforced by cstyle.pl.
The following were kept signed because they are passed to
taskq_create(), which expects signed values and modifying the
OpenSolaris/Illumos DDI is out of scope of this patch:
* metaslab_load_pct
* zfs_sync_taskq_batch_pct
* zfs_zil_clean_taskq_nthr_pct
* zfs_zil_clean_taskq_minalloc
* zfs_zil_clean_taskq_maxalloc
* zfs_arc_prune_task_threads
Also, negative values in those parameters was found to be harmless.
The following were left signed because either negative values make
sense, or more analysis was needed to determine whether negative values
should be disallowed:
* zfs_metaslab_switch_threshold
* zfs_pd_bytes_max
* zfs_livelist_min_percent_shared
zfs_multihost_history was made static to be consistent with other
parameters.
A number of module parameters were marked as signed, but in reality
referenced unsigned variables. upgrade_errlog_limit is one of the
numerous examples. In the case of zfs_vdev_async_read_max_active, it was
already uint32_t, but zdb had an extern int declaration for it.
Interestingly, the documentation in zfs.4 was right for
upgrade_errlog_limit despite the module parameter being wrongly marked,
while the documentation for zfs_vdev_async_read_max_active (and friends)
was wrong. It was also wrong for zstd_abort_size, which was unsigned,
but was documented as signed.
Also, the documentation in zfs.4 incorrectly described the following
parameters as ulong when they were int:
* zfs_arc_meta_adjust_restarts
* zfs_override_estimate_recordsize
They are now uint_t as of this patch and thus the man page has been
updated to describe them as uint.
dbuf_state_index was left alone since it does nothing and perhaps should
be removed in another patch.
If any module parameters were missed, they were not found by `grep -r
'ZFS_MODULE_PARAM' | grep ', INT'`. I did find a few that grep missed,
but only because they were in files that had hits.
This patch intentionally did not attempt to address whether some of
these module parameters should be elevated to 64-bit parameters, because
the length of a long on 32-bit is 32-bit.
Lastly, it was pointed out during review that uint_t is a better match
for these variables than uint32_t because FreeBSD kernel parameter
definitions are designed for uint_t, whose bit width can change in
future memory models. As a result, we change the existing parameters
that are uint32_t to use uint_t.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Neal Gompa <ngompa@datto.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13875
2022-09-28 02:42:41 +03:00
|
|
|
ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, cache_size, UINT, ZMOD_RD,
|
2019-09-06 00:49:49 +03:00
|
|
|
"Total size of the per-disk cache");
|
2011-05-04 02:09:28 +04:00
|
|
|
|
Cleanup: Specify unsignedness on things that should not be signed
In #13871, zfs_vdev_aggregation_limit_non_rotating and
zfs_vdev_aggregation_limit being signed was pointed out as a possible
reason not to eliminate an unnecessary MAX(unsigned, 0) since the
unsigned value was assigned from them.
There is no reason for these module parameters to be signed and upon
inspection, it was found that there are a number of other module
parameters that are signed, but should not be, so we make them unsigned.
Making them unsigned made it clear that some other variables in the code
should also be unsigned, so we also make those unsigned. This prevents
users from setting negative values that could potentially cause bad
behaviors. It also makes the code slightly easier to understand.
Mostly module parameters that deal with timeouts, limits, bitshifts and
percentages are made unsigned by this. Any that are boolean are left
signed, since whether booleans should be considered signed or unsigned
does not matter.
Making zfs_arc_lotsfree_percent unsigned caused a
`zfs_arc_lotsfree_percent >= 0` check to become redundant, so it was
removed. Removing the check was also necessary to prevent a compiler
error from -Werror=type-limits.
Several end of line comments had to be moved to their own lines because
replacing int with uint_t caused us to exceed the 80 character limit
enforced by cstyle.pl.
The following were kept signed because they are passed to
taskq_create(), which expects signed values and modifying the
OpenSolaris/Illumos DDI is out of scope of this patch:
* metaslab_load_pct
* zfs_sync_taskq_batch_pct
* zfs_zil_clean_taskq_nthr_pct
* zfs_zil_clean_taskq_minalloc
* zfs_zil_clean_taskq_maxalloc
* zfs_arc_prune_task_threads
Also, negative values in those parameters was found to be harmless.
The following were left signed because either negative values make
sense, or more analysis was needed to determine whether negative values
should be disallowed:
* zfs_metaslab_switch_threshold
* zfs_pd_bytes_max
* zfs_livelist_min_percent_shared
zfs_multihost_history was made static to be consistent with other
parameters.
A number of module parameters were marked as signed, but in reality
referenced unsigned variables. upgrade_errlog_limit is one of the
numerous examples. In the case of zfs_vdev_async_read_max_active, it was
already uint32_t, but zdb had an extern int declaration for it.
Interestingly, the documentation in zfs.4 was right for
upgrade_errlog_limit despite the module parameter being wrongly marked,
while the documentation for zfs_vdev_async_read_max_active (and friends)
was wrong. It was also wrong for zstd_abort_size, which was unsigned,
but was documented as signed.
Also, the documentation in zfs.4 incorrectly described the following
parameters as ulong when they were int:
* zfs_arc_meta_adjust_restarts
* zfs_override_estimate_recordsize
They are now uint_t as of this patch and thus the man page has been
updated to describe them as uint.
dbuf_state_index was left alone since it does nothing and perhaps should
be removed in another patch.
If any module parameters were missed, they were not found by `grep -r
'ZFS_MODULE_PARAM' | grep ', INT'`. I did find a few that grep missed,
but only because they were in files that had hits.
This patch intentionally did not attempt to address whether some of
these module parameters should be elevated to 64-bit parameters, because
the length of a long on 32-bit is 32-bit.
Lastly, it was pointed out during review that uint_t is a better match
for these variables than uint32_t because FreeBSD kernel parameter
definitions are designed for uint_t, whose bit width can change in
future memory models. As a result, we change the existing parameters
that are uint32_t to use uint_t.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Neal Gompa <ngompa@datto.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13875
2022-09-28 02:42:41 +03:00
|
|
|
ZFS_MODULE_PARAM(zfs_vdev, zfs_vdev_, cache_bshift, UINT, ZMOD_RW,
|
2019-09-06 00:49:49 +03:00
|
|
|
"Shift size to inflate reads too");
|