Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Untested ashift #3

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions support/MacZFS.pmdoc/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
<versions min-spec="1.000000" />
<scripts></scripts>
</distribution>
<description>Welcome to MacZFS, a free implementation of the ZFS file system for Mac OSX Leopard and newer.

MacZFS offers nearly unlimited storage capacity, only limited by the amount and size of hard disks connected to an computer. It offers data replication in mirror or raidz configuration, dynamic stripping and build-in storage pool based volume management.

MacZFS has end-to-end compression and strong data checksumming, including self-healing of bit-rot or any other read problem in redundant pools and offers unlimited, nearly-instantaneous snapshot support for backup and ecovery. Snapshots can be mount for read-only inspection, efficiently transfered between storage pools for off-site backups or promoted to full read-write filesystems.

MacZFS is based on the original Sun implementation of the ZFS file system and Apple's initial port to Leopard whch was discontinued before public release.

Today, MacZFS is developed by a community effort on www.maczfs.org and released under the CDDL and APSL liecenses.
</description>
<contents>
<choice title="ZFS for Leopard" id="zfs105"
tooltip="ZFS for Leopard"
Expand All @@ -29,9 +39,9 @@
startHidden="unchanged" />
</choice-reqs>
</choice>
<choice title="ZFS for Snow Leopard and Lion" id="zfs106"
tooltip="ZFS for Snow Leopard and Lion"
description="ZFS for Snow Leopard and Lion on Intel 32 bit and 64 bit machines"
<choice title="ZFS for Snow Leopard, Lion and Mountain Lion" id="zfs106"
tooltip="ZFS for Snow Leopard to Mountain Lion"
description="ZFS for Snow Leopard, Lion and Mountain Lion on Intel 32 bit and 64 bit machines"
starts_selected="true" starts_enabled="true"
starts_hidden="false">
<pkgref id="com.bandlem.mac.zfs.106.pkg" />
Expand All @@ -40,7 +50,7 @@
selected="no" enabled="no" hidden="yes"
startSelected="unchanged" startEnabled="unchanged"
startHidden="unchanged" />
<requirement id="tosv" operator="lt" value="'10.8'"
<requirement id="tosv" operator="lt" value="'10.9'"
selected="no" enabled="no" hidden="yes"
startSelected="unchanged" startEnabled="unchanged"
startHidden="unchanged" />
Expand All @@ -59,20 +69,21 @@
{\colortbl;\red255\green255\blue255;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural

\f0\fs26 \cf0 This will install the next-generation ZFS support for Mac OSX systems running either Leopard or Snow Leopard. Preview support for Lion is available.}]]>
\f0\fs26 \cf0 This will install the next-generation ZFS support for Mac OSX systems running either Leopard or Snow Leopard and newer.}]]>
</resource>
</locale>
</resources>
<requirements>
<requirement id="tosv" operator="ge" value="'10.5'">
<message>Mac ZFS needs at least Leopard to run.</message>
</requirement>
<requirement id="tosv" operator="lt" value="'10.8'">
<message>Mac ZFS is only certified to run on Leopard and Snow Leopard at this time, though preview support for Lion is available.</message>
<requirement id="tosv" operator="lt" value="'10.9'">
<message>Mac ZFS is only certified to run on Mac OSX Leopard to Mountain Lion.</message>
</requirement>
</requirements>
<flags />
<item type="file">01zfs.xml</item>
<item type="file">02zfs.xml</item>
<mod>properties.title</mod>
<mod>description</mod>
</pkmkdoc>
13 changes: 10 additions & 3 deletions support/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
DIR=`dirname $0`
BUILD=build

DEFAULT_IDENTIFIER=com.bandlem.mac

VERSION=`${DIR}/version.sh`
if [ -z "${VERSION}" ]
then
Expand All @@ -12,6 +14,7 @@ then
fi

CONFIG=Release
IDENTIFIER=${DEFAULT_IDENTIFIER}
INSTALL=No

