diff options
author | Marcin Niestroj <m.niestroj@grinn-global.com> | 2018-09-26 13:08:46 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-10-08 09:53:31 +0200 |
commit | 383b9348d7af2ba9caad23c08fd6553d014457a9 (patch) | |
tree | 6a664cdee4c9438b852f548a41a5aa76a60b18f9 /fs | |
parent | 5154902196cb4d2da17a7236e720db0b8d4ac565 (diff) | |
download | barebox-383b9348d7af2ba9caad23c08fd6553d014457a9.tar.gz barebox-383b9348d7af2ba9caad23c08fd6553d014457a9.tar.xz |
fs: improve ramfs_truncate speed
During sequential writes into single file, fs layer is consequently
calling ramfs_truncate() function. When file size grows
ramfs_truncate() takes more and more time to complete, due to
interations through all already written data chunks. As an example
loading ~450M image using usb fastboot protocol took over 500s to
complete.
Use ramfs_find_chunk() function to search for last chunk of data in
ramfs_truncate() implementation, which saves a lot of loop
iterations. As a result loading ~450M image using usb fastboot
protocol takes around 25s now.
Tested-by: Maciej Zagrabski <m.zagrabski@grinn-global.com>
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ramfs.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/ramfs.c b/fs/ramfs.c index 65dcefcc06..84ecfa0ddb 100644 --- a/fs/ramfs.c +++ b/fs/ramfs.c @@ -379,7 +379,9 @@ static int ramfs_truncate(struct device_d *dev, FILE *f, ulong size) } if (newchunks > oldchunks) { - if (!data) { + if (data) { + data = ramfs_find_chunk(node, oldchunks - 1); + } else { node->data = ramfs_get_chunk(); if (!node->data) return -ENOMEM; |