Print this page
6621014 Support multipathing to tape devices

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/scsi/targets/st.c
          +++ new/usr/src/uts/common/io/scsi/targets/st.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27      -#pragma ident   "@(#)st.c       1.275   08/02/26 SMI"
       27 +#pragma ident   "@(#)st.c       1.276   08/03/03 SMI"
  28   28  
  29   29  /*
  30   30   * SCSI  SCSA-compliant and not-so-DDI-compliant Tape Driver
  31   31   */
  32   32  
  33   33  #if defined(lint) && !defined(DEBUG)
  34   34  #define DEBUG   1
  35   35  #endif
  36   36  
  37   37  #include <sys/modctl.h>
↓ open down ↓ 612 lines elided ↑ open up ↑
 650  650  _NOTE(DATA_READABLE_WITHOUT_LOCK(st_drivetype scsi_address))
 651  651  #endif
 652  652  
 653  653  /*
 654  654   * autoconfiguration routines.
 655  655   */
 656  656  char _depends_on[] = "misc/scsi";
 657  657  
 658  658  static struct modldrv modldrv = {
 659  659          &mod_driverops,         /* Type of module. This one is a driver */
 660      -        "SCSI tape Driver 1.275", /* Name of the module. */
      660 +        "SCSI tape Driver 1.276", /* Name of the module. */
 661  661          &st_ops                 /* driver ops */
 662  662  };
 663  663  
 664  664  static struct modlinkage modlinkage = {
 665  665          MODREV_1, &modldrv, NULL
 666  666  };
 667  667  
 668  668  /*
 669  669   * Notes on Post Reset Behavior in the tape driver:
 670  670   *
↓ open down ↓ 377 lines elided ↑ open up ↑
1048 1048           * Get the max allowable cdb size
1049 1049           */
1050 1050          un->un_max_cdb_sz =
1051 1051              scsi_ifgetcap(&devp->sd_address, "max-cdb-length", 1);
1052 1052          if (un->un_max_cdb_sz < CDB_GROUP0) {
1053 1053                  ST_DEBUG(devi, st_label, SCSI_DEBUG,
1054 1054                      "HBA reported max-cdb-length as %d\n", un->un_max_cdb_sz);
1055 1055                  un->un_max_cdb_sz = CDB_GROUP4; /* optimistic default */
1056 1056          }
1057 1057  
     1058 +        if (strcmp(ddi_driver_name(ddi_get_parent(ST_DEVINFO)), "scsi_vhci")) {
     1059 +                un->un_multipath = 0;
     1060 +        } else {
     1061 +                un->un_multipath = 1;
     1062 +        }
     1063 +
1058 1064          un->un_maxbsize = MAXBSIZE_UNKNOWN;
1059 1065  
1060 1066          un->un_mediastate = MTIO_NONE;
1061 1067          un->un_HeadClean  = TAPE_ALERT_SUPPORT_UNKNOWN;
1062 1068  
1063 1069          /*
1064 1070           * initialize kstats
1065 1071           */
1066 1072          un->un_stats = kstat_create("st", instance, NULL, "tape",
1067 1073              KSTAT_TYPE_IO, 1, KSTAT_FLAG_PERSISTENT);
↓ open down ↓ 141 lines elided ↑ open up ↑
1209 1215                  if (((un->un_dp->options & ST_UNLOADABLE) == 0) ||
1210 1216                      (un->un_ncmds != 0) || (un->un_quef != NULL) ||
1211 1217                      (un->un_state != ST_STATE_CLOSED)) {
1212 1218                          /*
1213 1219                           * we cannot unload some targets because the
1214 1220                           * inquiry returns junk unless immediately
1215 1221                           * after a reset
1216 1222                           */
1217 1223                          ST_DEBUG2(ST_DEVINFO, st_label, SCSI_DEBUG,
1218 1224                              "cannot unload instance %x\n", instance);
     1225 +                        un->un_unit_attention_flags |= 4;
1219 1226                          return (DDI_FAILURE);
1220 1227                  }
1221 1228  
1222 1229                  /*
1223 1230                   * if the tape has been removed then we may unload;
1224 1231                   * do a test unit ready and if it returns NOT READY
1225 1232                   * then we assume that it is safe to unload.
1226 1233                   * as a side effect, pmode may be set to invalid if the
1227 1234                   * the test unit ready fails;
1228 1235                   * also un_state may be set to non-closed, so reset it
↓ open down ↓ 35 lines elided ↑ open up ↑
1264 1271                      (un->un_pos.fileno > 0) ||  /* Known position not rewound */
1265 1272                      (un->un_pos.blkno != 0)) || /* Or within first file */
1266 1273                      ((un->un_pos.pmode == logical) &&
1267 1274                      (un->un_pos.lgclblkno > 0)))) {
1268 1275  
1269 1276                          ST_DEBUG(ST_DEVINFO, st_label, SCSI_DEBUG,
1270 1277                              "cannot detach: pmode=%d fileno=0x%x, blkno=0x%x"
1271 1278                              " lgclblkno=0x%"PRIx64"\n", un->un_pos.pmode,
1272 1279                              un->un_pos.fileno, un->un_pos.blkno,
1273 1280                              un->un_pos.lgclblkno);
     1281 +                        un->un_unit_attention_flags |= 4;
1274 1282                          return (DDI_FAILURE);
1275 1283                  }
1276 1284  
1277 1285                  /*
1278 1286                   * Just To make sure that we have released the
1279 1287                   * tape unit .
1280 1288                   */
1281 1289                  if (un->un_dev && (un->un_rsvd_status & ST_RESERVE) &&
1282 1290                      !DEVI_IS_DEVICE_REMOVED(devi)) {
1283 1291                          mutex_enter(ST_MUTEX);
↓ open down ↓ 572 lines elided ↑ open up ↑
1856 1864          /* make sure if we are supposed to be variable, make it variable */
1857 1865          if (dp->options & ST_VARIABLE) {
1858 1866                  dp->bsize = 0;
1859 1867          }
1860 1868  
1861 1869          if (reserved != ((un->un_rsvd_status & ST_RESERVE) ? ST_RESERVE
1862 1870              : ST_RELEASE)) {
1863 1871                  (void) st_reserve_release(un, reserved, st_uscsi_cmd);
1864 1872          }
1865 1873  
1866      -        un->un_unit_attention_flags = 1;
     1874 +        un->un_unit_attention_flags |= 1;
1867 1875  
1868 1876          scsi_log(ST_DEVINFO, st_label, CE_NOTE, "?<%s>\n", dp->name);
1869 1877  
1870 1878  }
1871 1879  
1872 1880  
1873 1881  typedef struct {
1874 1882          int mask;
1875 1883          int bottom;
1876 1884          int top;