-
Notifications
You must be signed in to change notification settings - Fork 3k
Standardized FileSystem init/deinit/reset to match KVStore API #8700
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
Standardized: FileSystem::mount -> FileSystem::init FileSystem::unmount -> FileSystem::deinit FileSystem::reformat -> FileSystem::reset Note that init/reset no longer accept BlockDevice arguments. This paves the way to standardizing classes to be configured only at construction time. To make this work, recursive init/deinit functions were needed similar to the BlockDevices, and these init/deinit functions are lazily called during the first filesystem operations to match the existing behavior where init/deinit are ignored completely.
bcef816
to
833379c
Compare
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.
Great change, great timing. 👍
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.
Looks good to me, just few queries for my understanding
} | ||
|
||
FATFileSystem::~FATFileSystem() | ||
{ | ||
// nop if unmounted | ||
unmount(); | ||
// noop if unmounted |
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.
Is the comment still valid? Unmounted - Not initialized?
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.
Yep! The reference counting also handles more deinits than inits:
if (_ref > 0) {
_ref -= 1;
if (_ref == 0) {
res = f_mount(NULL, _fsid, 0);
_ffs[_id] = NULL;
_id = -1;
}
}
}
*/ | ||
virtual int deinit(); | ||
|
||
/** Reformats the underlying filesystem |
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.
Should we specify explicitly that file system will be initialised and mounted as part of reset call?
} | ||
|
||
/* See http://elm-chan.org/fsw/ff/en/mkfs.html for details of f_mkfs() and | ||
* associated arguments. */ | ||
int FATFileSystem::format(BlockDevice *bd, bd_size_t cluster_size) | ||
{ | ||
FATFileSystem fs; | ||
fs.lock(); |
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.
Not sure why locking is removed in format operation..
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.
Ah, it's because I narrowed the scope of the fs instance.
The file system only exists inside this function, so locking didn't have any benefit.
* | ||
* The init function may be called multiple times recursively as long | ||
* as each init has a matching deinit. If not called, the file system | ||
* will be mounted on the first file system operation. |
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.
Reset will be considered as valid call before init?
@geky I need some review here to understand the motivation, will look at this after the weekend |
Lazy init() comes with its toll .. lots of copies of "if (_ref == 0) { // make sure we're mounted ..." .. not sure if its avoidable.. I thought of these scenarios e.g. (maybe its not legit or I got it wrong..) Scenario (A):
Scenario (B):
|
@geky This change defines existing API as deprecated and introduces new APIs. |
@dannybenor, up to you. It would be nice to have the big storage changes in the same release. |
It will be good to have test cases updated in same PR. Apart from that it looks good to me 👍 |
@dannybenor @geky Could you please confirm whether you expect this to come into 5.11 or not ? As this is changing APIs including deprecation then if it does not make 5.11 it is delayed to 5.12.... |
This should be delayed to 5.12. Needs review outside github. |
The version label was updated. |
@ARMmbed/mbed-os-storage Any progress? This has idled for nearly a month. |
@cmonr This needs review outside github. Not sure how to mark it but do expect this to be solved soon |
@geky , FYI: this now needs a rebase as well. |
@dannybenor That comment is sufficient. Let us know if the review will end up taking more than two weeks. |
As this is being discussed offlline, we will close this PR. Please reopen with an update |
Description
This standardizes init/deinit/reset to match behaviour in KVStore and BlockDevice. This makes init consistent across all three APIs.
Standardized:
Note that init/reset do not accept BlockDevice arguments. This paves the way to standardizing classes to be configured only at construction time.
To make this work, recursive init/deinit functions were needed similar to the BlockDevices, and these init/deinit functions are lazily called during the first filesystem operations to match the existing behavior where init/deinit are ignored completely.
Pull request type
Related to #8667
cc @armmbed/mbed-os-storage, @deepikabhavnani, @dannybenor, @davidsaada