Print this page
1845 allow disable of UNMAP via stmfadm(1M).

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/stmfadm/stmfadm.c
          +++ new/usr/src/cmd/stmfadm/stmfadm.c
↓ open down ↓ 72 lines elided ↑ open up ↑
  73   73  static int parseDevid(char *input, stmfDevid *devid);
  74   74  static void printGroupProps(stmfGroupProperties *groupProps);
  75   75  static int checkScsiNameString(wchar_t *, stmfDevid *);
  76   76  static int checkHexUpper(char *);
  77   77  static int checkIscsiName(wchar_t *);
  78   78  static void printLuProps(stmfLogicalUnitProperties *luProps);
  79   79  static int printExtLuProps(stmfGuid *guid);
  80   80  static void printGuid(stmfGuid *guid, FILE *printWhere);
  81   81  static void printTargetProps(stmfTargetProperties *);
  82   82  static void printSessionProps(stmfSessionList *);
  83      -static int setLuPropFromInput(luResource, char *);
       83 +static int setLuPropFromInput(luResource, char *, uint32_t *);
  84   84  static int convertCharToPropId(char *, uint32_t *);
  85   85  
  86   86  
  87   87  
  88   88  /*
  89   89   *  MAJOR - This should only change when there is an incompatible change made
  90   90   *  to the interfaces or the output.
  91   91   *
  92   92   *  MINOR - This should change whenever there is a new command or new feature
  93   93   *  with no incompatible change.
↓ open down ↓ 29 lines elided ↑ open up ↑
 123  123  #define VID                         "VID"
 124  124  #define PID                         "PID"
 125  125  #define META_FILE                   "META"
 126  126  #define WRITE_PROTECT               "WP"
 127  127  #define WRITEBACK_CACHE_DISABLE     "WCD"
 128  128  #define COMPANY_ID                  "OUI"
 129  129  #define BLOCK_SIZE                  "BLK"
 130  130  #define SERIAL_NUMBER               "SERIAL"
 131  131  #define MGMT_URL                    "MGMT-URL"
 132  132  #define HOST_ID                     "HOST-ID"
      133 +#define UNMAP                       "UNMAP"
 133  134  
 134  135  #define STMFADM_SUCCESS             0
 135  136  #define STMFADM_FAILURE             1
 136  137  
 137  138  #define MODIFY_HELP "\n"\
 138  139  "Description: Modify properties of a logical unit. \n" \
 139  140  "Valid properties for -p, --lu-prop are: \n" \
 140  141  "     alias    - alias for logical unit (up to 255 chars)\n" \
 141  142  "     mgmt-url - Management URL address\n" \
      143 +"     unmap    - iSCSI UNMAP enabled (true, false)\n" \
 142  144  "     wcd      - write cache disabled (true, false)\n" \
 143  145  "     wp       - write protect (true, false)\n\n" \
 144  146  "-f alters the meaning of the operand to be a file name\n" \
 145  147  "rather than a LU name. This allows for modification\n" \
 146  148  "of a logical unit that is not yet imported into stmf\n"
 147  149  
 148  150  #define CREATE_HELP "\n"\
 149  151  "Description: Create a logical unit. \n" \
 150  152  "Valid properties for -p, --lu-prop are: \n" \
 151  153  "     alias    - alias for logical unit (up to 255 chars)\n" \
 152  154  "     blk      - block size in bytes in 2^n\n" \
 153  155  "     guid     - 32 ascii hex characters in NAA format \n" \
 154  156  "     host-id  - host identifier to be used for GUID generation \n" \
 155  157  "                8 ascii hex characters\n" \
 156  158  "     meta     - separate meta data file name\n" \
 157  159  "     mgmt-url - Management URL address\n" \
 158  160  "     oui      - organizational unique identifier\n" \
 159  161  "                6 ascii hex characters of valid format\n" \
 160  162  "     pid      - product identifier (up to 16 chars)\n" \
 161  163  "     serial   - serial number (up to 252 chars)\n" \
      164 +"     unmap    - iSCSI UNMAP enabled (true, false)\n" \
 162  165  "     vid      - vendor identifier (up to 8 chars)\n" \
 163  166  "     wcd      - write cache disabled (true, false)\n" \
 164  167  "     wp       - write protect (true, false)\n"
 165  168  #define ADD_VIEW_HELP "\n"\
 166  169  "Description: Add a view entry to a logical unit. \n" \
 167  170  "A view entry is comprised of three elements; the \n" \
 168  171  "logical unit number, the target group name and the\n" \
 169  172  "host group name. These three elements combine together\n" \
 170  173  "to form a view for a given COMSTAR logical unit.\n" \
 171  174  "This view is realized by a client, a SCSI initiator,\n" \
↓ open down ↓ 635 lines elided ↑ open up ↑
 807  810  /*ARGSUSED*/
 808  811  static int
 809  812  createLuFunc(int operandLen, char *operands[], cmdOptions_t *options,
 810  813      void *args)
 811  814  {
 812  815          luResource hdl = NULL;
 813  816          int ret = 0;
 814  817          int stmfRet = 0;
 815  818          char guidAsciiBuf[33];
 816  819          stmfGuid createdGuid;
      820 +        uint32_t propid;
      821 +        boolean_t unmap_not_set = B_TRUE;
 817  822  
 818  823          stmfRet = stmfCreateLuResource(STMF_DISK, &hdl);
 819  824  
 820  825          if (stmfRet != STMF_STATUS_SUCCESS) {
 821  826                  (void) fprintf(stderr, "%s: %s\n",
 822  827                      cmdName, gettext("Failure to create lu resource\n"));
 823  828                  return (1);
 824  829          }
 825  830  
 826  831          for (; options->optval; options++) {
 827  832                  switch (options->optval) {
 828  833                          case 'p':
 829      -                                ret = setLuPropFromInput(hdl, options->optarg);
      834 +                                ret = setLuPropFromInput(hdl, options->optarg,
      835 +                                    &propid);
      836 +                                if (propid == STMF_LU_PROP_UNMAP)
      837 +                                        unmap_not_set = B_FALSE;
 830  838                                  if (ret != 0) {
 831  839                                          (void) stmfFreeLuResource(hdl);
 832  840                                          return (1);
 833  841                                  }
 834  842                                  break;
 835  843                          case 's':
 836  844                                  stmfRet = stmfSetLuProp(hdl, STMF_LU_PROP_SIZE,
 837  845                                      options->optarg);
 838  846                                  if (stmfRet != STMF_STATUS_SUCCESS) {
 839  847                                          (void) fprintf(stderr, "%s: %c: %s\n",
↓ open down ↓ 4 lines elided ↑ open up ↑
 844  852                                  }
 845  853                                  break;
 846  854                          default:
 847  855                                  (void) fprintf(stderr, "%s: %c: %s\n",
 848  856                                      cmdName, options->optval,
 849  857                                      gettext("unknown option"));
 850  858                                  return (1);
 851  859                  }
 852  860          }
 853  861  
      862 +        if (unmap_not_set) {
      863 +                /*
      864 +                 * We "enable" unmap by default, but STMF is hostile toward
      865 +                 * enable-by-default, so we enable it here if it hasn't
      866 +                 * already been set.
      867 +                 */
      868 +                if (stmfSetLuProp(hdl, STMF_LU_PROP_UNMAP, "true") !=
      869 +                    STMF_STATUS_SUCCESS) {
      870 +                        fprintf(stderr, "%s: %s\n", cmdName,
      871 +                            gettext("Problems setting UNMAP default"));
      872 +                }
      873 +        }
      874 +
 854  875          stmfRet = stmfSetLuProp(hdl, STMF_LU_PROP_FILENAME, operands[0]);
 855  876  
 856  877          if (stmfRet != STMF_STATUS_SUCCESS) {
 857  878                  (void) fprintf(stderr, "%s: %s\n",
 858  879                      cmdName, gettext("could not set filename"));
 859  880                  return (1);
 860  881          }
 861  882  
 862  883          stmfRet = stmfCreateLu(hdl, &createdGuid);
 863  884          switch (stmfRet) {
↓ open down ↓ 362 lines elided ↑ open up ↑
1226 1247              createdGuid.guid[9], createdGuid.guid[10], createdGuid.guid[11],
1227 1248              createdGuid.guid[12], createdGuid.guid[13], createdGuid.guid[14],
1228 1249              createdGuid.guid[15]);
1229 1250          (void) printf("Logical unit imported: %s\n", guidAsciiBuf);
1230 1251  
1231 1252  done:
1232 1253          return (ret);
1233 1254  }
1234 1255  
1235 1256  static int
1236      -setLuPropFromInput(luResource hdl, char *optarg)
     1257 +setLuPropFromInput(luResource hdl, char *optarg, uint32_t *propId)
1237 1258  {
1238 1259          char *prop = NULL;
1239 1260          char *propVal = NULL;
1240 1261          char *lasts = NULL;
1241      -        uint32_t propId;
1242 1262          int ret = 0;
1243 1263  
1244 1264          prop = strtok_r(optarg, "=", &lasts);
1245 1265          if ((propVal = strtok_r(NULL, "=", &lasts)) == NULL) {
1246 1266                  (void) fprintf(stderr, "%s: %s: %s\n",
1247 1267                      cmdName, optarg,
1248 1268                      gettext("invalid property specifier - prop=val\n"));
1249 1269                  return (1);
1250 1270          }
1251 1271  
1252      -        ret = convertCharToPropId(prop, &propId);
     1272 +        ret = convertCharToPropId(prop, propId);
1253 1273          if (ret != 0) {
1254 1274                  (void) fprintf(stderr, "%s: %s: %s\n",
1255 1275                      cmdName, gettext("invalid property specified"), prop);
1256 1276                  return (1);
1257 1277          }
1258 1278  
1259      -        ret = stmfSetLuProp(hdl, propId, propVal);
     1279 +        ret = stmfSetLuProp(hdl, *propId, propVal);
1260 1280          if (ret != STMF_STATUS_SUCCESS) {
1261 1281                  (void) fprintf(stderr, "%s: %s %s: ",
1262 1282                      cmdName, gettext("unable to set"), prop);
1263 1283                  switch (ret) {
1264 1284                          case STMF_ERROR_INVALID_PROPSIZE:
1265 1285                                  (void) fprintf(stderr, "invalid length\n");
1266 1286                                  break;
1267 1287                          case STMF_ERROR_INVALID_ARG:
1268 1288                                  (void) fprintf(stderr, "bad format\n");
1269 1289                                  break;
↓ open down ↓ 27 lines elided ↑ open up ↑
1297 1317          } else if (strcasecmp(prop, SERIAL_NUMBER) == 0) {
1298 1318                  *propId = STMF_LU_PROP_SERIAL_NUM;
1299 1319          } else if (strcasecmp(prop, COMPANY_ID) == 0) {
1300 1320                  *propId = STMF_LU_PROP_COMPANY_ID;
1301 1321          } else if (strcasecmp(prop, META_FILE) == 0) {
1302 1322                  *propId = STMF_LU_PROP_META_FILENAME;
1303 1323          } else if (strcasecmp(prop, MGMT_URL) == 0) {
1304 1324                  *propId = STMF_LU_PROP_MGMT_URL;
1305 1325          } else if (strcasecmp(prop, HOST_ID) == 0) {
1306 1326                  *propId = STMF_LU_PROP_HOST_ID;
     1327 +        } else if (strcasecmp(prop, UNMAP) == 0) {
     1328 +                *propId = STMF_LU_PROP_UNMAP;
1307 1329          } else {
1308 1330                  return (1);
1309 1331          }
1310 1332          return (0);
1311 1333  }
1312 1334  
1313 1335  /*
1314 1336   * deleteLuFunc
1315 1337   *
1316 1338   * Delete a logical unit
↓ open down ↓ 894 lines elided ↑ open up ↑
2211 2233          }
2212 2234  
2213 2235          stmfRet = stmfGetLuProp(hdl, STMF_LU_PROP_WRITE_CACHE_DISABLE, propVal,
2214 2236              &propValSize);
2215 2237          (void) printf(PROPS_FORMAT, "Writeback Cache");
2216 2238          if (stmfRet == STMF_STATUS_SUCCESS) {
2217 2239                  (void) printf("%s\n",
2218 2240                      strcasecmp(propVal, "true") ? "Enabled" : "Disabled");
2219 2241          } else if (stmfRet == STMF_ERROR_NO_PROP) {
2220 2242                  (void) printf("not set\n");
     2243 +        } else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) {
     2244 +                (void) printf("prop unavailable in standby\n");
     2245 +        } else {
     2246 +                (void) printf("<error retrieving property>\n");
     2247 +                ret++;
     2248 +        }
     2249 +
     2250 +        stmfRet = stmfGetLuProp(hdl, STMF_LU_PROP_UNMAP, propVal,
     2251 +            &propValSize);
     2252 +        (void) printf(PROPS_FORMAT, "UNMAP support");
     2253 +        if (stmfRet == STMF_STATUS_SUCCESS) {
     2254 +                (void) printf("%s\n", (strcasecmp(propVal, "true") == 0) ?
     2255 +                    "Enabled" : "Disabled");
     2256 +        } else if (stmfRet == STMF_ERROR_NO_PROP) {
     2257 +                (void) printf("not set\n");
2221 2258          } else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) {
2222 2259                  (void) printf("prop unavailable in standby\n");
2223 2260          } else {
2224 2261                  (void) printf("<error retrieving property>\n");
2225 2262                  ret++;
2226 2263          }
2227 2264  
2228 2265          stmfRet = stmfGetLuProp(hdl, STMF_LU_PROP_ACCESS_STATE, propVal,
2229 2266              &propValSize);
2230 2267          (void) printf(PROPS_FORMAT, "Access State");
↓ open down ↓ 1284 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX