Function esp_idf_sys::esp_spiffs_gc

source ยท
pub unsafe extern "C" fn esp_spiffs_gc(
    partition_label: *const c_char,
    size_to_gc: usize,
) -> esp_err_t
Expand description

@brief Perform garbage collection in SPIFFS partition

Call this function to run GC and ensure that at least the given amount of space is available in the partition. This function will fail with ESP_ERR_NOT_FINISHED if it is not possible to reclaim the requested space (that is, not enough free or deleted pages in the filesystem). This function will also fail if it fails to reclaim the requested space after CONFIG_SPIFFS_GC_MAX_RUNS number of GC iterations. On one GC iteration, SPIFFS will erase one logical block (4kB). Therefore the value of CONFIG_SPIFFS_GC_MAX_RUNS should be set at least to the maximum expected size_to_gc, divided by 4096. For example, if the application expects to make room for a 1MB file and calls esp_spiffs_gc(label, 1024 * 1024), CONFIG_SPIFFS_GC_MAX_RUNS should be set to at least 256. On the other hand, increasing CONFIG_SPIFFS_GC_MAX_RUNS value increases the maximum amount of time for which any SPIFFS GC or write operation may potentially block.

@param partition_label Label of the partition to be garbage-collected. The partition must be already mounted. @param size_to_gc The number of bytes that the GC process should attempt to make available. @return - ESP_OK on success - ESP_ERR_NOT_FINISHED if GC fails to reclaim the size given by size_to_gc - ESP_ERR_INVALID_STATE if the partition is not mounted - ESP_FAIL on all other errors