Re: [Libguestfs] [PATCH v2 04/11] resize: add support for logical partitions for calculate_surplus

2015-05-29 Thread Chen, Hanxiao


 -Original Message-
 From: Richard W.M. Jones [mailto:rjo...@redhat.com]
 Sent: Thursday, May 28, 2015 7:16 PM
 To: Chen, Hanxiao/陈 晗霄
 Cc: libguestfs@redhat.com
 Subject: Re: [Libguestfs] [PATCH v2 04/11] resize: add support for logical 
 partitions
 for calculate_surplus
 
 On Thu, May 28, 2015 at 12:11:17PM +0100, Richard W.M. Jones wrote:
  On Wed, May 20, 2015 at 06:51:30AM -0400, Chen Hanxiao wrote:
   Add support for logical partitions.
- count number of logical_partition (we've split partitions list)
- don't count size of extended partition
  For it'll duplicate with logical partition, we'll count it later
- we need at leat 1 gap between logical partitions.
  so --aligment=1 will be increased by 1
  
   Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com
   ---
resize/resize.ml | 17 +++--
1 file changed, 15 insertions(+), 2 deletions(-)
  
   diff --git a/resize/resize.ml b/resize/resize.ml
   index 92f7304..a0ed713 100644
   --- a/resize/resize.ml
   +++ b/resize/resize.ml
   @@ -741,8 +741,10 @@ read the man page virt-resize(1).
(* We need some overhead for partitioning. *)
let overhead =
  let maxl64 = List.fold_left max 0L in
   +  (* We need at least 1 sector gap between logical partitions *)
   +  let alignment = if alignment = 1L then 2L else alignment in
  
   -  let nr_partitions = List.length partitions in
   +  let nr_partitions = List.length partitions + List.length
 logical_partitions in
 
  I don't understand this at all.  Why do logical partitions count
  towards the surplus?  I don't think they do.
 
 OK I guess the answer is because logical partitions now need their
 own alignment (within the extended partition), and that contributes
 to the required surplus for the disk.
 
 Do we resize the extended partition sufficiently (eg. if the extended
 partition has 100 aligned logical partitions)?
 

My fault, we don't need the surplus of logical partitions.

For resizing extended partition, is in:
[10/11] resize: add support resize extended partition
https://www.redhat.com/archives/libguestfs/2015-May/msg00103.html

For dealing with alignment of logical partitions, is in:
[06/11] resize: add support for logical partitions of 
calculate_target_partitions
https://www.redhat.com/archives/libguestfs/2015-May/msg00098.html

Regards,
- Chen

___
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs

Re: [Libguestfs] [PATCH v2 04/11] resize: add support for logical partitions for calculate_surplus

2015-05-28 Thread Richard W.M. Jones
On Thu, May 28, 2015 at 12:11:17PM +0100, Richard W.M. Jones wrote:
 On Wed, May 20, 2015 at 06:51:30AM -0400, Chen Hanxiao wrote:
  Add support for logical partitions.
   - count number of logical_partition (we've split partitions list)
   - don't count size of extended partition
 For it'll duplicate with logical partition, we'll count it later
   - we need at leat 1 gap between logical partitions.
 so --aligment=1 will be increased by 1
  
  Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com
  ---
   resize/resize.ml | 17 +++--
   1 file changed, 15 insertions(+), 2 deletions(-)
  
  diff --git a/resize/resize.ml b/resize/resize.ml
  index 92f7304..a0ed713 100644
  --- a/resize/resize.ml
  +++ b/resize/resize.ml
  @@ -741,8 +741,10 @@ read the man page virt-resize(1).
   (* We need some overhead for partitioning. *)
   let overhead =
 let maxl64 = List.fold_left max 0L in
  +  (* We need at least 1 sector gap between logical partitions *)
  +  let alignment = if alignment = 1L then 2L else alignment in
   
  -  let nr_partitions = List.length partitions in
  +  let nr_partitions = List.length partitions + List.length 
  logical_partitions in
 
 I don't understand this at all.  Why do logical partitions count
 towards the surplus?  I don't think they do.

OK I guess the answer is because logical partitions now need their
own alignment (within the extended partition), and that contributes
to the required surplus for the disk.

Do we resize the extended partition sufficiently (eg. if the extended
partition has 100 aligned logical partitions)?

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html

___
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs


Re: [Libguestfs] [PATCH v2 04/11] resize: add support for logical partitions for calculate_surplus

2015-05-28 Thread Richard W.M. Jones
On Wed, May 20, 2015 at 06:51:30AM -0400, Chen Hanxiao wrote:
 Add support for logical partitions.
  - count number of logical_partition (we've split partitions list)
  - don't count size of extended partition
For it'll duplicate with logical partition, we'll count it later
  - we need at leat 1 gap between logical partitions.
so --aligment=1 will be increased by 1
 
 Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com
 ---
  resize/resize.ml | 17 +++--
  1 file changed, 15 insertions(+), 2 deletions(-)
 
 diff --git a/resize/resize.ml b/resize/resize.ml
 index 92f7304..a0ed713 100644
 --- a/resize/resize.ml
 +++ b/resize/resize.ml
 @@ -741,8 +741,10 @@ read the man page virt-resize(1).
  (* We need some overhead for partitioning. *)
  let overhead =
let maxl64 = List.fold_left max 0L in
 +  (* We need at least 1 sector gap between logical partitions *)
 +  let alignment = if alignment = 1L then 2L else alignment in
  
 -  let nr_partitions = List.length partitions in
 +  let nr_partitions = List.length partitions + List.length 
 logical_partitions in

I don't understand this at all.  Why do logical partitions count
towards the surplus?  I don't think they do.

Rich.

let gpt_start_sects = 64L in
let gpt_end_sects = gpt_start_sects in
 @@ -770,12 +772,23 @@ read the man page virt-resize(1).
  let required = List.fold_left (
fun total p -
  let newsize =
 +  (* size of extended partition is calculated seperately *)
 +  if p.p_type = ContentExtendedPartition then 0L else
 +match p.p_operation with
 +| OpCopy | OpIgnore - p.p_part.G.part_size
 +| OpDelete - 0L
 +| OpResize newsize - newsize in
 +total +^ newsize
 +) 0L partitions in
 +let required = required +^ List.fold_left (
 +  fun total p -
 +let newsize =
match p.p_operation with
| OpCopy | OpIgnore - p.p_part.G.part_size
| OpDelete - 0L
| OpResize newsize - newsize in
  total +^ newsize
 -) 0L partitions in
 +) 0L logical_partitions in
  
  let surplus = outsize -^ (required +^ overhead) in
  
 -- 
 2.1.0
 
 ___
 Libguestfs mailing list
 Libguestfs@redhat.com
 https://www.redhat.com/mailman/listinfo/libguestfs

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW

___
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs