Skip to content

Commit

Permalink
feat: Reorganizing post maxLBA change order of operations
Browse files Browse the repository at this point in the history
Reorganizing the things done post maxLBA change to reduce repeating unnecessary steps as much as possible while making sure everything is in sync and update in the device structure.

Signed-off-by: Tyler Erickson <tyler.erickson@seagate.com>
  • Loading branch information
vonericsen committed Aug 3, 2023
1 parent 10ea6b0 commit d436d92
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 10 additions & 4 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.3";
const char *buildVersion = "2.4.4";

////////////////////////////
// functions to declare //
Expand Down Expand Up @@ -2102,17 +2102,19 @@ int32_t main(int argc, char *argv[])
dco.feat2.extendedPowerConditions = false;
}
}
bool scsiAtaInSync = false;
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 (!is_Max_LBA_In_Sync_With_Adapter_Or_Driver(&deviceList[deviceIter], false))
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");
Expand Down Expand Up @@ -2996,13 +2998,15 @@ 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)
{
Expand All @@ -3022,7 +3026,7 @@ int32_t main(int argc, char *argv[])
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 (!is_Max_LBA_In_Sync_With_Adapter_Or_Driver(&deviceList[deviceIter], false))
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");
Expand All @@ -3048,13 +3052,15 @@ 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)
{
Expand All @@ -3074,7 +3080,7 @@ int32_t main(int argc, char *argv[])
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 (!is_Max_LBA_In_Sync_With_Adapter_Or_Driver(&deviceList[deviceIter], false))
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");
Expand Down
6 changes: 4 additions & 2 deletions utils/C/openSeaChest/openSeaChest_Erase.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
// Global Variables //
////////////////////////
const char *util_name = "openSeaChest_Erase";
const char *buildVersion = "4.3.3";
const char *buildVersion = "4.3.4";

typedef enum _eSeaChestEraseExitCodes
{
Expand Down Expand Up @@ -1654,10 +1654,12 @@ int32_t main(int argc, char *argv[])
if (ERASE_RESTORE_MAX_PREP)
{
bool doNotContinueToErase = true;
bool scsiAtaInSync = false;
switch (restore_Max_LBA_For_Erase(&deviceList[deviceIter]))
{
case SUCCESS:
doNotContinueToErase = false;//successfully restored so continuing onwards to erase is fine.
scsiAtaInSync = is_Max_LBA_In_Sync_With_Adapter_Or_Driver(&deviceList[deviceIter], false);
fill_Drive_Info_Data(&deviceList[deviceIter]);//refresh stale data
if (VERBOSITY_QUIET < toolVerbosity)
{
Expand All @@ -1677,7 +1679,7 @@ int32_t main(int argc, char *argv[])
capacity_Unit_Convert(&capacity, &capUnit);
printf("Successfully restored maxLBA to highest possible user addressable LBA!\n");
printf("New Drive Capacity (%s/%s): %0.02f/%0.02f\n", mCapUnit, capUnit, mCapacity, capacity);
if (!is_Max_LBA_In_Sync_With_Adapter_Or_Driver(&deviceList[deviceIter], false))
if (!scsiAtaInSync)
{
printf("\nWARNING: The adapter/driver/bridge is not in sync with the capacity change!\n");
printf(" If using a drive managed erase, this will not be an issue since the\n");
Expand Down

0 comments on commit d436d92

Please sign in to comment.