1#!/bin/ksh -p 2# 3# This file and its contents are supplied under the terms of the 4# Common Development and Distribution License ("CDDL"), version 1.0. 5# You may only use this file in accordance with the terms of version 6# 1.0 of the CDDL. 7# 8# A full copy of the text of the CDDL should have accompanied this 9# source. A copy of the CDDL is also available via the Internet at 10# http://www.illumos.org/license/CDDL. 11# 12 13# 14# Copyright 2019, loli10K <ezomori.nozomu@gmail.com>. All rights reserved. 15# Copyright 2019 Joyent, Inc. 16# 17 18. $STF_SUITE/tests/functional/upgrade/upgrade_common.kshlib 19 20# 21# DESCRIPTION: 22# User accounting upgrade should not be executed on readonly pool 23# 24# STRATEGY: 25# 1. Create a pool with the feature@userobj_accounting disabled to simulate 26# a legacy pool from a previous ZFS version. 27# 2. Create a file on the "legecy" dataset and store its checksum 28# 3. Enable feature@userobj_accounting on the pool and verify it is only 29# "enabled" and not "active": upgrading starts when the filesystem is mounted 30# 4. Export the pool and re-import is readonly, without mounting any filesystem 31# 5. Try to mount the root dataset manually without the "ro" option, then verify 32# filesystem status and the pool feature status (not "active") to ensure the 33# pool "readonly" status is enforced. 34# 35 36verify_runnable "global" 37 38TESTFILE="$TESTDIR/file.bin" 39 40log_assert "User accounting upgrade should not be executed on readonly pool" 41log_onexit cleanup_upgrade 42 43# 1. Create a pool with the feature@userobj_accounting disabled to simulate 44# a legacy pool from a previous ZFS version. 45log_must zpool create -d -m $TESTDIR $TESTPOOL $TMPDEV 46 47# 2. Create a file on the "legecy" dataset 48log_must touch $TESTDIR/file.bin 49 50# 3. Enable feature@userobj_accounting on the pool and verify it is only 51# "enabled" and not "active": upgrading starts when the filesystem is mounted 52log_must zpool set feature@userobj_accounting=enabled $TESTPOOL 53log_must test "enabled" == "$(get_pool_prop 'feature@userobj_accounting' $TESTPOOL)" 54 55# 4. Export the pool and re-import is readonly, without mounting any filesystem 56log_must zfs set mountpoint=legacy $TESTPOOL 57log_must zpool export $TESTPOOL 58log_must zpool import -o readonly=on -N -d "$(dirname $TMPDEV)" $TESTPOOL 59 60# 5. Try to mount the root dataset manually without the "ro" option, then verify 61# filesystem status and the pool feature status (not "active") to ensure the 62# pool "readonly" status is enforced. 63log_must mount -F zfs -o zfsutil $TESTPOOL $TESTDIR 64log_must stat "$TESTFILE" 65log_mustnot touch "$TESTFILE" 66log_must test "enabled" == "$(get_pool_prop 'feature@userobj_accounting' $TESTPOOL)" 67 68log_pass "User accounting upgrade is not executed on readonly pool" 69