Notable upstream pull request merges:
 #15630 a4bf6baae FreeBSD: Fix file descriptor leak on pool import
 #15780 d9cb42da9 FreeBSD: Fix bootstrapping tools under Linux/musl

Obtained from:	OpenZFS
OpenZFS commit:	a4bf6baaeb
This commit is contained in:
Martin Matuska 2024-01-24 12:41:22 +01:00
commit fedf5b965f
6 changed files with 72 additions and 17 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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"

View file

@ -1 +1 @@
#define ZFS_META_GITREV "zfs-2.2.99-310-ga0b2a93c4"
#define ZFS_META_GITREV "zfs-2.2.99-313-ga4bf6baae"