From 81ceee0cff137936d92f4a1bedc6a40c2f8c9e4f Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sat, 13 Sep 2025 12:58:48 -0400 Subject: [PATCH] Fix two infinite loops if dmu_prefetch_max set to zero Reviewed-by: Brian Behlendorf Signed-off-by: Alexander Motin Closes #17692 Closes #17729 --- module/zfs/dmu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index 8216786fb..a761fd8b3 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -770,6 +770,8 @@ dmu_prefetch_by_dnode(dnode_t *dn, int64_t level, uint64_t offset, */ uint8_t ibps = ibs - SPA_BLKPTRSHIFT; limit = P2ROUNDUP(dmu_prefetch_max, 1 << ibs) >> ibs; + if (limit == 0) + end2 = start2; do { level2++; start2 = P2ROUNDUP(start2, 1 << ibps) >> ibps; @@ -1684,8 +1686,8 @@ dmu_object_cached_size(objset_t *os, uint64_t object, dmu_object_info_from_dnode(dn, &doi); - for (uint64_t off = 0; off < doi.doi_max_offset; - off += dmu_prefetch_max) { + for (uint64_t off = 0; off < doi.doi_max_offset && + dmu_prefetch_max > 0; off += dmu_prefetch_max) { /* dbuf_read doesn't prefetch L1 blocks. */ dmu_prefetch_by_dnode(dn, 1, off, dmu_prefetch_max, ZIO_PRIORITY_SYNC_READ);