summaryrefslogtreecommitdiff
path: root/sys/boot/zfs/zfsimpl.c
Commit message (Collapse)AuthorAgeFilesLines
* Move sys/boot to stand. Fix all references to new locationWarner Losh2017-11-141-2536/+0
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=325834
* loader should support large_dnodeToomas Soome2017-09-121-3/+4
| | | | | | | | | | The zfsonlinux feature large_dnode is not yet supported by the loader. Reviewed by: avg, allanjude Differential Revision: https://reviews.freebsd.org/D12288 Notes: svn path=/head/; revision=323494
* Clean up style in print_state(..) and pager_printf(..)Enji Cooper2017-08-011-2/+3
| | | | | | | | | No functional change intended. MFC after: 3 days Notes: svn path=/head/; revision=321844
* loader: zfs reader vdev_probe should check for minimum device sizeToomas Soome2017-04-181-1/+10
| | | | | | | | | | | | | | | | | | | The smallest device we can have in the pool is 64MB, since we are trying to walk all four labels to find the most up to date uberblock, this limit will also give us good method to check if we even should attempt to probe. Enforcing the check also will make sure we are not getting wrapped while calculating the label offset. Also, after label check, we should verify if we actually got any UB or not. PR: 218473 Reported by: Masachika ISHIZUKA Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D10381 Notes: svn path=/head/; revision=317092
* loader: zfs reader should check all labelsToomas Soome2017-04-061-93/+131
| | | | | | | | | | | | | | | | | | | | | | | | The current zfs reader is only checking first label from each device, however, we do have 4 labels on device and we should check all 4 to be protected against disk failures and incomplete label updates. The difficulty is about the fact that 2 label copies are in front of the pool data, and 2 are at the end, which means, we have to know the size of the pool data area. Since we have now the mechanism from common/disk.c to use the partition information, it does help us in this task; however, there are still some corner cases. Namely, if the pool is created without partition, directly on the disk, and firmware will give us the wrong size for the disk, we only can check the first two label copies. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D10203 Notes: svn path=/head/; revision=316585
* Remove redundant declaration for `zfs_crc64_table`Enji Cooper2017-03-281-1/+0
| | | | | | | | | | | | | | zfssubr.c already defines this statically. Besides, zfsimpl.c defined it, but didn't use it. This fixes a -Wredundant-decls warning. MFC after: 3 days Reported by: amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc) Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316107
* Don't shadow read(2) definition with `read` argument in vdev_{create,probe}Enji Cooper2017-03-281-5/+5
| | | | | | | | | | | | This fixes several -Wshadow warnings introduced in r192194, but now errors with gcc 6.3.0. MFC after: 3 days Reported by: amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc) Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316106
* loader: r314112 did introduce dereference freed pointer entryToomas Soome2017-03-011-2/+2
| | | | | | | | | | | CID: 1371675 Reported by: Coverity Reviewed by: jhb, allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D9846 Notes: svn path=/head/; revision=314504
* loader: update symlink support in zfs readerToomas Soome2017-02-221-52/+152
| | | | | | | | | | | | | | | | As the current zfs file system is providing symlink via system attributes, need to update the code accordingly. Note, as the zfsboot code does not free the memory at this time, the object list will put some stress on the boot2 heap, eventually we should address the issue. Reviewed by: allanjude, smh Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D9706 Notes: svn path=/head/; revision=314112
* sys: Replace zero with NULL for pointers.Pedro F. Giffuni2017-02-221-3/+3
| | | | | | | | | Found with: devel/coccinelle MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D9694 Notes: svn path=/head/; revision=314068
* loader: zfs toplevel vdev must have spa set.Toomas Soome2016-11-171-1/+3
| | | | | | | | | | | | | | | | | | | The salt based checksum mechanisms, such as skein, are storing the seed in spa structure, and need to access the spa to use the seed. The current mechanism for quick access to correct spa is via pointer provided by vdev structure, but unfortunately the current code does set spa only for the leaf vdev. This patch will fix the issue by making sure the loader zfs reader will set spa also for top-level vdevs. PR: 214375 Reported by: lstewart Reviewed by: allanjude, imp Approved by: allanjude (mentor), imp (mentor) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D8487 Notes: svn path=/head/; revision=308776
* Loader paged/pageable data is not always paged.Toomas Soome2016-11-081-22/+49
| | | | | | | | | | | | | | | | | | | This change does modify devsw dv_print() to return the int value, enabling walkers to interrupt the walk on non zero value from dv_print(). This will allow the pager_print actually to stop displaying data on user input, and additionally pager is used in various *dev_print callbacks, where it was missing. For test, lsdev [-v] command should display data by screenfuls and should stop when the key 'q' is pressed on pager prompt. Reviewed by: allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D5461 Notes: svn path=/head/; revision=308434
* loader should boot pre-feature flags pools.Toomas Soome2016-10-241-2/+7
| | | | | | | | | | | | | | The feature flags chek is missing the corner case where we have valid pool version, but feature flags are not enabled - as for example plain v28 pool. This update does fix the boot support for such pools. Reviewed by: avg, allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D8331 Notes: svn path=/head/; revision=307865
* Add SHA512, skein, large blocks support for loader zfs.Toomas Soome2016-08-181-17/+104
| | | | | | | | | | | | | | | | | | | | | | | | | Updated sha512 from illumos. Using skein from freebsd crypto tree. Since loader itself is using 64MB memory for heap, updated zfsboot to use same, and this also allows to support zfs large blocks. Note, adding additional features does increate zfsboot code, therefore this update does increase zfsboot code to 128k, also I have ported gptldr.S update to zfsldr.S to support 64k+ code. With this update, boot1.efi has almost reached the current limit of the size set for it, so one of the future patches for boot1.efi will need to increase the limit. Currently known missing zfs features in boot loader are edonr and gzip support. Reviewed by: delphij, imp Approved by: imp (mentor) Obtained from: sha256.c update and skein_zfs.c stub from illumos. Differential Revision: https://reviews.freebsd.org/D7418 Notes: svn path=/head/; revision=304321
* Make boot code and loader check for unsupported ZFS feature flagsAllan Jude2016-08-011-11/+79
| | | | | | | | | | | | | | | | | | | | | | | | | OpenZFS uses feature flags instead of a zpool version number to track features since the split from Oracle. In addition to avoiding confusion on ZFS vs OpenZFS version numbers, this also allows features to be added to different operating systems that use OpenZFS in different order. The previous zfs boot code (gptzfsboot) and loader (zfsloader) blindly tries to read the pool, and if failed provided only a vague error message. With this change, both the boot code and loader check the MOS features list in the ZFS label and compare it against the list of features that the loader supports. If any unsupported feature is active, the pool is not considered as a candidate for booting, and a helpful diagnostic message is printed to the screen. Features that are merely enabled via zpool upgrade, but not in use, do not block booting from the pool. Submitted by: Toomas Soome <tsoome@me.com> Reviewed by: delphij, mav Relnotes: yes Differential Revision: https://reviews.freebsd.org/D6857 Notes: svn path=/head/; revision=303630
* Prevent bogus compiler in ZFS boot codeSteven Hartland2016-01-141-1/+7
| | | | | | | | | | | | Silence a bogus compiler warning about indexing past the end of dn_bonus. The ZFS code ensures this is not possible but the compiler can't determine this so added an additional check to prevent this warning. Sponsored by: Multiplay Notes: svn path=/head/; revision=294040
* Introduce the ZFS Boot Environments menu to the loader menuAllan Jude2015-12-311-6/+56
| | | | | | | | | | | | | | | | | | | | | If the system was booted with ZFS, a new menu item (#7) appears It contains an autogenerated list of ZFS Boot Environments This allows the user to switch to an alternate root file system Use Cases: - Revert a failed upgrade - Concurrently run different versions of FreeBSD with common home directory - Easier integration with the sysadmin/beadm utility Requested by: many Reviewed by: dteske MFC after: 10 days Relnotes: yes Sponsored by: ScaleEngine Inc. Differential Revision: https://reviews.freebsd.org/D3167 Notes: svn path=/head/; revision=293001
* dnode_read: fixup r284025, BP_IS_HOLE macro expects a pointerAndriy Gapon2015-06-051-1/+1
| | | | | | | | | | | PR: 199804 Reported by: sbruno Pointyhat to: avg MFC after: 10 days X-MFC with: r284025 Notes: svn path=/head/; revision=284032
* dnode_read: handle hole blocks in zfs boot codeAndriy Gapon2015-06-051-0/+4
| | | | | | | | | | | | | | | A hole block pointer can be encountered at any level and the hole can cover multiple data blocks, but we are reading the data blocks one by one, so we care only about the current one. PR: 199804 Reported by: Toomas Soome <tsoome@me.com> Submitted by: Toomas Soome <tsoome@me.com> (earlier version) Tested by: Toomas Soome <tsoome@me.com> MFC after: 11 days Notes: svn path=/head/; revision=284025
* MFV r274273:Xin LI2014-11-101-0/+6
| | | | | | | | | | | | | | | | | | | ZFS large block support. Please note that booting from datasets that have recordsize greater than 128KB is not supported (but it's Okay to enable the feature on the pool). This *may* remain unchanged because of memory constraint. Limited safety belt is provided for mounted root filesystem but use caution is advised. Illumos issue: 5027 zfs large block support MFC after: 1 month Notes: svn path=/head/; revision=274337
* MFV r267565:Xin LI2014-07-011-0/+29
| | | | | | | | | | 4757 ZFS embedded-data block pointers ("zero block compression") 4913 zfs release should not be subject to space checks MFC after: 2 weeks Notes: svn path=/head/; revision=268075
* MFV r259170:Xin LI2014-01-011-0/+3
| | | | | | | | | | | | | | | | 4370 avoid transmitting holes during zfs send 4371 DMU code clean up illumos/illumos-gate@43466aae47bfcd2ad9bf501faec8e75c08095e4f NOTE: Make sure the boot code is updated if a zpool upgrade is done on boot zpool. MFC after: 2 weeks Notes: svn path=/head/; revision=260150
* zfs boot: export boot/primary pool and vdev guid all the way to kenvAndriy Gapon2012-10-061-0/+28
| | | | | | | | | | This is work in progress to for znextboot and it also provides some convenient infrastructure. MFC after: 20 days Notes: svn path=/head/; revision=241293
* zfs boot spa_status: print bootfs for each reported poolAndriy Gapon2012-10-061-0/+11
| | | | | | | MFC after: 9 days Notes: svn path=/head/; revision=241291
* boot/zfs: call zfs_spa_init for all found poolsAndriy Gapon2012-10-061-3/+4
| | | | | | | | | | ... and drop those for which it fails. Also, add more sanity checking to the function. MFC after: 16 days Notes: svn path=/head/; revision=241289
* zfs boot: add code for listing child datasets of a given datasetAndriy Gapon2012-10-061-4/+32
| | | | | | | | | | | | - only filesystem datasets are supported - children names are printed to stdout To do: allow to iterate over the list and fetch names programatically MFC after: 17 days Notes: svn path=/head/; revision=241283
* zfs boot: add a size check for a value in fzap_lookupAndriy Gapon2012-09-111-0/+2
| | | | | | | MFC after: 25 days Notes: svn path=/head/; revision=240349
* zfs boot: print only an attribute name in fzap_listAndriy Gapon2012-09-111-1/+2
| | | | | | | | | ... this matches mzap_list behavior MFC after: 12 days Notes: svn path=/head/; revision=240348
* zfs boot: fix/replace fzap_rlookup implementationAndriy Gapon2012-09-111-47/+20
| | | | | | | | | | | | The previous one was totally bogus as it used hash value of _output_ variable as an index for searching... The only reliable way to do a reverse lookup here is to iterate over all entries. MFC after: 15 days Notes: svn path=/head/; revision=240347
* zfs boot: bring zap_leaf_chunk field names in sync with kernel codeAndriy Gapon2012-09-111-3/+3
| | | | | | | | | This change is cosmetic. MFC after: 10 days Notes: svn path=/head/; revision=240346
* Fix ZFS boot with pre-features pools (version <= 28) broken in r236884Martin Matuska2012-06-131-3/+4
| | | | | | | | Reported by: mav MFC after: 1 month Notes: svn path=/head/; revision=237001
* Introduce "feature flags" for ZFS pools (bump SPA version to 5000).Martin Matuska2012-06-111-1/+66
| | | | | | | | | | | | | | | | | | | | | | Add first feature "com.delphix:async_destroy" (asynchronous destroy of ZFS datasets). Implement features support in ZFS boot code. Illumos revisions merged: 13700:2889e2596bd6 13701:1949b688d5fb 2619 asynchronous destruction of ZFS file systems 2747 SPA versioning with zfs feature flags References: https://www.illumos.org/issues/2619 https://www.illumos.org/issues/2747 Obtained from: illumos (issue #2619, #2747) MFC after: 1 month Notes: svn path=/head/; revision=236884
* zfs boot code: mark spa_t arguments as const where they are used as suchAndriy Gapon2012-05-131-25/+25
| | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=235390
* sparc64/zfs boot: take advantage of new libzfsboot capabilitiesAndriy Gapon2012-05-121-32/+0
| | | | | | | | | | Also drop the now unneeded compatibility shims. Tested by: marius MFC after: 1 month Notes: svn path=/head/; revision=235364
* zfs boot code: use %j and uintmax_t instead %ll and uint64_t in printfsAndriy Gapon2012-05-121-9/+11
| | | | | | | | | | This is to silence warnings that result from different definitions of uint64_t on different architectures, specifically i386 and sparc64. MFC after: 1 month Notes: svn path=/head/; revision=235361
* zfsboot/zfsloader: support accessing filesystems within a poolAndriy Gapon2012-05-121-22/+332
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In zfs loader zfs device name format now is "zfs:pool/fs", fully qualified file path is "zfs:pool/fs:/path/to/file" loader allows accessing files from various pools and filesystems as well as changing currdev to a different pool/filesystem. zfsboot accepts kernel/loader name in a format pool:fs:path/to/file or, as before, pool:path/to/file; in the latter case a default filesystem is used (pool root or bootfs). zfsboot passes guids of the selected pool and dataset to zfsloader to be used as its defaults. zfs support should be architecture independent and is provided in a separate library, but architectures wishing to use this zfs support still have to provide some glue code and their devdesc should be compatible with zfs_devdesc. arch_zfs_probe method is used to discover all disk devices that may be part of ZFS pool(s). libi386 unconditionally includes zfs support, but some zfs-specific functions are stubbed out as weak symbols. The strong definitions are provided in libzfsboot. This change mean that the size of i386_devspec becomes larger to match zfs_devspec. Backward-compatibility shims are provided for recently added sparc64 zfs boot support. Currently that architecture still works the old way and does not support the new features. TODO: - clear up pool root filesystem vs pool bootfs filesystem distinction - update sparc64 support - set vfs.root.mountfrom based on currdev (for zfs) Mid-future TODO: - loader sub-menu for selecting alternative boot environment Distant future TODO: - support accessing snapshots, using a snapshot as readonly root Reviewed by: marius (sparc64), Gavin Mu <gavin.mu@gmail.com> (sparc64) Tested by: Florian Wagner <florian@wagner-flo.net> (x86), marius (sparc64) No objections: fs@, hackers@ MFC after: 1 month Notes: svn path=/head/; revision=235329
* zfs boot: allow file vdevs to be used in testing (e.g. with zfsboottest)Andriy Gapon2011-12-041-0/+3
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=228266
* - Correctly read gang header from raidz.Pawel Jakub Dawidek2011-10-201-51/+51
| | | | | | | | | | | | | - 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 MFC after: 3 days Notes: svn path=/head/; revision=226568
* Always pass data size for checksum verification function, as usingPawel Jakub Dawidek2011-10-191-1/+1
| | | | | | | | | | | | | 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. MFC after: 3 days Notes: svn path=/head/; revision=226553
* Never pass NULL block pointer when reading. This is neither expected norPawel Jakub Dawidek2011-10-191-1/+2
| | | | | | | | | | | 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. MFC after: 3 days Notes: svn path=/head/; revision=226552
* Don't mark vdev as healthy too soon, so we won't try to use invalid vdevs.Pawel Jakub Dawidek2011-10-191-2/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=226551
* Finally... Import the latest open-source ZFS version - (SPA) 28.Pawel Jakub Dawidek2011-02-271-65/+146
| | | | | | | | | | | | | | | | | | Few new things available from now on: - Data deduplication. - Triple parity RAIDZ (RAIDZ3). - zfs diff. - zpool split. - Snapshot holds. - zpool import -F. Allows to rewind corrupted pool to earlier transaction group. - Possibility to import pool in read-only mode. MFC after: 1 month Notes: svn path=/head/; revision=219089
* - Split code shared by almost any boot loader into separate files andPawel Jakub Dawidek2010-09-241-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | clean up most layering violations: sys/boot/i386/common/rbx.h: RBX_* defines OPT_SET() OPT_CHECK() sys/boot/common/util.[ch]: memcpy() memset() memcmp() bcpy() bzero() bcmp() strcmp() strncmp() [new] strcpy() strcat() strchr() strlen() printf() sys/boot/i386/common/cons.[ch]: ioctrl putc() xputc() putchar() getc() xgetc() keyhit() [now takes number of seconds as an argument] getstr() sys/boot/i386/common/drv.[ch]: struct dsk drvread() drvwrite() [new] drvsize() [new] sys/boot/common/crc32.[ch] [new] sys/boot/common/gpt.[ch] [new] - Teach gptboot and gptzfsboot about new files. I haven't touched the rest, but there is still a lot of code duplication to be removed. - Implement full GPT support. Currently we just read primary header and partition table and don't care about checksums, etc. After this change we verify checksums of primary header and primary partition table and if there is a problem we fall back to backup header and backup partition table. - Clean up most messages to use prefix of boot program, so in case of an error we know where the error comes from, eg.: gptboot: unable to read primary GPT header - If we can't boot, print boot prompt only once and not every five seconds. - Honour newly added GPT attributes: bootme - this is bootable partition bootonce - try to boot from this partition only once bootfailed - we failed to boot from this partition - Change boot order of gptboot to the following: 1. Try to boot from all the partitions that have both 'bootme' and 'bootonce' attributes one by one. 2. Try to boot from all the partitions that have only 'bootme' attribute one by one. 3. If there are no partitions with 'bootme' attribute, boot from the first UFS partition. - The 'bootonce' functionality is implemented in the following way: 1. Walk through all the partitions and when 'bootonce' attribute is found without 'bootme' attribute, remove 'bootonce' attribute and set 'bootfailed' attribute. 'bootonce' attribute alone means that we tried to boot from this partition, but boot failed after leaving gptboot and machine was restarted. 2. Find partition with both 'bootme' and 'bootonce' attributes. 3. Remove 'bootme' attribute. 4. Try to execute /boot/loader or /boot/kernel/kernel from that partition. If succeeded we stop here. 5. If execution failed, remove 'bootonce' and set 'bootfailed'. 6. Go to 2. If whole boot succeeded there is new /etc/rc.d/gptboot script coming that will log all partitions that we failed to boot from (the ones with 'bootfailed' attribute) and will remove this attribute. It will also find partition with 'bootonce' attribute - this is the partition we booted from successfully. The script will log success and remove the attribute. All the GPT updates we do here goes to both primary and backup GPT if they are valid. We don't touch headers or partition tables when checksum doesn't match. Reviewed by: arch (Message-ID: <20100917234542.GE1902@garage.freebsd.pl>) Obtained from: Wheel Systems Sp. z o.o. http://www.wheelsystems.com MFC after: 2 weeks Notes: svn path=/head/; revision=213136
* Remove empty lines committed by accident.Pawel Jakub Dawidek2010-09-091-2/+0
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=212387
* Ignore log vdevs.Pawel Jakub Dawidek2010-09-091-0/+7
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=212384
* Allow to boot from a pool within which replacing is in progress.Pawel Jakub Dawidek2010-09-091-3/+33
| | | | | | | | | | | | | | | Before the change it wasn't possible and the following error was printed: ZFS: can only boot from disk, mirror or raidz vdevs Now if the original vdev (the one we are replacing) is still present we will read from it, but if it is not present we won't read from the new vdev, as it might not have enough valid data yet. MFC after: 2 weeks Notes: svn path=/head/; revision=212383
* Remove duplicated code.Pawel Jakub Dawidek2010-09-091-20/+9
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=212382
* Return EIO if vdev->v_phys_read is NULL.Martin Matuska2010-08-091-0/+3
| | | | | | | | | | | | This fixes booting from a ZFS mirror with a unavailable primary device. PR: kern/148655 Reviewed by: avg Approved by: delphij (mentor) MFC after: 3 days Notes: svn path=/head/; revision=211091
* boot/zfs: fix gang block reading codeAndriy Gapon2010-05-281-4/+8
| | | | | | | | | | | | - use correct size (512) while reading a gang block - skip holes while reading child blocks - advance buffer pointer while reading child blocks PR: 144214 MFC after: 10 days Notes: svn path=/head/; revision=208610
* Space cleanup for revision 201689 committed separately for easier review.Xin LI2010-01-061-35/+35
| | | | | | | | | | | This commit is purely space changes. Submitted by: Matt Reimer Sponsored by: VPOP Technologies, Inc. MFC after: 2 weeks Notes: svn path=/head/; revision=201690