while [[ $1 == -* ]]; do
Expand All @@ -20,6 +23,7 @@ while [[ $1 == -* ]]; do
case $OPT in
--debug) CONFIG=Debug ;;
--install) INSTALL=Yes ;;
--id) IDENTIFIER="$1" ; shift ;;
--) break; ;;
*) echo "Unknown arguments $OPT $*"; exit 1; ;;
esac
Expand All @@ -36,17 +40,20 @@ USER=`whoami`
(
mkdir -p ${DIR}/../${BUILD}
rm -rf ${DIR}/../${BUILD}/ZFS105
rm -rf ${DIR}/../${BUILD}/ZFS105
rm -rf ${DIR}/../${BUILD}/ZFS106
cp -R ${DIR}/MacZFS.pmdoc ${DIR}/../${BUILD}
sed -i~ -e "s/0\\.0\\.0/${VERSION}/g" ${DIR}/../${BUILD}/MacZFS.pmdoc/*
if [ "${DEFAULT_IDENTIFIER}" != "${IDENTIFIER}" ] ; then
sed -i~ -e "s/${DEFAULT_IDENTIFIER}/${IDENTIFIER}/g" ${DIR}/../${BUILD}/MacZFS.pmdoc/* #${DIR}/../zfs_bundle/Info.plist
fi

cd ${DIR}/..
xcodebuild -sdk macosx10.5 -configuration ${CONFIG} -parallelizeTargets install INSTALL_OWNER=${USER} SYMROOT=${BUILD}/${CONFIG}105 DSTROOT=${BUILD}/ZFS105 || exit 2
xcodebuild -sdk macosx10.5 -configuration ${CONFIG} -parallelizeTargets install MODULE_NAME=${IDENTIFIER}.zfs.fs INSTALL_OWNER=${USER} SYMROOT=${BUILD}/${CONFIG}105 DSTROOT=${BUILD}/ZFS105 || exit 2

# No point in building on 10.5, it'll just do the same thing again
if [ "`sysctl -b kern.osrelease`" != "9.8.0" ]
then
xcodebuild -sdk macosx10.6 -configuration ${CONFIG} -parallelizeTargets install INSTALL_OWNER=${USER} SYMROOT=${BUILD}/${CONFIG}106 DSTROOT=${BUILD}/ZFS106 || exit 3
xcodebuild -sdk macosx10.6 -configuration ${CONFIG} -parallelizeTargets install MODULE_NAME=${IDENTIFIER}.zfs.fs INSTALL_OWNER=${USER} SYMROOT=${BUILD}/${CONFIG}106 DSTROOT=${BUILD}/ZFS106 || exit 3
fi

cd ${BUILD}
Expand Down
6 changes: 3 additions & 3 deletions usr/src/cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ zpool_do_add(int argc, char **argv)
}

/* pass off to get_vdev_spec for processing */
nvroot = make_root_vdev(zhp, force, !force, B_FALSE, argc, argv);
nvroot = make_root_vdev(zhp, NULL, force, !force, B_FALSE, argc, argv);
if (nvroot == NULL) {
zpool_close(zhp);
return (1);
Expand Down Expand Up @@ -657,7 +657,7 @@ zpool_do_create(int argc, char **argv)
}

/* pass off to get_vdev_spec for bulk processing */
nvroot = make_root_vdev(NULL, force, !force, B_FALSE, argc - 1,
nvroot = make_root_vdev(NULL, props, force, !force, B_FALSE, argc - 1,
argv + 1);
if (nvroot == NULL)
return (1);
Expand Down Expand Up @@ -2264,7 +2264,7 @@ zpool_do_attach_or_replace(int argc, char **argv, int replacing)
return (1);
}

nvroot = make_root_vdev(zhp, force, B_FALSE, replacing, argc, argv);
nvroot = make_root_vdev(zhp, NULL, force, B_FALSE, replacing, argc, argv);
if (nvroot == NULL) {
zpool_close(zhp);
return (1);
Expand Down
2 changes: 1 addition & 1 deletion usr/src/cmd/zpool/zpool_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ uint_t num_logs(nvlist_t *nv);
* Virtual device functions
*/

nvlist_t *make_root_vdev(zpool_handle_t *zhp, int force, int check_rep,
nvlist_t *make_root_vdev(zpool_handle_t *zhp, nvlist_t *props, int force, int check_rep,
boolean_t isreplace, int argc, char **argv);

/*
Expand Down
26 changes: 20 additions & 6 deletions usr/src/cmd/zpool/zpool_vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ is_whole_disk(const char *arg)
* xxx Shorthand for /dev/dsk/xxx
*/
static nvlist_t *
make_leaf_vdev(const char *arg, uint64_t is_log)
make_leaf_vdev(nvlist_t *props, const char *arg, uint64_t is_log)
{
char path[MAXPATHLEN];
struct stat64 statbuf;
Expand Down Expand Up @@ -540,6 +540,20 @@ make_leaf_vdev(const char *arg, uint64_t is_log)
(void) close(fd);
}

if (props != NULL) {

uint64_t ashift = 0;
char *value = NULL;

if (nvlist_lookup_string(props,
zpool_prop_to_name(ZPOOL_PROP_ASHIFT), &value) == 0)
zfs_nicestrtonum(NULL, value, &ashift);

if (ashift > 0)
verify(nvlist_add_uint64(vdev, ZPOOL_CONFIG_ASHIFT,
ashift) == 0);
}

return (vdev);
}

Expand Down Expand Up @@ -1180,7 +1194,7 @@ is_grouping(const char *type, int *mindev)
* because the program is just going to exit anyway.
*/
nvlist_t *
construct_spec(int argc, char **argv)
construct_spec(nvlist_t *props, int argc, char **argv)
{
nvlist_t *nvroot, *nv, **top, **spares, **l2cache;
int t, toplevels, mindev, nspares, nlogs, nl2cache;
Expand Down Expand Up @@ -1269,7 +1283,7 @@ construct_spec(int argc, char **argv)
children * sizeof (nvlist_t *));
if (child == NULL)
zpool_no_memory();
if ((nv = make_leaf_vdev(argv[c], B_FALSE))
if ((nv = make_leaf_vdev(props, argv[c], B_FALSE))
== NULL)
return (NULL);
child[children - 1] = nv;
Expand Down Expand Up @@ -1318,7 +1332,7 @@ construct_spec(int argc, char **argv)
* We have a device. Pass off to make_leaf_vdev() to
* construct the appropriate nvlist describing the vdev.
*/
if ((nv = make_leaf_vdev(argv[0], is_log)) == NULL)
if ((nv = make_leaf_vdev(props, argv[0], is_log)) == NULL)
return (NULL);
if (is_log)
nlogs++;
Expand Down Expand Up @@ -1388,7 +1402,7 @@ construct_spec(int argc, char **argv)
* added, even if they appear in use.
*/
nvlist_t *
make_root_vdev(zpool_handle_t *zhp, int force, int check_rep,
make_root_vdev(zpool_handle_t *zhp, nvlist_t *props, int force, int check_rep,
boolean_t isreplacing, int argc, char **argv)
{
nvlist_t *newroot;
Expand All @@ -1400,7 +1414,7 @@ make_root_vdev(zpool_handle_t *zhp, int force, int check_rep,
* that we have a valid specification, and that all devices can be
* opened.
*/
if ((newroot = construct_spec(argc, argv)) == NULL)
if ((newroot = construct_spec(props, argc, argv)) == NULL)
return (NULL);

if (zhp && ((poolconfig = zpool_get_config(zhp, NULL)) == NULL))
Expand Down
5 changes: 5 additions & 0 deletions usr/src/common/zfs/zfs_prop.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,15 @@ zfs_prop_init(void)
register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0,
PROP_READONLY, ZFS_TYPE_DATASET,
"<1.00x or higher if compressed>", "RATIO");

/* readonly onetime number properties */
register_number(ZPOOL_PROP_ASHIFT, "ashift", 0, PROP_ONETIME,
ZFS_TYPE_POOL, "<ashift, 9-17, or 0=default>", "ASHIFT");
register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize", 8192,
PROP_ONETIME,
ZFS_TYPE_VOLUME, "512 to 128k, power of 2", "VOLBLOCK");


/* default number properties */
register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT,
ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA");
Expand Down
18 changes: 18 additions & 0 deletions usr/src/lib/libzfs/common/libzfs_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
case ZPOOL_PROP_SIZE:
case ZPOOL_PROP_USED:
case ZPOOL_PROP_AVAILABLE:
case ZPOOL_PROP_ASHIFT:
(void) zfs_nicenum(intval, buf, len);
break;

Expand Down Expand Up @@ -353,6 +354,23 @@ zpool_validate_properties(libzfs_handle_t *hdl, const char *poolname,
}
break;

case ZPOOL_PROP_ASHIFT:
if (!create_or_import) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"property '%s' can only be set at "
"creation time"), propname);
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
goto error;
}
if (intval != 0 && (intval < 9 || intval > 17)) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"property '%s' number %d is invalid."),
propname, intval);
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
goto error;
}
break;

