diff mbox

[U-Boot,v2,1/8] JFFS2: Return early when file read not necessary

Message ID 1435725509-12300-2-git-send-email-mark.tomlinson@alliedtelesis.co.nz
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Mark Tomlinson July 1, 2015, 4:38 a.m. UTC
If a destination is not provided, jffs2_1pass_read_inode() only
returns the length of the file. In this case, avoid reading all
the data nodes, and return as soon as the length of the file is
known.

Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>

---

Changes in v2:
- Fix comment style
- Remove extra {} pair.

 fs/jffs2/jffs2_1pass.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Tom Rini Aug. 13, 2015, 1:17 p.m. UTC | #1
On Wed, Jul 01, 2015 at 04:38:22PM +1200, Mark Tomlinson wrote:

> If a destination is not provided, jffs2_1pass_read_inode() only
> returns the length of the file. In this case, avoid reading all
> the data nodes, and return as soon as the length of the file is
> known.
> 
> Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
index b1d6470..2e569ff 100644
--- a/fs/jffs2/jffs2_1pass.c
+++ b/fs/jffs2/jffs2_1pass.c
@@ -719,6 +719,12 @@  jffs2_1pass_read_inode(struct b_lists *pL, u32 inode, char *dest)
 		}
 		put_fl_mem(jNode, pL->readbuf);
 	}
+	/*
+	 * If no destination is provided, we are done.
+	 * Just return the total size.
+	 */
+	if (!dest)
+		return totalSize;
 #endif
 
 	for (b = pL->frag.listHead; b != NULL; b = b->next) {