diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2019-09-13 11:36:58 +0000 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2019-09-13 11:36:58 +0000 |
commit | 1e0a2e76d4f4a70a2b17e4bbb59848e2c1659b5a (patch) | |
tree | cd6b8c84bfde26420d7856316a5630d74eb5b4ae | |
parent | c6dd2307128aa25ac346f7818440cd5cfd1f7221 (diff) | |
parent | 7bbcfb41683a5ae8b95a944d06597ea13b32bb92 (diff) | |
download | illumos-joyent-1e0a2e76d4f4a70a2b17e4bbb59848e2c1659b5a.tar.gz |
[illumos-gate merge]
commit 7bbcfb41683a5ae8b95a944d06597ea13b32bb92
11666 loader: remove panic macro from zfssubr.c
commit 8bf394f116a79c011b8f9f3bd199e09b363742ef
11650 ZFS user accounting fixes
commit 0237b6992139d8334d00225b8f228740703fbbdd
11656 SMB share names appear as all lowercase
-rw-r--r-- | usr/src/boot/Makefile.version | 2 | ||||
-rw-r--r-- | usr/src/boot/sys/cddl/boot/zfs/zfssubr.c | 30 | ||||
-rw-r--r-- | usr/src/lib/smbsrv/libmlsvc/common/smb_share.c | 7 | ||||
-rw-r--r-- | usr/src/pkg/manifests/system-test-zfstest.mf | 2 | ||||
-rw-r--r-- | usr/src/test/zfs-tests/runfiles/delphix.run | 3 | ||||
-rw-r--r-- | usr/src/test/zfs-tests/runfiles/omnios.run | 3 | ||||
-rw-r--r-- | usr/src/test/zfs-tests/runfiles/openindiana.run | 3 | ||||
-rw-r--r-- | usr/src/test/zfs-tests/runfiles/smartos.run | 3 | ||||
-rwxr-xr-x | usr/src/test/zfs-tests/tests/functional/upgrade/upgrade_readonly_pool.ksh | 68 | ||||
-rw-r--r-- | usr/src/uts/common/fs/zfs/dmu_objset.c | 6 | ||||
-rw-r--r-- | usr/src/uts/common/fs/zfs/sys/zfs_vfsops.h | 2 | ||||
-rw-r--r-- | usr/src/uts/common/fs/zfs/zfs_ioctl.c | 2 | ||||
-rw-r--r-- | usr/src/uts/common/fs/zfs/zfs_vfsops.c | 9 | ||||
-rw-r--r-- | usr/src/uts/common/fs/zfs/zvol.c | 18 |
14 files changed, 117 insertions, 41 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version index 02fbcc53bf..bb38843679 100644 --- a/usr/src/boot/Makefile.version +++ b/usr/src/boot/Makefile.version @@ -33,4 +33,4 @@ LOADER_VERSION = 1.1 # Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes. # The version is processed from left to right, the version number can only # be increased. -BOOT_VERSION = $(LOADER_VERSION)-2019.09.02.2 +BOOT_VERSION = $(LOADER_VERSION)-2019.09.09.1 diff --git a/usr/src/boot/sys/cddl/boot/zfs/zfssubr.c b/usr/src/boot/sys/cddl/boot/zfs/zfssubr.c index e38f14f33b..ee52f43b3d 100644 --- a/usr/src/boot/sys/cddl/boot/zfs/zfssubr.c +++ b/usr/src/boot/sys/cddl/boot/zfs/zfssubr.c @@ -35,11 +35,6 @@ static uint64_t zfs_crc64_table[256]; #define ASSERT0(x) ((void)0) #define ASSERT(x) ((void)0) -#define panic(...) do { \ - printf(__VA_ARGS__); \ - for (;;) ; \ -} while (0) - #define kmem_alloc(size, flag) zfs_alloc((size)) #define kmem_free(ptr, size) zfs_free((ptr), (size)) @@ -54,10 +49,13 @@ zfs_init_crc(void) * function). */ if (zfs_crc64_table[128] != ZFS_CRC64_POLY) { - memset(zfs_crc64_table, 0, sizeof(zfs_crc64_table)); - for (i = 0; i < 256; i++) - for (ct = zfs_crc64_table + i, *ct = i, j = 8; j > 0; j--) - *ct = (*ct >> 1) ^ (-(*ct & 1) & ZFS_CRC64_POLY); + memset(zfs_crc64_table, 0, sizeof (zfs_crc64_table)); + for (i = 0; i < 256; i++) { + ct = zfs_crc64_table + i; + for (*ct = i, j = 8; j > 0; j--) + *ct = (*ct >> 1) ^ + (-(*ct & 1) & ZFS_CRC64_POLY); + } } } @@ -288,7 +286,7 @@ zio_checksum_verify(const spa_t *spa, const blkptr_t *bp, void *data) return (EINVAL); if (spa != NULL) { - zio_checksum_template_init(checksum, (spa_t *) spa); + zio_checksum_template_init(checksum, (spa_t *)spa); ctx = spa->spa_cksum_tmpls[checksum]; } @@ -336,7 +334,7 @@ zio_checksum_verify(const spa_t *spa, const blkptr_t *bp, void *data) static int zio_decompress_data(int cpfunc, void *src, uint64_t srcsize, - void *dest, uint64_t destsize) + void *dest, uint64_t destsize) { zio_compress_info_t *ci; @@ -1640,8 +1638,11 @@ reconstruct: * any errors. */ if (total_errors <= rm->rm_firstdatacol - parity_untried) { + int rv; + if (data_errors == 0) { - if (raidz_checksum_verify(vd->spa, bp, data, bytes) == 0) { + rv = raidz_checksum_verify(vd->spa, bp, data, bytes); + if (rv == 0) { /* * If we read parity information (unnecessarily * as it happens since no reconstruction was @@ -1686,7 +1687,8 @@ reconstruct: code = vdev_raidz_reconstruct(rm, tgts, n); - if (raidz_checksum_verify(vd->spa, bp, data, bytes) == 0) { + rv = raidz_checksum_verify(vd->spa, bp, data, bytes); + if (rv == 0) { /* * If we read more parity disks than were used * for reconstruction, confirm that the other @@ -1761,7 +1763,7 @@ reconstruct: error = EIO; } else if (total_errors < rm->rm_firstdatacol && (code = vdev_raidz_combrec(vd->spa, rm, bp, data, offset, bytes, - total_errors, data_errors)) != 0) { + total_errors, data_errors)) != 0) { /* * If we didn't use all the available parity for the * combinatorial reconstruction, verify that the remaining diff --git a/usr/src/lib/smbsrv/libmlsvc/common/smb_share.c b/usr/src/lib/smbsrv/libmlsvc/common/smb_share.c index 3bdf29a480..5736113ed7 100644 --- a/usr/src/lib/smbsrv/libmlsvc/common/smb_share.c +++ b/usr/src/lib/smbsrv/libmlsvc/common/smb_share.c @@ -20,6 +20,7 @@ * * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2018 Nexenta Systems, Inc. All rights reserved. + * Copyright 2019 RackTop Systems. */ /* @@ -1360,6 +1361,8 @@ smb_shr_cache_create(void) break; } + (void) ht_set_cmpfn(smb_shr_cache.sc_cache, + (HT_CMP)smb_strcasecmp); (void) ht_register_callback(smb_shr_cache.sc_cache, smb_shr_cache_freent); smb_shr_cache.sc_nops = 0; @@ -1462,7 +1465,6 @@ smb_shr_cache_findent(char *sharename) { HT_ITEM *item; - (void) smb_strlwr(sharename); item = ht_find_item(smb_shr_cache.sc_cache, sharename); if (item && item->hi_data) return ((smb_share_t *)item->hi_data); @@ -1509,8 +1511,6 @@ smb_shr_cache_addent(smb_share_t *si) if ((cache_ent = malloc(sizeof (smb_share_t))) == NULL) return (ERROR_NOT_ENOUGH_MEMORY); - (void) smb_strlwr(si->shr_name); - si->shr_type |= smb_shr_is_special(cache_ent->shr_name); if (smb_shr_is_admin(cache_ent->shr_name)) @@ -1538,7 +1538,6 @@ smb_shr_cache_addent(smb_share_t *si) static void smb_shr_cache_delent(char *sharename) { - (void) smb_strlwr(sharename); (void) ht_remove_item(smb_shr_cache.sc_cache, sharename); } diff --git a/usr/src/pkg/manifests/system-test-zfstest.mf b/usr/src/pkg/manifests/system-test-zfstest.mf index ce24ece461..66fc12ff3a 100644 --- a/usr/src/pkg/manifests/system-test-zfstest.mf +++ b/usr/src/pkg/manifests/system-test-zfstest.mf @@ -3053,6 +3053,8 @@ file path=opt/zfs-tests/tests/functional/upgrade/upgrade_common.kshlib \ mode=0444 file path=opt/zfs-tests/tests/functional/upgrade/upgrade_projectquota_001_pos \ mode=0555 +file path=opt/zfs-tests/tests/functional/upgrade/upgrade_readonly_pool \ + mode=0555 file path=opt/zfs-tests/tests/functional/upgrade/upgrade_userobj_001_pos \ mode=0555 file path=opt/zfs-tests/tests/functional/userquota/cleanup mode=0555 diff --git a/usr/src/test/zfs-tests/runfiles/delphix.run b/usr/src/test/zfs-tests/runfiles/delphix.run index 10dc739321..14ce6e5bd9 100644 --- a/usr/src/test/zfs-tests/runfiles/delphix.run +++ b/usr/src/test/zfs-tests/runfiles/delphix.run @@ -672,7 +672,8 @@ tags = ['functional', 'trim'] tests = ['truncate_001_pos', 'truncate_002_pos'] [/opt/zfs-tests/tests/functional/upgrade] -tests = ['upgrade_userobj_001_pos', 'upgrade_projectquota_001_pos'] +tests = ['upgrade_userobj_001_pos', 'upgrade_projectquota_001_pos', + 'upgrade_readonly_pool'] [/opt/zfs-tests/tests/functional/userquota] tests = [ diff --git a/usr/src/test/zfs-tests/runfiles/omnios.run b/usr/src/test/zfs-tests/runfiles/omnios.run index 23ba1045e5..6c127881da 100644 --- a/usr/src/test/zfs-tests/runfiles/omnios.run +++ b/usr/src/test/zfs-tests/runfiles/omnios.run @@ -672,7 +672,8 @@ tags = ['functional', 'trim'] tests = ['truncate_001_pos', 'truncate_002_pos'] [/opt/zfs-tests/tests/functional/upgrade] -tests = ['upgrade_userobj_001_pos', 'upgrade_projectquota_001_pos'] +tests = ['upgrade_userobj_001_pos', 'upgrade_projectquota_001_pos', + 'upgrade_readonly_pool'] [/opt/zfs-tests/tests/functional/userquota] tests = [ diff --git a/usr/src/test/zfs-tests/runfiles/openindiana.run b/usr/src/test/zfs-tests/runfiles/openindiana.run index 0949df34ae..011529f8f1 100644 --- a/usr/src/test/zfs-tests/runfiles/openindiana.run +++ b/usr/src/test/zfs-tests/runfiles/openindiana.run @@ -672,7 +672,8 @@ tags = ['functional', 'trim'] tests = ['truncate_001_pos', 'truncate_002_pos'] [/opt/zfs-tests/tests/functional/upgrade] -tests = ['upgrade_userobj_001_pos', 'upgrade_projectquota_001_pos'] +tests = ['upgrade_userobj_001_pos', 'upgrade_projectquota_001_pos', + 'upgrade_readonly_pool'] [/opt/zfs-tests/tests/functional/userquota] tests = [ diff --git a/usr/src/test/zfs-tests/runfiles/smartos.run b/usr/src/test/zfs-tests/runfiles/smartos.run index 0716e9325a..e6bcd4d8d5 100644 --- a/usr/src/test/zfs-tests/runfiles/smartos.run +++ b/usr/src/test/zfs-tests/runfiles/smartos.run @@ -582,7 +582,8 @@ tags = ['functional', 'trim'] tests = ['truncate_001_pos', 'truncate_002_pos'] [/opt/zfs-tests/tests/functional/upgrade] -tests = ['upgrade_userobj_001_pos', 'upgrade_projectquota_001_pos'] +tests = ['upgrade_userobj_001_pos', 'upgrade_projectquota_001_pos', + 'upgrade_readonly_pool'] [/opt/zfs-tests/tests/functional/userquota] tests = [ diff --git a/usr/src/test/zfs-tests/tests/functional/upgrade/upgrade_readonly_pool.ksh b/usr/src/test/zfs-tests/tests/functional/upgrade/upgrade_readonly_pool.ksh new file mode 100755 index 0000000000..45ec3a932a --- /dev/null +++ b/usr/src/test/zfs-tests/tests/functional/upgrade/upgrade_readonly_pool.ksh @@ -0,0 +1,68 @@ +#!/bin/ksh -p +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2019, loli10K <ezomori.nozomu@gmail.com>. All rights reserved. +# Copyright 2019 Joyent, Inc. +# + +. $STF_SUITE/tests/functional/upgrade/upgrade_common.kshlib + +# +# DESCRIPTION: +# User accounting upgrade should not be executed on readonly pool +# +# STRATEGY: +# 1. Create a pool with the feature@userobj_accounting disabled to simulate +# a legacy pool from a previous ZFS version. +# 2. Create a file on the "legecy" dataset and store its checksum +# 3. Enable feature@userobj_accounting on the pool and verify it is only +# "enabled" and not "active": upgrading starts when the filesystem is mounted +# 4. Export the pool and re-import is readonly, without mounting any filesystem +# 5. Try to mount the root dataset manually without the "ro" option, then verify +# filesystem status and the pool feature status (not "active") to ensure the +# pool "readonly" status is enforced. +# + +verify_runnable "global" + +TESTFILE="$TESTDIR/file.bin" + +log_assert "User accounting upgrade should not be executed on readonly pool" +log_onexit cleanup_upgrade + +# 1. Create a pool with the feature@userobj_accounting disabled to simulate +# a legacy pool from a previous ZFS version. +log_must zpool create -d -m $TESTDIR $TESTPOOL $TMPDEV + +# 2. Create a file on the "legecy" dataset +log_must touch $TESTDIR/file.bin + +# 3. Enable feature@userobj_accounting on the pool and verify it is only +# "enabled" and not "active": upgrading starts when the filesystem is mounted +log_must zpool set feature@userobj_accounting=enabled $TESTPOOL +log_must test "enabled" == "$(get_pool_prop 'feature@userobj_accounting' $TESTPOOL)" + +# 4. Export the pool and re-import is readonly, without mounting any filesystem +log_must zfs set mountpoint=legacy $TESTPOOL +log_must zpool export $TESTPOOL +log_must zpool import -o readonly=on -N -d "$(dirname $TMPDEV)" $TESTPOOL + +# 5. Try to mount the root dataset manually without the "ro" option, then verify +# filesystem status and the pool feature status (not "active") to ensure the +# pool "readonly" status is enforced. +log_must mount -F zfs -o zfsutil $TESTPOOL $TESTDIR +log_must stat "$TESTFILE" +log_mustnot touch "$TESTFILE" +log_must test "enabled" == "$(get_pool_prop 'feature@userobj_accounting' $TESTPOOL)" + +log_pass "User accounting upgrade is not executed on readonly pool" diff --git a/usr/src/uts/common/fs/zfs/dmu_objset.c b/usr/src/uts/common/fs/zfs/dmu_objset.c index 3e11d73cad..fb75ef3630 100644 --- a/usr/src/uts/common/fs/zfs/dmu_objset.c +++ b/usr/src/uts/common/fs/zfs/dmu_objset.c @@ -2051,6 +2051,9 @@ dmu_objset_do_userquota_updates(objset_t *os, dmu_tx_t *tx) if (os->os_encrypted && dmu_objset_is_receiving(os)) return; + if (tx->tx_txg <= os->os_spa->spa_claim_max_txg) + return; + /* Allocate the user/group/project used objects if necessary. */ if (DMU_USERUSED_DNODE(os)->dn_type == DMU_OT_NONE) { VERIFY0(zap_create_claim(os, @@ -2390,7 +2393,8 @@ dmu_objset_projectquota_upgradable(objset_t *os) return (dmu_objset_type(os) == DMU_OST_ZFS && !dmu_objset_is_snapshot(os) && dmu_objset_projectquota_enabled(os) && - !dmu_objset_projectquota_present(os)); + !dmu_objset_projectquota_present(os) && + spa_writeable(dmu_objset_spa(os))); } void diff --git a/usr/src/uts/common/fs/zfs/sys/zfs_vfsops.h b/usr/src/uts/common/fs/zfs/sys/zfs_vfsops.h index 13be805ccd..199c8446ca 100644 --- a/usr/src/uts/common/fs/zfs/sys/zfs_vfsops.h +++ b/usr/src/uts/common/fs/zfs/sys/zfs_vfsops.h @@ -155,7 +155,7 @@ extern boolean_t zfs_id_overobjquota(zfsvfs_t *zfsvfs, uint64_t usedobj, extern boolean_t zfs_id_overquota(zfsvfs_t *zfsvfs, uint64_t usedobj, uint64_t id); extern int zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers); -extern int zfsvfs_create(const char *name, zfsvfs_t **zfvp); +extern int zfsvfs_create(const char *name, boolean_t readony, zfsvfs_t **zfvp); extern int zfsvfs_create_impl(zfsvfs_t **zfvp, zfsvfs_t *zfsvfs, objset_t *os); extern void zfsvfs_free(zfsvfs_t *zfsvfs); extern int zfs_check_global_label(const char *dsname, const char *hexsl); diff --git a/usr/src/uts/common/fs/zfs/zfs_ioctl.c b/usr/src/uts/common/fs/zfs/zfs_ioctl.c index 35aa9eb20e..72e18d5305 100644 --- a/usr/src/uts/common/fs/zfs/zfs_ioctl.c +++ b/usr/src/uts/common/fs/zfs/zfs_ioctl.c @@ -1494,7 +1494,7 @@ zfsvfs_hold(const char *name, void *tag, zfsvfs_t **zfvp, boolean_t writer) int error = 0; if (getzfsvfs(name, zfvp) != 0) - error = zfsvfs_create(name, zfvp); + error = zfsvfs_create(name, B_FALSE, zfvp); if (error == 0) { rrm_enter(&(*zfvp)->z_teardown_lock, (writer) ? RW_WRITER : RW_READER, tag); diff --git a/usr/src/uts/common/fs/zfs/zfs_vfsops.c b/usr/src/uts/common/fs/zfs/zfs_vfsops.c index 571df521d4..6ee003101a 100644 --- a/usr/src/uts/common/fs/zfs/zfs_vfsops.c +++ b/usr/src/uts/common/fs/zfs/zfs_vfsops.c @@ -1153,12 +1153,12 @@ zfsvfs_init(zfsvfs_t *zfsvfs, objset_t *os) } int -zfsvfs_create(const char *osname, zfsvfs_t **zfvp) +zfsvfs_create(const char *osname, boolean_t readonly, zfsvfs_t **zfvp) { objset_t *os; zfsvfs_t *zfsvfs; int error; - boolean_t ro = (strchr(osname, '@') != NULL); + boolean_t ro = (readonly || (strchr(osname, '@') != NULL)); zfsvfs = kmem_zalloc(sizeof (zfsvfs_t), KM_SLEEP); @@ -1346,11 +1346,12 @@ zfs_domount(vfs_t *vfsp, char *osname) uint64_t recordsize, fsid_guid; int error = 0; zfsvfs_t *zfsvfs; + boolean_t readonly = vfsp->vfs_flag & VFS_RDONLY ? B_TRUE : B_FALSE; ASSERT(vfsp); ASSERT(osname); - error = zfsvfs_create(osname, &zfsvfs); + error = zfsvfs_create(osname, readonly, &zfsvfs); if (error) return (error); zfsvfs->z_vfs = vfsp; @@ -2228,7 +2229,7 @@ zfs_vget(vfs_t *vfsp, vnode_t **vpp, fid_t *fidp) uint64_t fid_gen = 0; uint64_t gen_mask; uint64_t zp_gen; - int i, err; + int i, err; *vpp = NULL; diff --git a/usr/src/uts/common/fs/zfs/zvol.c b/usr/src/uts/common/fs/zfs/zvol.c index 1e8db36b0e..7706747f9e 100644 --- a/usr/src/uts/common/fs/zfs/zvol.c +++ b/usr/src/uts/common/fs/zfs/zvol.c @@ -632,16 +632,16 @@ zvol_remove_minor(const char *name) } int -zvol_first_open(zvol_state_t *zv) +zvol_first_open(zvol_state_t *zv, boolean_t rdonly) { objset_t *os; uint64_t volsize; int error; uint64_t readonly; + boolean_t ro; - /* lie and say we're read-only */ - error = dmu_objset_own(zv->zv_name, DMU_OST_ZVOL, B_TRUE, B_TRUE, - zvol_tag, &os); + ro = (rdonly || (strchr(zv->zv_name, '@') != NULL)); + error = dmu_objset_own(zv->zv_name, DMU_OST_ZVOL, ro, B_TRUE, zv, &os); if (error) return (error); @@ -907,17 +907,13 @@ zvol_open(dev_t *devp, int flag, int otyp, cred_t *cr) } if (zv->zv_total_opens == 0) - err = zvol_first_open(zv); + err = zvol_first_open(zv, !(flag & FWRITE)); if (err) { mutex_exit(&zfsdev_state_lock); return (err); } - /* - * Check for a bad on-disk format version now since we - * lied about owning the dataset readonly before. - */ - if ((flag & FWRITE) && ((zv->zv_flags & ZVOL_RDONLY) || - dmu_objset_incompatible_encryption_version(zv->zv_objset))) { + + if ((flag & FWRITE) && (zv->zv_flags & ZVOL_RDONLY)) { err = SET_ERROR(EROFS); goto out; } |