Print this page
NEX-15279 support NFS server in zone
NEX-15520 online NFS shares cause zoneadm halt to hang in nfs_export_zone_fini
Portions contributed by: Dan Kruchinin dan.kruchinin@nexenta.com
Portions contributed by: Stepan Zastupov stepan.zastupov@gmail.com
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
NEX-1704 Clustered NFSv4 could cause I/O errors on clients after failover
Reviewed by:  Evan Layton <evan.layton@nexenta.com>
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
NEX-4122 All kernel messages seem to come from 'genunix' instead of individual modules after illumos #5272
Reviewed by: Hans Rosenfeld <hans.rosenfeld@nexenta.com>
Reviewed by: Marcel Telka <marcel.telka@nexenta.com>
NEX-4036 Unable to enable the nfs/server service when nothing is shared
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>


   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License (the "License").
   7 # You may not use this file except in compliance with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 
  23 #
  24 # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  25 # Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  26 # Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>

  27 #
  28 
  29 # Start/stop processes required for server NFS
  30 
  31 . /lib/svc/share/smf_include.sh
  32 . /lib/svc/share/ipf_include.sh
  33 zone=`smf_zonename`
  34 
  35 #
  36 # Handling a corner case here. If we were in offline state due to an
  37 # unsatisfied dependency, the ipf_method process wouldn't have generated
  38 # the ipfilter configuration. When we transition to online because the
  39 # dependency is satisfied, the start method will have to generate the
  40 # ipfilter configuration. To avoid all possible deadlock scenarios,
  41 # we restart ipfilter which will regenerate the ipfilter configuration
  42 # for the entire system.
  43 #
  44 # The ipf_method process signals that it didn't generate ipf rules by
  45 # removing the service's ipf file. Thus we only restart network/ipfilter
  46 # when the file is missing.


  49 {
  50         ipfile=`fmri_to_file $SMF_FMRI $IPF_SUFFIX`
  51         ip6file=`fmri_to_file $SMF_FMRI $IPF6_SUFFIX`
  52         [ -f "$ipfile" -a -f "$ip6file" ] && return 0
  53 
  54         #
  55         # Nothing to do if:
  56         # - ipfilter isn't online 
  57         # - global policy is 'custom'
  58         # - service's policy is 'use_global'
  59         #
  60         service_check_state $IPF_FMRI $SMF_ONLINE || return 0
  61         [ "`get_global_def_policy`" = "custom" ] && return 0
  62         [ "`get_policy $SMF_FMRI`" = "use_global" ] && return 0
  63 
  64         svcadm restart $IPF_FMRI
  65 }
  66 
  67 case "$1" in
  68 'start')
  69         # The NFS server is not supported in a local zone
  70         if smf_is_nonglobalzone; then
  71                 /usr/sbin/svcadm disable -t svc:/network/nfs/server
  72                 echo "The NFS server is not supported in a local zone"
  73                 sleep 5 &
  74                 exit $SMF_EXIT_OK
  75         fi
  76 
  77         # Share all file systems enabled for sharing. sharemgr understands
  78         # regular shares and ZFS shares and will handle both. Technically,
  79         # the shares would have been started long before getting here since
  80         # nfsd has a dependency on them.
  81 
  82         # restart stopped shares from the repository
  83         /usr/sbin/sharemgr start -P nfs -a
  84 
  85         # Options for nfsd are now set in SMF
  86 
  87         /usr/lib/nfs/mountd
  88         rc=$?
  89         if [ $rc != 0 ]; then
  90                 /usr/sbin/svcadm mark -t maintenance svc:/network/nfs/server
  91                 echo "$0: mountd failed with $rc"
  92                 sleep 5 &
  93                 exit $SMF_EXIT_ERR_FATAL
  94         fi
  95 
  96         /usr/lib/nfs/nfsd






















  97         rc=$?
  98         if [ $rc != 0 ]; then
  99                 /usr/sbin/svcadm mark -t maintenance svc:/network/nfs/server
 100                 echo "$0: nfsd failed with $rc"
 101                 sleep 5 &
 102                 exit $SMF_EXIT_ERR_FATAL
 103         fi
 104 
 105         configure_ipfilter
 106         ;;
 107 
 108 'refresh')
 109         /usr/sbin/sharemgr start -P nfs -a
 110         ;;
 111 
 112 'stop')
 113         /usr/bin/pkill -x -u 0,1 -z $zone '(nfsd|mountd)'
 114 
 115         # Unshare all shared file systems using NFS
 116 




   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License (the "License").
   7 # You may not use this file except in compliance with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 
  23 #
  24 # Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.

  25 # Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
  26 # Copyright 2018 Nexenta Systems, Inc.
  27 #
  28 
  29 # Start/stop processes required for server NFS
  30 
  31 . /lib/svc/share/smf_include.sh
  32 . /lib/svc/share/ipf_include.sh
  33 zone=`smf_zonename`
  34 
  35 #
  36 # Handling a corner case here. If we were in offline state due to an
  37 # unsatisfied dependency, the ipf_method process wouldn't have generated
  38 # the ipfilter configuration. When we transition to online because the
  39 # dependency is satisfied, the start method will have to generate the
  40 # ipfilter configuration. To avoid all possible deadlock scenarios,
  41 # we restart ipfilter which will regenerate the ipfilter configuration
  42 # for the entire system.
  43 #
  44 # The ipf_method process signals that it didn't generate ipf rules by
  45 # removing the service's ipf file. Thus we only restart network/ipfilter
  46 # when the file is missing.


  49 {
  50         ipfile=`fmri_to_file $SMF_FMRI $IPF_SUFFIX`
  51         ip6file=`fmri_to_file $SMF_FMRI $IPF6_SUFFIX`
  52         [ -f "$ipfile" -a -f "$ip6file" ] && return 0
  53 
  54         #
  55         # Nothing to do if:
  56         # - ipfilter isn't online 
  57         # - global policy is 'custom'
  58         # - service's policy is 'use_global'
  59         #
  60         service_check_state $IPF_FMRI $SMF_ONLINE || return 0
  61         [ "`get_global_def_policy`" = "custom" ] && return 0
  62         [ "`get_policy $SMF_FMRI`" = "use_global" ] && return 0
  63 
  64         svcadm restart $IPF_FMRI
  65 }
  66 
  67 case "$1" in
  68 'start')








  69         # Share all file systems enabled for sharing. sharemgr understands
  70         # regular shares and ZFS shares and will handle both. Technically,
  71         # the shares would have been started long before getting here since
  72         # nfsd has a dependency on them.
  73 
  74         # restart stopped shares from the repository
  75         /usr/sbin/sharemgr start -P nfs -a
  76 
  77         # Options for nfsd are now set in SMF
  78 
  79         /usr/lib/nfs/mountd
  80         rc=$?
  81         if [ $rc != 0 ]; then
  82                 /usr/sbin/svcadm mark -t maintenance svc:/network/nfs/server
  83                 echo "$0: mountd failed with $rc"
  84                 sleep 5 &
  85                 exit $SMF_EXIT_ERR_FATAL
  86         fi
  87 
  88         NFS_OPTS=
  89         if [ -f /opt/HAC/bin/rsf.sh ]; then
  90                 . /opt/HAC/bin/rsf.sh
  91 
  92                 if [ -f "$PRODUCT_CONFIG" ]; then
  93                         RSF_MNTS=$(/usr/bin/grep MOUNT_POINT "$PRODUCT_CONFIG" |\
  94                             /usr/bin/sed -e 's/^.*MOUNT_POINT.*\"\(.*\)\"$/\1/')
  95 
  96                         for RSF_MNT in $RSF_MNTS; do
  97                                 MATCH=$(/usr/bin/cat /etc/mnttab |\
  98                                     /usr/bin/awk '{print $2}' |\
  99                                     /usr/bin/egrep "^$RSF_MNT\$")
 100 
 101                                 if [ -n "$MATCH" ]; then
 102                                         /usr/bin/mkdir -p "$RSF_MNT/.nfs"
 103                                         /usr/bin/chown daemon:daemon "$RSF_MNT/.nfs"
 104                                         NFS_OPTS="$NFS_OPTS -s $RSF_MNT/.nfs"
 105                                 fi
 106                         done
 107                 fi
 108         fi
 109 
 110         /usr/lib/nfs/nfsd $NFS_OPTS
 111         rc=$?
 112         if [ $rc != 0 ]; then
 113                 /usr/sbin/svcadm mark -t maintenance svc:/network/nfs/server
 114                 echo "$0: nfsd failed with $rc"
 115                 sleep 5 &
 116                 exit $SMF_EXIT_ERR_FATAL
 117         fi
 118 
 119         configure_ipfilter
 120         ;;
 121 
 122 'refresh')
 123         /usr/sbin/sharemgr start -P nfs -a
 124         ;;
 125 
 126 'stop')
 127         /usr/bin/pkill -x -u 0,1 -z $zone '(nfsd|mountd)'
 128 
 129         # Unshare all shared file systems using NFS
 130