[U-Boot,v3,2/2] fs: fat: Reduce default max clustersize 64KiB from malloc pool

Message ID 1549868180-21635-2-git-send-email-tien.fong.chee@intel.com
State Accepted
Commit e48485f5e4f99811ba41e89f782a3f282f3c5a2e
Delegated to: Tom Rini
Headers show
Series
  • [U-Boot,v3,1/2] fs: fat: dynamically allocate memory for temporary buffer
Related show

Commit Message

Chee, Tien Fong Feb. 11, 2019, 6:56 a.m.
From: Tien Fong Chee <tien.fong.chee@intel.com>

Release cluster block immediately when no longer use would help to reduce
64KiB memory allocated to the memory pool.

Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>

---

changes for v3
- Dropped the if conditional because free(NULL) is valid.
---
 fs/fat/fat.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Tom Rini Feb. 20, 2019, 1:58 a.m. | #1
On Mon, Feb 11, 2019 at 02:56:20PM +0800, tien.fong.chee@intel.com wrote:

> From: Tien Fong Chee <tien.fong.chee@intel.com>
> 
> Release cluster block immediately when no longer use would help to reduce
> 64KiB memory allocated to the memory pool.
> 
> Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>

Applied to u-boot/master, thanks!

Patch

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index ea11250..26ae101 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -1151,7 +1151,15 @@  int file_fat_read_at(const char *filename, loff_t pos, void *buffer,
 		goto out_free_both;
 
 	debug("reading %s at pos %llu\n", filename, pos);
-	ret = get_contents(&fsdata, itr->dent, pos, buffer, maxsize, actread);
+
+	/* For saving default max clustersize memory allocated to malloc pool */
+	dir_entry *dentptr = itr->dent;
+
+	free(itr);
+
+	itr = NULL;
+
+	ret = get_contents(&fsdata, dentptr, pos, buffer, maxsize, actread);
 
 out_free_both:
 	free(fsdata.fatbuf);