Use KMALLOC_MAX_SIZE

This commit is contained in:
toninov 2025-10-05 12:41:15 +02:00
parent f4bbb60225
commit 9a71c3b4f3
No known key found for this signature in database

View file

@ -102,8 +102,8 @@ struct sflc_volume_base *sflite_vol_ctr(struct sflc_device_base *sd_base,
/* Dirty bitmap: slight over-allocation to fit a whole number of longs */
nblocks = sdev->posmap_size_blocks;
/* Use kmalloc for small allocations (disk <= 4 TiB), otherwise vmalloc */
if (BITS_TO_LONGS(nblocks) * sizeof(unsigned long) <= 4 * PAGE_SIZE)
/* Use kmalloc for small allocations, otherwise vmalloc */
if (BITS_TO_LONGS(nblocks) * sizeof(unsigned long) <= KMALLOC_MAX_SIZE)
svol->posmap.dirty = bitmap_zalloc(nblocks, GFP_KERNEL);
else
svol->posmap.dirty = vzalloc(BITS_TO_LONGS(nblocks) * sizeof(unsigned long));
@ -114,7 +114,7 @@ struct sflc_volume_base *sflite_vol_ctr(struct sflc_device_base *sd_base,
}
/* Pending FLUSH bitmap: slight over-allocation to fit a whole number of longs */
if (BITS_TO_LONGS(nblocks) * sizeof(unsigned long) <= 4 * PAGE_SIZE)
if (BITS_TO_LONGS(nblocks) * sizeof(unsigned long) <= KMALLOC_MAX_SIZE)
svol->posmap.flush_pending = bitmap_zalloc(nblocks, GFP_KERNEL);
else
svol->posmap.flush_pending = vzalloc(BITS_TO_LONGS(nblocks) * sizeof(unsigned long));
@ -125,7 +125,7 @@ struct sflc_volume_base *sflite_vol_ctr(struct sflc_device_base *sd_base,
}
/* CWB error bitmap: slight over-allocation to fit a whole number of longs */
if (BITS_TO_LONGS(nblocks) * sizeof(unsigned long) <= 4 * PAGE_SIZE)
if (BITS_TO_LONGS(nblocks) * sizeof(unsigned long) <= KMALLOC_MAX_SIZE)
svol->posmap.cwb_error = bitmap_zalloc(nblocks, GFP_KERNEL);
else
svol->posmap.cwb_error = vzalloc(BITS_TO_LONGS(nblocks) * sizeof(unsigned long));
@ -136,7 +136,7 @@ struct sflc_volume_base *sflite_vol_ctr(struct sflc_device_base *sd_base,
}
/* Sequence numbers */
if (nblocks * sizeof(u16) <= 4 * PAGE_SIZE)
if (nblocks * sizeof(u16) <= KMALLOC_MAX_SIZE)
svol->posmap.seqnum = kmalloc_array(nblocks, sizeof(u16), GFP_KERNEL | __GFP_ZERO);
else
svol->posmap.seqnum = vzalloc(nblocks * sizeof(u16));
@ -147,7 +147,7 @@ struct sflc_volume_base *sflite_vol_ctr(struct sflc_device_base *sd_base,
}
/* Snapshot sequence numbers */
if (nblocks * sizeof(u16) <= 4 * PAGE_SIZE)
if (nblocks * sizeof(u16) <= KMALLOC_MAX_SIZE)
svol->posmap.snap_seqnum = kmalloc_array(nblocks, sizeof(u16), GFP_KERNEL | __GFP_ZERO);
else
svol->posmap.snap_seqnum = vzalloc(nblocks * sizeof(u16));