summaryrefslogtreecommitdiff
path: root/super1.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2012-10-04 16:34:21 +1000
committerNeilBrown <neilb@suse.de>2012-10-04 16:34:21 +1000
commitcb19a251a581fe78dcddd1d95dca4d8cb7664819 (patch)
tree4bbeb54e5831adf527aecc406939ddea5365fd97 /super1.c
parent5e88ab2e2f87c4009529c19746841db136c8e1b9 (diff)
super1: reserve at least 2 chunks for reshape headroom.
sometimes 0.1% isn't enough, though mostly only in testing. We need one chunk for a successful reshape, so reserve 2. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'super1.c')
-rw-r--r--super1.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/super1.c b/super1.c
index 54bd5b32..8f5f3071 100644
--- a/super1.c
+++ b/super1.c
@@ -1330,11 +1330,15 @@ static int write_init_super1(struct supertype *st)
/* We try to leave 0.1% at the start for reshape
* operations, but limit this to 128Meg (0.1% of 10Gig)
* which is plenty for efficient reshapes
+ * However we make it at least 2 chunks as one chunk
+ * is minimum needed for reshape.
*/
headroom = 128 * 1024 * 2;
- while (headroom << 10 > array_size)
+ while (headroom << 10 > array_size &&
+ headroom/2 >= __le32_to_cpu(sb->chunksize) * 2)
headroom >>= 1;
+
switch(st->minor_version) {
case 0:
sb_offset = dsize;
@@ -1685,8 +1689,8 @@ 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,
- unsigned long long data_offset)
+static __u64 _avail_size1(struct supertype *st, __u64 devsize,
+ unsigned long long data_offset, int chunksize)
{
struct mdp_superblock_1 *super = st->sb;
int bmspace = 0;
@@ -1734,7 +1738,9 @@ static __u64 avail_size1(struct supertype *st, __u64 devsize,
* Limit slack to 128M, but aim for about 0.1%
*/
unsigned long long headroom = 128*1024*2;
- while ((headroom << 10) > devsize)
+ while ((headroom << 10) > devsize &&
+ (chunksize == 0 ||
+ headroom / 2 >= ((unsigned)chunksize*2)*2))
headroom >>= 1;
devsize -= headroom;
}
@@ -1751,6 +1757,11 @@ static __u64 avail_size1(struct supertype *st, __u64 devsize,
}
return 0;
}
+static __u64 avail_size1(struct supertype *st, __u64 devsize,
+ unsigned long long data_offset)
+{
+ return _avail_size1(st, devsize, data_offset, 0);
+}
static int
add_internal_bitmap1(struct supertype *st,
@@ -2010,7 +2021,7 @@ static int validate_geometry1(struct supertype *st, int level,
}
close(fd);
- *freesize = avail_size1(st, ldsize >> 9, data_offset);
+ *freesize = _avail_size1(st, ldsize >> 9, data_offset, *chunk);
return 1;
}
#endif /* MDASSEMBLE */