If a logical/extended partition is resized,
we had to re-calculate all the position of logical partitions.
For logical partitions can't be placed just next to each other,
we had to think about the loss of the size because of
the alignment of recalculation.
This patch will calculate a max number
to ensure a successfull parted.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
resize/resize.ml | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/resize/resize.ml b/resize/resize.ml
index f4cc588..7aa1c96 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -820,6 +820,23 @@ read the man page virt-resize(1).
)
);
+ (* filter out logical partitions for OpResize *)
+ let logical_resize = List.filter (
+ fun p ->
+ match p.p_operation with
+ | OpResize _ -> true
+ | OpCopy | OpIgnore | OpDelete -> false
+ ) logical_partitions in
+
+ (* calculate the max logical partition alignment *)
+ let logical_align =
+ if (List.length logical_resize) > 0 then
+ ((Int64.of_int nr_logical) -^ 1L) *^ alignment
+ else
+ 0L in
+ if verbose () then
+ printf "Max alignment loss of logical partition is %Ld\n" logical_align;
+
(* Calculate the final surplus.
* At this point, this number must be >= 0.
*)
--
2.1.0