summaryrefslogtreecommitdiff
path: root/super1.c
diff options
context:
space:
mode:
Diffstat (limited to 'super1.c')
-rw-r--r--super1.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/super1.c b/super1.c
index 4f20cc3..b3cc22d 100644
--- a/super1.c
+++ b/super1.c
@@ -1498,27 +1498,44 @@ static struct supertype *match_metadata_desc1(char *arg)
* superblock type st, and reserving 'reserve' sectors for
* a possible bitmap
*/
-static __u64 avail_size1(struct supertype *st, __u64 devsize)
+static __u64 avail_size1(struct supertype *st, __u64 devsize,
+ long long data_offset)
{
struct mdp_superblock_1 *super = st->sb;
+ int bmspace = 0;
if (devsize < 24)
return 0;
if (super == NULL)
/* creating: allow suitable space for bitmap */
- devsize -= choose_bm_space(devsize);
+ bmspace = choose_bm_space(devsize);
#ifndef MDASSEMBLE
else if (__le32_to_cpu(super->feature_map)&MD_FEATURE_BITMAP_OFFSET) {
/* hot-add. allow for actual size of bitmap */
struct bitmap_super_s *bsb;
bsb = (struct bitmap_super_s *)(((char*)super)+MAX_SB_SIZE);
- devsize -= bitmap_sectors(bsb);
+ bmspace = bitmap_sectors(bsb);
}
#endif
+
if (st->minor_version < 0)
/* not specified, so time to set default */
st->minor_version = 2;
+
+ if (data_offset > 0)
+ switch(st->minor_version) {
+ case 0:
+ return devsize - data_offset - 8*2;
+ case 1:
+ case 2:
+ return devsize - data_offset;
+ default:
+ return 0;
+ }
+
+ devsize -= bmspace;
+
if (super == NULL && st->minor_version > 0) {
/* haven't committed to a size yet, so allow some
* slack for space for reshape.
@@ -1781,7 +1798,7 @@ static int validate_geometry1(struct supertype *st, int level,
}
close(fd);
- *freesize = avail_size1(st, ldsize >> 9);
+ *freesize = avail_size1(st, ldsize >> 9, -1);
return 1;
}
#endif /* MDASSEMBLE */