Showing changes from revision #1 to #2:
Added | Removed | Changed
Term | Meaning |
---|---|
new map | Used to define a specific map type supported by FileCore |
zone | Discs are dvidided into a number of zones, each of which is contiguous section of the disc |
nzones | The number of zones on a disc |
map block | Each sector of the map is known as a map block, and controls the allocation of a zone of the disc |
ZoneCheck | Check byte for a zone’s map block. Is used to check that this zone’s map block is valid |
FreeLink | Link to first free fragment in a specific zone. Is a fragment block giving the offset to the first free space fragment block in the allocation bytes |
CrossCheck | Cross check byte for complete map. They are combined to check that the whole map is self-consistent |
A disc has a section of information defined as a Map. It controls the allocation of the disc to the files and directories.
Map | Information Stored | Compaction Required | Recovery Story |
---|---|---|---|
New | Space allocation | No | Two copies stored |
The type of map used is dependent on the format of the disc. These are detailed here.
The advantages of the New map discs are:
The numbering of zones start at 0, and successively contain higher numbered sectors on a disc. The map’s length is nzones × sectors long.
Zone Number | Detail |
---|---|
0 | Contains the lowest numbered sectors on the disc |
1 | |
2 | |
… | |
nzones – 2 | |
nzones – 1 | Contains the highest numbered sectors on the disc |
The location of the map is stored in the middle zone, or as close to the middle as possible, based on whether the number of zones are odd or even. The map’s location is: nzones/2 (rounded down).
So a disc where nzones = 99, the map’s location is at the start of zone 49
A disc where nzones = 100, the map’s location is at the start of zone 50
The map block controls the allocation of a zone of the disc. The first map block controls zone 0, the second controls zone 1, and so on.
The general format of a map block is:
Contents | Notes |
---|---|
Header | |
Disc Record | The Disc Record is only stored in Zone 0 |
Allocation Bytes | |
Unused |
Offset | Name | Meaning |
---|---|---|
0 | ZoneCheck | Check byte for this zone’s map block |
1 | FreeLink | Link to first free fragment in this zone |
3 | CrossCheck | Cross check byte for complete map |
Multiple Disc Record Types are supported by FileCore. The Current default used by FileCore is the Large Disc Record Type.
The Allocation Byte is the part of the map block that controls the allocation of a zone. Together, the allocation bytes from all the map block control the allocation of the whole disc. Each bit corresponds to an allocation unit on the disc.
The size of an allocation unit is defined in the disc record by log2bpmb, and so must be a power of two bytes. An allocation unit is not necessarily one sector – it may be smaller or larger.
Not only must space be logically mapped in whole allocation units; it must also be physically allocated in whole sectors. Consequently, the smallest unit by which allocation may be changed is the larger of the sector size and the allocation unit. This unit is known as the granularity.
A disc is split into a number of disc objects, each of which consists of one or more fragments spread over the surface of the disc. Fragments need not be held in the same zone, and their size can vary by whole units of granularity. Fragments have a minimum size, which is explained below:
Three disc objects are special, and contain:
All other disc objects contain either a directory (optionally with small files held within that directory), or one or more files that are held in a common disc object.
The allocation bytes are treated as an array of bits, with the lsb of a byte coming before the msb in the array.
The array is split into a series of fragment blocks, each representing a fragment.
Since each bit in the array corresponds with an allocation unit on the disc, the length of the fragment block (in bits) must be the same as the size of the fragment (in allocation units). The stream of 0 bits are used to pad the fragment block to the correct length, and the 1 bit to terminate the fragment block.
There are two fragment IDs with special meanings:
ID # | Meaning |
---|---|
1 | Represents the object which contains all bad sectors, and the spare piece of map which hangs over the real end of the disc |
2 | Represents the object which contains the boot block, the map, and the root directory |
Other fragment IDs represent either free space fragments, or allocated fragments:
The chain hence always runs from the beginning of the map block to the end. The offset to the first free space fragment block is given by the FreeLink fragment block in the map block’s header. Because that fragment block is 2 bytes long, and must have a terminating 1 bit, idlen cannot be greater than 15.
Therefore, the following deductions can be made:
Info | Explanation |
---|---|
Smallest fragment size | (idlen + 1) × allocation unit (rounded up to the nearest unit of granularity) This is because a fragment block cannot be smaller that idlen + 1 bits (the fragment id, and the terminating 1 bit) |
Minimum size of idlen | log2secsize + 3 This is to ensure that it is large enough to hold the maximum possible bit offset to the next free fragment block |
Maximum number of fragment ids in a map block, and hence disc objects in a zone) | allocation bytes × 8 / (idlen + 1) i.e. allocation bits / minimum fragment size This value is smaller for Zone 0 than other zones because it has a copy of the disc record, and hence fewer allocation bytes The value for zones other than Zone 0 is – for a given disc – always the same, and is known as the ids per zone. It is easiest to calculate using fields from the disc record: ((1 << (log2secsize + 3)) – zone_spare) / (idlen + 1) |
Allocation Unit Size | The allocation unit cannot be so small as to require more than 15 bits to represent all the fragment ids possible (ids per zone × nzones) ≤ 2 15 since the fragment id cannot be more than 15 bits long |
This An is object because may have a number of fragments allocated to it in several zones. These fragments must be logically joined together in some way to make the object appear as a contiguous sequence of bytes. The naïve approach would be to have the first fragment block on cannot the disc be smaller the that first fragment of the object. New map discs do not do this. The first fragment in an object is the first fragment on the disc searching from zone (idlenfragment id + / 1 bits (thefragment idids per zone , ) and upwards, wrapping round from the terminating disc’s 1 end bit) to its start. Any subsequent fragments belonging to the same disc object are joined in the order they are found by this search.
Object 2, being the object which carries the map with it, is special. It is always at the beginning of the middle zone, as opposed to being at the beginning of zone 0.
This is to ensure that it is large enough to hold the maximum possible bit offset to the next free fragment block.