-
Notifications
You must be signed in to change notification settings - Fork 3k
Storage: Fix FATFileSystem unmount issue #14137
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
@rajkan01, thank you for your changes. |
@@ -330,8 +330,14 @@ int FATFileSystem::unmount() | |||
} | |||
|
|||
FRESULT res = f_mount(NULL, _fsid, 0); | |||
_ffs[_id] = NULL; | |||
_id = -1; | |||
if (!res) { |
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.
res
is of type FRESULT
not boolean, so check if res != FR_OK
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 have done the rework in this PR, please re-review
Yes, this is rather confusing. Even the documentation does not mention mount() would also initialize the blockdevice. I guess even those who wrote the examples just forgot about bd->deinit(); Actually i am for adding bd->deinit() to fs.unmount(). That way also bd->deinit() would happen automatically, after which we need to call fs.mount(bd); anyway if we want to access the file system once again. At least i can not think of any use case where binding bd->deinit() to fs.unmount() would break the code. |
a5ef032
to
1f94a5c
Compare
…y libary) API is called from both mount() and unmount() Mbed OS APIs. f_mount() is doing both initializing (via find_volume() -> disk_initialize() where disk_initialize api calls Mbed OS init() function) underlying block device and register filesystem but in case of "unmount" calls this f_mount is doing deregister filesystem and missed to a deinitializing block device. So added the Mbed OS "deint()" call in unmount API to deinitialize block device as f_mount API doesn't have a way to call deinit().
1f94a5c
to
a29e3cd
Compare
@0xc0170 This PR is ready for CI, could you please review and start the CI |
CI started |
Jenkins CI Test : ❌ FAILEDBuild Number: 3 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
@0xc0170 CI failure related to mbed deploy command failed with mbed os AWS example, please restart the CI
|
Restarted |
Jenkins CI Test : ❌ FAILEDBuild Number: 4 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
CI restarted |
Jenkins CI Test : ✔️ SUCCESSBuild Number: 5 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
Summary of changes
f_mount() (http://www.elm-chan.org/fsw/ff/00index_e.html - third party libary) API is called from both mount() and unmount() Mbed OS APIs.
f_mount() is doing both initializing (via find_volume() -> disk_initialize() where disk_initialize API calls Mbed OS block device init() function) underlying block device and register filesystem but in case of "unmount" calls, this f_mount is doing deregister filesystem and missed to a deinitializing block device.
So added the Mbed OS "deint()" call in unmount API to deinitialize block device as f_mount API doesn't have a way to call deinit().
fixes #12621
Impact of changes
With these changes, Unmount API will do both deregistering filesystem and deinitializing the underlaying block device.
Migration actions required
None.
Documentation
None.
Pull request type
Test results
Reviewers