All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wic/partionedfs: Avoid reserving space for non-existing ext. partition
@ 2017-01-27  6:51 Kristian Amlie
  2017-02-14 14:46 ` Kristian Amlie
  0 siblings, 1 reply; 8+ messages in thread
From: Kristian Amlie @ 2017-01-27  6:51 UTC (permalink / raw)
  To: openembedded-core

We don't need the gap that the extended partition occupies if we
already know that we have less than five partitions. Saves up to one
full alignment of space.

Signed-off-by: Kristian Amlie <kristian.amlie@mender.io>
---
 scripts/lib/wic/utils/partitionedfs.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py
index 721d514..9db6d56 100644
--- a/scripts/lib/wic/utils/partitionedfs.py
+++ b/scripts/lib/wic/utils/partitionedfs.py
@@ -131,6 +131,10 @@ class Image():
 
         self._partitions_layed_out = True
 
+        # The number of primary and logical partitions. Extended partition and
+        # partitions not listed in the table are not included.
+        num_real_partitions = len([p for p in self.partitions if not p['no_table']])
+
         # Go through partitions in the order they are added in .ks file
         for num in range(len(self.partitions)):
             part = self.partitions[num]
@@ -162,7 +166,7 @@ class Image():
                 # Skip one sector required for the partitioning scheme overhead
                 disk['offset'] += overhead
 
-            if disk['realpart'] > 3:
+            if disk['realpart'] > 3 and num_real_partitions > 4:
                 # Reserve a sector for EBR for every logical partition
                 # before alignment is performed.
                 if ptable_format == "msdos":
@@ -202,7 +206,7 @@ class Image():
 
             if disk['ptable_format'] == "msdos":
                 # only count the partitions that are in partition table
-                if len([p for p in self.partitions if not p['no_table']]) > 4:
+                if num_real_partitions > 4:
                     if disk['realpart'] > 3:
                         part['type'] = 'logical'
                         part['num'] = disk['realpart'] + 1
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] wic/partionedfs: Avoid reserving space for non-existing ext. partition
  2017-01-27  6:51 [PATCH] wic/partionedfs: Avoid reserving space for non-existing ext. partition Kristian Amlie
@ 2017-02-14 14:46 ` Kristian Amlie
  2017-02-14 19:26   ` Burton, Ross
  0 siblings, 1 reply; 8+ messages in thread
From: Kristian Amlie @ 2017-02-14 14:46 UTC (permalink / raw)
  To: openembedded-core

Ping. Patch still applies, should be a very easy change.

-- 
Kristian


On 27/01/17 07:51, Kristian Amlie wrote:
> We don't need the gap that the extended partition occupies if we
> already know that we have less than five partitions. Saves up to one
> full alignment of space.
> 
> Signed-off-by: Kristian Amlie <kristian.amlie@mender.io>
> ---
>  scripts/lib/wic/utils/partitionedfs.py | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py
> index 721d514..9db6d56 100644
> --- a/scripts/lib/wic/utils/partitionedfs.py
> +++ b/scripts/lib/wic/utils/partitionedfs.py
> @@ -131,6 +131,10 @@ class Image():
>  
>          self._partitions_layed_out = True
>  
> +        # The number of primary and logical partitions. Extended partition and
> +        # partitions not listed in the table are not included.
> +        num_real_partitions = len([p for p in self.partitions if not p['no_table']])
> +
>          # Go through partitions in the order they are added in .ks file
>          for num in range(len(self.partitions)):
>              part = self.partitions[num]
> @@ -162,7 +166,7 @@ class Image():
>                  # Skip one sector required for the partitioning scheme overhead
>                  disk['offset'] += overhead
>  
> -            if disk['realpart'] > 3:
> +            if disk['realpart'] > 3 and num_real_partitions > 4:
>                  # Reserve a sector for EBR for every logical partition
>                  # before alignment is performed.
>                  if ptable_format == "msdos":
> @@ -202,7 +206,7 @@ class Image():
>  
>              if disk['ptable_format'] == "msdos":
>                  # only count the partitions that are in partition table
> -                if len([p for p in self.partitions if not p['no_table']]) > 4:
> +                if num_real_partitions > 4:
>                      if disk['realpart'] > 3:
>                          part['type'] = 'logical'
>                          part['num'] = disk['realpart'] + 1
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] wic/partionedfs: Avoid reserving space for non-existing ext. partition
  2017-02-14 14:46 ` Kristian Amlie
@ 2017-02-14 19:26   ` Burton, Ross
  2017-02-16 10:30     ` Kristian Amlie
  0 siblings, 1 reply; 8+ messages in thread
From: Burton, Ross @ 2017-02-14 19:26 UTC (permalink / raw)
  To: Kristian Amlie; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 263 bytes --]

On 14 February 2017 at 14:46, Kristian Amlie <kristian.amlie@mender.io>
wrote:

