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

*** 78,88 **** static void printLuProps(stmfLogicalUnitProperties *luProps); static int printExtLuProps(stmfGuid *guid); static void printGuid(stmfGuid *guid, FILE *printWhere); static void printTargetProps(stmfTargetProperties *); static void printSessionProps(stmfSessionList *); ! static int setLuPropFromInput(luResource, char *); static int convertCharToPropId(char *, uint32_t *); /* --- 78,88 ---- static void printLuProps(stmfLogicalUnitProperties *luProps); static int printExtLuProps(stmfGuid *guid); static void printGuid(stmfGuid *guid, FILE *printWhere); static void printTargetProps(stmfTargetProperties *); static void printSessionProps(stmfSessionList *); ! static int setLuPropFromInput(luResource, char *, uint32_t *); static int convertCharToPropId(char *, uint32_t *); /*
*** 128,146 **** --- 128,148 ---- #define COMPANY_ID "OUI" #define BLOCK_SIZE "BLK" #define SERIAL_NUMBER "SERIAL" #define MGMT_URL "MGMT-URL" #define HOST_ID "HOST-ID" + #define UNMAP "UNMAP" #define STMFADM_SUCCESS 0 #define STMFADM_FAILURE 1 #define MODIFY_HELP "\n"\ "Description: Modify properties of a logical unit. \n" \ "Valid properties for -p, --lu-prop are: \n" \ " alias - alias for logical unit (up to 255 chars)\n" \ " mgmt-url - Management URL address\n" \ + " unmap - iSCSI UNMAP enabled (true, false)\n" \ " wcd - write cache disabled (true, false)\n" \ " wp - write protect (true, false)\n\n" \ "-f alters the meaning of the operand to be a file name\n" \ "rather than a LU name. This allows for modification\n" \ "of a logical unit that is not yet imported into stmf\n"
*** 157,166 **** --- 159,169 ---- " mgmt-url - Management URL address\n" \ " oui - organizational unique identifier\n" \ " 6 ascii hex characters of valid format\n" \ " pid - product identifier (up to 16 chars)\n" \ " serial - serial number (up to 252 chars)\n" \ + " unmap - iSCSI UNMAP enabled (true, false)\n" \ " vid - vendor identifier (up to 8 chars)\n" \ " wcd - write cache disabled (true, false)\n" \ " wp - write protect (true, false)\n" #define ADD_VIEW_HELP "\n"\ "Description: Add a view entry to a logical unit. \n" \
*** 812,821 **** --- 815,826 ---- luResource hdl = NULL; int ret = 0; int stmfRet = 0; char guidAsciiBuf[33]; stmfGuid createdGuid; + uint32_t propid; + boolean_t unmap_not_set = B_TRUE; stmfRet = stmfCreateLuResource(STMF_DISK, &hdl); if (stmfRet != STMF_STATUS_SUCCESS) { (void) fprintf(stderr, "%s: %s\n",
*** 824,834 **** } for (; options->optval; options++) { switch (options->optval) { case 'p': ! ret = setLuPropFromInput(hdl, options->optarg); if (ret != 0) { (void) stmfFreeLuResource(hdl); return (1); } break; --- 829,842 ---- } for (; options->optval; options++) { switch (options->optval) { case 'p': ! ret = setLuPropFromInput(hdl, options->optarg, ! &propid); ! if (propid == STMF_LU_PROP_UNMAP) ! unmap_not_set = B_FALSE; if (ret != 0) { (void) stmfFreeLuResource(hdl); return (1); } break;
*** 849,858 **** --- 857,879 ---- gettext("unknown option")); return (1); } } + if (unmap_not_set) { + /* + * We "enable" unmap by default, but STMF is hostile toward + * enable-by-default, so we enable it here if it hasn't + * already been set. + */ + if (stmfSetLuProp(hdl, STMF_LU_PROP_UNMAP, "true") != + STMF_STATUS_SUCCESS) { + fprintf(stderr, "%s: %s\n", cmdName, + gettext("Problems setting UNMAP default")); + } + } + stmfRet = stmfSetLuProp(hdl, STMF_LU_PROP_FILENAME, operands[0]); if (stmfRet != STMF_STATUS_SUCCESS) { (void) fprintf(stderr, "%s: %s\n", cmdName, gettext("could not set filename"));
*** 1231,1246 **** done: return (ret); } static int ! setLuPropFromInput(luResource hdl, char *optarg) { char *prop = NULL; char *propVal = NULL; char *lasts = NULL; - uint32_t propId; int ret = 0; prop = strtok_r(optarg, "=", &lasts); if ((propVal = strtok_r(NULL, "=", &lasts)) == NULL) { (void) fprintf(stderr, "%s: %s: %s\n", --- 1252,1266 ---- done: return (ret); } static int ! setLuPropFromInput(luResource hdl, char *optarg, uint32_t *propId) { char *prop = NULL; char *propVal = NULL; char *lasts = NULL; int ret = 0; prop = strtok_r(optarg, "=", &lasts); if ((propVal = strtok_r(NULL, "=", &lasts)) == NULL) { (void) fprintf(stderr, "%s: %s: %s\n",
*** 1247,1264 **** cmdName, optarg, gettext("invalid property specifier - prop=val\n")); return (1); } ! ret = convertCharToPropId(prop, &propId); if (ret != 0) { (void) fprintf(stderr, "%s: %s: %s\n", cmdName, gettext("invalid property specified"), prop); return (1); } ! ret = stmfSetLuProp(hdl, propId, propVal); if (ret != STMF_STATUS_SUCCESS) { (void) fprintf(stderr, "%s: %s %s: ", cmdName, gettext("unable to set"), prop); switch (ret) { case STMF_ERROR_INVALID_PROPSIZE: --- 1267,1284 ---- cmdName, optarg, gettext("invalid property specifier - prop=val\n")); return (1); } ! ret = convertCharToPropId(prop, propId); if (ret != 0) { (void) fprintf(stderr, "%s: %s: %s\n", cmdName, gettext("invalid property specified"), prop); return (1); } ! ret = stmfSetLuProp(hdl, *propId, propVal); if (ret != STMF_STATUS_SUCCESS) { (void) fprintf(stderr, "%s: %s %s: ", cmdName, gettext("unable to set"), prop); switch (ret) { case STMF_ERROR_INVALID_PROPSIZE:
*** 1302,1311 **** --- 1322,1333 ---- *propId = STMF_LU_PROP_META_FILENAME; } else if (strcasecmp(prop, MGMT_URL) == 0) { *propId = STMF_LU_PROP_MGMT_URL; } else if (strcasecmp(prop, HOST_ID) == 0) { *propId = STMF_LU_PROP_HOST_ID; + } else if (strcasecmp(prop, UNMAP) == 0) { + *propId = STMF_LU_PROP_UNMAP; } else { return (1); } return (0); }
*** 2216,2225 **** --- 2238,2262 ---- if (stmfRet == STMF_STATUS_SUCCESS) { (void) printf("%s\n", strcasecmp(propVal, "true") ? "Enabled" : "Disabled"); } else if (stmfRet == STMF_ERROR_NO_PROP) { (void) printf("not set\n"); + } else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) { + (void) printf("prop unavailable in standby\n"); + } else { + (void) printf("<error retrieving property>\n"); + ret++; + } + + stmfRet = stmfGetLuProp(hdl, STMF_LU_PROP_UNMAP, propVal, + &propValSize); + (void) printf(PROPS_FORMAT, "UNMAP support"); + if (stmfRet == STMF_STATUS_SUCCESS) { + (void) printf("%s\n", (strcasecmp(propVal, "true") == 0) ? + "Enabled" : "Disabled"); + } else if (stmfRet == STMF_ERROR_NO_PROP) { + (void) printf("not set\n"); } else if (stmfRet == STMF_ERROR_NO_PROP_STANDBY) { (void) printf("prop unavailable in standby\n"); } else { (void) printf("<error retrieving property>\n"); ret++;