Print this page
9702 HBA drivers don't need the redundant devfs_clean step
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas.c
          +++ new/usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas.c
↓ open down ↓ 94 lines elided ↑ open up ↑
  95   95   * private header files.
  96   96   *
  97   97   */
  98   98  #include <sys/scsi/impl/scsi_reset_notify.h>
  99   99  #include <sys/scsi/adapters/mpt_sas/mptsas_var.h>
 100  100  #include <sys/scsi/adapters/mpt_sas/mptsas_ioctl.h>
 101  101  #include <sys/scsi/adapters/mpt_sas/mptsas_smhba.h>
 102  102  #include <sys/scsi/adapters/mpt_sas/mptsas_hash.h>
 103  103  #include <sys/raidioctl.h>
 104  104  
 105      -#include <sys/fs/dv_node.h>     /* devfs_clean */
 106      -
 107  105  /*
 108  106   * FMA header files
 109  107   */
 110  108  #include <sys/ddifm.h>
 111  109  #include <sys/fm/protocol.h>
 112  110  #include <sys/fm/util.h>
 113  111  #include <sys/fm/io/ddi.h>
 114  112  
 115  113  /*
 116  114   * autoconfiguration data and routines.
↓ open down ↓ 273 lines elided ↑ open up ↑
 390  388      dev_info_t **dip, mptsas_target_t *ptgt, int lun);
 391  389  
 392  390  static int mptsas_create_phys_lun(dev_info_t *pdip, struct scsi_inquiry *sd,
 393  391      char *guid, dev_info_t **dip, mptsas_target_t *ptgt, int lun);
 394  392  static int mptsas_create_virt_lun(dev_info_t *pdip, struct scsi_inquiry *sd,
 395  393      char *guid, dev_info_t **dip, mdi_pathinfo_t **pip, mptsas_target_t *ptgt,
 396  394      int lun);
 397  395  
 398  396  static void mptsas_offline_missed_luns(dev_info_t *pdip,
 399  397      uint16_t *repluns, int lun_cnt, mptsas_target_t *ptgt);
 400      -static int mptsas_offline_lun(dev_info_t *pdip, dev_info_t *rdip,
 401      -    mdi_pathinfo_t *rpip, uint_t flags);
      398 +static int mptsas_offline_lun(dev_info_t *rdip, mdi_pathinfo_t *rpip);
 402  399  
 403  400  static int mptsas_config_smp(dev_info_t *pdip, uint64_t sas_wwn,
 404  401      dev_info_t **smp_dip);
 405      -static int mptsas_offline_smp(dev_info_t *pdip, mptsas_smp_t *smp_node,
 406      -    uint_t flags);
      402 +static int mptsas_offline_smp(dev_info_t *pdip, mptsas_smp_t *smp_node);
 407  403  
 408  404  static int mptsas_event_query(mptsas_t *mpt, mptsas_event_query_t *data,
 409  405      int mode, int *rval);
 410  406  static int mptsas_event_enable(mptsas_t *mpt, mptsas_event_enable_t *data,
 411  407      int mode, int *rval);
 412  408  static int mptsas_event_report(mptsas_t *mpt, mptsas_event_report_t *data,
 413  409      int mode, int *rval);
 414  410  static void mptsas_record_event(void *args);
 415  411  static int mptsas_reg_access(mptsas_t *mpt, mptsas_reg_access_t *data,
 416  412      int mode);
↓ open down ↓ 6467 lines elided ↑ open up ↑
6884 6880                      mptsas_smp_eval_devhdl, &devhdl);
6885 6881                  if (psmp == NULL)
6886 6882                          break;
6887 6883                  /*
6888 6884                   * The mptsas_smp_t data is released only if the dip is offlined
6889 6885                   * successfully.
6890 6886                   */
6891 6887                  mutex_exit(&mpt->m_mutex);
6892 6888  
6893 6889                  ndi_devi_enter(parent, &circ1);
6894      -                rval = mptsas_offline_smp(parent, psmp, NDI_DEVI_REMOVE);
     6890 +                rval = mptsas_offline_smp(parent, psmp);
6895 6891                  ndi_devi_exit(parent, circ1);
6896 6892  
6897 6893                  dev_info = psmp->m_deviceinfo;
6898 6894                  if ((dev_info & DEVINFO_DIRECT_ATTACHED) ==
6899 6895                      DEVINFO_DIRECT_ATTACHED) {
6900 6896                          if (ddi_prop_update_int(DDI_DEV_T_NONE, parent,
6901 6897                              MPTSAS_VIRTUAL_PORT, 1) !=
6902 6898                              DDI_PROP_SUCCESS) {
6903 6899                                  (void) ddi_prop_remove(DDI_DEV_T_NONE, parent,
6904 6900                                      MPTSAS_VIRTUAL_PORT);
↓ open down ↓ 7781 lines elided ↑ open up ↑
14686 14682                                          break;
14687 14683                                  }
14688 14684                          }
14689 14685                  } else {
14690 14686                          continue;
14691 14687                  }
14692 14688                  if (find == 0) {
14693 14689                          /*
14694 14690                           * The lun has not been there already
14695 14691                           */
14696      -                        (void) mptsas_offline_lun(pdip, savechild, NULL,
14697      -                            NDI_DEVI_REMOVE);
     14692 +                        (void) mptsas_offline_lun(savechild, NULL);
14698 14693                  }
14699 14694          }
14700 14695  
14701 14696          pip = mdi_get_next_client_path(pdip, NULL);
14702 14697          while (pip) {
14703 14698                  find = 0;
14704 14699                  savepip = pip;
14705 14700                  addr = MDI_PI(pip)->pi_addr;
14706 14701  
14707 14702                  pip = mdi_get_next_client_path(pdip, pip);
↓ open down ↓ 15 lines elided ↑ open up ↑
14723 14718                                  }
14724 14719                          }
14725 14720                  } else {
14726 14721                          continue;
14727 14722                  }
14728 14723  
14729 14724                  if (find == 0) {
14730 14725                          /*
14731 14726                           * The lun has not been there already
14732 14727                           */
14733      -                        (void) mptsas_offline_lun(pdip, NULL, savepip,
14734      -                            NDI_DEVI_REMOVE);
     14728 +                        (void) mptsas_offline_lun(NULL, savepip);
14735 14729                  }
14736 14730          }
14737 14731  }
14738 14732  
14739 14733  /*
14740 14734   * If this enclosure doesn't exist in the enclosure list, add it. If it does,
14741 14735   * update it.
14742 14736   */
14743 14737  static void
14744 14738  mptsas_enclosure_update(mptsas_t *mpt, mptsas_enclosure_t *mep)
↓ open down ↓ 273 lines elided ↑ open up ↑
15018 15012                  if ((cp = strchr(addr, ',')) == NULL) {
15019 15013                          continue;
15020 15014                  }
15021 15015  
15022 15016                  s = (uintptr_t)cp - (uintptr_t)addr;
15023 15017  
15024 15018                  if (strncmp(addr, name, s) != 0) {
15025 15019                          continue;
15026 15020                  }
15027 15021  
15028      -                tmp_rval = mptsas_offline_lun(pdip, prechild, NULL,
15029      -                    NDI_DEVI_REMOVE);
     15022 +                tmp_rval = mptsas_offline_lun(prechild, NULL);
15030 15023                  if (tmp_rval != DDI_SUCCESS) {
15031 15024                          rval = DDI_FAILURE;
15032 15025                          if (ndi_prop_create_boolean(DDI_DEV_T_NONE,
15033 15026                              prechild, MPTSAS_DEV_GONE) !=
15034 15027                              DDI_PROP_SUCCESS) {
15035 15028                                  mptsas_log(mpt, CE_WARN, "mptsas driver "
15036 15029                                      "unable to create property for "
15037 15030                                      "SAS %s (MPTSAS_DEV_GONE)", addr);
15038 15031                          }
15039 15032                  }
↓ open down ↓ 11 lines elided ↑ open up ↑
15051 15044                  if ((cp = strchr(addr, ',')) == NULL) {
15052 15045                          continue;
15053 15046                  }
15054 15047  
15055 15048                  s = (uintptr_t)cp - (uintptr_t)addr;
15056 15049  
15057 15050                  if (strncmp(addr, name, s) != 0) {
15058 15051                          continue;
15059 15052                  }
15060 15053  
15061      -                (void) mptsas_offline_lun(pdip, NULL, savepip,
15062      -                    NDI_DEVI_REMOVE);
     15054 +                (void) mptsas_offline_lun(NULL, savepip);
15063 15055                  /*
15064 15056                   * driver will not invoke mdi_pi_free, so path will not
15065 15057                   * be freed forever, return DDI_FAILURE.
15066 15058                   */
15067 15059                  rval = DDI_FAILURE;
15068 15060          }
15069 15061          return (rval);
15070 15062  }
15071 15063  
15072 15064  static int
15073      -mptsas_offline_lun(dev_info_t *pdip, dev_info_t *rdip,
15074      -    mdi_pathinfo_t *rpip, uint_t flags)
     15065 +mptsas_offline_lun(dev_info_t *rdip, mdi_pathinfo_t *rpip)
