mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
dm: publish array_too_big
Move array_too_big to include/linux/device-mapper.h because it is used by targets. Remove the test from dm-raid1 as the number of mirror legs is limited such that it can never fail. (Even for stripes it seems rather unlikely.) Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
This commit is contained in:
parent
7acedc5b98
commit
d63a5ce3c0
4 changed files with 5 additions and 14 deletions
|
@ -1315,9 +1315,6 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors,
|
||||||
size_t len;
|
size_t len;
|
||||||
struct mirror_set *ms = NULL;
|
struct mirror_set *ms = NULL;
|
||||||
|
|
||||||
if (array_too_big(sizeof(*ms), sizeof(ms->mirror[0]), nr_mirrors))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
len = sizeof(*ms) + (sizeof(ms->mirror[0]) * nr_mirrors);
|
len = sizeof(*ms) + (sizeof(ms->mirror[0]) * nr_mirrors);
|
||||||
|
|
||||||
ms = kzalloc(len, GFP_KERNEL);
|
ms = kzalloc(len, GFP_KERNEL);
|
||||||
|
|
|
@ -60,7 +60,7 @@ static inline struct stripe_c *alloc_context(unsigned int stripes)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if (array_too_big(sizeof(struct stripe_c), sizeof(struct stripe),
|
if (dm_array_too_big(sizeof(struct stripe_c), sizeof(struct stripe),
|
||||||
stripes))
|
stripes))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -62,15 +62,6 @@ void dm_put_target_type(struct target_type *t);
|
||||||
int dm_target_iterate(void (*iter_func)(struct target_type *tt,
|
int dm_target_iterate(void (*iter_func)(struct target_type *tt,
|
||||||
void *param), void *param);
|
void *param), void *param);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------
|
|
||||||
* Useful inlines.
|
|
||||||
*---------------------------------------------------------------*/
|
|
||||||
static inline int array_too_big(unsigned long fixed, unsigned long obj,
|
|
||||||
unsigned long num)
|
|
||||||
{
|
|
||||||
return (num > (ULONG_MAX - fixed) / obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
int dm_split_args(int *argc, char ***argvp, char *input);
|
int dm_split_args(int *argc, char ***argvp, char *input);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -354,6 +354,9 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size);
|
||||||
*/
|
*/
|
||||||
#define dm_round_up(n, sz) (dm_div_up((n), (sz)) * (sz))
|
#define dm_round_up(n, sz) (dm_div_up((n), (sz)) * (sz))
|
||||||
|
|
||||||
|
#define dm_array_too_big(fixed, obj, num) \
|
||||||
|
((num) > (UINT_MAX - (fixed)) / (obj))
|
||||||
|
|
||||||
static inline sector_t to_sector(unsigned long n)
|
static inline sector_t to_sector(unsigned long n)
|
||||||
{
|
{
|
||||||
return (n >> SECTOR_SHIFT);
|
return (n >> SECTOR_SHIFT);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue