-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix two issues in ExhaustibleBlockDevice #7058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -24,6 +24,10 @@ | |||
|
|||
#include "BlockDevice.h" | |||
|
|||
enum { | |||
BD_ERROR_ERASE_UNIT_WORN_OUT = -3301, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused. Why is this an anonymous enum that only has one entry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an error code specific to exhaustible block device. Followed the convention dictated by existing block devices, like MBRBlockDevice. My understanding is that these error codes are additions to the ones defined in BlockDevice base class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I figured as much, but wanted to be sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the error should be removed. Real flash will not identify the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. The error will be removed as it also breaks the LittleFS wear level test.
831c36d
to
79a8f3e
Compare
Removed the "worn out" error addition (and fixed the commit message). |
@mbed-os-storage please review |
// TODO possibly something more destructive here | ||
return 0; | ||
if (_erase_array[addr / eu_size] == 0) { | ||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the erase expands over several sectors and only one of them was exhausted do you stop in the middle of the erase while and not erase the other sectors? Also, is there no error indication for cycles exhausted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the loop exit: Good point, will fix.
Regarding the error indication: This was originally included in the PR (see the strikethrough text in the description) and then I reverted it. Reason was the fact that flash components don't give you an indication for it (you won't get an error, just read the wrong data). In addition, This broke the LittleFS resilience test.
return err; | ||
} | ||
addr += eu_size; | ||
size -= eu_size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can size become negative and then the while loop wont exit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this can't happen. The function checks that the erase is valid (at its start), meaning that the erase size is a multiple of the erase unit size, so the scenario you describe can't happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw the assert now, thanks
79a8f3e
to
4af2c9d
Compare
Pushed a fix with @offirko 's comment (not returning when reaching a worn sector). |
/morph build |
Build : SUCCESSBuild number : 2350 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 1974 |
Test : SUCCESSBuild number : 2135 |
Description
This PR fixes two issues in the exhaustible block device (block device simulating wearing of flash sectors):
1. Return errors when attempting to erase a worn out erase unit or write to it. Current code simply returns 0, without performing the erase/program action, meaning that the failure will be postponed to the time someone attempts to read these values (if at all).2. Support erasing of more than one erase unit, in one call (as current erase API assumes we only erase one erase unit).
Pull request type