Skip to content

Commit

Permalink
merge: Merge branch 'develop' into feature/data_sanitization_capabili…
Browse files Browse the repository at this point in the history
…ties

Signed-off-by: Tyler Erickson <tyler.erickson@seagate.com>

# Conflicts:
#	subprojects/opensea-operations
  • Loading branch information
vonericsen committed Aug 22, 2023
2 parents b40cf70 + 2e2c504 commit db93e4b
Show file tree
Hide file tree
Showing 12 changed files with 229 additions and 38 deletions.
9 changes: 9 additions & 0 deletions include/openseachest_util_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,12 @@ extern "C"
#define ZERO_VERIFY_LONG_OPT_STRING "zeroVerify"
#define ZERO_VERIFY_LONG_OPT { ZERO_VERIFY_LONG_OPT_STRING, required_argument, NULL, 0 }

//before erasing a drive, restore the max LBA to make sure all user accessible spaces will be erased.
#define ERASE_RESTORE_MAX_PREP eraseRestoreMaxLBAPrep
#define ERASE_RESTORE_MAX_VAR getOptBool ERASE_RESTORE_MAX_PREP = goFalse;
#define ERASE_RESTORE_MAX_PREP_LONG_OPT_STRING "eraseRestoreMaxPrep"
#define ERASE_RESTORE_MAX_PREP_LONG_OPT { ERASE_RESTORE_MAX_PREP_LONG_OPT_STRING, no_argument, &ERASE_RESTORE_MAX_PREP, goTrue }

//Generic read test options
#define GENERIC_TEST_MODE_FLAG genericTestMode
#define GENERIC_TEST_MODE_VAR int genericTestMode = 0; //0 = read, 1 = write, 2 = verify
Expand Down Expand Up @@ -3483,6 +3489,9 @@ extern "C"
void print_Persistent_Reservations_Preempt_Abort_Help(bool shortHelp);

void print_Zero_Verify_Help(bool shortHelp);

void print_Erase_Restore_Max_Prep_Help(bool shortHelp);

void print_NVME_Health_Help(bool shortHelp);

void print_Delay_CMD_Segment_Help(bool shortHelp);
Expand Down
28 changes: 19 additions & 9 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,38 @@ endif

add_project_arguments(c.get_supported_arguments(warning_flags), language : 'c')

if not (target_machine.system() == 'sunos') and (c.get_id() == 'gcc' or c.get_id() == 'clang')
add_global_arguments(
small_code_cc_flags = []
small_code_link_flags = []

if (c.get_id() == 'gcc' or c.get_id() == 'clang')

small_code_cc_flags = [
'-ffunction-sections',
'-fdata-sections',
language: 'c',
)
add_global_link_arguments(
]
small_code_link_flags = [
'-Wl,--gc-sections',
language: 'c',
)
]

#if GCC less than 5, need to set -std=gnu99 at minimum. gnu11 became the default in 5, 17 default in 7 or 8.
#TODO: May be able to move to c11/gnu11 instead, but will need to do a lot of testing first
#skipping sunos since this was a compatibility issue that was reported earlier. May be able to find a better way to handle this in the future.
if not (target_machine.system() == 'sunos') and c.get_id().contains('gcc')
verStr = c.version().split('.')
if verStr.get(0).to_int() < 5
if c.version().version_compare('<5.0')
if c.has_argument('-std=gnu99')
#Add this argument to the list since C99 is a minimum required C compiler standard
add_global_arguments('-std=gnu99', language: 'c',)
else
error('C99/GNU99 standard is required but was not able to be set!')
endif
endif
endif

endif

add_global_arguments(c.get_supported_arguments(small_code_cc_flags), language : 'c')
add_global_link_arguments(c.get_supported_link_arguments(small_code_link_flags), language : 'c')

if not get_option('tcg').enabled()
add_project_arguments('-DDISABLE_TCG_SUPPORT', language : 'c')
endif
Expand Down
24 changes: 24 additions & 0 deletions src/openseachest_util_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -4351,6 +4351,30 @@ void print_Persistent_Reservations_Preempt_Abort_Help(bool shortHelp)
}
}

