Skip to content

Commit

Permalink
macOS: Add macOS support
Browse files Browse the repository at this point in the history
macOS: change update_pages

OsX traditionally used uio_copy to re-issue the write in update_pages() to
mapped memory. Based on Linux, it is now changed to using dmu_read() from
ARC, to save the uio allocation, and clean up zfs_write().

macOS: enhance getxattr/setxattr code to use txg

macOS: xattr writes to use txg, and correct xattr=sa

macOS: rollback to notify finder of change

macOS: setattr(uid/gid) incorrect

macOS: replace obj-C function with C

macOS: move AT_ to ATTR_

Appears Linux already defines them in headers, but doesn't use them.
Since we just match to XNU values, it doesn't matter what they are called.

macOS: zfs_writes were truncated

macOS: zed changes

macOS: const required after C++ fix commit

macOS: Add primitive auto unmount of idle snapshots.

macOS: uio changes after uio PR

macOS: rebase master fixes

macOS: Add all tunables from upstream

macOS: compile fixes after vdev_disk_t change

macOS: remove semaphore.h

macOS: ASM changes after revert

macOS: correct cv_wait_sig() return values

macOS: Ensure to use -O2 on dsl_scan.c

macOS: Disambiguate condvar API contract

This is the macOS changes required for the upstream commit:
8056a75

Also correct cstyle.

remember cv_timedwait() and cv_timedwait_hires() take different
timeout types!

macOS: Add abd_cache_reap_now for abd_chunk_cache users

macOS changes needed for commit 7564073

macOS: fix zfstester get_time

macOS: can not pass componentname to ZFS

as ZFS updates the name with the real name (case insensitive) and
will cause panic, as it is often protected. We need to pass a buffer
to use, and use the returned name as cachename.

macOS: remove more tests to fit in 60mins

macOS: zvol need to verify and lock zv before use.

When called from, or calling to C++, we need to treat the stored 'zv'
as a unique ID, and verify it is still in the list of active zvols.
If found, lock in the correct order.

SPL: correct cstyle.pl

