diff options
author | Andriy Gapon <avg@FreeBSD.org> | 2019-11-21 14:02:54 +0000 |
---|---|---|
committer | Andriy Gapon <avg@FreeBSD.org> | 2019-11-21 14:02:54 +0000 |
commit | 5bba77446a9a9ac2414b9b709826721d377c0cb5 (patch) | |
tree | cec92ec56115a8f872791b2a07b9139b4cadb9cf /uts/common/fs/zfs/arc.c | |
parent | 4e865a0d75c5993fa1ba6f54335b896903c0c139 (diff) | |
download | src-5bba77446a9a9ac2414b9b709826721d377c0cb5.tar.gz src-5bba77446a9a9ac2414b9b709826721d377c0cb5.zip |
10853 spa_sync, vs_alloc can underflow and checkpoint test fixes
illumos/illumos-gate@9740f25f0360eb7d9131fa15fabebf958bf19126
https://github.com/illumos/illumos-gate/commit/9740f25f0360eb7d9131fa15fabebf958bf19126
https://www.illumos.org/issues/10853
From ZoL
7558997 vs_alloc can underflow in L2ARC vdevs
8dc2197 Simplify spa_sync by breaking it up to smaller functions
db58794 Make zdb results for checkpoint tests consistent
Here are the commit msg summaries from ZoL:
vs_alloc can underflow in L2ARC vdevs
The current L2 ARC device code consistently uses psize to
increment vs_alloc but varies between psize and lsize when
decrementing it. The result of this behavior is that
vs_alloc can be decremented more that it is incremented
and underflow. This patch changes the code so asize is
used anywhere.
In addition, it ensures that vs_alloc gets incremented by
the L2 ARC device code as buffers are written and not at
the end of the l2arc_write_buffers() routine. The latter
(and old) way would temporarily underflow vs_alloc as
buffers that were just written, would be destroyed while
l2arc_write_buffers() was still looping.
Simplify spa_sync by breaking it up to smaller functions
The point of this refactoring is to break the high-level conceptual
steps of spa_sync() to their own helper functions. In general large
functions can enhance readability if structured well, but in this
case the amount of conceptual steps taken could use the help of
helper functions.
Make zdb results for checkpoint tests consistent
This patch exports and re-imports the pool when these tests are
analyzed with zdb to get consistent results.
Portions contributed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Author: Serapheim Dimitropoulos <serapheim@delphix.com>
Notes
Notes:
svn path=/vendor-sys/illumos/dist/; revision=354957
Diffstat (limited to 'uts/common/fs/zfs/arc.c')
-rw-r--r-- | uts/common/fs/zfs/arc.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/uts/common/fs/zfs/arc.c b/uts/common/fs/zfs/arc.c index e64d8945973f..2db6cc557046 100644 --- a/uts/common/fs/zfs/arc.c +++ b/uts/common/fs/zfs/arc.c @@ -3124,7 +3124,8 @@ arc_hdr_l2hdr_destroy(arc_buf_hdr_t *hdr) { l2arc_buf_hdr_t *l2hdr = &hdr->b_l2hdr; l2arc_dev_t *dev = l2hdr->b_dev; - uint64_t psize = arc_hdr_size(hdr); + uint64_t psize = HDR_GET_PSIZE(hdr); + uint64_t asize = vdev_psize_to_asize(dev->l2ad_vdev, psize); ASSERT(MUTEX_HELD(&dev->l2ad_mtx)); ASSERT(HDR_HAS_L2HDR(hdr)); @@ -3134,9 +3135,10 @@ arc_hdr_l2hdr_destroy(arc_buf_hdr_t *hdr) ARCSTAT_INCR(arcstat_l2_psize, -psize); ARCSTAT_INCR(arcstat_l2_lsize, -HDR_GET_LSIZE(hdr)); - vdev_space_update(dev->l2ad_vdev, -psize, 0, 0); + vdev_space_update(dev->l2ad_vdev, -asize, 0, 0); - (void) zfs_refcount_remove_many(&dev->l2ad_alloc, psize, hdr); + (void) zfs_refcount_remove_many(&dev->l2ad_alloc, arc_hdr_size(hdr), + hdr); arc_hdr_clear_flags(hdr, ARC_FLAG_HAS_L2HDR); } @@ -6759,10 +6761,12 @@ top: list_remove(buflist, hdr); arc_hdr_clear_flags(hdr, ARC_FLAG_HAS_L2HDR); - ARCSTAT_INCR(arcstat_l2_psize, -arc_hdr_size(hdr)); + uint64_t psize = HDR_GET_PSIZE(hdr); + ARCSTAT_INCR(arcstat_l2_psize, -psize); ARCSTAT_INCR(arcstat_l2_lsize, -HDR_GET_LSIZE(hdr)); - bytes_dropped += arc_hdr_size(hdr); + bytes_dropped += + vdev_psize_to_asize(dev->l2ad_vdev, psize); (void) zfs_refcount_remove_many(&dev->l2ad_alloc, arc_hdr_size(hdr), hdr); } @@ -7213,6 +7217,7 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz) write_psize += psize; write_asize += asize; dev->l2ad_hand += asize; + vdev_space_update(dev->l2ad_vdev, asize, 0, 0); mutex_exit(hash_lock); @@ -7238,7 +7243,6 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz) ARCSTAT_INCR(arcstat_l2_write_bytes, write_psize); ARCSTAT_INCR(arcstat_l2_lsize, write_lsize); ARCSTAT_INCR(arcstat_l2_psize, write_psize); - vdev_space_update(dev->l2ad_vdev, write_psize, 0, 0); /* * Bump device hand to the device start if it is approaching the end. |