case ZPOOL_PROP_BOOTFS:
if (create_or_import) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
Expand Down
4 changes: 2 additions & 2 deletions usr/src/lib/libzpool/common/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,13 +826,13 @@ size_t u8_textprep_str(char *i, size_t *il, char *o, size_t *ol, int nf,
}

uid_t
crgetuid(cred_t *cr)
crgetuid(const cred_t *cr)
{
return (0);
}

gid_t
crgetgid(cred_t *cr)
crgetgid(const cred_t *cr)
{
return (0);
}
Expand Down
44 changes: 44 additions & 0 deletions usr/src/maczfs/maczfs_vnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,9 @@ typedef enum {

#define VTOZONE(vp) ((vp)->v_vfsp->vfs_zone)

#ifndef NULLVP /* protect agianst redef' if /System/Library/Frameworks/Kernel.framework/Headers/sys/vnode.h is included. */
#define NULLVP ((struct vnode *)0)
#endif
#define NULLVPP ((struct vnode **)0)

#ifdef __APPLE__
Expand Down Expand Up @@ -1600,6 +1602,48 @@ struct async_reqs {
page_destroy((pp), (dn)); \
}


// Copied from /System/Library/Frameworks/Kernel.framework/Headers/miscfs/fifofs/fifo.h
/*
* Prototypes for fifo operations on vnodes.
*/
int fifo_ebadf(void *);

#define fifo_create (int (*) (struct vnop_create_args *))err_create
#define fifo_mknod (int (*) (struct vnop_mknod_args *))err_mknod
#define fifo_access (int (*) (struct vnop_access_args *))fifo_ebadf
#define fifo_getattr (int (*) (struct vnop_getattr_args *))fifo_ebadf
#define fifo_setattr (int (*) (struct vnop_setattr_args *))fifo_ebadf
#define fifo_revoke nop_revoke
#define fifo_mmap (int (*) (struct vnop_mmap_args *))err_mmap
#define fifo_fsync (int (*) (struct vnop_fsync_args *))nullop
#define fifo_remove (int (*) (struct vnop_remove_args *))err_remove
#define fifo_link (int (*) (struct vnop_link_args *))err_link
#define fifo_rename (int (*) (struct vnop_rename_args *))err_rename
#define fifo_mkdir (int (*) (struct vnop_mkdir_args *))err_mkdir
#define fifo_rmdir (int (*) (struct vnop_rmdir_args *))err_rmdir
#define fifo_symlink (int (*) (struct vnop_symlink_args *))err_symlink
#define fifo_readdir (int (*) (struct vnop_readdir_args *))err_readdir
#define fifo_readlink (int (*) (struct vnop_readlink_args *))err_readlink
#define fifo_reclaim (int (*) (struct vnop_reclaim_args *))nullop
#define fifo_strategy (int (*) (struct vnop_strategy_args *))err_strategy
#define fifo_valloc (int (*) (struct vnop_valloc_args *))err_valloc
#define fifo_vfree (int (*) (struct vnop_vfree_args *))err_vfree
#define fifo_bwrite (int (*) (struct vnop_bwrite_args *))nullop
#define fifo_blktooff (int (*) (struct vnop_blktooff_args *))err_blktooff

int fifo_lookup (struct vnop_lookup_args *);
int fifo_open (struct vnop_open_args *);
int fifo_close (struct vnop_close_args *);
int fifo_read (struct vnop_read_args *);
int fifo_write (struct vnop_write_args *);
int fifo_ioctl (struct vnop_ioctl_args *);
int fifo_select (struct vnop_select_args *);
int fifo_inactive (struct vnop_inactive_args *);
int fifo_pathconf (struct vnop_pathconf_args *);
int fifo_advlock (struct vnop_advlock_args *);


#endif /* _KERNEL */

#endif /* !__APPLE__ */
Expand Down
2 changes: 2 additions & 0 deletions usr/src/uts/common/fs/zfs/spa_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ spa_add(const char *name, const char *altroot)
cv_init(&spa->spa_async_cv, NULL, CV_DEFAULT, NULL);
cv_init(&spa->spa_scrub_cv, NULL, CV_DEFAULT, NULL);
cv_init(&spa->spa_scrub_io_cv, NULL, CV_DEFAULT, NULL);
cv_init(&spa->spa_zio_cv, NULL, CV_DEFAULT, NULL);

spa->spa_name = spa_strdup(name);
spa->spa_state = POOL_STATE_UNINITIALIZED;
Expand Down Expand Up @@ -331,6 +332,7 @@ spa_remove(spa_t *spa)
cv_destroy(&spa->spa_async_cv);
cv_destroy(&spa->spa_scrub_cv);
cv_destroy(&spa->spa_scrub_io_cv);
cv_destroy(&spa->spa_zio_cv);

mutex_destroy(&spa->spa_uberblock_lock);
mutex_destroy(&spa->spa_async_lock);
Expand Down
4 changes: 4 additions & 0 deletions usr/src/uts/common/fs/zfs/space_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ space_map_create(space_map_t *sm, uint64_t start, uint64_t size, uint8_t shift,
sm->sm_size = size;
sm->sm_shift = shift;
sm->sm_lock = lp;

cv_init(&sm->sm_load_cv, NULL, CV_DEFAULT, NULL);
}

void
Expand All @@ -75,6 +77,8 @@ space_map_destroy(space_map_t *sm)
ASSERT(!sm->sm_loaded && !sm->sm_loading);
VERIFY3U(sm->sm_space, ==, 0);
avl_destroy(&sm->sm_root);

cv_destroy(&sm->sm_load_cv);
}

void
Expand Down
Loading