From d76d37d9c3f33de9155c16f3b1eceb288c0702a0 Mon Sep 17 00:00:00 2001 From: Martin Matuska Date: Wed, 14 Apr 2021 08:03:07 +0200 Subject: [PATCH] Update vendor/openzfs to openzfs/zfs/master@3522f57b6 Notable upstream pull request merges: #11742 When specifying raidz vdev name, parity count should match #11744 Use a helper function to clarify gang block size #11771 Support running FreeBSD buildworld on Arm-based macOS hosts --- .editorconfig | 10 +++ .gitignore | 70 +++++++++++++++++++ .gitmodules | 3 + META | 2 +- cmd/raidz_test/raidz_bench.c | 2 - cmd/zed/zed_exec.c | 1 + cmd/zfs/zfs_main.c | 2 - cmd/zpool/os/linux/zpool_vdev_os.c | 3 - .../libzfs_core/test/test_libzfs_core.py | 2 +- include/sys/dmu_recv.h | 1 - include/sys/dmu_send.h | 1 - include/sys/spa.h | 6 ++ include/sys/vdev.h | 9 +++ lib/libspl/include/os/freebsd/sys/stat.h | 11 +++ lib/libspl/include/sys/dklabel.h | 1 - lib/libzfs/libzfs_dataset.c | 2 - lib/libzfs/libzfs_pool.c | 31 +++++++- lib/libzfs/libzfs_sendrecv.c | 1 - lib/libzutil/os/linux/zutil_import_os.c | 1 - lib/libzutil/zutil_import.c | 1 - man/man8/zed.8.in | 4 +- module/os/linux/zfs/arc_os.c | 1 - module/os/linux/zfs/zpl_file.c | 2 +- module/zfs/arc.c | 1 - module/zfs/dmu_recv.c | 1 - module/zfs/fm.c | 1 - module/zfs/metaslab.c | 8 +-- module/zfs/zio.c | 18 +++-- 28 files changed, 160 insertions(+), 36 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 .gitmodules diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000000..0f4b96a83070 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{c,h}] +tab_width = 8 +indent_style = tab diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..056bbb8f08c9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,70 @@ +# +# N.B. +# This is the toplevel .gitignore file. +# This is not the place for entries that are specific to +# a subdirectory. Instead add those files to the +# .gitignore file in that subdirectory. +# +# N.B. +# Please use 'git ls-files -i --exclude-standard' +# command after changing this file, to see if there are +# any tracked files which get ignored after the change. + +# +# Normal rules +# +*.[oa] +*.o.ur-safe +*.lo +*.la +*.mod.c +*~ +*.swp +*.gcno +*.gcda +*.pyc +*.pyo +.deps +.libs +.dirstamp +.DS_Store +modules.order +Makefile +Makefile.in + +# +# Top level generated files specific to this top level dir +# +/bin +/build +/configure +/config.log +/config.status +/libtool +/zfs_config.h +/zfs_config.h.in +/zfs.release +/stamp-h1 +/aclocal.m4 +/autom4te.cache + +# +# Top level generic files +# +!.gitignore +tags +TAGS +current +cscope.* +*.rpm +*.deb +*.tar.gz +*.patch +*.orig +*.log +*.tmp +venv + +*.so +*.so.debug +*.so.full diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000000..d400f10a7e63 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "scripts/zfs-images"] + path = scripts/zfs-images + url = https://github.com/zfsonlinux/zfs-images diff --git a/META b/META index abced52178a7..480849288719 100644 --- a/META +++ b/META @@ -1,7 +1,7 @@ Meta: 1 Name: zfs Branch: 1.0 -Version: 2.0.0 +Version: 2.1.0 Release: rc1 Release-Tags: relext License: CDDL diff --git a/cmd/raidz_test/raidz_bench.c b/cmd/raidz_test/raidz_bench.c index a3446c52c416..f44d6fbde707 100644 --- a/cmd/raidz_test/raidz_bench.c +++ b/cmd/raidz_test/raidz_bench.c @@ -31,8 +31,6 @@ #include #include -#include - #include "raidz_test.h" #define GEN_BENCH_MEMORY (((uint64_t)1ULL)<<32) diff --git a/cmd/zed/zed_exec.c b/cmd/zed/zed_exec.c index aae607a9b7de..e8f510213868 100644 --- a/cmd/zed/zed_exec.c +++ b/cmd/zed/zed_exec.c @@ -173,6 +173,7 @@ _zed_exec_fork_child(uint64_t eid, const char *dir, const char *prog, zed_log_msg(LOG_WARNING, "Killing hung \"%s\" pid=%d", prog, pid); (void) kill(pid, SIGKILL); + (void) waitpid(pid, &status, 0); } } diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 9a59fddbf06d..1a5129f79493 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include @@ -71,7 +70,6 @@ #include #include #include -#include #ifdef HAVE_IDMAP #include #include diff --git a/cmd/zpool/os/linux/zpool_vdev_os.c b/cmd/zpool/os/linux/zpool_vdev_os.c index d087c4c14dac..55a9367ec180 100644 --- a/cmd/zpool/os/linux/zpool_vdev_os.c +++ b/cmd/zpool/os/linux/zpool_vdev_os.c @@ -79,9 +79,6 @@ #include #include -#include -#include -#include #include #include #include diff --git a/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py b/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py index 08b58b5d1e0d..87138b305f73 100644 --- a/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py +++ b/contrib/pyzfs/libzfs_core/test/test_libzfs_core.py @@ -1062,7 +1062,7 @@ def test_bookmarks_empty(self): lzc.lzc_bookmark({}) @skipUnlessBookmarksSupported - def test_bookmarks_foregin_source(self): + def test_bookmarks_foreign_source(self): snaps = [ZFSTest.pool.makeName(b'fs1@snap1')] bmarks = [ZFSTest.pool.makeName(b'fs2#bmark1')] bmark_dict = {x: y for x, y in zip(bmarks, snaps)} diff --git a/include/sys/dmu_recv.h b/include/sys/dmu_recv.h index dacc6b7829da..7188b2a02248 100644 --- a/include/sys/dmu_recv.h +++ b/include/sys/dmu_recv.h @@ -34,7 +34,6 @@ #include #include #include -#include extern const char *recv_clone_name; diff --git a/include/sys/dmu_send.h b/include/sys/dmu_send.h index d6d050e01f97..d150f816c945 100644 --- a/include/sys/dmu_send.h +++ b/include/sys/dmu_send.h @@ -34,7 +34,6 @@ #include #include #include -#include #include #define BEGINNV_REDACT_SNAPS "redact_snaps" diff --git a/include/sys/spa.h b/include/sys/spa.h index 8391be8328b6..c960478efe50 100644 --- a/include/sys/spa.h +++ b/include/sys/spa.h @@ -405,6 +405,12 @@ typedef struct blkptr { /* * Macros to get and set fields in a bp or DVA. */ + +/* + * Note, for gang blocks, DVA_GET_ASIZE() is the total space allocated for + * this gang DVA including its children BP's. The space allocated at this + * DVA's vdev/offset is vdev_gang_header_asize(vdev). + */ #define DVA_GET_ASIZE(dva) \ BF64_GET_SB((dva)->dva_word[0], 0, SPA_ASIZEBITS, SPA_MINBLOCKSHIFT, 0) #define DVA_SET_ASIZE(dva, x) \ diff --git a/include/sys/vdev.h b/include/sys/vdev.h index d1ef6b5b59b4..f235bfc8cc19 100644 --- a/include/sys/vdev.h +++ b/include/sys/vdev.h @@ -133,6 +133,15 @@ extern int64_t vdev_deflated_space(vdev_t *vd, int64_t space); extern uint64_t vdev_psize_to_asize(vdev_t *vd, uint64_t psize); +/* + * Return the amount of space allocated for a gang block header. + */ +static inline uint64_t +vdev_gang_header_asize(vdev_t *vd) +{ + return (vdev_psize_to_asize(vd, SPA_GANGBLOCKSIZE)); +} + extern int vdev_fault(spa_t *spa, uint64_t guid, vdev_aux_t aux); extern int vdev_degrade(spa_t *spa, uint64_t guid, vdev_aux_t aux); extern int vdev_online(spa_t *spa, uint64_t guid, uint64_t flags, diff --git a/lib/libspl/include/os/freebsd/sys/stat.h b/lib/libspl/include/os/freebsd/sys/stat.h index 07f9762f09ee..38c684d62a1b 100644 --- a/lib/libspl/include/os/freebsd/sys/stat.h +++ b/lib/libspl/include/os/freebsd/sys/stat.h @@ -29,6 +29,7 @@ #include_next /* Note: this file can be used on linux/macOS when bootstrapping tools. */ + #if defined(__FreeBSD__) #include /* for BLKGETSIZE64 */ @@ -71,4 +72,14 @@ fstat64_blk(int fd, struct stat64 *st) return (0); } #endif /* defined(__FreeBSD__) */ + +/* + * Only Intel-based Macs have a separate stat64; Arm-based Macs are like + * FreeBSD and have a full 64-bit stat from the start. + */ +#if defined(__APPLE__) && !(defined(__i386__) || defined(__x86_64__)) +#define stat64 stat +#define fstat64 fstat +#endif + #endif /* _LIBSPL_SYS_STAT_H */ diff --git a/lib/libspl/include/sys/dklabel.h b/lib/libspl/include/sys/dklabel.h index 95faf2bb4ab3..8c2ca06c0cbc 100644 --- a/lib/libspl/include/sys/dklabel.h +++ b/lib/libspl/include/sys/dklabel.h @@ -31,7 +31,6 @@ #include #include -#include #ifdef __cplusplus extern "C" { diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 47418b3237bb..4598e87f2921 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -48,7 +48,6 @@ #include #include #include -#include #include #ifdef HAVE_IDMAP #include @@ -66,7 +65,6 @@ #include "zfs_namecheck.h" #include "zfs_prop.h" #include "libzfs_impl.h" -#include "libzfs.h" #include "zfs_deleg.h" static int userquota_propname_decode(const char *propname, boolean_t zoned, diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index 1934466536dc..9ef97cd677ff 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -49,7 +49,6 @@ #include #include #include -#include #include "zfs_namecheck.h" #include "zfs_prop.h" @@ -2670,6 +2669,36 @@ vdev_to_nvlist_iter(nvlist_t *nv, nvlist_t *search, boolean_t *avail_spare, errno = 0; vdev_id = strtoull(idx, &end, 10); + /* + * If we are looking for a raidz and a parity is + * specified, make sure it matches. + */ + int rzlen = strlen(VDEV_TYPE_RAIDZ); + assert(rzlen == strlen(VDEV_TYPE_DRAID)); + int typlen = strlen(type); + if ((strncmp(type, VDEV_TYPE_RAIDZ, rzlen) == 0 || + strncmp(type, VDEV_TYPE_DRAID, rzlen) == 0) && + typlen != rzlen) { + uint64_t vdev_parity; + int parity = *(type + rzlen) - '0'; + + if (parity <= 0 || parity > 3 || + (typlen - rzlen) != 1) { + /* + * Nonsense parity specified, can + * never match + */ + free(type); + return (NULL); + } + verify(nvlist_lookup_uint64(nv, + ZPOOL_CONFIG_NPARITY, &vdev_parity) == 0); + if ((int)vdev_parity != parity) { + free(type); + break; + } + } + free(type); if (errno != 0) return (NULL); diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index 1e3a0bf5618a..bc887e72a23c 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/libzutil/os/linux/zutil_import_os.c b/lib/libzutil/os/linux/zutil_import_os.c index 519ab3a078e3..2e0baecb3bec 100644 --- a/lib/libzutil/os/linux/zutil_import_os.c +++ b/lib/libzutil/os/linux/zutil_import_os.c @@ -61,7 +61,6 @@ #include #include #include -#include #include #include diff --git a/lib/libzutil/zutil_import.c b/lib/libzutil/zutil_import.c index e1f31b385503..93d05354f30f 100644 --- a/lib/libzutil/zutil_import.c +++ b/lib/libzutil/zutil_import.c @@ -62,7 +62,6 @@ #include #include #include -#include #include #include diff --git a/man/man8/zed.8.in b/man/man8/zed.8.in index 3d36c33ac9ca..e32a89de8a0f 100644 --- a/man/man8/zed.8.in +++ b/man/man8/zed.8.in @@ -234,8 +234,8 @@ Terminate the daemon. Events are processed synchronously by a single thread. This can delay the processing of simultaneous zevents. .PP -There is no maximum timeout for ZEDLET execution. Consequently, a misbehaving -ZEDLET can delay the processing of subsequent zevents. +ZEDLETs are killed after a maximum of ten seconds. +This can lead to a violation of a ZEDLET's atomicity assumptions. .PP The ownership and permissions of the \fIenabled-zedlets\fR directory (along with all parent directories) are not checked. If any of these directories diff --git a/module/os/linux/zfs/arc_os.c b/module/os/linux/zfs/arc_os.c index 83d4a3d8496c..465775a6748e 100644 --- a/module/os/linux/zfs/arc_os.c +++ b/module/os/linux/zfs/arc_os.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include diff --git a/module/os/linux/zfs/zpl_file.c b/module/os/linux/zfs/zpl_file.c index ea6993ffa4b0..d042783da1b2 100644 --- a/module/os/linux/zfs/zpl_file.c +++ b/module/os/linux/zfs/zpl_file.c @@ -867,7 +867,7 @@ __zpl_ioctl_setflags(struct inode *ip, uint32_t ioctl_flags, xvattr_t *xva) if ((fchange(ioctl_flags, zfs_flags, FS_IMMUTABLE_FL, ZFS_IMMUTABLE) || fchange(ioctl_flags, zfs_flags, FS_APPEND_FL, ZFS_APPENDONLY)) && !capable(CAP_LINUX_IMMUTABLE)) - return (-EACCES); + return (-EPERM); if (!zpl_inode_owner_or_capable(kcred->user_ns, ip)) return (-EACCES); diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 9be0a4e8a4a9..55c71a3829cd 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -294,7 +294,6 @@ #include #include #include -#include #include #include #include diff --git a/module/zfs/dmu_recv.c b/module/zfs/dmu_recv.c index a0fd157ebc5f..123ea05b0436 100644 --- a/module/zfs/dmu_recv.c +++ b/module/zfs/dmu_recv.c @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include diff --git a/module/zfs/fm.c b/module/zfs/fm.c index a5003f85d621..3070cab1e49d 100644 --- a/module/zfs/fm.c +++ b/module/zfs/fm.c @@ -67,7 +67,6 @@ #include #include #include -#include #include int zfs_zevent_len_max = 0; diff --git a/module/zfs/metaslab.c b/module/zfs/metaslab.c index 463806c6078a..3b2b79b2f42f 100644 --- a/module/zfs/metaslab.c +++ b/module/zfs/metaslab.c @@ -5544,7 +5544,7 @@ metaslab_unalloc_dva(spa_t *spa, const dva_t *dva, uint64_t txg) ASSERT3P(vd->vdev_indirect_mapping, ==, NULL); if (DVA_GET_GANG(dva)) - size = vdev_psize_to_asize(vd, SPA_GANGBLOCKSIZE); + size = vdev_gang_header_asize(vd); msp = vd->vdev_ms[offset >> vd->vdev_ms_shift]; @@ -5579,7 +5579,7 @@ metaslab_free_dva(spa_t *spa, const dva_t *dva, boolean_t checkpoint) ASSERT3U(spa_config_held(spa, SCL_ALL, RW_READER), !=, 0); if (DVA_GET_GANG(dva)) { - size = vdev_psize_to_asize(vd, SPA_GANGBLOCKSIZE); + size = vdev_gang_header_asize(vd); } metaslab_free_impl(vd, offset, size, checkpoint); @@ -5768,7 +5768,7 @@ metaslab_claim_dva(spa_t *spa, const dva_t *dva, uint64_t txg) ASSERT(DVA_IS_VALID(dva)); if (DVA_GET_GANG(dva)) - size = vdev_psize_to_asize(vd, SPA_GANGBLOCKSIZE); + size = vdev_gang_header_asize(vd); return (metaslab_claim_impl(vd, offset, size, txg)); } @@ -6034,7 +6034,7 @@ metaslab_check_free(spa_t *spa, const blkptr_t *bp) uint64_t size = DVA_GET_ASIZE(&bp->blk_dva[i]); if (DVA_GET_GANG(&bp->blk_dva[i])) - size = vdev_psize_to_asize(vd, SPA_GANGBLOCKSIZE); + size = vdev_gang_header_asize(vd); ASSERT3P(vd, !=, NULL); diff --git a/module/zfs/zio.c b/module/zfs/zio.c index 23d45ded6270..d97c8ddc95cf 100644 --- a/module/zfs/zio.c +++ b/module/zfs/zio.c @@ -995,7 +995,8 @@ zfs_blkptr_verify(spa_t *spa, const blkptr_t *bp, boolean_t config_held, * that are in the log) to be arbitrarily large. */ for (int i = 0; i < BP_GET_NDVAS(bp); i++) { - uint64_t vdevid = DVA_GET_VDEV(&bp->blk_dva[i]); + const dva_t *dva = &bp->blk_dva[i]; + uint64_t vdevid = DVA_GET_VDEV(dva); if (vdevid >= spa->spa_root_vdev->vdev_children) { errors += zfs_blkptr_verify_log(spa, bp, blk_verify, @@ -1024,10 +1025,10 @@ zfs_blkptr_verify(spa_t *spa, const blkptr_t *bp, boolean_t config_held, */ continue; } - uint64_t offset = DVA_GET_OFFSET(&bp->blk_dva[i]); - uint64_t asize = DVA_GET_ASIZE(&bp->blk_dva[i]); - if (BP_IS_GANG(bp)) - asize = vdev_psize_to_asize(vd, SPA_GANGBLOCKSIZE); + uint64_t offset = DVA_GET_OFFSET(dva); + uint64_t asize = DVA_GET_ASIZE(dva); + if (DVA_GET_GANG(dva)) + asize = vdev_gang_header_asize(vd); if (offset + asize > vd->vdev_asize) { errors += zfs_blkptr_verify_log(spa, bp, blk_verify, "blkptr at %p DVA %u has invalid OFFSET %llu", @@ -1064,8 +1065,8 @@ zfs_dva_valid(spa_t *spa, const dva_t *dva, const blkptr_t *bp) uint64_t offset = DVA_GET_OFFSET(dva); uint64_t asize = DVA_GET_ASIZE(dva); - if (BP_IS_GANG(bp)) - asize = vdev_psize_to_asize(vd, SPA_GANGBLOCKSIZE); + if (DVA_GET_GANG(dva)) + asize = vdev_gang_header_asize(vd); if (offset + asize > vd->vdev_asize) return (B_FALSE); @@ -3984,6 +3985,9 @@ zio_vdev_io_assess(zio_t *zio) */ if (zio->io_error == ENXIO && zio->io_type == ZIO_TYPE_WRITE && vd != NULL && !vd->vdev_ops->vdev_op_leaf) { + vdev_dbgmsg(vd, "zio_vdev_io_assess(zio=%px) setting " + "cant_write=TRUE due to write failure with ENXIO", + zio); vd->vdev_cant_write = B_TRUE; }