Skip to content

Commit

Permalink
BRT: Skip getting length in brt_entry_lookup()
Browse files Browse the repository at this point in the history
Unlike DDT, where ZAP values may have different lengths due to
compression, all BRT entries are identical 8-byte counters.  It
does not make sense to first fetch the length only to assert it.
zap_lookup_uint64() is specifically designed to work with counters
of different size and should return error if something odd found.
Calling it straight allows to save some measurable CPU time.

Signed-off-by:	Alexander Motin <mav@FreeBSD.org>
Sponsored by:	iXsystems, Inc.
  • Loading branch information
amotin committed Mar 1, 2024
1 parent 8f2f6cd commit 7c4397e
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions module/zfs/brt.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,6 @@ static int
brt_entry_lookup(brt_t *brt, brt_vdev_t *brtvd, brt_entry_t *bre)
{
uint64_t mos_entries;
uint64_t one, physsize;
int error;

ASSERT(RW_LOCK_HELD(&brt->brt_lock));
Expand All @@ -919,15 +918,9 @@ brt_entry_lookup(brt_t *brt, brt_vdev_t *brtvd, brt_entry_t *bre)

brt_unlock(brt);

error = zap_length_uint64(brt->brt_mos, mos_entries, &bre->bre_offset,
BRT_KEY_WORDS, &one, &physsize);
if (error == 0) {
ASSERT3U(one, ==, 1);
ASSERT3U(physsize, ==, sizeof (bre->bre_refcount));

error = zap_lookup_uint64(brt->brt_mos, mos_entries,
&bre->bre_offset, BRT_KEY_WORDS, 1,
sizeof (bre->bre_refcount), &bre->bre_refcount);
error = zap_lookup_uint64(brt->brt_mos, mos_entries, &bre->bre_offset,
BRT_KEY_WORDS, 1, sizeof (bre->bre_refcount), &bre->bre_refcount);
if (error != ENOENT) {
BRT_DEBUG("ZAP lookup: object=%llu vdev=%llu offset=%llu "
"count=%llu error=%d", (u_longlong_t)mos_entries,
(u_longlong_t)brtvd->bv_vdevid,
Expand Down

0 comments on commit 7c4397e

Please sign in to comment.