Bug 441244 - parted breaks reloading logical partitions
Summary: parted breaks reloading logical partitions
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: parted
Version: 5.2
Hardware: All
OS: Linux
high
medium
Target Milestone: rc
: ---
Assignee: Joel Andres Granados
QA Contact: Alexander Todorov
URL:
Whiteboard:
: 441043 (view as bug list)
Depends On:
Blocks: 391501
TreeView+ depends on / blocked
 
Reported: 2008-04-07 12:08 UTC by Bryn M. Reeves
Modified: 2018-11-26 18:53 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-01-20 21:08:43 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Patch to avoid creating overlapping partitions via BLKPG ioctls (609 bytes, patch)
2008-04-07 12:08 UTC, Bryn M. Reeves
no flags Details | Diff
extended partition patch (704 bytes, patch)
2008-06-11 16:17 UTC, Joel Andres Granados
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2009:0110 0 normal SHIPPED_LIVE parted bug fix update 2009-01-20 16:04:41 UTC

Description Bryn M. Reeves 2008-04-07 12:08:47 UTC
Description of problem:
Versions of parted since 1.8.0 upstream have a problem reloading some extended
partitions.

This is a regression introduced by commit ID
26cfacb70d75923b23a0e07f1a01ed7ed88622c6. Previous versions of parted would
refuse to honor the extended partition when reloading the partition table using
parted/partprobe:

-                        /* extended partitions have no business in the kernel!
-                         * blkpg doesn't like overlapping partitions.  Hmmm,
-                         * LILO isn't going to like this.
-                         */
-                        if (part->type & PED_PARTITION_EXTENDED)
-                                continue;
-

The change included code that mimics the kernel's behavior when reading the
partition table (e.g. on device detection or BLKRRPART ioctl), taken from
fs/partitions/msdos.c:

                if (is_extended_partition(p)) {
                        /* prevent someone doing mkfs or mkswap on an
                           extended partition, but leave room for LILO */
                        put_partition(state, slot, start, size == 1 ? 1 : 2);

The corresponding code in parted looks like:

+        /* see fs/partitions/msdos.c:msdos_partition(): "leave room for LILO" */
+        if (part->type & PED_PARTITION_EXTENDED)
+                linux_part.length = part->geom.length == 1 ? 512 : 1024;
+        else
+                linux_part.length = part->geom.length * disk->dev->sector_size;

Unfortunately this is not possible using the BLKPG ioctl commands that parted
uses to reload the partition table. The kernel enforces strict overlap checking
and after adding an extended partition with geom.length != 1 the partition will
overlap into what may be the 1st sector of a subsequent logical partition. If
this is the case parted will fail with EBUSY when attempting to load this partition.

Version-Release number of selected component (if applicable):
parted-1.8.1-12.el5

How reproducible:
Always with an appropriate partition table.

Steps to Reproduce:
1. Create a partition layout that includes an extended partition with length != 1
2. Create logical partitions within this extended partition that begin at the
1st sector of the extended partition
3. partprobe
  
Actual results:
# partprobe /dev/sdu
Error: Error informing the kernel about modifications to partition /dev/sdu5 --
Device or resource busy.  This means Linux won't know about any changes you made
to /dev/sdu5 until you reboot -- so you shouldn't mount it or use it in any way
before rebooting.

# grep sdu /proc/partitions
  65    64    5242880 sdu
  65    65     900549 sdu1
  65    66     900550 sdu2
  65    67     900550 sdu3
  65    68          1 sdu4


Expected results:
# partprobe /dev/sdu

# grep sdu /proc/partitions
  65    64    5242880 sdu
  65    65     900549 sdu1
  65    66     900550 sdu2
  65    67     900550 sdu3
  65    68          1 sdu4
  65    69     900549 sdu5
  65    70     900549 sdu6


Additional info:
Easiest way to set up the partition tables to reproduce is via sfdisk:

# cat parted-extended-repro.cmds
,175
,175
,175
,,E
,175
,175

# cat ~/parted-extended-repro.cmds | sfdisk /dev/sdu
Checking that no-one is using this disk right now ...
OK

Disk /dev/sdu: 1018 cylinders, 166 heads, 62 sectors/track
Old situation:
Units = cylinders of 5269504 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdu1          0+    174     175-    900549+  83  Linux
/dev/sdu2        175     349     175     900550   83  Linux
/dev/sdu3        350     524     175     900550   83  Linux
/dev/sdu4        525    1017     493    2536978    5  Extended
/dev/sdu5        525+    699     175-    900549+  83  Linux
/dev/sdu6        700+    874     175-    900549+  83  Linux
New situation:
Units = cylinders of 5269504 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdu1          0+    174     175-    900549+  83  Linux
/dev/sdu2        175     349     175     900550   83  Linux
/dev/sdu3        350     524     175     900550   83  Linux
/dev/sdu4        525    1017     493    2536978    5  Extended
/dev/sdu5        525+    699     175-    900549+  83  Linux
/dev/sdu6        700+    874     175-    900549+  83  Linux
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)

Comment 1 Bryn M. Reeves 2008-04-07 12:08:48 UTC
Created attachment 301509 [details]
Patch to avoid creating overlapping partitions via BLKPG ioctls

Comment 2 Bryn M. Reeves 2008-04-07 12:12:00 UTC
The patch in comment #1 avoids this problem but I'm not sure it's the right fix.
The kernel creates the partitions with the overlap between extended/logical for
bootloaders to access the EBR, but re-creating this situation is currently not
possible using BLKPG ioctl commands.

This could probably use some discussion upstream - the effect of this patch
can't be any worse than versions of parted prior to commit 26cfacb7.. since
these versions simply removed the extended partition completely on a reload, but
since the main point of leaving the partition there is for bootloader access it
doesn't seem all that useful either.


Comment 3 Bryn M. Reeves 2008-04-07 12:17:19 UTC
This is the RHEL5 equivalent of bug 218477

Comment 5 Joel Andres Granados 2008-05-27 09:44:03 UTC
I'll commit Bryns patch.  Thx.

Comment 6 RHEL Program Management 2008-06-02 20:09:39 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 8 Joel Andres Granados 2008-06-11 16:17:13 UTC
Created attachment 308956 [details]
extended partition patch

This is the patch I'll apply
This will be present in parted 1.8.1-18

Comment 14 Joel Andres Granados 2008-08-27 20:37:17 UTC
*** Bug 441043 has been marked as a duplicate of this bug. ***

Comment 17 errata-xmlrpc 2009-01-20 21:08:43 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2009-0110.html


Note You need to log in before you can comment on or make changes to this bug.