Fixed kmem_bufctl_cache memory leak (#273)

macOS: cstyle fixes, remove spl-kobj.c

macOS: cstyle.pl-ify SPL

macOS: cstyle.pl all kernel header files.

macOS: cstyle kernel C files

macOS: cstyle kernel CPP files

macOS: libspl cstyle fixes.

Fixed memory leak during zfs driver unload. (#279)

macOS: fix file based pools

zfs_dev_is_whole_disk() was incorrectly ported from FreeBSD. Use
Linux version.

macOS: undo previous decmpfs handling

We used to handle decmpfs by uncompressing it after the fact, but it
added a lot of dependencies.

Now, if decmpfs XATTR is set, AND it sets UF_COMPRESSED, AND is
followed by a setsize(0), we will ignore the truncate, and delete
the XATTR.

Only concern is if we were to stop a truncate, which was supposed to happen
(ie, not decmpfs related).

macOS: make codecheck pass

macOS: change send/recv pipe to fifo

Simplify kernel dependencies by only do IO on vnodes, and userland
to wrap send to pipes with fifo (opened to get vnode) and relay
child processes.
  • Loading branch information
lundman committed Jul 17, 2020
1 parent 24b5bd5 commit 109dff5
Show file tree
Hide file tree
Showing 250 changed files with 91,492 additions and 56 deletions.
12 changes: 12 additions & 0 deletions appveryor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 1.0.{build}
branches:
only:
- macos
image: macOS
build_script:
- sh: >-
pwd
ls -l
sh autoconf.sh
./configure CPPFLAGS="-I/usr/local/opt/gettext/include -I/usr/local/opt/[email protected]/include" LDFLAGS="-L/usr/local/opt/gettext/lib/ -L/usr/local/opt/[email protected]/lib"
make
4 changes: 4 additions & 0 deletions cmd/zed/zed.d/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ dist_zedexec_SCRIPTS = \
scrub_finish-notify.sh \
statechange-led.sh \
statechange-notify.sh \
snapshot_mount.sh \
snapshot_unmount.sh \
vdev_clear-led.sh \
vdev_attach-led.sh \
pool_import-led.sh \
Expand All @@ -38,6 +40,8 @@ zedconfdefaults = \
scrub_finish-notify.sh \
statechange-led.sh \
statechange-notify.sh \
snapshot_mount.sh \
snapshot_unmount.sh \
vdev_clear-led.sh \
vdev_attach-led.sh \
pool_import-led.sh \
Expand Down
29 changes: 29 additions & 0 deletions cmd/zed/zed.d/snapshot_mount.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh
#
# Helper to mount and unmount snapshots when asked to by kernel.
#
# Mostly used in macOS.
#
set -ef

[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc"
. "${ZED_ZEDLET_DIR}/zed-functions.sh"

[ -n "${ZEVENT_SNAPSHOT_NAME}" ] || exit 1
[ -n "${ZEVENT_SUBCLASS}" ] || exit 2

if [ "${ZEVENT_SUBCLASS}" = "snapshot_mount" ]; then
action="mount"
elif [ "${ZEVENT_SUBCLASS}" = "snapshot_unmount" ]; then
action="unmount"
else
zed_log_err "unsupported event class \"${ZEVENT_SUBCLASS}\""
exit 3
fi

zed_exit_if_ignoring_this_event
zed_check_cmd "${ZFS}" || exit 4

"${ZFS}" "${action}" "${ZEVENT_SNAPSHOT_NAME}"

finished
1 change: 1 addition & 0 deletions cmd/zed/zed.d/snapshot_unmount.sh
12 changes: 6 additions & 6 deletions cmd/zfs/zfs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,11 +766,11 @@ zfs_mount_and_share(libzfs_handle_t *hdl, const char *dataset, zfs_type_t type)
} else if (zfs_mount(zhp, NULL, 0) != 0) {
(void) fprintf(stderr, gettext("filesystem "
"successfully created, but not mounted\n"));
ret = 1;
ret = 0;
} else if (zfs_share(zhp) != 0) {
(void) fprintf(stderr, gettext("filesystem "
"successfully created, but not shared\n"));
ret = 1;
ret = 0;
}
zfs_commit_all_shares();
}
Expand Down Expand Up @@ -6973,7 +6973,7 @@ share_mount(int op, int argc, char **argv)
}

} else {
#if defined (__APPLE__)
#if defined(__APPLE__)
/*
* OsX can not mount from kernel, users are expected to mount
* by hand using "zfs mount dataset@snapshot".
Expand All @@ -6997,8 +6997,8 @@ share_mount(int op, int argc, char **argv)

} else {

ret = share_mount_one(zhp, op, flags, NULL, B_TRUE,
options);
ret = share_mount_one(zhp, op, flags, NULL,
B_TRUE, options);
}

zfs_close(zhp);
Expand Down Expand Up @@ -7400,7 +7400,7 @@ unshare_unmount(int op, int argc, char **argv)
return (unshare_unmount_path(op, argv[0],
flags, B_FALSE));

#if defined (__APPLE__)
#if defined(__APPLE__)
/* Temporarily, allow mounting snapshots on OS X */

if ((zhp = zfs_open(g_zfs, argv[0],
Expand Down
71 changes: 71 additions & 0 deletions cmd/zpool/os/macos/zpool_vdev_os.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* 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
*/

#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <libintl.h>
#include <libnvpair.h>
#include <libzutil.h>
#include <limits.h>
#include <sys/spa.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "zpool_util.h"
#include <sys/zfs_context.h>

#include <sys/efi_partition.h>
#include <sys/stat.h>
#include <sys/vtoc.h>
#include <sys/mntent.h>
#include <uuid/uuid.h>

boolean_t
check_sector_size_database(char *path, int *sector_size)
{
return (B_FALSE);
}

void
zpool_vdev_enable_file(struct stat64 *statbuf, boolean_t *wholedisk)
{
if (S_ISCHR(statbuf->st_mode)) {
statbuf->st_mode &= ~S_IFCHR;
statbuf->st_mode |= S_IFBLK;
*wholedisk = B_FALSE;
}
}

int
check_device(const char *name, boolean_t force,
boolean_t isspare, boolean_t iswholedisk)
{
char path[MAXPATHLEN];

if (strncmp(name, _PATH_DEV, sizeof (_PATH_DEV) - 1) != 0)
snprintf(path, sizeof (path), "%s%s", _PATH_DEV, name);
else
strlcpy(path, name, sizeof (path));

return (check_file(path, force, isspare));
}
8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ AC_CONFIG_FILES([
include/os/macos/spl/Makefile
include/os/macos/spl/rpc/Makefile
include/os/macos/spl/sys/Makefile
include/os/macos/zfs/Makefile
include/os/macos/zfs/sys/Makefile
include/sys/Makefile
include/sys/crypto/Makefile
include/sys/fm/Makefile
Expand All @@ -161,6 +163,12 @@ AC_CONFIG_FILES([
lib/libspl/include/os/freebsd/sys/Makefile
lib/libspl/include/os/linux/Makefile
lib/libspl/include/os/linux/sys/Makefile
lib/libspl/include/os/macos/Makefile
lib/libspl/include/os/macos/ia32/Makefile
lib/libspl/include/os/macos/ia32/sys/Makefile
lib/libspl/include/os/macos/mach/Makefile
lib/libspl/include/os/macos/rpc/Makefile
lib/libspl/include/os/macos/sys/Makefile
lib/libspl/include/rpc/Makefile
lib/libspl/include/sys/Makefile
lib/libspl/include/sys/dktp/Makefile
Expand Down
1 change: 1 addition & 0 deletions include/os/macos/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SUBDIRS = spl zfs
1 change: 1 addition & 0 deletions include/os/macos/spl/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SUBDIRS = sys rpc
Loading

0 comments on commit 109dff5

Please sign in to comment.