Commit 2d6d93a2ddb7111f42e87d3e0d8be754d4bcfb52

Authored by Mark Tomlinson
Committed by Tom Rini
1 parent 891224a5d8

JFFS2: Improve speed reading flash files

jffs2_1pass_read_inode() would read the entire data for each node
in the filesystem, regardless of whether it was part of the file
to be loaded or not. By only reading the header data for an inode,
and then reading the data only when it is found to be part of the
file to be loaded, much copying of data is saved.

jffs2_1pass_list_inodes() read each inode for every file in the
directory into a buffer. By using NULL as a buffer pointer, NOR
flash simply returns a pointer, and therefore avoids a memory copy.

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

Showing 1 changed file with 21 additions and 6 deletions Side-by-side Diff

fs/jffs2/jffs2_1pass.c
... ... @@ -735,8 +735,13 @@
735 735 #endif
736 736  
737 737 for (b = pL->frag.listHead; b != NULL; b = b->next) {
738   - jNode = (struct jffs2_raw_inode *) get_node_mem(b->offset,
739   - pL->readbuf);
  738 + /*
  739 + * Copy just the node and not the data at this point,
  740 + * since we don't yet know if we need this data.
  741 + */
  742 + jNode = (struct jffs2_raw_inode *)get_fl_mem(b->offset,
  743 + sizeof(struct jffs2_raw_inode),
  744 + pL->readbuf);
740 745 if (inode == jNode->ino) {
741 746 #if 0
742 747 putLabeledWord("\r\n\r\nread_inode: totlen = ", jNode->totlen);
... ... @@ -760,7 +765,15 @@
760 765 #endif
761 766  
762 767 if(dest) {
763   - src = ((uchar *) jNode) + sizeof(struct jffs2_raw_inode);
  768 + /*
  769 + * Now that the inode has been checked,
  770 + * read the entire inode, including data.
  771 + */
  772 + put_fl_mem(jNode, pL->readbuf);
  773 + jNode = (struct jffs2_raw_inode *)
  774 + get_node_mem(b->offset, pL->readbuf);
  775 + src = ((uchar *)jNode) +
  776 + sizeof(struct jffs2_raw_inode);
764 777 /* ignore data behind latest known EOF */
765 778 if (jNode->offset > totalSize) {
766 779 put_fl_mem(jNode, pL->readbuf);
... ... @@ -967,7 +980,6 @@
967 980 pL->readbuf);
968 981 if (pino == jDir->pino) {
969 982 u32 i_version = 0;
970   - struct jffs2_raw_inode ojNode;
971 983 struct jffs2_raw_inode *jNode, *i = NULL;
972 984 struct b_node *b2;
973 985  
... ... @@ -1003,8 +1015,10 @@
1003 1015  
1004 1016 for (b2 = pL->frag.listHead; b2; b2 = b2->next) {
1005 1017 jNode = (struct jffs2_raw_inode *)
1006   - get_fl_mem(b2->offset, sizeof(ojNode), &ojNode);
1007   - if (jNode->ino == jDir->ino && jNode->version >= i_version) {
  1018 + get_fl_mem(b2->offset, sizeof(*jNode),
  1019 + NULL);
  1020 + if (jNode->ino == jDir->ino &&
  1021 + jNode->version >= i_version) {
1008 1022 i_version = jNode->version;
1009 1023 if (i)
1010 1024 put_fl_mem(i, NULL);
... ... @@ -1017,6 +1031,7 @@
1017 1031 sizeof(*i),
1018 1032 NULL);
1019 1033 }
  1034 + put_fl_mem(jNode, NULL);
1020 1035 }
1021 1036  
1022 1037 dump_inode(pL, jDir, i);