diff options
author | NeilBrown <neilb@suse.de> | 2011-09-08 12:20:36 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-09-08 12:20:36 +1000 |
commit | 01619b481883926f13da2b1b88f3125359a6a08b (patch) | |
tree | c40c54f82dfbea748ba9b0d88105c0be17609537 /super0.c | |
parent | 42de2ac27d632236909f88bd5309161a32379327 (diff) |
Fix component size checks in validate_super0.
A 0.90 array can use at most 4TB of each device - 2TB between
2.6.39 and 3.1 due to a kernel bug.
The test for this in validate_super0 is very wrong. 'size' is sectors
and the number it is compared against is just confusing.
So fix it all up and correct the spelling of terabytes and remove
a second redundant test on 'size'.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'super0.c')
-rw-r--r-- | super0.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1115,6 +1115,13 @@ static int validate_geometry0(struct supertype *st, int level, { unsigned long long ldsize; int fd; + unsigned int tbmax = 4; + + /* prior to linux 3.1, a but limits usable device size to 2TB. + * It was introduced in 2.6.29, but we won't worry about that detail + */ + if (get_linux_version() < 3001000) + tbmax = 2; if (level == LEVEL_CONTAINER) { if (verbose) @@ -1127,9 +1134,10 @@ static int validate_geometry0(struct supertype *st, int level, MD_SB_DISKS); return 0; } - if (size > (0x7fffffffULL<<9)) { + if (size >= tbmax * 1024*1024*1024*2ULL) { if (verbose) - fprintf(stderr, Name ": 0.90 metadata supports at most 2 terrabytes per device\n"); + fprintf(stderr, Name ": 0.90 metadata supports at most " + "%d terabytes per device\n", tbmax); return 0; } if (chunk && *chunk == UnSet) @@ -1154,8 +1162,6 @@ static int validate_geometry0(struct supertype *st, int level, if (ldsize < MD_RESERVED_SECTORS * 512) return 0; - if (size > (0x7fffffffULL<<9)) - return 0; *freesize = MD_NEW_SIZE_SECTORS(ldsize >> 9); return 1; } |