From: Lukasz Orlowski Date: Mon, 14 Nov 2011 05:41:03 +0000 (+1100) Subject: imsm: fix: Allowed to create 2 volumes with total size less then maximum. X-Git-Tag: mdadm-3.2.3~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3baa56ab61e371e064db23e5c6b2fe0f23e79d84;p=thirdparty%2Fmdadm.git imsm: fix: Allowed to create 2 volumes with total size less then maximum. mdadm allows to create second volume on the same disk set, whose size is less then the free space left in the container (with IMSM_NO_PLATFORM undefined or set to 0). This is an OROM compatibility issue. It is fixed by verifying whether IMSM_NO_PLATFORM is set and for the second volume creation scenario, requested size is verified against remaining available space. Signed-off-by: Lukasz Orlowski Signed-off-by: NeilBrown --- diff --git a/super-intel.c b/super-intel.c index 215679db..d80c5df9 100644 --- a/super-intel.c +++ b/super-intel.c @@ -5276,6 +5276,15 @@ static int validate_geometry_imsm_volume(struct supertype *st, int level, i += dl->extent_cnt; maxsize = merge_extents(super, i); + + if (!check_env("IMSM_NO_PLATFORM") && + mpb->num_raid_devs > 0 && size && size != maxsize) { + fprintf(stderr, Name ": attempting to create a second " + "volume with size less then remaining space. " + "Aborting...\n"); + return 0; + } + if (maxsize < size || maxsize == 0) { if (verbose) fprintf(stderr, Name ": not enough space after merge (%llu < %llu)\n",