mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-02 07:09:33 +01:00
nvs_flash: Fix nvs_set_blob hang when partition is near to FULL
Marking a page full does not skip it from page selection process and the same page might get returned if there is no other page with more unused entries. Added a check for the same while storing blobs. Fixes: https://github.com/espressif/esp-idf/issues/2313
This commit is contained in:
@@ -180,6 +180,9 @@ esp_err_t Storage::writeMultiPageBlob(uint8_t nsIndex, const char* key, const vo
|
||||
err = mPageManager.requestNewPage();
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
} else if(getCurrentPage().getVarDataTailroom() == tailroom) {
|
||||
/* We got the same page or we are not improving.*/
|
||||
return ESP_ERR_NVS_NOT_ENOUGH_SPACE;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
@@ -257,7 +260,6 @@ esp_err_t Storage::writeItem(uint8_t nsIndex, ItemType datatype, const char* key
|
||||
err = findItem(nsIndex, datatype, key, findPage, item);
|
||||
}
|
||||
|
||||
|
||||
if (err != ESP_OK && err != ESP_ERR_NVS_NOT_FOUND) {
|
||||
return err;
|
||||
}
|
||||
@@ -280,6 +282,7 @@ esp_err_t Storage::writeItem(uint8_t nsIndex, ItemType datatype, const char* key
|
||||
}
|
||||
/* Write the blob with new version*/
|
||||
err = writeMultiPageBlob(nsIndex, key, data, dataSize, nextStart);
|
||||
|
||||
if (err == ESP_ERR_NVS_PAGE_FULL) {
|
||||
return ESP_ERR_NVS_NOT_ENOUGH_SPACE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user