Print this page
OS-1987 disks in zpools never go away when pulled


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   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  * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
  24  * Copyright 2012 Garrett D'Amore <garrett@damore.org>.  All rights reserved.

  25  */
  26 
  27 #include <sys/note.h>
  28 #include <sys/t_lock.h>
  29 #include <sys/cmn_err.h>
  30 #include <sys/instance.h>
  31 #include <sys/conf.h>
  32 #include <sys/stat.h>
  33 #include <sys/ddi.h>
  34 #include <sys/hwconf.h>
  35 #include <sys/sunddi.h>
  36 #include <sys/sunndi.h>
  37 #include <sys/ddi_impldefs.h>
  38 #include <sys/ndi_impldefs.h>
  39 #include <sys/modctl.h>
  40 #include <sys/contract/device_impl.h>
  41 #include <sys/dacf.h>
  42 #include <sys/promif.h>
  43 #include <sys/pci.h>
  44 #include <sys/cpuvar.h>


5873          * Invoke notify if offlining
5874          */
5875         if (flags & NDI_DEVI_OFFLINE) {
5876                 RIO_DEBUG((CE_NOTE, "devi_detach_node: offlining dip=%p",
5877                     (void *)dip));
5878                 if (e_ddi_offline_notify(dip) != DDI_SUCCESS) {
5879                         RIO_DEBUG((CE_NOTE, "devi_detach_node: offline NACKed"
5880                             "dip=%p", (void *)dip));
5881                         return (NDI_FAILURE);
5882                 }
5883         }
5884 
5885         if (flags & NDI_POST_EVENT) {
5886                 if (i_ddi_devi_attached(pdip)) {
5887                         if (ddi_get_eventcookie(dip, DDI_DEVI_REMOVE_EVENT,
5888                             &cookie) == NDI_SUCCESS)
5889                                 (void) ndi_post_event(dip, dip, cookie, NULL);
5890                 }
5891         }
5892 







5893         if (i_ddi_detachchild(dip, flags) != DDI_SUCCESS) {
5894                 if (flags & NDI_DEVI_OFFLINE) {
5895                         RIO_DEBUG((CE_NOTE, "devi_detach_node: offline failed."
5896                             " Calling e_ddi_offline_finalize with result=%d. "
5897                             "dip=%p", DDI_FAILURE, (void *)dip));
5898                         e_ddi_offline_finalize(dip, DDI_FAILURE);
5899                 }
5900                 return (NDI_FAILURE);
5901         }
5902 
5903         if (flags & NDI_DEVI_OFFLINE) {
5904                 RIO_DEBUG((CE_NOTE, "devi_detach_node: offline succeeded."
5905                     " Calling e_ddi_offline_finalize with result=%d, "
5906                     "dip=%p", DDI_SUCCESS, (void *)dip));
5907                 e_ddi_offline_finalize(dip, DDI_SUCCESS);
5908         }
5909 
5910         if (flags & NDI_AUTODETACH)
5911                 return (NDI_SUCCESS);
5912 




   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   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  * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
  24  * Copyright 2012 Garrett D'Amore <garrett@damore.org>.  All rights reserved.
  25  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
  26  */
  27 
  28 #include <sys/note.h>
  29 #include <sys/t_lock.h>
  30 #include <sys/cmn_err.h>
  31 #include <sys/instance.h>
  32 #include <sys/conf.h>
  33 #include <sys/stat.h>
  34 #include <sys/ddi.h>
  35 #include <sys/hwconf.h>
  36 #include <sys/sunddi.h>
  37 #include <sys/sunndi.h>
  38 #include <sys/ddi_impldefs.h>
  39 #include <sys/ndi_impldefs.h>
  40 #include <sys/modctl.h>
  41 #include <sys/contract/device_impl.h>
  42 #include <sys/dacf.h>
  43 #include <sys/promif.h>
  44 #include <sys/pci.h>
  45 #include <sys/cpuvar.h>


5874          * Invoke notify if offlining
5875          */
5876         if (flags & NDI_DEVI_OFFLINE) {
5877                 RIO_DEBUG((CE_NOTE, "devi_detach_node: offlining dip=%p",
5878                     (void *)dip));
5879                 if (e_ddi_offline_notify(dip) != DDI_SUCCESS) {
5880                         RIO_DEBUG((CE_NOTE, "devi_detach_node: offline NACKed"
5881                             "dip=%p", (void *)dip));
5882                         return (NDI_FAILURE);
5883                 }
5884         }
5885 
5886         if (flags & NDI_POST_EVENT) {
5887                 if (i_ddi_devi_attached(pdip)) {
5888                         if (ddi_get_eventcookie(dip, DDI_DEVI_REMOVE_EVENT,
5889                             &cookie) == NDI_SUCCESS)
5890                                 (void) ndi_post_event(dip, dip, cookie, NULL);
5891                 }
5892         }
5893 
5894         /*
5895          * dv_mknod places a hold on the dev_info_t for each devfs node
5896          * created.  If we're to succeed in detaching this device, we must
5897          * first release all outstanding references held by devfs.
5898          */
5899         (void) devfs_clean(pdip, NULL, DV_CLEAN_FORCE);
5900 
5901         if (i_ddi_detachchild(dip, flags) != DDI_SUCCESS) {
5902                 if (flags & NDI_DEVI_OFFLINE) {
5903                         RIO_DEBUG((CE_NOTE, "devi_detach_node: offline failed."
5904                             " Calling e_ddi_offline_finalize with result=%d. "
5905                             "dip=%p", DDI_FAILURE, (void *)dip));
5906                         e_ddi_offline_finalize(dip, DDI_FAILURE);
5907                 }
5908                 return (NDI_FAILURE);
5909         }
5910 
5911         if (flags & NDI_DEVI_OFFLINE) {
5912                 RIO_DEBUG((CE_NOTE, "devi_detach_node: offline succeeded."
5913                     " Calling e_ddi_offline_finalize with result=%d, "
5914                     "dip=%p", DDI_SUCCESS, (void *)dip));
5915                 e_ddi_offline_finalize(dip, DDI_SUCCESS);
5916         }
5917 
5918         if (flags & NDI_AUTODETACH)
5919                 return (NDI_SUCCESS);
5920