Skip to content

Commit 45bcbcb

Browse files
committed
exposed garbage collector in FS, and tune garbage cycles
1 parent 073299b commit 45bcbcb

File tree

6 files changed

+48
-1
lines changed

6 files changed

+48
-1
lines changed

cores/esp8266/FS.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,26 @@ File FS::open(const char* path, const char* mode) {
206206
return File(_impl->open(path, om, am));
207207
}
208208

209+
void FS::check(void){
210+
if (!_impl) {
211+
return;
212+
}
213+
//_impl->check();
214+
return;
215+
}
216+
217+
uint32_t FS::gc(int size){
218+
if (!_impl) {
219+
return 0;
220+
}
221+
return _impl->gc(size);
222+
}
223+
224+
uint32_t FS::delPages(void){
225+
return _impl->delPages();
226+
}
227+
228+
209229
bool FS::exists(const char* path) {
210230
if (!_impl) {
211231
return false;

cores/esp8266/FS.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ class FS
106106

107107
bool begin();
108108
void end();
109+
void check(void);
110+
uint32_t gc(int size);
111+
uint32_t delPages(void);
109112

110113
bool format();
111114
bool info(FSInfo& info);

cores/esp8266/FSImpl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ class FSImpl {
7171
virtual DirImplPtr openDir(const char* path) = 0;
7272
virtual bool rename(const char* pathFrom, const char* pathTo) = 0;
7373
virtual bool remove(const char* path) = 0;
74+
virtual void check(void) = 0;
75+
virtual uint32_t gc(int size) = 0;
76+
virtual uint32_t delPages(void) = 0;
7477

7578
};
7679

cores/esp8266/spiffs/spiffs_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ typedef uint8_t u8_t;
130130

131131
// Define maximum number of gc runs to perform to reach desired free pages.
132132
#ifndef SPIFFS_GC_MAX_RUNS
133-
#define SPIFFS_GC_MAX_RUNS 5
133+
#define SPIFFS_GC_MAX_RUNS 15
134134
#endif
135135

136136
// Enable/disable statistics on gc. Debug/test purpose only.

cores/esp8266/spiffs_api.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@
2525

2626
using namespace fs;
2727

28+
void SPIFFSImpl::check(void){
29+
DEBUGV("SPIFFSImpl::check: starting SPIFFS_check_" );
30+
SPIFFS_check(&_fs);
31+
return;}
32+
33+
34+
uint32_t SPIFFSImpl::gc(int size){
35+
DEBUGV("SPIFFSImpl::check: starting SPIFFS_GC_" );
36+
SPIFFS_gc(&_fs, size);
37+
return _fs.stats_p_deleted;
38+
}
39+
40+
uint32_t SPIFFSImpl::delPages(void){
41+
return _fs.stats_p_deleted;
42+
}
43+
44+
2845
FileImplPtr SPIFFSImpl::open(const char* path, OpenMode openMode, AccessMode accessMode)
2946
{
3047
if (!isSpiffsFilenameValid(path)) {

cores/esp8266/spiffs_api.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ class SPIFFSImpl : public FSImpl
5858
memset(&_fs, 0, sizeof(_fs));
5959
}
6060

61+
void check(void) override;
62+
uint32_t delPages(void) override;
63+
uint32_t gc(int size) override;
64+
6165
FileImplPtr open(const char* path, OpenMode openMode, AccessMode accessMode) override;
6266
bool exists(const char* path) override;
6367
DirImplPtr openDir(const char* path) override;

0 commit comments

Comments
 (0)