15075 15066  {
15076 15067          int             rval = DDI_FAILURE;
15077      -        char            *devname;
15078      -        dev_info_t      *cdip, *parent;
15079 15068  
15080 15069          if (rpip != NULL) {
15081      -                parent = scsi_vhci_dip;
15082      -                cdip = mdi_pi_get_client(rpip);
15083      -        } else if (rdip != NULL) {
15084      -                parent = pdip;
15085      -                cdip = rdip;
15086      -        } else {
15087      -                return (DDI_FAILURE);
15088      -        }
15089      -
15090      -        /*
15091      -         * Make sure node is attached otherwise
15092      -         * it won't have related cache nodes to
15093      -         * clean up.  i_ddi_devi_attached is
15094      -         * similiar to i_ddi_node_state(cdip) >=
15095      -         * DS_ATTACHED.
15096      -         */
15097      -        if (i_ddi_devi_attached(cdip)) {
15098      -
15099      -                /* Get full devname */
15100      -                devname = kmem_alloc(MAXNAMELEN + 1, KM_SLEEP);
15101      -                (void) ddi_deviname(cdip, devname);
15102      -                /* Clean cache */
15103      -                (void) devfs_clean(parent, devname + 1,
15104      -                    DV_CLEAN_FORCE);
15105      -                kmem_free(devname, MAXNAMELEN + 1);
15106      -        }
15107      -        if (rpip != NULL) {
15108 15070                  if (MDI_PI_IS_OFFLINE(rpip)) {
15109 15071                          rval = DDI_SUCCESS;
15110 15072                  } else {
15111 15073                          rval = mdi_pi_offline(rpip, 0);
15112 15074                  }
15113      -        } else {
15114      -                rval = ndi_devi_offline(cdip, flags);
     15075 +        } else if (rdip != NULL) {
     15076 +                rval = ndi_devi_offline(rdip,
     15077 +                    NDI_DEVFS_CLEAN | NDI_DEVI_REMOVE);
15115 15078          }
15116 15079  
15117 15080          return (rval);
15118 15081  }
15119 15082  
15120 15083  static dev_info_t *
15121 15084  mptsas_find_smp_child(dev_info_t *parent, char *str_wwn)
15122 15085  {
15123 15086          dev_info_t      *child = NULL;
15124 15087          char            *smp_wwn = NULL;
↓ open down ↓ 11 lines elided ↑ open up ↑
15136 15099                          ddi_prop_free(smp_wwn);
15137 15100                          break;
15138 15101                  }
15139 15102                  child = ddi_get_next_sibling(child);
15140 15103                  ddi_prop_free(smp_wwn);
15141 15104          }
15142 15105          return (child);
15143 15106  }
15144 15107  
15145 15108  static int
15146      -mptsas_offline_smp(dev_info_t *pdip, mptsas_smp_t *smp_node, uint_t flags)
     15109 +mptsas_offline_smp(dev_info_t *pdip, mptsas_smp_t *smp_node)
15147 15110  {
15148 15111          int             rval = DDI_FAILURE;
15149      -        char            *devname;
15150 15112          char            wwn_str[MPTSAS_WWN_STRLEN];
15151 15113          dev_info_t      *cdip;
15152 15114  
15153 15115          (void) sprintf(wwn_str, "%"PRIx64, smp_node->m_addr.mta_wwn);
15154 15116  
15155 15117          cdip = mptsas_find_smp_child(pdip, wwn_str);
15156      -
15157 15118          if (cdip == NULL)
15158 15119                  return (DDI_SUCCESS);
15159 15120  
15160      -        /*
15161      -         * Make sure node is attached otherwise
15162      -         * it won't have related cache nodes to
15163      -         * clean up.  i_ddi_devi_attached is
15164      -         * similiar to i_ddi_node_state(cdip) >=
15165      -         * DS_ATTACHED.
15166      -         */
15167      -        if (i_ddi_devi_attached(cdip)) {
     15121 +        rval = ndi_devi_offline(cdip, NDI_DEVFS_CLEAN | NDI_DEVI_REMOVE);
15168 15122  
15169      -                /* Get full devname */
15170      -                devname = kmem_alloc(MAXNAMELEN + 1, KM_SLEEP);
15171      -                (void) ddi_deviname(cdip, devname);
15172      -                /* Clean cache */
15173      -                (void) devfs_clean(pdip, devname + 1,
15174      -                    DV_CLEAN_FORCE);
15175      -                kmem_free(devname, MAXNAMELEN + 1);
15176      -        }
15177      -
15178      -        rval = ndi_devi_offline(cdip, flags);
15179      -
15180 15123          return (rval);
15181 15124  }
15182 15125  
15183 15126  static dev_info_t *
15184 15127  mptsas_find_child(dev_info_t *pdip, char *name)
15185 15128  {
15186 15129          dev_info_t      *child = NULL;
15187 15130          char            *rname = NULL;
15188 15131          int             rval = DDI_FAILURE;
15189 15132  
↓ open down ↓ 1780 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX