History log of /freebsd-9.3-release/sys/boot/common/disk.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 267654 19-Jun-2014 gjb

Copy stable/9 to releng/9.3 as part of the 9.3-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 243243 18-Nov-2012 ae

MFC 239054,239057,239058,239060,239066,239067,239068,239070,239073,
239087,239088,239127,239210,239211,239230,239231,239232,239243,
239292,239293,239294,239325,240272,240273,240274,240275,240276,
240277,240335,240481,241023,241047,241053,241065,241068,241069,
241070,241164,241809,241876

239054:
Create the interface to work with various partition tables from the
loader(8). The following partition tables are supported: BSD label, GPT,
MBR, EBR and VTOC8.
239057:
Remove unused variables.
239058:
Introduce new API to work with disks from the loader's drivers.
It uses new API from the part.c to work with partition tables.
239060:
When GPT signature is invalid in the primary GPT header, then try to
read backup GPT header.
239066:
Add offset field to the i386_devdesc structure to be compatible with
disk_devdesc structure. Update biosdisk driver to the new disk API.
239067:
Remove unneeded flag.
239068:
Teach the ZFS use new partitions API when probing.
Note: now ZFS does probe only for partitions with type "freebsd-zfs"
and "freebsd".
239070:
Add simple test program that uses the partition tables handling code.
It is useful to test and debug how boot loader handles partition tables
metadata.
239073:
Bump USERBOOT_VERSION.
239087:
Add to the debug output the offset from the parent partitioning scheme.
239088:
Fix start offset calculation for the EBR partitions.
239127:
As it turned out, there are some installations, where BSD label
contains partitions with type zero. And it has worked.
So, allow detect these partitions.
239210:
Add more debug messages.
239211:
Add another debug message.
239230:
Unbreak booting from the true dedicated disks.
When we open the disk, check the type of partition table, that has
been detected. If this is BSD label, then we assume this is DD mode.
239231:
Remove colons from the debug message, device name returned by the
disk_fmtdev() already has the colons.
239232:
Restore the old behaviour. If requested partition is a BSD slice,
but d_partition isn't explicitly set, then try to open BSD label and its
first partition.
239243:
After r239066, reinitialize v86.ctl and v86.addr for int 13 EDD probing
in sys/boot/i386/libi386/biosdisk.c. Otherwise, when DISK_DEBUG is
enabled, the DEBUG() macros will clobber those fields, and cause the
probing to always fail mysteriously when debugging is enabled.
239292:
Explicitly terminate the string after strncpy(3).
239293:
Rework r239232 to unbreak ZFS detection on MBR slices.
239294:
Some BIOSes return incorrect number of sectors, make checks less
strictly, to do not lost some partitions.
239325:
Add comment why the code has been disabled.
240272:
Make struct uboot_devdesc compatible with struct disk_devdesc.
240273:
Use disk_fmtdev() and disk_parsedev() functions from the new DISK API.
240274:
Update uboot's disk driver to use new DISK API.
240275:
Build disk.c only when DISK_SUPPORT is enabled.
240276:
Update according to the change of struct uboot_devdesc.
240277:
Handle LOADER_NO_DISK_SUPPORT knob in the arm and powerpc ubldr.
240335:
Slightly reduce an overhead for the open() call in the zfsloader.
libstand(3) tries to detect file system in the predefined order,
but zfsloader usually is used for the booting from ZFS, and there is
no need to try detect several file system types for each open() call.
240481:
The MBR data is not necessarily aligned. This is a problem on ARM.
241023:
Make the loader a bit smarter, when it tries to open disk and the slice
number is not exactly specified. When the disk has MBR, also try to read
BSD label after ptable_getpart() call. When the disk has GPT, also set
d_partition to 255. Mostly, this is how it worked before.
241047:
Disable splitfs support, since we aren't support floppies for a long
time. This slightly reduces an overhead, when loader tries to open
file that doesn't exist.
241053:
Almost each time when loader opens a file, this leads to calling
disk_open(). Very often this is called several times for one file.
This leads to reading partition table metadata for each call. To
reduce the number of disk I/O we have a simple block cache, but it
is very dumb and more than half of I/O operations related to reading
metadata, misses this cache.

