Re: partition block cleanup

Russell King (rmk@arm.linux.org.uk)
Sun, 8 Aug 1999 14:52:49 +0100 (BST)


Jes Sorensen writes:
> Anyway I would very much like to get this patch in before 2.4 as it is
> a 95KB patch. As potentially it affects all other architectures
> (though it shouldn't break for anyone) I reckon it is probably a good
> idea to get it tested.

There is a problem lurking in there, which exists when you have partition
information occupying various different locations on the disk.

The above patch allows 'partition modules', which are a bad thing in this
situation, since it does mean that the kernel behaviour becomes indeterminant,
or even impossible to get the correct behaviour with a pre-compiled kernel.

A similar situation arose during the early development of the ARM kernel
on Acorn machines, which I will describe now.

Acorn does not have a partition table on the first sector of the disk.
Instead, you have a filesystem boot block located at sector 6 (more correctly,
starting at the 0xC00th byte into the disk). They supported only one ADFS
partition, which can be optionally followed by a 'non-ADFS' partition (also
defined in this sector). The first sectors are unused and untouched.

Various manufacturers of IDE and SCSI cards decided that they wanted to allow
the user to partition the drive, and each manufacturer invented a different
way of doing this. Some manufacturers decided to use the first sector, others
decided on other weird and wacky schemes.

A lot of people reformat PC drives when they put them in their Acorn machines.
Generally, this leaves the BIOS partition table in the first sector on the
drive.

When these people run Linux on their machines, the order which the partitions
are detected becomes vitally important. If the BIOS partition table is present
in sector 0 along with an ADFS boot block, it is possible for the disk to be
interpreted in two different ways. If the BIOS partition table is detected
first, then the disk will be interpreted incorrectly. If the ADFS boot block
with a non-ADFS partition is detected first, then it will be correct.

Since your support allows modules, the order in which the partition types
probe the drive are indeterminent, and indeterminent behaviour in the kernel
is bad. Also, this is not limited to Acorn machines, since there are people
using Linux on PCs to access their Acorn drives.

One solution to this would be to blank out the first sector of ADFS drives.
However, as I highlighted earlier, it may not be a BIOS partition table, but
some other partition table which is actually valid on this drive. In this
case, the user, who might not know a lot about the disk format may end up
removing a perfectly valid partition table, or worse still, end up filling
the drive with /dev/zero.

Another solution may be to allocate a number to each partition type which
determines the scan order. Alternatively, the modularity of the partition
code could be removed so that the scan order is always known.
_____
|_____| ------------------------------------------------- ---+---+-
| | Russell King rmk@arm.linux.org.uk --- ---
| | | | http://www.arm.linux.org.uk/~rmk/aboutme.html / / |
| +-+-+ --- -+-
/ | THE developer of ARM Linux |+| /|\
/ | | | --- |
+-+-+ ------------------------------------------------- /\\\ |

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/