From 8479169dd015f1e96a0b4d52bf15bcdf2f86476a Mon Sep 17 00:00:00 2001 From: Alex Deiter Date: Fri, 26 Aug 2016 16:48:17 +0000 Subject: [PATCH] 7291 Attempting to destroy ZFS filesystem and create ZFS volume with the same name caused system panic Reviewed by: Sanjay Nadkarni Reviewed by: Saso Kiselkov Reviewed by: Roman Strashkin Reviewed by: Alek Pinchuk --- usr/src/pkg/manifests/system-test-zfstest.mf | 2 + usr/src/test/zfs-tests/runfiles/delphix.run | 3 +- usr/src/test/zfs-tests/runfiles/omnios.run | 3 +- .../test/zfs-tests/runfiles/openindiana.run | 3 +- .../zvol/zvol_misc/zvol_misc_007_pos.ksh | 47 +++++++++++++++++++ usr/src/uts/common/fs/dev/sdev_subr.c | 4 ++ 6 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 usr/src/test/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_007_pos.ksh diff --git a/usr/src/pkg/manifests/system-test-zfstest.mf b/usr/src/pkg/manifests/system-test-zfstest.mf index 114e9108dff8..b70e1941654c 100644 --- a/usr/src/pkg/manifests/system-test-zfstest.mf +++ b/usr/src/pkg/manifests/system-test-zfstest.mf @@ -2275,6 +2275,8 @@ file path=opt/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_005_neg \ mode=0555 file path=opt/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_006_pos \ mode=0555 +file path=opt/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_007_pos \ + mode=0555 file path=opt/zfs-tests/tests/functional/zvol/zvol_swap/cleanup mode=0555 file path=opt/zfs-tests/tests/functional/zvol/zvol_swap/setup mode=0555 file path=opt/zfs-tests/tests/functional/zvol/zvol_swap/zvol_swap.cfg \ diff --git a/usr/src/test/zfs-tests/runfiles/delphix.run b/usr/src/test/zfs-tests/runfiles/delphix.run index a2f1b2c4b2ad..01114ed5a7fa 100644 --- a/usr/src/test/zfs-tests/runfiles/delphix.run +++ b/usr/src/test/zfs-tests/runfiles/delphix.run @@ -560,7 +560,8 @@ tests = ['zvol_cli_001_pos', 'zvol_cli_002_pos', 'zvol_cli_003_neg'] [/opt/zfs-tests/tests/functional/zvol/zvol_misc] tests = ['zvol_misc_001_neg', 'zvol_misc_002_pos', 'zvol_misc_003_neg', - 'zvol_misc_004_pos', 'zvol_misc_005_neg', 'zvol_misc_006_pos'] + 'zvol_misc_004_pos', 'zvol_misc_005_neg', 'zvol_misc_006_pos', + 'zvol_misc_007_pos'] [/opt/zfs-tests/tests/functional/libzfs] tests = ['many_fds'] diff --git a/usr/src/test/zfs-tests/runfiles/omnios.run b/usr/src/test/zfs-tests/runfiles/omnios.run index 3982dd6ba80e..d8090880bbd6 100644 --- a/usr/src/test/zfs-tests/runfiles/omnios.run +++ b/usr/src/test/zfs-tests/runfiles/omnios.run @@ -556,7 +556,8 @@ tests = ['zvol_cli_001_pos', 'zvol_cli_002_pos', 'zvol_cli_003_neg'] [/opt/zfs-tests/tests/functional/zvol/zvol_misc] tests = ['zvol_misc_001_neg', 'zvol_misc_002_pos', 'zvol_misc_003_neg', - 'zvol_misc_004_pos', 'zvol_misc_005_neg', 'zvol_misc_006_pos'] + 'zvol_misc_004_pos', 'zvol_misc_005_neg', 'zvol_misc_006_pos', + 'zvol_misc_007_pos'] [/opt/zfs-tests/tests/functional/zvol/zvol_swap] tests = ['zvol_swap_001_pos', 'zvol_swap_002_pos', 'zvol_swap_003_pos', diff --git a/usr/src/test/zfs-tests/runfiles/openindiana.run b/usr/src/test/zfs-tests/runfiles/openindiana.run index 01a30c8c06e8..0bd3c27947fa 100644 --- a/usr/src/test/zfs-tests/runfiles/openindiana.run +++ b/usr/src/test/zfs-tests/runfiles/openindiana.run @@ -556,7 +556,8 @@ tests = ['zvol_cli_001_pos', 'zvol_cli_002_pos', 'zvol_cli_003_neg'] [/opt/zfs-tests/tests/functional/zvol/zvol_misc] tests = ['zvol_misc_001_neg', 'zvol_misc_002_pos', 'zvol_misc_003_neg', - 'zvol_misc_004_pos', 'zvol_misc_005_neg', 'zvol_misc_006_pos'] + 'zvol_misc_004_pos', 'zvol_misc_005_neg', 'zvol_misc_006_pos', + 'zvol_misc_007_pos'] [/opt/zfs-tests/tests/functional/zvol/zvol_swap] tests = ['zvol_swap_001_pos', 'zvol_swap_002_pos', 'zvol_swap_003_pos', diff --git a/usr/src/test/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_007_pos.ksh b/usr/src/test/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_007_pos.ksh new file mode 100644 index 000000000000..f042f73c3aee --- /dev/null +++ b/usr/src/test/zfs-tests/tests/functional/zvol/zvol_misc/zvol_misc_007_pos.ksh @@ -0,0 +1,47 @@ +#! /usr/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 2016 Nexenta Systems, Inc. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/zvol/zvol_common.shlib + +# +# DESCRIPTION: +# Verify name collision occurs when an attempt to destroy ZFS filesystem +# and create ZFS volume with the same name cannot cause system panic +# +# STRATEGY: +# 1. Create ZFS filesystems +# 2. Create nested ZFS volume +# 3. Read and displays information about the ZFS volume +# 4. Recursive destroy ZFS filesystems +# 5. Create ZFS volume with the same name as ZFS filesystem +# 6. Read and displays information about the ZFS volume +# 7. Verify the system continued work +# + +verify_runnable "global" +log_assert "zfs can handle race volume create operation." +log_onexit cleanup + +log_must $ZFS create $TESTPOOL/$TESTFS +log_must $ZFS create -V 1M $TESTPOOL/$TESTFS/$TESTVOL +log_must $STAT /dev/zvol/rdsk/$TESTPOOL/$TESTFS/$TESTVOL +log_must $ZFS destroy -r $TESTPOOL/$TESTFS +log_must $ZFS create -V 1M $TESTPOOL/$TESTFS +log_must $STAT /dev/zvol/rdsk/$TESTPOOL/$TESTFS + +log_pass "zfs handle race volume create operation." diff --git a/usr/src/uts/common/fs/dev/sdev_subr.c b/usr/src/uts/common/fs/dev/sdev_subr.c index 9234cc4a0c1e..69d81080db54 100644 --- a/usr/src/uts/common/fs/dev/sdev_subr.c +++ b/usr/src/uts/common/fs/dev/sdev_subr.c @@ -2170,6 +2170,10 @@ devname_lookup_func(struct sdev_node *ddv, char *nm, struct vnode **vpp, rw_exit(&ddv->sdev_contents); rw_enter(&ddv->sdev_contents, RW_WRITER); } + + if (SDEVTOV(dv)->v_type == VDIR) + (void) sdev_cleandir(dv, NULL, SDEV_ENFORCE); + sdev_cache_update(ddv, &dv, nm, SDEV_CACHE_DELETE); rw_downgrade(&ddv->sdev_contents); SDEV_RELE(dv);