Skip to content

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

Merged
merged 1 commit into from
Jun 15, 2018

Conversation

davidsaada
Copy link
Contributor

@davidsaada davidsaada commented May 30, 2018

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

[x] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change

@0xc0170 0xc0170 requested a review from a team May 30, 2018 14:18
@@ -24,6 +24,10 @@

#include "BlockDevice.h"

enum {
BD_ERROR_ERASE_UNIT_WORN_OUT = -3301,
Copy link
Contributor

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?

Copy link
Contributor Author

@davidsaada davidsaada May 31, 2018

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.

Copy link
Contributor

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.

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.

Copy link
Contributor Author

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.

@davidsaada davidsaada force-pushed the david_exhaustible_bd_fix branch from 831c36d to 79a8f3e Compare June 3, 2018 13:12
@davidsaada
Copy link
Contributor Author

Removed the "worn out" error addition (and fixed the commit message).

0xc0170
0xc0170 previously approved these changes Jun 4, 2018
@0xc0170
Copy link
Contributor

0xc0170 commented Jun 11, 2018

@mbed-os-storage please review

// TODO possibly something more destructive here
return 0;
if (_erase_array[addr / eu_size] == 0) {
return 0;
Copy link
Contributor

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?

Copy link
Contributor Author

@davidsaada davidsaada Jun 11, 2018

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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

@davidsaada
Copy link
Contributor Author

davidsaada commented Jun 11, 2018

Pushed a fix with @offirko 's comment (not returning when reaching a worn sector).

@cmonr
Copy link
Contributor

cmonr commented Jun 13, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jun 13, 2018

Build : SUCCESS

Build number : 2350
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7058/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Jun 13, 2018

@mbed-ci
Copy link

mbed-ci commented Jun 15, 2018

@cmonr cmonr merged commit 74a75d5 into ARMmbed:master Jun 15, 2018
@davidsaada davidsaada deleted the david_exhaustible_bd_fix branch July 9, 2018 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants