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)
committerTom Rini <trini@konsulko.com>
Thu, 13 Aug 2015 00:47:29 +0000 (20:47 -0400)
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);
        }
+       /*
+        * 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) {