]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
dm: publish array_too_big
authorMikulas Patocka <mpatocka@redhat.com>
Tue, 21 Oct 2008 16:44:57 +0000 (17:44 +0100)
committerAlasdair G Kergon <agk@redhat.com>
Tue, 21 Oct 2008 16:44:57 +0000 (17:44 +0100)
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>
drivers/md/dm-raid1.c
drivers/md/dm-stripe.c
drivers/md/dm.h
include/linux/device-mapper.h

index 29913e42c4ab436da84fc7fdf6e42da4fe051e49..ecfd82169cb36c76f4905c1938e24f9553e5ccac 100644 (file)
@@ -1315,9 +1315,6 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors,
        size_t len;
        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);
 
        ms = kzalloc(len, GFP_KERNEL);
index b745d8ac625b5ffd6730f585e95fec2081cf8429..287e245847303ef4064b1e4e75a7a31ef5695636 100644 (file)
@@ -60,8 +60,8 @@ static inline struct stripe_c *alloc_context(unsigned int stripes)
 {
        size_t len;
 
-       if (array_too_big(sizeof(struct stripe_c), sizeof(struct stripe),
-                         stripes))
+       if (dm_array_too_big(sizeof(struct stripe_c), sizeof(struct stripe),
+                            stripes))
                return NULL;
 
        len = sizeof(struct stripe_c) + (sizeof(struct stripe) * stripes);
index cd189da2b2fa1fbad7293f152f0744b7bdbb8c35..0ade60cdef42dd062bf8f11210ee27b65dd651d2 100644 (file)
@@ -62,15 +62,6 @@ void dm_put_target_type(struct target_type *t);
 int dm_target_iterate(void (*iter_func)(struct target_type *tt,
                                        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);
 
 /*
index 08d783592b73ef4ef6bf8f2b03c8b1359ebe5b40..dfb30db475ed61c2c5562952c3e8add25a1754a2 100644 (file)
@@ -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_array_too_big(fixed, obj, num) \
+       ((num) > (UINT_MAX - (fixed)) / (obj))
+
 static inline sector_t to_sector(unsigned long n)
 {
        return (n >> SECTOR_SHIFT);