ddt: add support for prefetching tables into the ARC

This change adds a new `zpool prefetch -t ddt $pool` command which
causes a pool's DDT to be loaded into the ARC. The primary goal is to
remove the need to "warm" a pool's cache before deduplication stops
slowing write performance. It may also provide a way to reload portions
of a DDT if they have been flushed due to inactivity.

Sponsored-by: iXsystems, Inc.
Sponsored-by: Catalogics, Inc.
Sponsored-by: Klara, Inc.
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Allan Jude <allan@klarasystems.com>
Signed-off-by: Will Andrews <will.andrews@klarasystems.com>
Signed-off-by: Fred Weigel <fred.weigel@klarasystems.com>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Signed-off-by: Don Brady <don.brady@klarasystems.com>
Co-authored-by: Will Andrews <will.andrews@klarasystems.com>
Co-authored-by: Don Brady <don.brady@klarasystems.com>
Closes #15890
This commit is contained in:
Allan Jude
2024-07-26 12:16:18 -04:00
committed by GitHub
parent 2ed1aebaf6
commit 62e7d3c89e
37 changed files with 1067 additions and 52 deletions
+52 -1
View File
@@ -26,7 +26,7 @@
* Copyright (c) 2017, Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2019, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
* Copyright (c) 2020, George Amanakis. All rights reserved.
* Copyright (c) 2019, Klara Inc.
* Copyright (c) 2019, 2023, Klara Inc.
* Copyright (c) 2019, Allan Jude
* Copyright (c) 2020, The FreeBSD Foundation [1]
*
@@ -5471,6 +5471,57 @@ arc_read_done(zio_t *zio)
}
}
/*
* Lookup the block at the specified DVA (in bp), and return the manner in
* which the block is cached. A zero return indicates not cached.
*/
int
arc_cached(spa_t *spa, const blkptr_t *bp)
{
arc_buf_hdr_t *hdr = NULL;
kmutex_t *hash_lock = NULL;
uint64_t guid = spa_load_guid(spa);
int flags = 0;
if (BP_IS_EMBEDDED(bp))
return (ARC_CACHED_EMBEDDED);
hdr = buf_hash_find(guid, bp, &hash_lock);
if (hdr == NULL)
return (0);
if (HDR_HAS_L1HDR(hdr)) {
arc_state_t *state = hdr->b_l1hdr.b_state;
/*
* We switch to ensure that any future arc_state_type_t
* changes are handled. This is just a shift to promote
* more compile-time checking.
*/
switch (state->arcs_state) {
case ARC_STATE_ANON:
break;
case ARC_STATE_MRU:
flags |= ARC_CACHED_IN_MRU | ARC_CACHED_IN_L1;
break;
case ARC_STATE_MFU:
flags |= ARC_CACHED_IN_MFU | ARC_CACHED_IN_L1;
break;
case ARC_STATE_UNCACHED:
/* The header is still in L1, probably not for long */
flags |= ARC_CACHED_IN_L1;
break;
default:
break;
}
}
if (HDR_HAS_L2HDR(hdr))
flags |= ARC_CACHED_IN_L2;
mutex_exit(hash_lock);
return (flags);
}
/*
* "Read" the block at the specified DVA (in bp) via the
* cache. If the block is found in the cache, invoke the provided