Print this page
8115 parallel zfs mount


   8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 
  22 #
  23 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 
  27 #
  28 # Copyright (c) 2016 by Delphix. All rights reserved.
  29 #
  30 
  31 . $STF_SUITE/include/libtest.shlib
  32 . $STF_SUITE/tests/functional/cli_root/zfs_mount/zfs_mount.cfg
  33 
  34 function force_unmount #dev
  35 {
  36         typeset dev=$1
  37 
  38         ismounted $dev
  39         if (( $? == 0 )); then
  40                 log_must zfs $unmountforce $dev
  41         fi
  42         return 0
  43 }
  44 
  45 # Create pool and  ( fs | container | vol ) with the given parameters,
  46 # it'll destroy prior exist one that has the same name.
  47 
  48 function setup_filesystem #disklist #pool #fs #mntpoint #type #vdev


  67         if [[ $vdev != "" && \
  68                 $vdev != "mirror" && \
  69                 $vdev != "raidz" ]] ; then
  70 
  71                 log_note "Wrong vdev: (\"$vdev\")"
  72                 return 1
  73         fi
  74 
  75         poolexists $pool || \
  76                 create_pool $pool $vdev $disklist
  77 
  78         datasetexists $pool/$fs && \
  79                 log_must cleanup_filesystem $pool $fs
  80 
  81         rmdir $mntpoint > /dev/null 2>&1
  82         if [[ ! -d $mntpoint ]]; then
  83                 log_must mkdir -p $mntpoint
  84         fi
  85 
  86         case "$type" in
  87                 'ctr')  log_must zfs create $pool/$fs
  88                         log_must zfs set mountpoint=$mntpoint $pool/$fs
  89                         ;;
  90                 'vol')  log_must zfs create -V $VOLSIZE $pool/$fs
  91                         ;;
  92                 *)      log_must zfs create $pool/$fs
  93                         log_must zfs set mountpoint=$mntpoint $pool/$fs
  94                         ;;
  95         esac
  96 
  97         return 0
  98 }
  99 
 100 # Destroy ( fs | container | vol ) with the given parameters.
 101 function cleanup_filesystem #pool #fs
 102 {
 103         typeset pool=$1
 104         typeset fs=${2##/}
 105         typeset mtpt=""
 106 
 107         if [[ -z $pool || -z $fs ]]; then
 108                 log_note "Missing parameter: (\"$pool\", \"$fs\")"
 109                 return 1
 110         fi
 111 
 112         if datasetexists "$pool/$fs" ; then
 113                 mtpt=$(get_prop mountpoint "$pool/$fs")




   8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 
  22 #
  23 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 
  27 #
  28 # Copyright (c) 2017 by Delphix. All rights reserved.
  29 #
  30 
  31 . $STF_SUITE/include/libtest.shlib
  32 . $STF_SUITE/tests/functional/cli_root/zfs_mount/zfs_mount.cfg
  33 
  34 function force_unmount #dev
  35 {
  36         typeset dev=$1
  37 
  38         ismounted $dev
  39         if (( $? == 0 )); then
  40                 log_must zfs $unmountforce $dev
  41         fi
  42         return 0
  43 }
  44 
  45 # Create pool and  ( fs | container | vol ) with the given parameters,
  46 # it'll destroy prior exist one that has the same name.
  47 
  48 function setup_filesystem #disklist #pool #fs #mntpoint #type #vdev


  67         if [[ $vdev != "" && \
  68                 $vdev != "mirror" && \
  69                 $vdev != "raidz" ]] ; then
  70 
  71                 log_note "Wrong vdev: (\"$vdev\")"
  72                 return 1
  73         fi
  74 
  75         poolexists $pool || \
  76                 create_pool $pool $vdev $disklist
  77 
  78         datasetexists $pool/$fs && \
  79                 log_must cleanup_filesystem $pool $fs
  80 
  81         rmdir $mntpoint > /dev/null 2>&1
  82         if [[ ! -d $mntpoint ]]; then
  83                 log_must mkdir -p $mntpoint
  84         fi
  85 
  86         case "$type" in
  87                 'ctr')  log_must zfs create -o mountpoint=$mntpoint $pool/$fs

  88                         ;;
  89                 'vol')  log_must zfs create -V $VOLSIZE $pool/$fs
  90                         ;;
  91                 *)      log_must zfs create -o mountpoint=$mntpoint $pool/$fs

  92                         ;;
  93         esac
  94 
  95         return 0
  96 }
  97 
  98 # Destroy ( fs | container | vol ) with the given parameters.
  99 function cleanup_filesystem #pool #fs
 100 {
 101         typeset pool=$1
 102         typeset fs=${2##/}
 103         typeset mtpt=""
 104 
 105         if [[ -z $pool || -z $fs ]]; then
 106                 log_note "Missing parameter: (\"$pool\", \"$fs\")"
 107                 return 1
 108         fi
 109 
 110         if datasetexists "$pool/$fs" ; then
 111                 mtpt=$(get_prop mountpoint "$pool/$fs")