]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
JFFS2: Return early when file read not necessary
authorMark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
Wed, 1 Jul 2015 04:38:22 +0000 (16:38 +1200)
committerLothar Waßmann <LW@KARO-electronics.de>
Thu, 10 Sep 2015 06:24:12 +0000 (08:24 +0200)
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>
fs/jffs2/jffs2_1pass.c

index b1d647021928897855166f34c421f5aac680c491..2e569ff59bb30a1d2b0594ba09a5e9d09c1979e4 100644 (file)
@@ -719,6 +719,12 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 inode, char *dest)
                }
                put_fl_mem(jNode, pL->readbuf);
        }
                }
                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) {
 #endif
 
        for (b = pL->frag.listHead; b != NULL; b = b->next) {