Add IMMED FORMAT UNIT tool + progress poller; fix half-format on slow HDDs#2
Open
mwventures wants to merge 1 commit into
Open
Add IMMED FORMAT UNIT tool + progress poller; fix half-format on slow HDDs#2mwventures wants to merge 1 commit into
mwventures wants to merge 1 commit into
Conversation
… slow HDDs The existing formatters send FORMAT UNIT without the IMMED bit, so the command blocks until the whole format finishes. On a fast SSD that can complete before the RAID controller's command timeout (the origin of the "status 45 but it worked" note); on a slow multi-TB 7200rpm SAS HDD the format takes hours, the controller timeout aborts it with SCSI_IO_FAILED, and the medium is left half-formatted and invalid. Changes: - mega_format_immed.c: MODE SELECT to 512, then FORMAT UNIT with IMMED=1 so the drive returns immediately and formats in the background (reliable on HDDs). - mega_progress.c: poll background format progress via REQUEST SENSE (sense key 0x2 / ASC 0x04 / ASCQ 0x04 -> percent complete). - README: explain the IMMED issue and half-format failure mode; add a cold power-cycle option for chassis without a hot-swap backplane; document the two new tools; note validation on a PERC H730 with 2 TB HGST SAS HDDs. Both tools build clean with -O2 -Wall -Wextra. Approach builds on the existing passthrough tools in this repo. (CI left untouched; see PR notes for the suggested build lines.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
Two tools + docs that make the 520→512 reformat reliable on slow multi-TB HDDs (not just SSDs), and explains a failure this repo's README currently notes as a mystery ("status 45 failure but it actually worked").
The problem
The existing formatters send
FORMAT UNITwithout the IMMED bit, so it blocks until the format finishes. On a fast SSD it can complete before the RAID controller's command timeout (hence "status 45 but worked"). On a slow 7200rpm multi-TB SAS HDD the format takes hours, the controller timeout aborts it withSCSI_IO_FAILED, and the medium is left half-formatted and invalid (SMART self-test = I/O error, controller shows 0 KB / UBad). Note:smartctlcan still print512 bytes / full capacity— that's the intended geometry from the mode page, not proof the medium is good.The fix
mega_format_immed.c— MODE SELECT to 512, thenFORMAT UNITwith IMMED=1; returns immediately, formats in the background.mega_progress.c— polls progress viaREQUEST SENSE(sense key0x2/ ASC0x04/ ASCQ0x04→ percent complete).UGUnsp/0 KBidentity).Testing
Validated on a Dell PowerEdge T130 / PERC H730 (HBA mode) reformatting 2 TB HGST HMRP2000 7200rpm SAS drives: the non-IMMED path timed out and half-formatted; these tools completed cleanly (~4h/drive) with a full cold power cycle to clear the controller cache. Both tools build clean with
-O2 -Wall -Wextra.Notes
.github/workflows/build-and-release.ymluntouched (didn't want to push CI changes). If you'd like CI to build/package the new tools, addmega_format_immedandmega_progressto the build / test / archive / release lists — happy to include that here.