void print_Erase_Restore_Max_Prep_Help(bool shortHelp)
{
printf("\t--%s\n", ERASE_RESTORE_MAX_PREP_LONG_OPT_STRING);
if (!shortHelp)
{
printf("\t\tThis option will attempt to restore the max LBA to the highest\n");
printf("\t\tuser addressable sector prior to beginning a drive erasure.\n");
printf("\t\tIf any failure is encountered while restoring the maxLBA, then\n");
printf("\t\tan error will be indicated and the erase will not be started or\n");
printf("\t\tattempted until other user intervention can be completed.\n");
printf("\t\tIf a feature is frozen, locked, or has already been used during\n");
printf("\t\tthe current power cycle, then these things can cause a failure.\n");
printf("\t\tThe solution is to power cycle the drive, but in some cases it may\n");
printf("\t\tbe necessary to try a different computer or adapter as commands may\n");
printf("\t\tbe blocked by the system or automatically issued by the BIOS to lock\n");
printf("\t\taccess to capacity changing commands.\n");
printf("\t\tThis option will handle the ATA HPA (Host Protected Area), AMAC (Accessible\n");
printf("\t\tMax Address Configuration), HPA Security Extension, and DCO (Device\n");
printf("\t\tConfiguration Overlay) features in accordance with the specifications.\n");
printf("\t\tIf the restore completes without error, then the erase will proceed\n");
printf("\t\tand additional errors will only be in relation to those erasure methods.\n\n");
}
}