> Ping. Patch still applies, should be a very easy change.
>

The consolidated pull I just sent has a large refactoring series in, can
you rebase this on top of that?

Ross

[-- Attachment #2: Type: text/html, Size: 660 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] wic/partionedfs: Avoid reserving space for non-existing ext. partition
  2017-02-14 19:26   ` Burton, Ross
@ 2017-02-16 10:30     ` Kristian Amlie
  2017-02-16 11:40       ` Ed Bartosh
  0 siblings, 1 reply; 8+ messages in thread
From: Kristian Amlie @ 2017-02-16 10:30 UTC (permalink / raw)
  To: Burton, Ross; +Cc: OE-core

We don't need the gap that the extended partition occupies if we
already know that we have less than five partitions. Saves up to one
full alignment of space.

Signed-off-by: Kristian Amlie <kristian.amlie@mender.io>
---
 scripts/lib/wic/plugins/imager/direct.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index 481d24d..bc2d620 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -344,6 +344,10 @@ class PartitionedImage():
 
         msger.debug("Assigning %s partitions to disks" % self.ptable_format)
 
+        # The number of primary and logical partitions. Extended partition and
+        # partitions not listed in the table are not included.
+        num_real_partitions = len([p for p in self.partitions if not p['no_table']])
+
         # Go through partitions in the order they are added in .ks file
         for num in range(len(self.partitions)):
             part = self.partitions[num]
@@ -369,7 +373,7 @@ class PartitionedImage():
                 # Skip one sector required for the partitioning scheme overhead
                 self.offset += overhead
 
-            if self.realpart > 3:
+            if self.realpart > 3 and num_real_partitions > 4:
                 # Reserve a sector for EBR for every logical partition
                 # before alignment is performed.
                 if self.ptable_format == "msdos":
@@ -408,7 +412,7 @@ class PartitionedImage():
 
             if self.ptable_format == "msdos":
                 # only count the partitions that are in partition table
-                if len([p for p in self.partitions if not p.no_table]) > 4:
+                if num_real_partitions > 4:
                     if self.realpart > 3:
                         part.type = 'logical'
                         part.num = self.realpart + 1
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] wic/partionedfs: Avoid reserving space for non-existing ext. partition
  2017-02-16 10:30     ` Kristian Amlie
@ 2017-02-16 11:40       ` Ed Bartosh
  2017-02-16 12:10         ` Kristian Amlie
  0 siblings, 1 reply; 8+ messages in thread
From: Ed Bartosh @ 2017-02-16 11:40 UTC (permalink / raw)
  To: Kristian Amlie; +Cc: OE-core

Hi Kristian,

Thank you for the patch. It looks good to me. Just one thing needs to be
changed. See my comment below.

On Thu, Feb 16, 2017 at 11:30:12AM +0100, Kristian Amlie wrote:
> We don't need the gap that the extended partition occupies if we
> already know that we have less than five partitions. Saves up to one
> full alignment of space.
> 
> Signed-off-by: Kristian Amlie <kristian.amlie@mender.io>
> ---
>  scripts/lib/wic/plugins/imager/direct.py | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
> index 481d24d..bc2d620 100644
> --- a/scripts/lib/wic/plugins/imager/direct.py
> +++ b/scripts/lib/wic/plugins/imager/direct.py
> @@ -344,6 +344,10 @@ class PartitionedImage():
>  
>          msger.debug("Assigning %s partitions to disks" % self.ptable_format)
>  
> +        # The number of primary and logical partitions. Extended partition and
> +        # partitions not listed in the table are not included.
> +        num_real_partitions = len([p for p in self.partitions if not p['no_table']])
> +
Hm... shouldn't it be 'if p.no_table'?

Did you run 'oe-selftest -r wic' btw? I'd be surprised if it doesn't
fail at least some test cases with this change.

>          # Go through partitions in the order they are added in .ks file
>          for num in range(len(self.partitions)):
>              part = self.partitions[num]
> @@ -369,7 +373,7 @@ class PartitionedImage():
>                  # Skip one sector required for the partitioning scheme overhead
>                  self.offset += overhead
>  
> -            if self.realpart > 3:
> +            if self.realpart > 3 and num_real_partitions > 4:
>                  # Reserve a sector for EBR for every logical partition
>                  # before alignment is performed.
>                  if self.ptable_format == "msdos":
> @@ -408,7 +412,7 @@ class PartitionedImage():
>  
>              if self.ptable_format == "msdos":
>                  # only count the partitions that are in partition table
> -                if len([p for p in self.partitions if not p.no_table]) > 4:
> +                if num_real_partitions > 4:
>                      if self.realpart > 3:
>                          part.type = 'logical'
>                          part.num = self.realpart + 1

--
Regards,
Ed


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] wic/partionedfs: Avoid reserving space for non-existing ext. partition
  2017-02-16 11:40       ` Ed Bartosh
@ 2017-02-16 12:10         ` Kristian Amlie
  2017-03-10 13:16           ` Kristian Amlie
  0 siblings, 1 reply; 8+ messages in thread
From: Kristian Amlie @ 2017-02-16 12:10 UTC (permalink / raw)
  To: ed.bartosh; +Cc: OE-core

On 16/02/17 12:40, Ed Bartosh wrote:
> Hi Kristian,
> 
> Thank you for the patch. It looks good to me. Just one thing needs to be
> changed. See my comment below.
> 
> On Thu, Feb 16, 2017 at 11:30:12AM +0100, Kristian Amlie wrote:
>> We don't need the gap that the extended partition occupies if we
>> already know that we have less than five partitions. Saves up to one
>> full alignment of space.
>>
>> Signed-off-by: Kristian Amlie <kristian.amlie@mender.io>
>> ---
>>  scripts/lib/wic/plugins/imager/direct.py | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
>> index 481d24d..bc2d620 100644
>> --- a/scripts/lib/wic/plugins/imager/direct.py
>> +++ b/scripts/lib/wic/plugins/imager/direct.py
>> @@ -344,6 +344,10 @@ class PartitionedImage():
>>  
>>          msger.debug("Assigning %s partitions to disks" % self.ptable_format)
>>  
>> +        # The number of primary and logical partitions. Extended partition and
>> +        # partitions not listed in the table are not included.
>> +        num_real_partitions = len([p for p in self.partitions if not p['no_table']])
>> +
> Hm... shouldn't it be 'if p.no_table'?
> 
> Did you run 'oe-selftest -r wic' btw? I'd be surprised if it doesn't
> fail at least some test cases with this change.

Hmm, you caught me. Since the code block looked virtually identical (but
indeed wasn't) I didn't rerun. But I think you're right, I will rerun them.

-- 
Kristian


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] wic/partionedfs: Avoid reserving space for non-existing ext. partition
  2017-02-16 12:10         ` Kristian Amlie
