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# 16 17. $STF_SUITE/tests/functional/upgrade/upgrade_common.kshlib 18 19# 20# DESCRIPTION: 21# User accounting upgrade should not be executed on readonly pool 22# 23# STRATEGY: 24# 1. Create a pool with the feature@userobj_accounting disabled to simulate 25# a legacy pool from a previous ZFS version. 26# 2. Create a file on the "legecy" dataset and store its checksum 27# 3. Enable feature@userobj_accounting on the pool and verify it is only 28# "enabled" and not "active": upgrading starts when the filesystem is mounted 29# 4. Export the pool and re-import is readonly, without mounting any filesystem 30# 5. Try to mount the root dataset manually without the "ro" option, then verify 31# filesystem status and the pool feature status (not "active") to ensure the 32# pool "readonly" status is enforced. 33# 34 35verify_runnable "global" 36 37TESTFILE="$TESTDIR/file.bin" 38 39log_assert "User accounting upgrade should not be executed on readonly pool" 40log_onexit cleanup_upgrade 41 42# 1. Create a pool with the feature@userobj_accounting disabled to simulate 43# a legacy pool from a previous ZFS version. 44log_must zpool create -d -m $TESTDIR $TESTPOOL $TMPDEV 45 46# 2. Create a file on the "legecy" dataset 47log_must touch $TESTDIR/file.bin 48 49# 3. Enable feature@userobj_accounting on the pool and verify it is only 50# "enabled" and not "active": upgrading starts when the filesystem is mounted 51log_must zpool set feature@userobj_accounting=enabled $TESTPOOL 52log_must test "enabled" == "$(get_pool_prop 'feature@userobj_accounting' $TESTPOOL)" 53 54# 4. Export the pool and re-import is readonly, without mounting any filesystem 55log_must zpool export $TESTPOOL 56log_must zpool import -o readonly=on -N -d "$(dirname $TMPDEV)" $TESTPOOL 57 58# 5. Try to mount the root dataset manually without the "ro" option, then verify 59# filesystem status and the pool feature status (not "active") to ensure the 60# pool "readonly" status is enforced. 61log_must mount -t zfs -o zfsutil $TESTPOOL $TESTDIR 62log_must stat "$TESTFILE" 63log_mustnot touch "$TESTFILE" 64log_must test "enabled" == "$(get_pool_prop 'feature@userobj_accounting' $TESTPOOL)" 65 66log_pass "User accounting upgrade is not executed on readonly pool" 67