void print_Zero_Verify_Help(bool shortHelp)
{
printf("\t--%s [full | quick]\n", ZERO_VERIFY_LONG_OPT_STRING);
Expand Down
2 changes: 1 addition & 1 deletion subprojects/opensea-common
2 changes: 1 addition & 1 deletion subprojects/opensea-transport
2 changes: 1 addition & 1 deletion subprojects/wingetopt
Submodule wingetopt updated 1 files
+2 −1 meson.build
58 changes: 55 additions & 3 deletions utils/C/openSeaChest/openSeaChest_Configure.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// Global Variables //
////////////////////////
const char *util_name = "openSeaChest_Configure";
const char *buildVersion = "2.4.1";
const char *buildVersion = "2.4.5";

////////////////////////////
// functions to declare //
Expand Down Expand Up @@ -1845,12 +1845,21 @@ int32_t main(int argc, char *argv[])

if (ATA_DCO_RESTORE)
{
bool scsiAtaInSync = false;
switch (dco_Restore(&deviceList[deviceIter]))
{
case SUCCESS:
scsiAtaInSync = is_Max_LBA_In_Sync_With_Adapter_Or_Driver(&deviceList[deviceIter], false);
fill_Drive_Info_Data(&deviceList[deviceIter]);
if (VERBOSITY_QUIET < toolVerbosity)
{
printf("Successfully restored factory settings using DCO.\n");
if (!scsiAtaInSync)
{
printf("\nWARNING: The adapter/driver/bridge is not in sync with the capacity change!\n");
printf(" A reboot is strongly recommended to make sure the system works without\n");
printf(" errors with the drive at its new capacity.\n\n");
}
}
break;
case NOT_SUPPORTED:
Expand Down Expand Up @@ -1895,6 +1904,7 @@ int32_t main(int argc, char *argv[])
if (ATA_DCO_DISABLE_FEATURES || ATA_DCO_SETMAXMODE || ATA_DCO_SETMAXLBA)
{
dcoData dco;
bool scsiAtaInSync = false;
memset(&dco, 0, sizeof(dcoData));
switch (dco_Identify(&deviceList[deviceIter], &dco))
{
Expand Down Expand Up @@ -2098,9 +2108,20 @@ int32_t main(int argc, char *argv[])
switch (dco_Set(&deviceList[deviceIter], &dco))
{
case SUCCESS:
if (ATA_DCO_SETMAXLBA)
{
scsiAtaInSync = is_Max_LBA_In_Sync_With_Adapter_Or_Driver(&deviceList[deviceIter], false);
fill_Drive_Info_Data(&deviceList[deviceIter]);
}
if (VERBOSITY_QUIET < toolVerbosity)
{
printf("Successfully configured available features/modes/maxLBA using DCO.\n");
if (!scsiAtaInSync)
{
printf("\nWARNING: The adapter/driver/bridge is not in sync with the capacity change!\n");
printf(" A reboot is strongly recommended to make sure the system works without\n");
printf(" errors with the drive at its new capacity.\n\n");
}
}
break;
case NOT_SUPPORTED:
Expand Down Expand Up @@ -2979,25 +3000,40 @@ int32_t main(int argc, char *argv[])

if (SET_MAX_LBA_FLAG)
{
bool scsiAtaInSync = false;
if (VERBOSITY_QUIET < toolVerbosity)
{
printf("Setting MaxLBA to %"PRIu64"\n", SET_MAX_LBA_VALUE);
}
switch (set_Max_LBA(&deviceList[deviceIter], SET_MAX_LBA_VALUE, false))
{
case SUCCESS:
scsiAtaInSync = is_Max_LBA_In_Sync_With_Adapter_Or_Driver(&deviceList[deviceIter], false);
fill_Drive_Info_Data(&deviceList[deviceIter]);
if (VERBOSITY_QUIET < toolVerbosity)
{
double mCapacity = 0, capacity = 0;
char mCapUnits[UNIT_STRING_LENGTH] = { 0 }, capUnits[UNIT_STRING_LENGTH] = { 0 };
char* mCapUnit = &mCapUnits[0], * capUnit = &capUnits[0];
mCapacity = C_CAST(double, deviceList[deviceIter].drive_info.deviceMaxLba * deviceList[deviceIter].drive_info.deviceBlockSize);
if (deviceList[deviceIter].drive_info.bridge_info.isValid)
{
mCapacity = C_CAST(double, deviceList[deviceIter].drive_info.bridge_info.childDeviceMaxLba * deviceList[deviceIter].drive_info.bridge_info.childDeviceBlockSize);
}
else
{
mCapacity = C_CAST(double, deviceList[deviceIter].drive_info.deviceMaxLba * deviceList[deviceIter].drive_info.deviceBlockSize);
}
capacity = mCapacity;
metric_Unit_Convert(&mCapacity, &mCapUnit);
capacity_Unit_Convert(&capacity, &capUnit);
printf("Successfully set the max LBA to %" PRIu64 "\n", SET_MAX_LBA_VALUE);
printf("New Drive Capacity (%s/%s): %0.02f/%0.02f\n", mCapUnit, capUnit, mCapacity, capacity);
if (!scsiAtaInSync)
{
printf("\nWARNING: The adapter/driver/bridge is not in sync with the capacity change!\n");
printf(" A reboot is strongly recommended to make sure the system works without\n");
printf(" errors with the drive at its new capacity.\n\n");
}
}
break;
case NOT_SUPPORTED:
Expand All @@ -3018,24 +3054,40 @@ int32_t main(int argc, char *argv[])
}
if (RESTORE_MAX_LBA_FLAG)
{
bool scsiAtaInSync = false;
if (VERBOSITY_QUIET < toolVerbosity)
{
printf("Restoring max LBA\n");
}
switch (set_Max_LBA(&deviceList[deviceIter], 0, true))
{
case SUCCESS:
scsiAtaInSync = is_Max_LBA_In_Sync_With_Adapter_Or_Driver(&deviceList[deviceIter], false);
fill_Drive_Info_Data(&deviceList[deviceIter]);
if (VERBOSITY_QUIET < toolVerbosity)
{
double mCapacity = 0, capacity = 0;
char mCapUnits[UNIT_STRING_LENGTH] = { 0 }, capUnits[UNIT_STRING_LENGTH] = { 0 };
char* mCapUnit = &mCapUnits[0], * capUnit = &capUnits[0];
mCapacity = C_CAST(double, deviceList[deviceIter].drive_info.deviceMaxLba * deviceList[deviceIter].drive_info.deviceBlockSize);
if (deviceList[deviceIter].drive_info.bridge_info.isValid)
{
mCapacity = C_CAST(double, deviceList[deviceIter].drive_info.bridge_info.childDeviceMaxLba * deviceList[deviceIter].drive_info.bridge_info.childDeviceBlockSize);
}
else
{
mCapacity = C_CAST(double, deviceList[deviceIter].drive_info.deviceMaxLba * deviceList[deviceIter].drive_info.deviceBlockSize);
}
capacity = mCapacity;
metric_Unit_Convert(&mCapacity, &mCapUnit);
capacity_Unit_Convert(&capacity, &capUnit);
printf("Successfully restored the max LBA\n");
printf("New Drive Capacity (%s/%s): %0.02f/%0.02f\n", mCapUnit, capUnit, mCapacity, capacity);
if (!scsiAtaInSync)
{
printf("\nWARNING: The adapter/driver/bridge is not in sync with the capacity change!\n");
printf(" A reboot is strongly recommended to make sure the system works without\n");
printf(" errors with the drive at its new capacity.\n\n");
}
}
break;
case NOT_SUPPORTED:
Expand Down
Loading

0 comments on commit db93e4b

Please sign in to comment.