Skip to content

Commit 3f4312a

Browse files
authored
Fix two infinite loops if dmu_prefetch_max set to zero
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <alexander.motin@TrueNAS.com> Closes #17692 Closes #17729
1 parent 9b772f3 commit 3f4312a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

module/zfs/dmu.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,8 @@ dmu_prefetch_by_dnode(dnode_t *dn, int64_t level, uint64_t offset,
759759
*/
760760
uint8_t ibps = ibs - SPA_BLKPTRSHIFT;
761761
limit = P2ROUNDUP(dmu_prefetch_max, 1 << ibs) >> ibs;
762+
if (limit == 0)
763+
end2 = start2;
762764
do {
763765
level2++;
764766
start2 = P2ROUNDUP(start2, 1 << ibps) >> ibps;
@@ -1689,8 +1691,8 @@ dmu_object_cached_size(objset_t *os, uint64_t object,
16891691

16901692
dmu_object_info_from_dnode(dn, &doi);
16911693

1692-
for (uint64_t off = 0; off < doi.doi_max_offset;
1693-
off += dmu_prefetch_max) {
1694+
for (uint64_t off = 0; off < doi.doi_max_offset &&
1695+
dmu_prefetch_max > 0; off += dmu_prefetch_max) {
16941696
/* dbuf_read doesn't prefetch L1 blocks. */
16951697
dmu_prefetch_by_dnode(dn, 1, off,
16961698
dmu_prefetch_max, ZIO_PRIORITY_SYNC_READ);

0 commit comments

Comments
 (0)