mirror of
https://codeberg.org/shufflecake/shufflecake-c.git
synced 2025-12-27 14:14:57 -05:00
Use KMALLOC_MAX_SIZE
This commit is contained in:
parent
f4bbb60225
commit
9a71c3b4f3
1 changed files with 6 additions and 6 deletions
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue