aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/stat.h6
-rw-r--r--sys/contrib/openzfs/module/os/freebsd/zfs/zfs_file_os.c63
-rwxr-xr-xsys/contrib/openzfs/tests/zfs-tests/tests/functional/bclone/cleanup.ksh9
-rwxr-xr-xsys/contrib/openzfs/tests/zfs-tests/tests/functional/bclone/setup.ksh5
-rw-r--r--sys/modules/zfs/zfs_config.h4
-rw-r--r--sys/modules/zfs/zfs_gitrev.h2
6 files changed, 72 insertions, 17 deletions
diff --git a/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/stat.h b/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/stat.h
index 88773cceb951..af488244bd05 100644
--- a/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/stat.h
+++ b/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/stat.h
@@ -76,8 +76,12 @@ fstat64_blk(int fd, struct stat64 *st)
/*
* Only Intel-based Macs have a separate stat64; Arm-based Macs are like
* FreeBSD and have a full 64-bit stat from the start.
+ *
+ * On Linux, musl libc is full 64-bit too and has deprecated its own version
+ * of these defines since version 1.2.4.
*/
-#if defined(__APPLE__) && !(defined(__i386__) || defined(__x86_64__))
+#if (defined(__APPLE__) && !(defined(__i386__) || defined(__x86_64__))) || \
+ (defined(__linux__) && !defined(__GLIBC__))
#define stat64 stat
#define fstat64 fstat
#endif
diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_file_os.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_file_os.c
index 9d68499d82ec..b337932b9dcc 100644
--- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_file_os.c
+++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_file_os.c
@@ -50,26 +50,65 @@ int
zfs_file_open(const char *path, int flags, int mode, zfs_file_t **fpp)
{
struct thread *td;
- int rc, fd;
+ struct vnode *vp;
+ struct file *fp;
+ struct nameidata nd;
+ int error;
td = curthread;
pwd_ensure_dirs();
- /* 12.x doesn't take a const char * */
- rc = kern_openat(td, AT_FDCWD, __DECONST(char *, path),
- UIO_SYSSPACE, flags, mode);
- if (rc)
- return (SET_ERROR(rc));
- fd = td->td_retval[0];
- td->td_retval[0] = 0;
- if (fget(curthread, fd, &cap_no_rights, fpp))
- kern_close(td, fd);
+
+ KASSERT((flags & (O_EXEC | O_PATH)) == 0,
+ ("invalid flags: 0x%x", flags));
+ KASSERT((flags & O_ACCMODE) != O_ACCMODE,
+ ("invalid flags: 0x%x", flags));
+ flags = FFLAGS(flags);
+
+ error = falloc_noinstall(td, &fp);
+ if (error != 0) {
+ return (error);
+ }
+ fp->f_flag = flags & FMASK;
+
+#if __FreeBSD_version >= 1400043
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path);
+#else
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, td);
+#endif
+ error = vn_open(&nd, &flags, mode, fp);
+ if (error != 0) {
+ falloc_abort(td, fp);
+ return (SET_ERROR(error));
+ }
+ NDFREE_PNBUF(&nd);
+ vp = nd.ni_vp;
+ fp->f_vnode = vp;
+ if (fp->f_ops == &badfileops) {
+ finit_vnode(fp, flags, NULL, &vnops);
+ }
+ VOP_UNLOCK(vp);
+ if (vp->v_type != VREG) {
+ zfs_file_close(fp);
+ return (SET_ERROR(EACCES));
+ }
+
+ if (flags & O_TRUNC) {
+ error = fo_truncate(fp, 0, td->td_ucred, td);
+ if (error != 0) {
+ zfs_file_close(fp);
+ return (SET_ERROR(error));
+ }
+ }
+
+ *fpp = fp;
+
return (0);
}
void
zfs_file_close(zfs_file_t *fp)
{
- fo_close(fp, curthread);
+ fdrop(fp, curthread);
}
static int
@@ -260,7 +299,7 @@ zfs_file_get(int fd)
void
zfs_file_put(zfs_file_t *fp)
{
- fdrop(fp, curthread);
+ zfs_file_close(fp);
}
loff_t
diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bclone/cleanup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bclone/cleanup.ksh
index df6d9c08fece..0021ccb57ae0 100755
--- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bclone/cleanup.ksh
+++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bclone/cleanup.ksh
@@ -34,4 +34,11 @@
log_must zfs destroy $TESTSRCFS
log_must zfs destroy $TESTDSTFS
-default_cleanup
+
+default_cleanup_noexit
+
+if tunable_exists BCLONE_ENABLED ; then
+ log_must restore_tunable BCLONE_ENABLED
+fi
+
+log_pass
diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bclone/setup.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bclone/setup.ksh
index c68719ee72a2..9d26088c5a8a 100755
--- a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bclone/setup.ksh
+++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/bclone/setup.ksh
@@ -36,6 +36,11 @@ if ! command -v clonefile > /dev/null ; then
log_unsupported "clonefile program required to test block cloning"
fi
+if tunable_exists BCLONE_ENABLED ; then
+ log_must save_tunable BCLONE_ENABLED
+ log_must set_tunable32 BCLONE_ENABLED 1
+fi
+
DISK=${DISKS%% *}
default_setup_noexit $DISK "true"
diff --git a/sys/modules/zfs/zfs_config.h b/sys/modules/zfs/zfs_config.h
index 70eea47ba127..f248e896babb 100644
--- a/sys/modules/zfs/zfs_config.h
+++ b/sys/modules/zfs/zfs_config.h
@@ -1137,7 +1137,7 @@
/* #undef ZFS_IS_GPL_COMPATIBLE */
/* Define the project alias string. */
-#define ZFS_META_ALIAS "zfs-2.2.99-310-FreeBSD_ga0b2a93c4"
+#define ZFS_META_ALIAS "zfs-2.2.99-313-FreeBSD_ga4bf6baae"
/* Define the project author. */
#define ZFS_META_AUTHOR "OpenZFS"
@@ -1167,7 +1167,7 @@
#define ZFS_META_NAME "zfs"
/* Define the project release. */
-#define ZFS_META_RELEASE "310_FreeBSD-ga0b2a93c4"
+#define ZFS_META_RELEASE "313-FreeBSD_ga4bf6baae"
/* Define the project version. */
#define ZFS_META_VERSION "2.2.99"
diff --git a/sys/modules/zfs/zfs_gitrev.h b/sys/modules/zfs/zfs_gitrev.h
index 95aaf9e57f95..55e68d933978 100644
--- a/sys/modules/zfs/zfs_gitrev.h
+++ b/sys/modules/zfs/zfs_gitrev.h
@@ -1 +1 @@
-#define ZFS_META_GITREV "zfs-2.2.99-310-ga0b2a93c4"
+#define ZFS_META_GITREV "zfs-2.2.99-313-ga4bf6baae"