From: "Georgy Yakovlev" <gyakovlev@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/zfs/, sys-fs/zfs/files/
Date: Sun, 7 Nov 2021 23:59:18 +0000 (UTC) [thread overview]
Message-ID: <1636329460.7c97da7804003db7be32a3c696f930ca5555ba24.gyakovlev@gentoo> (raw)
commit: 7c97da7804003db7be32a3c696f930ca5555ba24
Author: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 7 23:01:06 2021 +0000
Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
CommitDate: Sun Nov 7 23:57:40 2021 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7c97da78
sys-fs/zfs: revbump 2.1.1, add patch and dist-kernel version limit
We don't really need patch in userspace package, but
patch also installs tests for test-suite and what's why we include it.
also remove coreutils blocker
Bug: https://bugs.gentoo.org/815469
Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>
sys-fs/zfs/files/2.1.1-fix-lseek-mmap.patch | 594 ++++++++++++++++++++++++++++
sys-fs/zfs/zfs-2.1.1-r3.ebuild | 298 ++++++++++++++
2 files changed, 892 insertions(+)
diff --git a/sys-fs/zfs/files/2.1.1-fix-lseek-mmap.patch b/sys-fs/zfs/files/2.1.1-fix-lseek-mmap.patch
new file mode 100644
index 00000000000..2c3a66a97bf
--- /dev/null
+++ b/sys-fs/zfs/files/2.1.1-fix-lseek-mmap.patch
@@ -0,0 +1,594 @@
+From de198f2d9507b6dcf3d0d8f037ba33940208733e Mon Sep 17 00:00:00 2001
+From: Brian Behlendorf <behlendorf1@llnl.gov>
+Date: Sun, 7 Nov 2021 13:27:44 -0800
+Subject: [PATCH] Fix lseek(SEEK_DATA/SEEK_HOLE) mmap consistency
+
+When using lseek(2) to report data/holes memory mapped regions of
+the file were ignored. This could result in incorrect results.
+To handle this zfs_holey_common() was updated to asynchronously
+writeback any dirty mmap(2) regions prior to reporting holes.
+
+Additionally, while not strictly required, the dn_struct_rwlock is
+now held over the dirty check to prevent the dnode structure from
+changing. This ensures that a clean dnode can't be dirtied before
+the data/hole is located. The range lock is now also taken to
+ensure the call cannot race with zfs_write().
+
+Furthermore, the code was refactored to provide a dnode_is_dirty()
+helper function which checks the dnode for any dirty records to
+determine its dirtiness.
+
+Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
+Reviewed-by: Tony Hutter <hutter2@llnl.gov>
+Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
+Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Issue #11900
+Closes #12724
+---
+ configure.ac | 1 +
+ include/os/freebsd/spl/sys/vnode.h | 18 +++
+ include/os/freebsd/zfs/sys/zfs_znode_impl.h | 3 +-
+ include/os/linux/zfs/sys/zfs_znode_impl.h | 1 +
+ include/sys/dnode.h | 1 +
+ man/man4/zfs.4 | 2 +-
+ module/zfs/dmu.c | 53 ++++---
+ module/zfs/dnode.c | 20 +++
+ module/zfs/zfs_vnops.c | 9 +-
+ tests/runfiles/common.run | 2 +-
+ tests/zfs-tests/cmd/Makefile.am | 1 +
+ tests/zfs-tests/cmd/mmap_seek/.gitignore | 1 +
+ tests/zfs-tests/cmd/mmap_seek/Makefile.am | 6 +
+ tests/zfs-tests/cmd/mmap_seek/mmap_seek.c | 147 ++++++++++++++++++
+ tests/zfs-tests/include/commands.cfg | 1 +
+ tests/zfs-tests/include/tunables.cfg | 1 +
+ .../tests/functional/mmap/Makefile.am | 3 +-
+ .../functional/mmap/mmap_seek_001_pos.ksh | 67 ++++++++
+ 18 files changed, 305 insertions(+), 32 deletions(-)
+ create mode 100644 tests/zfs-tests/cmd/mmap_seek/.gitignore
+ create mode 100644 tests/zfs-tests/cmd/mmap_seek/Makefile.am
+ create mode 100644 tests/zfs-tests/cmd/mmap_seek/mmap_seek.c
+ create mode 100755 tests/zfs-tests/tests/functional/mmap/mmap_seek_001_pos.ksh
+
+diff --git a/configure.ac b/configure.ac
+index 6f34b210d2b..ebc7b276a64 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -221,6 +221,7 @@ AC_CONFIG_FILES([
+ tests/zfs-tests/cmd/mktree/Makefile
+ tests/zfs-tests/cmd/mmap_exec/Makefile
+ tests/zfs-tests/cmd/mmap_libaio/Makefile
++ tests/zfs-tests/cmd/mmap_seek/Makefile
+ tests/zfs-tests/cmd/mmapwrite/Makefile
+ tests/zfs-tests/cmd/nvlist_to_lua/Makefile
+ tests/zfs-tests/cmd/randfree_file/Makefile
+diff --git a/include/os/freebsd/spl/sys/vnode.h b/include/os/freebsd/spl/sys/vnode.h
+index 3670712a045..3bc8a18eeb7 100644
+--- a/include/os/freebsd/spl/sys/vnode.h
++++ b/include/os/freebsd/spl/sys/vnode.h
+@@ -59,6 +59,8 @@ enum symfollow { NO_FOLLOW = NOFOLLOW };
+ #include <sys/file.h>
+ #include <sys/filedesc.h>
+ #include <sys/syscallsubr.h>
++#include <sys/vm.h>
++#include <vm/vm_object.h>
+
+ typedef struct vop_vector vnodeops_t;
+ #define VOP_FID VOP_VPTOFH
+@@ -83,6 +85,22 @@ vn_is_readonly(vnode_t *vp)
+ #define vn_has_cached_data(vp) \
+ ((vp)->v_object != NULL && \
+ (vp)->v_object->resident_page_count > 0)
++
++static __inline void
++vn_flush_cached_data(vnode_t *vp, boolean_t sync)
++{
++#if __FreeBSD_version > 1300054
++ if (vm_object_mightbedirty(vp->v_object)) {
++#else
++ if (vp->v_object->flags & OBJ_MIGHTBEDIRTY) {
++#endif
++ int flags = sync ? OBJPC_SYNC : 0;
++ zfs_vmobject_wlock(vp->v_object);
++ vm_object_page_clean(vp->v_object, 0, 0, flags);
++ zfs_vmobject_wunlock(vp->v_object);
++ }
++}
++
+ #define vn_exists(vp) do { } while (0)
+ #define vn_invalid(vp) do { } while (0)
+ #define vn_renamepath(tdvp, svp, tnm, lentnm) do { } while (0)
+diff --git a/include/os/freebsd/zfs/sys/zfs_znode_impl.h b/include/os/freebsd/zfs/sys/zfs_znode_impl.h
+index 7d28bddbf51..4456046e6e4 100644
+--- a/include/os/freebsd/zfs/sys/zfs_znode_impl.h
++++ b/include/os/freebsd/zfs/sys/zfs_znode_impl.h
+@@ -116,7 +116,8 @@ typedef struct zfs_soft_state {
+ #define Z_ISLNK(type) ((type) == VLNK)
+ #define Z_ISDIR(type) ((type) == VDIR)
+
+-#define zn_has_cached_data(zp) vn_has_cached_data(ZTOV(zp))
++#define zn_has_cached_data(zp) vn_has_cached_data(ZTOV(zp))
++#define zn_flush_cached_data(zp, sync) vn_flush_cached_data(ZTOV(zp), sync)
+ #define zn_rlimit_fsize(zp, uio) \
+ vn_rlimit_fsize(ZTOV(zp), GET_UIO_STRUCT(uio), zfs_uio_td(uio))
+
+diff --git a/include/os/linux/zfs/sys/zfs_znode_impl.h b/include/os/linux/zfs/sys/zfs_znode_impl.h
+index 0a6273442b7..de46fc8f2bd 100644
+--- a/include/os/linux/zfs/sys/zfs_znode_impl.h
++++ b/include/os/linux/zfs/sys/zfs_znode_impl.h
+@@ -71,6 +71,7 @@ extern "C" {
+ #define Z_ISDIR(type) S_ISDIR(type)
+
+ #define zn_has_cached_data(zp) ((zp)->z_is_mapped)
++#define zn_flush_cached_data(zp, sync) write_inode_now(ZTOI(zp), sync)
+ #define zn_rlimit_fsize(zp, uio) (0)
+
+ /*
+diff --git a/include/sys/dnode.h b/include/sys/dnode.h
+index e7cccd044ab..3f5fcc958c3 100644
+--- a/include/sys/dnode.h
++++ b/include/sys/dnode.h
+@@ -425,6 +425,7 @@ boolean_t dnode_add_ref(dnode_t *dn, void *ref);
+ void dnode_rele(dnode_t *dn, void *ref);
+ void dnode_rele_and_unlock(dnode_t *dn, void *tag, boolean_t evicting);
+ int dnode_try_claim(objset_t *os, uint64_t object, int slots);
++boolean_t dnode_is_dirty(dnode_t *dn);
+ void dnode_setdirty(dnode_t *dn, dmu_tx_t *tx);
+ void dnode_set_dirtyctx(dnode_t *dn, dmu_tx_t *tx, void *tag);
+ void dnode_sync(dnode_t *dn, dmu_tx_t *tx);
+diff --git a/man/man4/zfs.4 b/man/man4/zfs.4
+index d7fc31bfde1..a136690c76e 100644
+--- a/man/man4/zfs.4
++++ b/man/man4/zfs.4
+@@ -1586,7 +1586,7 @@ Allow no-operation writes.
+ The occurrence of nopwrites will further depend on other pool properties
+ .Pq i.a. the checksumming and compression algorithms .
+ .
+-.It Sy zfs_dmu_offset_next_sync Ns = Ns Sy 0 Ns | ns 1 Pq int
++.It Sy zfs_dmu_offset_next_sync Ns = Ns Sy 0 Ns | Ns 1 Pq int
+ Enable forcing TXG sync to find holes.
+ When enabled forces ZFS to act like prior versions when
+ .Sy SEEK_HOLE No or Sy SEEK_DATA
+diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c
+index b29d82fd793..f12c5eda8b5 100644
+--- a/module/zfs/dmu.c
++++ b/module/zfs/dmu.c
+@@ -2093,42 +2093,41 @@ int
+ dmu_offset_next(objset_t *os, uint64_t object, boolean_t hole, uint64_t *off)
+ {
+ dnode_t *dn;
+- int i, err;
+- boolean_t clean = B_TRUE;
++ int err;
+
++restart:
+ err = dnode_hold(os, object, FTAG, &dn);
+ if (err)
+ return (err);
+
+- /*
+- * Check if dnode is dirty
+- */
+- for (i = 0; i < TXG_SIZE; i++) {
+- if (multilist_link_active(&dn->dn_dirty_link[i])) {
+- clean = B_FALSE;
+- break;
+- }
+- }
++ rw_enter(&dn->dn_struct_rwlock, RW_READER);
+
+- /*
+- * If compatibility option is on, sync any current changes before
+- * we go trundling through the block pointers.
+- */
+- if (!clean && zfs_dmu_offset_next_sync) {
+- clean = B_TRUE;
+- dnode_rele(dn, FTAG);
+- txg_wait_synced(dmu_objset_pool(os), 0);
+- err = dnode_hold(os, object, FTAG, &dn);
+- if (err)
+- return (err);
+- }
++ if (dnode_is_dirty(dn)) {
++ /*
++ * If the zfs_dmu_offset_next_sync module option is enabled
++ * then strict hole reporting has been requested. Dirty
++ * dnodes must be synced to disk to accurately report all
++ * holes. When disabled (the default) dirty dnodes are
++ * reported to not have any holes which is always safe.
++ *
++ * When called by zfs_holey_common() the zp->z_rangelock
++ * is held to prevent zfs_write() and mmap writeback from
++ * re-dirtying the dnode after txg_wait_synced().
++ */
++ if (zfs_dmu_offset_next_sync) {
++ rw_exit(&dn->dn_struct_rwlock);
++ dnode_rele(dn, FTAG);
++ txg_wait_synced(dmu_objset_pool(os), 0);
++ goto restart;
++ }
+
+- if (clean)
+- err = dnode_next_offset(dn,
+- (hole ? DNODE_FIND_HOLE : 0), off, 1, 1, 0);
+- else
+ err = SET_ERROR(EBUSY);
++ } else {
++ err = dnode_next_offset(dn, DNODE_FIND_HAVELOCK |
++ (hole ? DNODE_FIND_HOLE : 0), off, 1, 1, 0);
++ }
+
++ rw_exit(&dn->dn_struct_rwlock);
+ dnode_rele(dn, FTAG);
+
+ return (err);
+diff --git a/module/zfs/dnode.c b/module/zfs/dnode.c
+index 900240479c7..6f87f49f89f 100644
+--- a/module/zfs/dnode.c
++++ b/module/zfs/dnode.c
+@@ -1648,6 +1648,26 @@ dnode_try_claim(objset_t *os, uint64_t object, int slots)
+ slots, NULL, NULL));
+ }
+
++/*
++ * Checks if the dnode contains any uncommitted dirty records.
++ */
++boolean_t
++dnode_is_dirty(dnode_t *dn)
++{
++ mutex_enter(&dn->dn_mtx);
++
++ for (int i = 0; i < TXG_SIZE; i++) {
++ if (list_head(&dn->dn_dirty_records[i]) != NULL) {
++ mutex_exit(&dn->dn_mtx);
++ return (B_TRUE);
++ }
++ }
++
++ mutex_exit(&dn->dn_mtx);
++
++ return (B_FALSE);
++}
++
+ void
+ dnode_setdirty(dnode_t *dn, dmu_tx_t *tx)
+ {
+diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c
+index a83f0b02ab5..7cbb70f499a 100644
+--- a/module/zfs/zfs_vnops.c
++++ b/module/zfs/zfs_vnops.c
+@@ -85,6 +85,7 @@ zfs_fsync(znode_t *zp, int syncflag, cred_t *cr)
+ static int
+ zfs_holey_common(znode_t *zp, ulong_t cmd, loff_t *off)
+ {
++ zfs_locked_range_t *lr;
+ uint64_t noff = (uint64_t)*off; /* new offset */
+ uint64_t file_sz;
+ int error;
+@@ -100,12 +101,18 @@ zfs_holey_common(znode_t *zp, ulong_t cmd, loff_t *off)
+ else
+ hole = B_FALSE;
+
++ /* Flush any mmap()'d data to disk */
++ if (zn_has_cached_data(zp))
++ zn_flush_cached_data(zp, B_FALSE);
++
++ lr = zfs_rangelock_enter(&zp->z_rangelock, 0, file_sz, RL_READER);
+ error = dmu_offset_next(ZTOZSB(zp)->z_os, zp->z_id, hole, &noff);
++ zfs_rangelock_exit(lr);
+
+ if (error == ESRCH)
+ return (SET_ERROR(ENXIO));
+
+- /* file was dirty, so fall back to using generic logic */
++ /* File was dirty, so fall back to using generic logic */
+ if (error == EBUSY) {
+ if (hole)
+ *off = file_sz;
+diff --git a/tests/runfiles/common.run b/tests/runfiles/common.run
+index 7f7d161be35..9f181b53e15 100644
+--- a/tests/runfiles/common.run
++++ b/tests/runfiles/common.run
+@@ -675,7 +675,7 @@ tests = ['migration_001_pos', 'migration_002_pos', 'migration_003_pos',
+ tags = ['functional', 'migration']
+
+ [tests/functional/mmap]
+-tests = ['mmap_write_001_pos', 'mmap_read_001_pos']
++tests = ['mmap_write_001_pos', 'mmap_read_001_pos', 'mmap_seek_001_pos']
+ tags = ['functional', 'mmap']
+
+ [tests/functional/mount]
+diff --git a/tests/zfs-tests/cmd/Makefile.am b/tests/zfs-tests/cmd/Makefile.am
+index 2b965ca7000..d1c29fcd1c6 100644
+--- a/tests/zfs-tests/cmd/Makefile.am
++++ b/tests/zfs-tests/cmd/Makefile.am
+@@ -19,6 +19,7 @@ SUBDIRS = \
+ mktree \
+ mmap_exec \
+ mmap_libaio \
++ mmap_seek \
+ mmapwrite \
+ nvlist_to_lua \
+ randwritecomp \
+diff --git a/tests/zfs-tests/cmd/mmap_seek/.gitignore b/tests/zfs-tests/cmd/mmap_seek/.gitignore
+new file mode 100644
+index 00000000000..6b05a791750
+--- /dev/null
++++ b/tests/zfs-tests/cmd/mmap_seek/.gitignore
+@@ -0,0 +1 @@
++/mmap_seek
+diff --git a/tests/zfs-tests/cmd/mmap_seek/Makefile.am b/tests/zfs-tests/cmd/mmap_seek/Makefile.am
+new file mode 100644
+index 00000000000..b938931125f
+--- /dev/null
++++ b/tests/zfs-tests/cmd/mmap_seek/Makefile.am
+@@ -0,0 +1,6 @@
++include $(top_srcdir)/config/Rules.am
++
++pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin
++
++pkgexec_PROGRAMS = mmap_seek
++mmap_seek_SOURCES = mmap_seek.c
+diff --git a/tests/zfs-tests/cmd/mmap_seek/mmap_seek.c b/tests/zfs-tests/cmd/mmap_seek/mmap_seek.c
+new file mode 100644
+index 00000000000..f476e1dba9a
+--- /dev/null
++++ b/tests/zfs-tests/cmd/mmap_seek/mmap_seek.c
+@@ -0,0 +1,147 @@
++/*
++ * CDDL HEADER START
++ *
++ * The contents of this file are subject to the terms of the
++ * Common Development and Distribution License (the "License").
++ * You may not use this file except in compliance with the License.
++ *
++ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
++ * or http://www.opensolaris.org/os/licensing.
++ * See the License for the specific language governing permissions
++ * and limitations under the License.
++ *
++ * When distributing Covered Code, include this CDDL HEADER in each
++ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
++ * If applicable, add the following below this CDDL HEADER, with the
++ * fields enclosed by brackets "[]" replaced with your own identifying
++ * information: Portions Copyright [yyyy] [name of copyright owner]
++ *
++ * CDDL HEADER END
++ */
++
++/*
++ * Copyright (c) 2021 by Lawrence Livermore National Security, LLC.
++ */
++
++#include <unistd.h>
++#include <fcntl.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <sys/mman.h>
++#include <errno.h>
++
++static void
++seek_data(int fd, off_t offset, off_t expected)
++{
++ off_t data_offset = lseek(fd, offset, SEEK_DATA);
++ if (data_offset != expected) {
++ fprintf(stderr, "lseek(fd, %d, SEEK_DATA) = %d (expected %d)\n",
++ (int)offset, (int)data_offset, (int)expected);
++ exit(2);
++ }
++}
++
++static void
++seek_hole(int fd, off_t offset, off_t expected)
++{
++ off_t hole_offset = lseek(fd, offset, SEEK_HOLE);
++ if (hole_offset != expected) {
++ fprintf(stderr, "lseek(fd, %d, SEEK_HOLE) = %d (expected %d)\n",
++ (int)offset, (int)hole_offset, (int)expected);
++ exit(2);
++ }
++}
++
++int
++main(int argc, char **argv)
++{
++ char *execname = argv[0];
++ char *file_path = argv[1];
++ char *buf = NULL;
++ int err;
++
++ if (argc != 4) {
++ (void) printf("usage: %s <file name> <file size> "
++ "<block size>\n", argv[0]);
++ exit(1);
++ }
++
++ int fd = open(file_path, O_RDWR | O_CREAT, 0666);
++ if (fd == -1) {
++ (void) fprintf(stderr, "%s: %s: ", execname, file_path);
++ perror("open");
++ exit(2);
++ }
++
++ off_t file_size = atoi(argv[2]);
++ off_t block_size = atoi(argv[3]);
++
++ if (block_size * 2 > file_size) {
++ (void) fprintf(stderr, "file size must be at least "
++ "double the block size\n");
++ exit(2);
++ }
++
++ err = ftruncate(fd, file_size);
++ if (err == -1) {
++ perror("ftruncate");
++ exit(2);
++ }
++
++ if ((buf = mmap(NULL, file_size, PROT_READ | PROT_WRITE,
++ MAP_SHARED, fd, 0)) == MAP_FAILED) {
++ perror("mmap");
++ exit(2);
++ }
++
++ /* Verify the file is sparse and reports no data. */
++ seek_data(fd, 0, -1);
++
++ /* Verify the file is reported as a hole. */
++ seek_hole(fd, 0, 0);
++
++ /* Verify search beyond end of file is an error. */
++ seek_data(fd, 2 * file_size, -1);
++ seek_hole(fd, 2 * file_size, -1);
++
++ /* Dirty the first byte. */
++ memset(buf, 'a', 1);
++ seek_data(fd, 0, 0);
++ seek_data(fd, block_size, -1);
++ seek_hole(fd, 0, block_size);
++ seek_hole(fd, block_size, block_size);
++
++ /* Dirty the first half of the file. */
++ memset(buf, 'b', file_size / 2);
++ seek_data(fd, 0, 0);
++ seek_data(fd, block_size, block_size);
++ seek_hole(fd, 0, P2ROUNDUP(file_size / 2, block_size));
++ seek_hole(fd, block_size, P2ROUNDUP(file_size / 2, block_size));
++
++ /* Dirty the whole file. */
++ memset(buf, 'c', file_size);
++ seek_data(fd, 0, 0);
++ seek_data(fd, file_size * 3 / 4,
++ P2ROUNDUP(file_size * 3 / 4, block_size));
++ seek_hole(fd, 0, file_size);
++ seek_hole(fd, file_size / 2, file_size);
++
++ /* Punch a hole (required compression be enabled). */
++ memset(buf + block_size, 0, block_size);
++ seek_data(fd, 0, 0);
++ seek_data(fd, block_size, 2 * block_size);
++ seek_hole(fd, 0, block_size);
++ seek_hole(fd, block_size, block_size);
++ seek_hole(fd, 2 * block_size, file_size);
++
++ err = munmap(buf, file_size);
++ if (err == -1) {
++ perror("munmap");
++ exit(2);
++ }
++
++ close(fd);
++
++ return (0);
++}
+diff --git a/tests/zfs-tests/include/commands.cfg b/tests/zfs-tests/include/commands.cfg
+index 1ec73f25bae..4497a6248b4 100644
+--- a/tests/zfs-tests/include/commands.cfg
++++ b/tests/zfs-tests/include/commands.cfg
+@@ -209,6 +209,7 @@ export ZFSTEST_FILES='badsend
+ mktree
+ mmap_exec
+ mmap_libaio
++ mmap_seek
+ mmapwrite
+ nvlist_to_lua
+ randfree_file
+diff --git a/tests/zfs-tests/include/tunables.cfg b/tests/zfs-tests/include/tunables.cfg
+index 56d430a3987..fff43e46916 100644
+--- a/tests/zfs-tests/include/tunables.cfg
++++ b/tests/zfs-tests/include/tunables.cfg
+@@ -33,6 +33,7 @@ DEADMAN_FAILMODE deadman.failmode zfs_deadman_failmode
+ DEADMAN_SYNCTIME_MS deadman.synctime_ms zfs_deadman_synctime_ms
+ DEADMAN_ZIOTIME_MS deadman.ziotime_ms zfs_deadman_ziotime_ms
+ DISABLE_IVSET_GUID_CHECK disable_ivset_guid_check zfs_disable_ivset_guid_check
++DMU_OFFSET_NEXT_SYNC dmu_offset_next_sync zfs_dmu_offset_next_sync
+ INITIALIZE_CHUNK_SIZE initialize_chunk_size zfs_initialize_chunk_size
+ INITIALIZE_VALUE initialize_value zfs_initialize_value
+ KEEP_LOG_SPACEMAPS_AT_EXPORT keep_log_spacemaps_at_export zfs_keep_log_spacemaps_at_export
+diff --git a/tests/zfs-tests/tests/functional/mmap/Makefile.am b/tests/zfs-tests/tests/functional/mmap/Makefile.am
+index 2adc398b8c0..b26791ee7ce 100644
+--- a/tests/zfs-tests/tests/functional/mmap/Makefile.am
++++ b/tests/zfs-tests/tests/functional/mmap/Makefile.am
+@@ -4,7 +4,8 @@ dist_pkgdata_SCRIPTS = \
+ cleanup.ksh \
+ mmap_read_001_pos.ksh \
+ mmap_write_001_pos.ksh \
+- mmap_libaio_001_pos.ksh
++ mmap_libaio_001_pos.ksh \
++ mmap_seek_001_pos.ksh
+
+ dist_pkgdata_DATA = \
+ mmap.cfg
+diff --git a/tests/zfs-tests/tests/functional/mmap/mmap_seek_001_pos.ksh b/tests/zfs-tests/tests/functional/mmap/mmap_seek_001_pos.ksh
+new file mode 100755
+index 00000000000..6188549ad8d
+--- /dev/null
++++ b/tests/zfs-tests/tests/functional/mmap/mmap_seek_001_pos.ksh
+@@ -0,0 +1,67 @@
++#!/bin/ksh -p
++#
++# CDDL HEADER START
++#
++# The contents of this file are subject to the terms of the
++# Common Development and Distribution License (the "License").
++# You may not use this file except in compliance with the License.
++#
++# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
++# or http://www.opensolaris.org/os/licensing.
++# See the License for the specific language governing permissions
++# and limitations under the License.
++#
++# When distributing Covered Code, include this CDDL HEADER in each
++# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
++# If applicable, add the following below this CDDL HEADER, with the
++# fields enclosed by brackets "[]" replaced with your own identifying
++# information: Portions Copyright [yyyy] [name of copyright owner]
++#
++# CDDL HEADER END
++#
++
++#
++# Copyright (c) 2021 by Lawrence Livermore National Security, LLC.
++#
++
++. $STF_SUITE/include/libtest.shlib
++. $STF_SUITE/tests/functional/mmap/mmap.cfg
++
++#
++# DESCRIPTION:
++# lseek() data/holes for an mmap()'d file.
++#
++# STRATEGY:
++# 1. Enable compression and hole reporting for dirty files.
++# 2. Call mmap_seek binary test case for various record sizes.
++#
++
++verify_runnable "global"
++
++function cleanup
++{
++ log_must zfs set compression=off $TESTPOOL/$TESTFS
++ log_must zfs set recordsize=128k $TESTPOOL/$TESTFS
++ log_must rm -f $TESTDIR/test-mmap-file
++ log_must set_tunable64 DMU_OFFSET_NEXT_SYNC $dmu_offset_next_sync
++}
++
++log_assert "lseek() data/holes for an mmap()'d file."
++
++log_onexit cleanup
++
++# Enable hole reporting for dirty files.
++typeset dmu_offset_next_sync=$(get_tunable DMU_OFFSET_NEXT_SYNC)
++log_must set_tunable64 DMU_OFFSET_NEXT_SYNC 1
++
++# Compression must be enabled to convert zero'd blocks to holes.
++# This behavior is checked by the mmap_seek test.
++log_must zfs set compression=on $TESTPOOL/$TESTFS
++
++for bs in 4096 8192 16384 32768 65536 131072; do
++ log_must zfs set recordsize=$bs $TESTPOOL/$TESTFS
++ log_must mmap_seek $TESTDIR/test-mmap-file $((1024*1024)) $bs
++ log_must rm $TESTDIR/test-mmap-file
++done
++
++log_pass "lseek() data/holes for an mmap()'d file succeeded."
diff --git a/sys-fs/zfs/zfs-2.1.1-r3.ebuild b/sys-fs/zfs/zfs-2.1.1-r3.ebuild
new file mode 100644
index 00000000000..9b78e0fc383
--- /dev/null
+++ b/sys-fs/zfs/zfs-2.1.1-r3.ebuild
@@ -0,0 +1,298 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+DISTUTILS_OPTIONAL=1
+DISTUTILS_USE_SETUPTOOLS=manual
+PYTHON_COMPAT=( python3_{8,9,10} )
+
+inherit autotools bash-completion-r1 dist-kernel-utils distutils-r1 flag-o-matic linux-info pam systemd udev usr-ldscript
+
+DESCRIPTION="Userland utilities for ZFS Linux kernel module"
+HOMEPAGE="https://github.com/openzfs/zfs"
+
+if [[ ${PV} == "9999" ]]; then
+ inherit git-r3 linux-mod
+ EGIT_REPO_URI="https://github.com/openzfs/zfs.git"
+else
+ VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/openzfs.asc
+ inherit verify-sig
+
+ MY_P="${P/_rc/-rc}"
+ SRC_URI="https://github.com/openzfs/${PN}/releases/download/${MY_P}/${MY_P}.tar.gz"
+ SRC_URI+=" verify-sig? ( https://github.com/openzfs/${PN}/releases/download/${MY_P}/${MY_P}.tar.gz.asc )"
+ S="${WORKDIR}/${P%_rc?}"
+
+ if [[ ${PV} != *_rc* ]]; then
+ KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv"
+ fi
+fi
+
+LICENSE="BSD-2 CDDL MIT"
+# just libzfs soname major for now.
+# possible candidates: libuutil, libzpool, libnvpair. Those do not provide stable abi, but are considered.
+# see libsoversion_check() below as well
+SLOT="0/5"
+IUSE="custom-cflags debug dist-kernel kernel-builtin minimal nls pam python +rootfs test-suite"
+
+DEPEND="
+ net-libs/libtirpc
+ sys-apps/util-linux
+ sys-libs/zlib
+ virtual/libudev:=
+ dev-libs/openssl:0=
+ !minimal? ( ${PYTHON_DEPS} )
+ pam? ( sys-libs/pam )
+ python? (
+ virtual/python-cffi[${PYTHON_USEDEP}]
+ )
+"
+
+BDEPEND="virtual/awk
+ virtual/pkgconfig
+ nls? ( sys-devel/gettext )
+ python? (
+ dev-python/setuptools[${PYTHON_USEDEP}]
+ )
+"
+
+if [[ ${PV} != "9999" ]] ; then
+ BDEPEND+=" verify-sig? ( app-crypt/openpgp-keys-openzfs )"
+fi
+
+# awk is used for some scripts, completions, and the Dracut module
+RDEPEND="${DEPEND}
+ !kernel-builtin? ( ~sys-fs/zfs-kmod-${PV}:= )
+ !prefix? ( virtual/udev )
+ sys-fs/udev-init-scripts
+ virtual/awk
+ dist-kernel? ( virtual/dist-kernel:= )
+ rootfs? (
+ app-arch/cpio
+ app-misc/pax-utils
+ !<sys-kernel/genkernel-3.5.1.1
+ )
+ test-suite? (
+ sys-apps/kmod[tools]
+ sys-apps/util-linux
+ sys-devel/bc
+ sys-block/parted
+ sys-fs/lsscsi
+ sys-fs/mdadm
+ sys-process/procps
+ )
+"
+
+# PDEPEND in this form is needed to trick portage suggest
+# enabling dist-kernel if only 1 package have it set, without suggesting to disable
+PDEPEND="dist-kernel? ( ~sys-fs/zfs-kmod-${PV}[dist-kernel] )"
+
+REQUIRED_USE="
+ !minimal? ( ${PYTHON_REQUIRED_USE} )
+ python? ( !minimal )
+ test-suite? ( !minimal )
+"
+
+RESTRICT="test"
+
+PATCHES=(
+ "${FILESDIR}/2.0.4-scrub-timers.patch"
+ "${FILESDIR}/2.1.1-fix-lseek-mmap.patch"
+)
+
+pkg_pretend() {
+ use rootfs || return 0
+
+ if has_version virtual/dist-kernel && ! use dist-kernel; then
+ ewarn "You have virtual/dist-kernel installed, but"
+ ewarn "USE=\"dist-kernel\" is not enabled for ${CATEGORY}/${PN}"
+ ewarn "It's recommended to globally enable dist-kernel USE flag"
+ ewarn "to auto-trigger initrd rebuilds with kernel updates"
+ fi
+}
+
+pkg_setup() {
+ if use kernel_linux; then
+ linux-info_pkg_setup
+
+ if ! linux_config_exists; then
+ ewarn "Cannot check the linux kernel configuration."
+ else
+ if use test-suite; then
+ if linux_chkconfig_present BLK_DEV_LOOP; then
+ eerror "The ZFS test suite requires loop device support enabled."
+ eerror "Please enable it:"
+ eerror " CONFIG_BLK_DEV_LOOP=y"
+ eerror "in /usr/src/linux/.config or"
+ eerror " Device Drivers --->"
+ eerror " Block devices --->"
+ eerror " [X] Loopback device support"
+ fi
+ fi
+ fi
+ fi
+}
+
+libsoversion_check() {
+ local bugurl libzfs_sover
+ bugurl="https://bugs.gentoo.org/enter_bug.cgi?form_name=enter_bug&product=Gentoo+Linux&component=Current+packages"
+
+ libzfs_sover="$(grep 'libzfs_la_LDFLAGS += -version-info' lib/libzfs/Makefile.am \
+ | grep -Eo '[0-9]+:[0-9]+:[0-9]+')"
+ libzfs_sover="${libzfs_sover%%:*}"
+
+ if [[ ${libzfs_sover} -ne $(ver_cut 2 ${SLOT}) ]]; then
+ echo
+ eerror "BUG BUG BUG BUG BUG BUG BUG BUG"
+ eerror "ebuild subslot does not match libzfs soversion!"
+ eerror "libzfs soversion: ${libzfs_sover}"
+ eerror "ebuild value: $(ver_cut 2 ${SLOT})"
+ eerror "This is a bug in the ebuild, please use the following URL to report it"
+ eerror "${bugurl}&short_desc=${CATEGORY}%2F${P}+update+subslot"
+ echo
+ # we want to abort for releases, but just print a warning for live ebuild
+ # to keep package installable
+ [[ ${PV} == "9999" ]] || die
+ fi
+}
+
+src_prepare() {
+ default
+ libsoversion_check
+
+ # Run unconditionally (bug #792627)
+ eautoreconf
+
+ if [[ ${PV} != "9999" ]]; then
+ # Set revision number
+ sed -i "s/\(Release:\)\(.*\)1/\1\2${PR}-gentoo/" META || die "Could not set Gentoo release"
+ fi
+
+ if use python; then
+ pushd contrib/pyzfs >/dev/null || die
+ distutils-r1_src_prepare
+ popd >/dev/null || die
+ fi
+
+ # prevent errors showing up on zfs-mount stop, #647688
+ # openrc will unmount all filesystems anyway.
+ sed -i "/^ZFS_UNMOUNT=/ s/yes/no/" "etc/default/zfs.in" || die
+}
+
+src_configure() {
+ use custom-cflags || strip-flags
+ use minimal || python_setup
+
+ local myconf=(
+ --bindir="${EPREFIX}/bin"
+ --enable-shared
+ --enable-sysvinit
+ --localstatedir="${EPREFIX}/var"
+ --sbindir="${EPREFIX}/sbin"
+ --with-config=user
+ --with-dracutdir="${EPREFIX}/usr/lib/dracut"
+ --with-linux="${KV_DIR}"
+ --with-linux-obj="${KV_OUT_DIR}"
+ --with-udevdir="$(get_udevdir)"
+ --with-pamconfigsdir="${EPREFIX}/unwanted_files"
+ --with-pammoduledir="$(getpam_mod_dir)"
+ --with-systemdunitdir="$(systemd_get_systemunitdir)"
+ --with-systemdpresetdir="${EPREFIX}/lib/systemd/system-preset"
+ --with-vendor=gentoo
+ # Building zfs-mount-generator.c on musl breaks as strndupa
+ # isn't available. But systemd doesn't support musl anyway, so
+ # just disable building it.
+ $(use_enable !elibc_musl systemd)
+ $(use_enable debug)
+ $(use_enable nls)
+ $(use_enable pam)
+ $(use_enable python pyzfs)
+ --disable-static
+ $(usex minimal --without-python --with-python="${EPYTHON}")
+ )
+
+ econf "${myconf[@]}"
+}
+
+src_compile() {
+ default
+ if use python; then
+ pushd contrib/pyzfs >/dev/null || die
+ distutils-r1_src_compile
+ popd >/dev/null || die
+ fi
+}
+
+src_install() {
+ default
+
+ gen_usr_ldscript -a nvpair uutil zfsbootenv zfs zfs_core zpool
+
+ use pam && { rm -rv "${ED}/unwanted_files" || die ; }
+
+ use test-suite || { rm -r "${ED}"/usr/share/zfs/{test-runner,zfs-tests,runfiles,*sh} || die ; }
+
+ find "${ED}" -name '*.la' -delete || die
+
+ dobashcomp contrib/bash_completion.d/zfs
+ bashcomp_alias zfs zpool
+
+ # strip executable bit from conf.d file
+ fperms 0644 /etc/conf.d/zfs
+
+ if use python; then
+ pushd contrib/pyzfs >/dev/null || die
+ distutils-r1_src_install
+ popd >/dev/null || die
+ fi
+
+ # enforce best available python implementation
+ use minimal || python_fix_shebang "${ED}/bin"
+}
+
+pkg_postinst() {
+ # we always need userspace utils in sync with zfs-kmod
+ # so force initrd update for userspace as well, to avoid
+ # situation when zfs-kmod trigger initrd rebuild before
+ # userspace component is rebuilt
+ # KV_* variables are provided by linux-info.eclass
+ if [[ -z ${ROOT} ]] && use dist-kernel; then
+ dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+ fi
+
+ if use rootfs; then
+ if ! has_version sys-kernel/genkernel && ! has_version sys-kernel/dracut; then
+ elog "Root on zfs requires an initramfs to boot"
+ elog "The following packages provide one and are tested on a regular basis:"
+ elog " sys-kernel/dracut"
+ elog " sys-kernel/genkernel"
+ fi
+ fi
+
+ if ! use kernel-builtin && [[ ${PV} == "9999" ]]; then
+ einfo "Adding ${P} to the module database to ensure that the"
+ einfo "kernel modules and userland utilities stay in sync."
+ update_moduledb
+ fi
+
+ if systemd_is_booted || has_version sys-apps/systemd; then
+ einfo "Please refer to ${EROOT}/lib/systemd/system-preset/50-zfs.preset"
+ einfo "for default zfs systemd service configuration"
+ else
+ [[ -e "${EROOT}/etc/runlevels/boot/zfs-import" ]] || \
+ einfo "You should add zfs-import to the boot runlevel."
+ [[ -e "${EROOT}/etc/runlevels/boot/zfs-mount" ]]|| \
+ einfo "You should add zfs-mount to the boot runlevel."
+ [[ -e "${EROOT}/etc/runlevels/default/zfs-share" ]] || \
+ einfo "You should add zfs-share to the default runlevel."
+ [[ -e "${EROOT}/etc/runlevels/default/zfs-zed" ]] || \
+ einfo "You should add zfs-zed to the default runlevel."
+ fi
+}
+
+pkg_postrm() {
+ if ! use kernel-builtin && [[ ${PV} == "9999" ]]; then
+ remove_moduledb
+ fi
+}
next reply other threads:[~2021-11-07 23:59 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-07 23:59 Georgy Yakovlev [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-02-23 6:33 [gentoo-commits] repo/gentoo:master commit in: sys-fs/zfs/, sys-fs/zfs/files/ Sam James
2023-12-16 10:06 Sam James
2023-07-03 21:03 Sam James
2022-12-25 0:24 Georgy Yakovlev
2022-12-08 19:48 Georgy Yakovlev
2022-10-04 5:07 Sam James
2022-09-17 22:16 Georgy Yakovlev
2022-09-16 23:09 Georgy Yakovlev
2022-07-01 7:34 Sam James
2022-06-07 18:56 Georgy Yakovlev
2021-12-26 22:35 Georgy Yakovlev
2021-12-23 22:28 Georgy Yakovlev
2021-12-16 2:51 Georgy Yakovlev
2021-06-04 2:14 Georgy Yakovlev
2020-11-03 20:07 Georgy Yakovlev
2020-09-25 20:28 Georgy Yakovlev
2020-05-26 23:58 Georgy Yakovlev
2019-11-26 20:32 Georgy Yakovlev
2019-09-27 19:16 Georgy Yakovlev
2019-03-31 3:53 Georgy Yakovlev
2018-02-14 20:39 Matt Thode
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1636329460.7c97da7804003db7be32a3c696f930ca5555ba24.gyakovlev@gentoo \
--to=gyakovlev@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox