mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-30 00:21:06 +00:00
10d3ac346f
When building the file system the existing code does an insertion into a linked list. It attempts to speed this up by keeping a pointer to where the last entry was inserted but it's still slow. Now the nodes are just inserted into the list without searching through for the correct place. This unsorted list is then sorted once using mergesort after all the entries have been added to the list. This speeds up the scanning of the flash file system considerably. Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
105 lines
2 KiB
C
105 lines
2 KiB
C
#ifndef jffs2_private_h
|
|
#define jffs2_private_h
|
|
|
|
#include <jffs2/jffs2.h>
|
|
|
|
|
|
struct b_node {
|
|
u32 offset;
|
|
struct b_node *next;
|
|
enum { CRC_UNKNOWN = 0, CRC_OK, CRC_BAD } datacrc;
|
|
};
|
|
|
|
struct b_list {
|
|
struct b_node *listTail;
|
|
struct b_node *listHead;
|
|
#ifdef CONFIG_SYS_JFFS2_SORT_FRAGMENTS
|
|
struct b_node *listLast;
|
|
int (*listCompare)(struct b_node *new, struct b_node *node);
|
|
u32 listLoops;
|
|
#endif
|
|
u32 listCount;
|
|
struct mem_block *listMemBase;
|
|
};
|
|
|
|
struct b_lists {
|
|
struct b_list dir;
|
|
struct b_list frag;
|
|
void *readbuf;
|
|
};
|
|
|
|
struct b_compr_info {
|
|
u32 num_frags;
|
|
u32 compr_sum;
|
|
u32 decompr_sum;
|
|
};
|
|
|
|
struct b_jffs2_info {
|
|
struct b_compr_info compr_info[JFFS2_NUM_COMPR];
|
|
};
|
|
|
|
static inline int
|
|
hdr_crc(struct jffs2_unknown_node *node)
|
|
{
|
|
#if 1
|
|
u32 crc = crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4);
|
|
#else
|
|
/* what's the semantics of this? why is this here? */
|
|
u32 crc = crc32_no_comp(~0, (unsigned char *)node, sizeof(struct jffs2_unknown_node) - 4);
|
|
|
|
crc ^= ~0;
|
|
#endif
|
|
if (node->hdr_crc != crc) {
|
|
return 0;
|
|
} else {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
static inline int
|
|
dirent_crc(struct jffs2_raw_dirent *node)
|
|
{
|
|
if (node->node_crc != crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_raw_dirent) - 8)) {
|
|
return 0;
|
|
} else {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
static inline int
|
|
dirent_name_crc(struct jffs2_raw_dirent *node)
|
|
{
|
|
if (node->name_crc != crc32_no_comp(0, (unsigned char *)&(node->name), node->nsize)) {
|
|
return 0;
|
|
} else {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
static inline int
|
|
inode_crc(struct jffs2_raw_inode *node)
|
|
{
|
|
if (node->node_crc != crc32_no_comp(0, (unsigned char *)node, sizeof(struct jffs2_raw_inode) - 8)) {
|
|
return 0;
|
|
} else {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
static inline int
|
|
data_crc(struct jffs2_raw_inode *node)
|
|
{
|
|
if (node->data_crc != crc32_no_comp(0, (unsigned char *)
|
|
((int) &node->node_crc + sizeof (node->node_crc)),
|
|
node->csize)) {
|
|
return 0;
|
|
} else {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
#if defined(CONFIG_SYS_JFFS2_SORT_FRAGMENTS)
|
|
/* External merge sort. */
|
|
int sort_list(struct b_list *list);
|
|
#endif
|
|
#endif /* jffs2_private.h */
|