From 2e0502cbb721c72fcae6807ac85edd9900b60a40 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 7 Jul 2022 14:43:25 +0100 Subject: [PATCH] Storage: Don't align files <512 bytes to page boundaries - all files now stored in order (ref #2232) --- ChangeLog | 3 ++- src/jsflash.c | 16 +++------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index a38e646ce..113e1cc79 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,7 +14,8 @@ nRF5x: Add 'onWriteDesc' in NRF.setServices - allowing you to know when something subscribed for notifications nRF5x: Move advertising_start and restart_softdevice outside of IRQs (MEMORY_BUSY warnings less likely now) Bangle.js: Ensure E.showMessage background color comes from theme - Bangle.js: Add "filename table" support to Bangle.js - avoids slow file read/list when there are many deleted/updated files in Storage + Bangle.js: Add "filename table" support to Bangle.js - avoids slow file read/list when there are many deleted/updated files in Storage (fix #2152) + Storage: Don't align files <512 bytes to page boundaries - all files now stored in order (ref #2232) 2v14 : Bangle.js2: Fix issue with E.showMenu creating a global `s` variable Bangle.js2: Recheck string wrapping after font change inside E.showMenu diff --git a/src/jsflash.c b/src/jsflash.c index e624fad90..c69ecff4c 100644 --- a/src/jsflash.c +++ b/src/jsflash.c @@ -681,20 +681,10 @@ static uint32_t jsfCreateFile(JsfFileName name, uint32_t size, JsfFileFlags flag } } }; - // If we were going to straddle the next page and there's enough space, - // push this file forwards so it starts on a clean page boundary - // Maybe we shouldn't do this any more - see https://github.com/espruino/Espruino/issues/2232 + /* We used to push files forward to the nearest page boundary but now there's very little point + doing this. While we still have to cope with it when reading storage, we now don't try and align + new files - see https://github.com/espruino/Espruino/issues/2232 */ addr = freeAddr; - uint32_t spaceAvailable = jsfGetSpaceLeftInPage(addr); - uint32_t nextPage = jsfGetAddressOfNextPage(addr); - if (nextPage && // there is a next page - ((nextPage - addr) < requiredSize) && // it would straddle pages - (spaceAvailable > (size + nextPage - addr)) && // there is space - (requiredSize < 512) && // it's not too big. We should always try and put big files as near the start as possible. See note in jsfCompact - !jsfGetFileHeader(nextPage, &header, false)) { // the next page is free - jsDebug(DBG_INFO,"CreateFile straddles page boundary, pushed to next page (0x%08x -> 0x%08x)\n", addr, nextPage); - addr = nextPage; - } // write out the header jsDebug(DBG_INFO,"CreateFile new 0x%08x\n", addr+(uint32_t)sizeof(JsfFileHeader)); header.size = size | (flags<<24);