@ 2017-03-10 13:16           ` Kristian Amlie
  2017-03-10 13:16             ` [PATCH v3] " Kristian Amlie
  0 siblings, 1 reply; 8+ messages in thread
From: Kristian Amlie @ 2017-03-10 13:16 UTC (permalink / raw)
  To: ed.bartosh, OE-core


Alright, finally got around to this again. Patch rebased, and passing
tests.

-- 
Kristian


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3] wic/partionedfs: Avoid reserving space for non-existing ext. partition
  2017-03-10 13:16           ` Kristian Amlie
@ 2017-03-10 13:16             ` Kristian Amlie
  0 siblings, 0 replies; 8+ messages in thread
From: Kristian Amlie @ 2017-03-10 13:16 UTC (permalink / raw)
  To: ed.bartosh, OE-core

We don't need the gap that the extended partition occupies if we
already know that we have less than five partitions. Saves up to one
full alignment of space.

Signed-off-by: Kristian Amlie <kristian.amlie@mender.io>
---
 scripts/lib/wic/plugins/imager/direct.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index b7e324a..5fbed56 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -344,6 +344,10 @@ class PartitionedImage():
 
         logger.debug("Assigning %s partitions to disks", self.ptable_format)
 
+        # The number of primary and logical partitions. Extended partition and
+        # partitions not listed in the table are not included.
+        num_real_partitions = len([p for p in self.partitions if not p.no_table])
+
         # Go through partitions in the order they are added in .ks file
         for num in range(len(self.partitions)):
             part = self.partitions[num]
@@ -369,7 +373,7 @@ class PartitionedImage():
                 # Skip one sector required for the partitioning scheme overhead
                 self.offset += overhead
 
-            if self.realpart > 3:
+            if self.realpart > 3 and num_real_partitions > 4:
                 # Reserve a sector for EBR for every logical partition
                 # before alignment is performed.
                 if self.ptable_format == "msdos":
@@ -408,7 +412,7 @@ class PartitionedImage():
 
             if self.ptable_format == "msdos":
                 # only count the partitions that are in partition table
-                if len([p for p in self.partitions if not p.no_table]) > 4:
+                if num_real_partitions > 4:
                     if self.realpart > 3:
                         part.type = 'logical'
                         part.num = self.realpart + 1
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-03-10 13:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-27  6:51 [PATCH] wic/partionedfs: Avoid reserving space for non-existing ext. partition Kristian Amlie
2017-02-14 14:46 ` Kristian Amlie
2017-02-14 19:26   ` Burton, Ross
2017-02-16 10:30     ` Kristian Amlie
2017-02-16 11:40       ` Ed Bartosh
2017-02-16 12:10         ` Kristian Amlie
2017-03-10 13:16           ` Kristian Amlie
2017-03-10 13:16             ` [PATCH v3] " Kristian Amlie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.