Commit e2228bd9 authored by Matt Macy's avatar Matt Macy
Browse files

Update OpenZFS to 2.0.0-rc3-gfc5966

parent 01ea34f1
# Contributing to OpenZFS
<p align="center">
<img alt="OpenZFS Logo"
*First of all, thank you for taking the time to contribute!*
By using the following guidelines, you can help us make OpenZFS even better.
## Table Of Contents
[What should I know before I get
* [Get ZFS](#get-zfs)
* [Debug ZFS](#debug-zfs)
* [Where can I ask for help?](#where-can-I-ask-for-help)
[How Can I Contribute?](#how-can-i-contribute)
* [Reporting Bugs](#reporting-bugs)
* [Suggesting Enhancements](#suggesting-enhancements)
* [Pull Requests](#pull-requests)
* [Testing](#testing)
[Style Guides](#style-guides)
* [Coding Conventions](#coding-conventions)
* [Commit Message Formats](#commit-message-formats)
* [New Changes](#new-changes)
* [OpenZFS Patch Ports](#openzfs-patch-ports)
* [Coverity Defect Fixes](#coverity-defect-fixes)
* [Signed Off By](#signed-off-by)
Helpful resources
* [OpenZFS Documentation](
* [OpenZFS Developer Resources](
* [Git and GitHub for beginners](
## What should I know before I get started?
### Get ZFS
You can build zfs packages by following [these
or install stable packages from [your distribution's
### Debug ZFS
A variety of methods and tools are available to aid ZFS developers.
It's strongly recommended that when developing a patch the `--enable-debug`
configure option should be set. This will enable additional correctness
checks and all the ASSERTs to help quickly catch potential issues.
In addition, there are numerous utilities and debugging files which
provide visibility into the inner workings of ZFS. The most useful
of these tools are discussed in detail on the [Troubleshooting
### Where can I ask for help?
The [zfs-discuss mailing
or IRC are the best places to ask for help. Please do not file
support requests on the GitHub issue tracker.
## How Can I Contribute?
### Reporting Bugs
*Please* contact us via the [zfs-discuss mailing
or IRC if you aren't certain that you are experiencing a bug.
If you run into an issue, please search our [issue
tracker]( *first* to ensure the
issue hasn't been reported before. Open a new issue only if you haven't
found anything similar to your issue.
You can open a new issue and search existing issues using the public [issue
#### When opening a new issue, please include the following information at the top of the issue:
* What distribution (with version) you are using.
* The spl and zfs versions you are using, installation method (repository
or manual compilation).
* Describe the issue you are experiencing.
* Describe how to reproduce the issue.
* Including any warning/errors/backtraces from the system logs.
When a new issue is opened, it is not uncommon for developers to request
additional information.
In general, the more detail you share about a problem the quicker a
developer can resolve it. For example, providing a simple test case is always
exceptionally helpful.
Be prepared to work with the developers investigating your issue. Your
assistance is crucial in providing a quick solution. They may ask for
information like:
* Your pool configuration as reported by `zdb` or `zpool status`.
* Your hardware configuration, such as
* Number of CPUs.
* Amount of memory.
* Whether your system has ECC memory.
* Whether it is running under a VMM/Hypervisor.
* Kernel version.
* Values of the spl/zfs module parameters.
* Stack traces which may be logged to `dmesg`.
### Suggesting Enhancements
OpenZFS is a widely deployed production filesystem which is under active
development. The team's primary focus is on fixing known issues, improving
performance, and adding compelling new features.
You can view the list of proposed features
by filtering the issue tracker by the ["Type: Feature"
If you have an idea for a feature first check this list. If your idea already
appears then add a +1 to the top most comment, this helps us gauge interest
in that feature.
Otherwise, open a new issue and describe your proposed feature. Why is this
feature needed? What problem does it solve?
### Pull Requests
#### General
* All pull requests must be based on the current master branch and apply
without conflicts.
* Please attempt to limit pull requests to a single commit which resolves
one specific issue.
* Make sure your commit messages are in the correct format. See the
[Commit Message Formats](#commit-message-formats) section for more information.
* When updating a pull request squash multiple commits by performing a
[rebase]( (squash).
* For large pull requests consider structuring your changes as a stack of
logically independent patches which build on each other. This makes large
changes easier to review and approve which speeds up the merging process.
* Try to keep pull requests simple. Simple code with comments is much easier
to review and approve.
* All proposed changes must be approved by an OpenZFS organization member.
* If you have an idea you'd like to discuss or which requires additional testing, consider opening it as a draft pull request.
Once everything is in good shape and the details have been worked out you can remove its draft status.
Any required reviews can then be finalized and the pull request merged.
#### Tests and Benchmarks
* Every pull request will by tested by the buildbot on multiple platforms by running the [ and]( test suites.
* To verify your changes conform to the [style guidelines](
), please run `make checkstyle` and resolve any warnings.
* Static code analysis of each pull request is performed by the buildbot; run `make lint` to check your changes.
* Test cases should be provided when appropriate.
This includes making sure new features have adequate code coverage.
* If your pull request improves performance, please include some benchmarks.
* The pull request must pass all required [ZFS
Buildbot]( builders before
being accepted. If you are experiencing intermittent TEST
builder failures, you may be experiencing a [test suite
There are also various [buildbot options](
to control how changes are tested.
### Testing
All help is appreciated! If you're in a position to run the latest code
consider helping us by reporting any functional problems, performance
regressions or other suspected issues. By running the latest code to a wide
range of realistic workloads, configurations and architectures we're better
able quickly identify and resolve potential issues.
Users can also run the [ZFS Test
Suite]( on their systems
to verify ZFS is behaving as intended.
## Style Guides
### Repository Structure
OpenZFS uses a standardised branching structure.
- The "development and main branch", is the branch all development should be based on.
- "Release branches" contain the latest released code for said version.
- "Staging branches" contain selected commits prior to being released.
**Branch Names:**
- Development and Main branch: `master`
- Release branches: `zfs-$VERSION-release`
- Staging branches: `zfs-$VERSION-staging`
`$VERSION` should be replaced with the `major.minor` version number.
_(This is the version number without the `.patch` version at the end)_
### Coding Conventions
We currently use [C Style and Coding Standards for
SunOS]( as our
coding convention.
This repository has an `.editorconfig` file. If your editor [supports
editorconfig](, it will
automatically respect most of this project's whitespace preferences.
Additionally, Git can help warn on whitespace problems as well:
git config --local core.whitespace trailing-space,space-before-tab,indent-with-non-tab,-tab-in-indent
### Commit Message Formats
#### New Changes
Commit messages for new changes must meet the following guidelines:
* In 72 characters or less, provide a summary of the change as the
first line in the commit message.
* A body which provides a description of the change. If necessary,
please summarize important information such as why the proposed
approach was chosen or a brief description of the bug you are resolving.
Each line of the body must be 72 characters or less.
* The last line must be a `Signed-off-by:` tag. See the
[Signed Off By](#signed-off-by) section for more information.
An example commit message for new changes is provided below.
This line is a brief summary of your change
Please provide at least a couple sentences describing the
change. If necessary, please summarize decisions such as
why the proposed approach was chosen or what bug you are
attempting to solve.
Signed-off-by: Contributor <>
#### OpenZFS Patch Ports
If you are porting OpenZFS patches, the commit message must meet
the following guidelines:
* The first line must be the summary line from the most important OpenZFS commit being ported.
It must begin with `OpenZFS dddd, dddd - ` where `dddd` are OpenZFS issue numbers.
* Provides a `Authored by:` line to attribute each patch for each original author.
* Provides the `Reviewed by:` and `Approved by:` lines from each original
OpenZFS commit.
* Provides a `Ported-by:` line with the developer's name followed by
their email for each OpenZFS commit.
* Provides a `OpenZFS-issue:` line with link for each original illumos
* Provides a `OpenZFS-commit:` line with link for each original OpenZFS commit.
* If necessary, provide some porting notes to describe any deviations from
the original OpenZFS commits.
An example OpenZFS patch port commit message for a single patch is provided
OpenZFS 1234 - Summary from the original OpenZFS commit
Authored by: Original Author <>
Reviewed by: Reviewer One <>
Reviewed by: Reviewer Two <>
Approved by: Approver One <>
Ported-by: ZFS Contributor <>
Provide some porting notes here if necessary.
If necessary, multiple OpenZFS patches can be combined in a single port.
This is useful when you are porting a new patch and its subsequent bug
fixes. An example commit message is provided below.
OpenZFS 1234, 5678 - Summary of most important OpenZFS commit
1234 Summary from original OpenZFS commit for 1234
Authored by: Original Author <>
Reviewed by: Reviewer Two <>
Approved by: Approver One <>
Ported-by: ZFS Contributor <>
Provide some porting notes here for 1234 if necessary.
5678 Summary from original OpenZFS commit for 5678
Authored by: Original Author2 <>
Reviewed by: Reviewer One <>
Approved by: Approver Two <>
Ported-by: ZFS Contributor <>
Provide some porting notes here for 5678 if necessary.
#### Coverity Defect Fixes
If you are submitting a fix to a
[Coverity defect](,
the commit message should meet the following guidelines:
* Provides a subject line in the format of
`Fix coverity defects: CID dddd, dddd...` where `dddd` represents
each CID fixed by the commit.
* Provides a body which lists each Coverity defect and how it was corrected.
* The last line must be a `Signed-off-by:` tag. See the
[Signed Off By](#signed-off-by) section for more information.
An example Coverity defect fix commit message is provided below.
Fix coverity defects: CID 12345, 67890
CID 12345: Logically dead code (DEADCODE)
Removed the if(var != 0) block because the condition could never be
CID 67890: Resource Leak (RESOURCE_LEAK)
Ensure free is called after allocating memory in function().
Signed-off-by: Contributor <>
#### Signed Off By
A line tagged as `Signed-off-by:` must contain the developer's
name followed by their email. This is the developer's certification
that they have the right to submit the patch for inclusion into
the code base and indicates agreement to the [Developer's Certificate
of Origin](
Code without a proper signoff cannot be merged.
Git can append the `Signed-off-by` line to your commit messages. Simply
provide the `-s` or `--signoff` option when performing a `git commit`.
For more information about writing commit messages, visit [How to Write
a Git Commit Message](
#### Co-authored By
If someone else had part in your pull request, please add the following to the commit:
`Co-authored-by: Name <gitregistered@email.address>`
This is useful if their authorship was lost during squashing, rebasing, etc.,
but may be used in any situation where there are co-authors.
The email address used here should be the same as on the GitHub profile of said user.
If said user does not have their email address public, please use the following instead:
`Co-authored-by: Name <[username]>`
......@@ -363,16 +363,16 @@ get_usage(zfs_help_t idx)
return (gettext("\tuserspace [-Hinp] [-o field[,...]] "
"[-s field] ...\n"
"\t [-S field] ... [-t type[,...]] "
return (gettext("\tgroupspace [-Hinp] [-o field[,...]] "
"[-s field] ...\n"
"\t [-S field] ... [-t type[,...]] "
return (gettext("\tprojectspace [-Hp] [-o field[,...]] "
"[-s field] ... \n"
"\t [-S field] ... <filesystem|snapshot>\n"));
"\t [-S field] ... <filesystem|snapshot|path>\n"));
return (gettext("\tproject [-d|-r] <directory|file ...>\n"
"\tproject -c [-0] [-d|-r] [-p id] <directory|file ...>\n"
......@@ -2481,11 +2481,13 @@ zfs_do_upgrade(int argc, char **argv)
* zfs userspace [-Hinp] [-o field[,...]] [-s field [-s field]...]
* [-S field [-S field]...] [-t type[,...]] filesystem | snapshot
* [-S field [-S field]...] [-t type[,...]]
* filesystem | snapshot | path
* zfs groupspace [-Hinp] [-o field[,...]] [-s field [-s field]...]
* [-S field [-S field]...] [-t type[,...]] filesystem | snapshot
* [-S field [-S field]...] [-t type[,...]]
* filesystem | snapshot | path
* zfs projectspace [-Hp] [-o field[,...]] [-s field [-s field]...]
* [-S field [-S field]...] filesystem | snapshot
* [-S field [-S field]...] filesystem | snapshot | path
* -H Scripted mode; elide headers and separate columns by tabs.
* -i Translate SID to POSIX ID.
......@@ -3191,7 +3193,7 @@ zfs_do_userspace(int argc, char **argv)
} while (delim != NULL);
if ((zhp = zfs_open(g_zfs, argv[0], ZFS_TYPE_FILESYSTEM |
if ((zhp = zfs_path_to_zhandle(g_zfs, argv[0], ZFS_TYPE_FILESYSTEM |
return (1);
if (zhp->zfs_head_type != ZFS_TYPE_FILESYSTEM) {
AC_MSG_CHECKING([whether mutex_lock() is GPL-only])
ZFS_LINUX_TEST_RESULT([config_debug_lock_alloc], [
ZFS_LINUX_TEST_RESULT([config_debug_lock_alloc_license], [
......@@ -6,10 +6,11 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_OBJTOOL], [
dnl # 4.6 API for compile-time stack validation
ZFS_LINUX_TEST_SRC([objtool], [
#undef __ASSEMBLY__
#include <asm/ptrace.h>
#include <asm/frame.h>
#if !defined(FRAME_BEGIN)
#error "FRAME_BEGIN is not defined"
......@@ -18,7 +19,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_OBJTOOL], [
#include <linux/frame.h>
#error "STACK_FRAME_NON_STANDARD is not defined."
......@@ -204,6 +204,7 @@ AC_CONFIG_FILES([
......@@ -15,8 +15,8 @@
# See "4.5 Disable root prompt on the initramfs" of Securing Debian Manual:
shell() {
if type panic > /dev/null 2>&1; then
panic $@
if command -v panic > /dev/null 2>&1; then
......@@ -26,22 +26,23 @@ shell() {
# pools and mounting any filesystems.
if type run_scripts > /dev/null 2>&1 && \
[ -f "/scripts/local-top" -o -d "/scripts/local-top" ]
if command -v run_scripts > /dev/null 2>&1
[ "$quiet" != "y" ] && \
zfs_log_begin_msg "Running /scripts/local-top"
run_scripts /scripts/local-top
[ "$quiet" != "y" ] && zfs_log_end_msg
if [ -f "/scripts/local-top" ] || [ -d "/scripts/local-top" ]
[ "$quiet" != "y" ] && \
zfs_log_begin_msg "Running /scripts/local-top"
run_scripts /scripts/local-top
[ "$quiet" != "y" ] && zfs_log_end_msg
if type run_scripts > /dev/null 2>&1 && \
[ -f "/scripts/local-premount" -o -d "/scripts/local-premount" ]
[ "$quiet" != "y" ] && \
zfs_log_begin_msg "Running /scripts/local-premount"
run_scripts /scripts/local-premount
[ "$quiet" != "y" ] && zfs_log_end_msg
if [ -f "/scripts/local-premount" ] || [ -d "/scripts/local-premount" ]
[ "$quiet" != "y" ] && \
zfs_log_begin_msg "Running /scripts/local-premount"
run_scripts /scripts/local-premount
[ "$quiet" != "y" ] && zfs_log_end_msg
......@@ -57,10 +58,10 @@ disable_plymouth()
# Get a ZFS filesystem property value.
local fs="$1"
local value=$2
"${ZFS}" get -H -ovalue $value "$fs" 2> /dev/null
"${ZFS}" get -H -ovalue "$value" "$fs" 2> /dev/null
# Find the 'bootfs' property on pool $1.
......@@ -68,7 +69,7 @@ get_fs_value()
# pool by exporting it again.
local pool="$1"
# If 'POOL_IMPORTED' isn't set, no pool imported and therefore
# we won't be able to find a root fs.
......@@ -84,7 +85,7 @@ find_rootfs()
# Make sure it's not '-' and that it starts with /.
if [ "${ZFS_BOOTFS}" != "-" ] && \
$(get_fs_value "${ZFS_BOOTFS}" mountpoint | grep -q '^/$')
get_fs_value "${ZFS_BOOTFS}" mountpoint | grep -q '^/$'
# Keep it mounted
......@@ -101,14 +102,13 @@ find_rootfs()
# Support function to get a list of all pools, separated with ';'
local CMD="$*"
local pools pool
pools=$($CMD 2> /dev/null | \
grep -E "pool:|^[a-zA-Z0-9]" | \
sed 's@.*: @@' | \
while read pool; do \
echo -n "$pool;"
while read -r pool; do \
printf "%s" "$pool;"
echo "${pools%%;}" # Return without the last ';'.
......@@ -117,8 +117,6 @@ find_pools()
# Get a list of all available pools
local available_pools npools
if [ -n "${ZFS_POOL_IMPORT}" ]; then
return 0
......@@ -159,9 +157,8 @@ get_pools()
# Filter out any exceptions...
local found=""
local apools=""
local pool exception
OLD_IFS="$IFS" ; IFS=";"
for pool in $available_pools
......@@ -194,8 +191,7 @@ get_pools()
# Import given pool $1
local pool="$1"
local dirs dir
# Verify that the pool isn't already imported
# Make as sure as we can to not require '-f' to import.
......@@ -205,7 +201,7 @@ import_pool()
# to something we can use later with the real import(s). We want to
# make sure we find all by* dirs, BUT by-vdev should be first (if it
# exists).
if [ -n "$USE_DISK_BY_ID" -a -z "$ZPOOL_IMPORT_PATH" ]
if [ -n "$USE_DISK_BY_ID" ] && [ -z "$ZPOOL_IMPORT_PATH" ]
dirs="$(for dir in $(echo /dev/disk/by-*)
......@@ -213,7 +209,7 @@ import_pool()
echo "$dir" | grep -q /by-vdev && continue
[ ! -d "$dir" ] && continue
echo -n "$dir:"
printf "%s" "$dir:"
done | sed 's,:$,,g')"
if [ -d "/dev/disk/by-vdev" ]
......@@ -277,7 +273,7 @@ import_pool()
# with more logging etc.
if [ "$ZFS_INITRD_PRE_MOUNTROOT_SLEEP" -gt 0 ] 2>/dev/null
if [ "$quiet" != "y" ]; then
zfs_log_begin_msg "Sleeping for" \
......@@ -288,9 +284,9 @@ load_module_initrd()
# Wait for all of the /dev/{hd,sd}[a-z] device nodes to appear.
if type wait_for_udev > /dev/null 2>&1 ; then
if command -v wait_for_udev > /dev/null 2>&1 ; then
wait_for_udev 10
elif type wait_for_dev > /dev/null 2>&1 ; then
elif command -v wait_for_dev > /dev/null 2>&1 ; then
......@@ -300,7 +296,7 @@ load_module_initrd()
# Load the module
load_module "zfs" || return 1
if [ "$ZFS_INITRD_POST_MODPROBE_SLEEP" -gt 0 ] 2>/dev/null
if [ "$quiet" != "y" ]; then
zfs_log_begin_msg "Sleeping for" \
......@@ -316,12 +312,10 @@ load_module_initrd()
# Mount a given filesystem
local fs="$1"
local mountpoint
# Check that the filesystem exists
"${ZFS}" list -oname -tfilesystem -H "${fs}" > /dev/null 2>&1
[ "$?" -ne 0 ] && return 1
"${ZFS}" list -oname -tfilesystem -H "${fs}" > /dev/null 2>&1 || return 1
# Skip filesystems with canmount=off. The root fs should not have
# canmount=off, but ignore it for backwards compatibility just in case.
......@@ -333,14 +327,14 @@ mount_fs()
# Need the _original_ datasets mountpoint!
mountpoint=$(get_fs_value "$fs" mountpoint)
if [ "$mountpoint" = "legacy" -o "$mountpoint" = "none" ]; then
if [ "$mountpoint" = "legacy" ] || [ "$mountpoint" = "none" ]; then
# Can't use the mountpoint property. Might be one of our
# clones. Check the 'org.zol:mountpoint' property set in
# clone_snap() if that's usable.
mountpoint=$(get_fs_value "$fs" org.zol:mountpoint)
if [ "$mountpoint" = "legacy" -o \
"$mountpoint" = "none" -o \
"$mountpoint" = "-" ]
if [ "$mountpoint" = "legacy" ] ||
[ "$mountpoint" = "none" ] ||
[ "$mountpoint" = "-" ]
if [ "$fs" != "${ZFS_BOOTFS}" ]; then
# We don't have a proper mountpoint and this
......@@ -396,10 +390,10 @@ mount_fs()
# Unlock a ZFS native encrypted filesystem.
local fs="$1"