Introduce new cache layer to resolve this problem. It is independent
and doesn't need initialization like bcache, and will work by default
for all loaders which use the new DISK API. A successful disk_open()
call to each new disk or partition produces new entry in the cache.
Even more, when disk was already open, now opening of any nested
partitions does not require reading top level partition table.
So, if without this cache, partition table metadata was read around
20-50 times during boot, now it reads only once. This affects the booting
from GPT and MBR from the UFS.
241065:
Fix disk_cleanup() to work without DISK_DEBUG too.
241068:
Reduce the number of attempts to detect proper kld format for the amd64
loader.
241069:
Remember the file format of the last loaded module and try to use it for
next files.
241070:
Fix the style.
241164:
Replace all references to loader_callbacks_v1 with loader_callbacks.
241809:
Add the flags parameter to the disk_open() function and DISK_F_NOCACHE
flag, that disables the caching of partition tables metadata.
Use this flag for floppies in the libi386/biosdisk driver.
241876:
When loader tries to open GPT partition, but partition table is not GPT,
then try automatically detect an appropriate partition type.


# 227705 19-Nov-2011 pjd

MFC r226549,r226550,r226551,r226552,r226553,r226554,r226568,r226569,r226611,
r226612:

r226549:

Remove redundant size calculation.

r226550:

Initialize 'rc' properly before using it. This error could lead to infinite
loop when data reconstruction was needed.

r226551:

Don't mark vdev as healthy too soon, so we won't try to use invalid vdevs.

r226552:

Never pass NULL block pointer when reading. This is neither expected nor
handled by lower layers like vdev_raidz, which uses bp for checksum
verification. This bug could lead to NULL pointer reference and resets
during boot.

r226553:

Always pass data size for checksum verification function, as using
physical block size declared in bp may not always be what we want.
For example in case of gang block header physical block size declared
in bp is much larger than SPA_GANGBLOCKSIZE (512 bytes) and checksum
calculation failed. This bug could lead to accessing unallocated
memory and resets/failures during boot.

r226554:

Fix missing return when LOADER_GPT_SUPPORT is defined, but LOADER_MBR_SUPPORT
is not.

r226568:

- Correctly read gang header from raidz.
- Decompress assembled gang block data if compressed.
- Verify checksum of a gang header.
- Verify checksum of assembled gang block data.
- Verify checksum of uber block.

Submitted by: avg

r226569:

With LOADER_MBR_SUPPORT defined and LOADER_GPT_SUPPORT undefined we would
never call disk_openmbr().

Submitted by: avg

r226611:

- Allow to specify multiple files to check, eg.

zfsboottest gpt/system0 gpt/system1 - /boot/kernel/kernel /boot/zfsloader

- Instead of printing file's content calculate MD5 hash of the file,
so it can be easly compared to the hash calculated via file system.
- Some other minor improvements.

r226612:

Because ZFS boot code was very fragile in the past and real PITA to debug,
introduce zfsboottest.sh script that will verify if it will be possible to boot
from the given pool.

# zfsboottest.sh system

Where "system" is pool name of the pool we want to boot from.

What is being verified by the script:
- Does the pool exist?
- Does it have bootfs property configured?
- Is mountpoint property of the boot dataset set to 'legacy'?

Dataset configured in bootfs property has to be mounted to perform more
checks:
- Does the /boot directory in boot dataset exist?
- Is this dataset configured as root file system in /etc/fstab or set
in vfs.root.mountfrom variable in /boot/loader.conf?

By using zfsboottest tool the script will read all the files in /boot
directory using ZFS boot code and calculate their checksums.
Then, it will walk /boot directory using find(1) though regular file sytem
and also read all the files in /boot directory and calculate their checksums.
If any of the files cannot be looked up, read or checksum is invalid it will
be reported and booting off of this pool is probably not possible.

Some additional checks may be interesting as well. For example if the disks
contain proper pmbr and gptzfsboot code or if all expected files in /boot/
are present.

When upgrading FreeBSD, one should snapshot datasets that contain operating
system, upgrade (install new world and kernel) and use zfsboottest.sh to verify
if it will be possible to boot from new configuration. If all is good one
should upgrade boot blocks, by eg.:

# gpart -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada1

If something is wrong, one should rollback datasets and report the problems.

Approved by: re (kib)


# 225736 22-Sep-2011 kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by: re (implicit)


# 223712 01-Jul-2011 marius

Fix r223695 to compile on architectures which don't use the MBR scheme; wrap
the MBR support in the common part of the loader in #ifdef's and enable it
only for userboot for now.


# 223695 30-Jun-2011 dfr

Add a version of the FreeBSD bootloader which can run in userland, packaged
as a shared library. This is intended to be used by BHyVe to load FreeBSD
kernels into new virtual machines.