From 376958cfb105b875a2e380d122263cd7fd067afe Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Mon, 9 Dec 2024 16:02:21 -0500 Subject: [PATCH] BRT: Check bv_mos_entries in brt_entry_lookup() When vdev first sees some block cloning, there is a window when brt_maybe_exists() might already return true since something was cloned, but bv_mos_entries is still 0 since BRT ZAP was not yet created. In such case we should not try to look into the ZAP and dereference NULL bv_mos_entries_dnode. Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. --- module/zfs/brt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/module/zfs/brt.c b/module/zfs/brt.c index 7d94214143ea..79748cd69bc0 100644 --- a/module/zfs/brt.c +++ b/module/zfs/brt.c @@ -859,6 +859,9 @@ brt_entry_lookup(brt_vdev_t *brtvd, brt_entry_t *bre) { uint64_t off = BRE_OFFSET(bre); + if (brtvd->bv_mos_entries == 0) + return (SET_ERROR(ENOENT)); + return (zap_lookup_uint64_by_dnode(brtvd->bv_mos_entries_dnode, &off, BRT_KEY_WORDS, 1, sizeof (bre->bre_count), &bre->bre_count)); }