git: 9dcf00aa404b - releng/14.0 - zfs: merge openzfs/zfs@e96fbdba3 (zfs-2.2-release) into stable/14

From: Martin Matuska <mm_at_FreeBSD.org>
Date: Mon, 11 Sep 2023 19:48:24 UTC
The branch releng/14.0 has been updated by mm:

URL: https://cgit.FreeBSD.org/src/commit/?id=9dcf00aa404bb62052433c45aaa5475e2760f5ed

commit 9dcf00aa404bb62052433c45aaa5475e2760f5ed
Author:     Martin Matuska <mm@FreeBSD.org>
AuthorDate: 2023-09-11 07:20:55 +0000
Commit:     Martin Matuska <mm@FreeBSD.org>
CommitDate: 2023-09-11 19:47:08 +0000

    zfs: merge openzfs/zfs@e96fbdba3 (zfs-2.2-release) into stable/14
    
    Notable upstream pull request merges:
      #15251 Add more constraints for block cloning
    
    Obtained from:  OpenZFS
    OpenZFS commit: e96fbdba344e9c25cad624a10d4a4b300fd35f6c
    Approved by:    re (gjb)
    
    (cherry picked from commit 2b2fbeb3a97b44e88b1ca1a01a9671a8be9fd04f)
---
 sys/contrib/openzfs/META                            |  2 +-
 .../openzfs/module/os/linux/zfs/qat_compress.c      |  2 ++
 sys/contrib/openzfs/module/zfs/zfs_vnops.c          | 21 +++++++++++++++++++--
 sys/modules/zfs/zfs_config.h                        |  4 ++--
 sys/modules/zfs/zfs_gitrev.h                        |  2 +-
 5 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/sys/contrib/openzfs/META b/sys/contrib/openzfs/META
index e4e770026b57..0953cc51922f 100644
--- a/sys/contrib/openzfs/META
+++ b/sys/contrib/openzfs/META
@@ -2,7 +2,7 @@ Meta:          1
 Name:          zfs
 Branch:        1.0
 Version:       2.2.0
-Release:       rc3
+Release:       rc4
 Release-Tags:  relext
 License:       CDDL
 Author:        OpenZFS
diff --git a/sys/contrib/openzfs/module/os/linux/zfs/qat_compress.c b/sys/contrib/openzfs/module/os/linux/zfs/qat_compress.c
index 07d5d34dae33..6d0595dd5f76 100644
--- a/sys/contrib/openzfs/module/os/linux/zfs/qat_compress.c
+++ b/sys/contrib/openzfs/module/os/linux/zfs/qat_compress.c
@@ -193,7 +193,9 @@ qat_dc_init(void)
 		sd.huffType = CPA_DC_HT_FULL_DYNAMIC;
 		sd.sessDirection = CPA_DC_DIR_COMBINED;
 		sd.sessState = CPA_DC_STATELESS;
+#if (CPA_DC_API_VERSION_NUM_MAJOR == 1 && CPA_DC_API_VERSION_NUM_MINOR < 6)
 		sd.deflateWindowSize = 7;
+#endif
 		sd.checksum = CPA_DC_ADLER32;
 		status = cpaDcGetSessionSize(dc_inst_handles[i],
 		    &sd, &sess_size, &ctx_size);
diff --git a/sys/contrib/openzfs/module/zfs/zfs_vnops.c b/sys/contrib/openzfs/module/zfs/zfs_vnops.c
index f8d13075d5c0..a64e1e2dc83d 100644
--- a/sys/contrib/openzfs/module/zfs/zfs_vnops.c
+++ b/sys/contrib/openzfs/module/zfs/zfs_vnops.c
@@ -1172,9 +1172,20 @@ zfs_clone_range(znode_t *inzp, uint64_t *inoffp, znode_t *outzp,
 	inblksz = inzp->z_blksz;
 
 	/*
-	 * We cannot clone into files with different block size.
+	 * We cannot clone into files with different block size if we can't
+	 * grow it (block size is already bigger or more than one block).
 	 */
-	if (inblksz != outzp->z_blksz && outzp->z_size > inblksz) {
+	if (inblksz != outzp->z_blksz && (outzp->z_size > outzp->z_blksz ||
+	    outzp->z_size > inblksz)) {
+		error = SET_ERROR(EINVAL);
+		goto unlock;
+	}
+
+	/*
+	 * Block size must be power-of-2 if destination offset != 0.
+	 * There can be no multiple blocks of non-power-of-2 size.
+	 */
+	if (outoff != 0 && !ISP2(inblksz)) {
 		error = SET_ERROR(EINVAL);
 		goto unlock;
 	}
@@ -1358,6 +1369,12 @@ unlock:
 		*inoffp += done;
 		*outoffp += done;
 		*lenp = done;
+	} else {
+		/*
+		 * If we made no progress, there must be a good reason.
+		 * EOF is handled explicitly above, before the loop.
+		 */
+		ASSERT3S(error, !=, 0);
 	}
 
 	zfs_exit_two(inzfsvfs, outzfsvfs, FTAG);
diff --git a/sys/modules/zfs/zfs_config.h b/sys/modules/zfs/zfs_config.h
index 29425d3368e0..122a7a3f032e 100644
--- a/sys/modules/zfs/zfs_config.h
+++ b/sys/modules/zfs/zfs_config.h
@@ -1074,7 +1074,7 @@
 /* #undef ZFS_IS_GPL_COMPATIBLE */
 
 /* Define the project alias string. */
-#define ZFS_META_ALIAS "zfs-2.2.0-FreeBSD_g32949f256"
+#define ZFS_META_ALIAS "zfs-2.2.0-FreeBSD_ge96fbdba3"
 
 /* Define the project author. */
 #define ZFS_META_AUTHOR "OpenZFS"
@@ -1104,7 +1104,7 @@
 #define ZFS_META_NAME "zfs"
 
 /* Define the project release. */
-#define ZFS_META_RELEASE "FreeBSD_g32949f256"
+#define ZFS_META_RELEASE "FreeBSD_ge96fbdba3"
 
 /* Define the project version. */
 #define ZFS_META_VERSION "2.2.0"
diff --git a/sys/modules/zfs/zfs_gitrev.h b/sys/modules/zfs/zfs_gitrev.h
index 71be2d813a0a..f29b7621500d 100644
--- a/sys/modules/zfs/zfs_gitrev.h
+++ b/sys/modules/zfs/zfs_gitrev.h
@@ -1 +1 @@
-#define	ZFS_META_GITREV "zfs-2.2.0-rc3-31-g32949f256"
+#define	ZFS_META_GITREV "zfs-2.2.0-rc4-1-ge96fbdba3"