diff options
author | Daniel Drake <dsd@laptop.org> | 2010-10-07 14:14:02 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2010-10-24 19:57:19 -0400 |
commit | 65e5a0e18e5fb5bc6cfabd8ef4b9fc1c8569ba62 (patch) | |
tree | 0790ae9e682c5de24b0ffd7111a0bfab4f03aab3 /fs/jffs2/fs.c | |
parent | b46daf7eb1a143169699a8f9df634aa751a6ddde (diff) |
jffs2: Dynamically choose inocache hash size
When JFFS2 is used for large volumes, the mount times are quite long.
Increasing the hash size provides a significant speed boost on the OLPC
XO-1 laptop.
Add logic that dynamically selects a hash size based on the size of
the medium. A 64mb medium will result in a hash size of 128, and a 512mb
medium will result in a hash size of 1024.
Signed-off-by: Daniel Drake <dsd@laptop.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'fs/jffs2/fs.c')
-rw-r--r-- | fs/jffs2/fs.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index 6b2964a19850..2701b372da78 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c | |||
@@ -478,6 +478,25 @@ struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_i | |||
478 | return inode; | 478 | return inode; |
479 | } | 479 | } |
480 | 480 | ||
481 | static int calculate_inocache_hashsize(uint32_t flash_size) | ||
482 | { | ||
483 | /* | ||
484 | * Pick a inocache hash size based on the size of the medium. | ||
485 | * Count how many megabytes we're dealing with, apply a hashsize twice | ||
486 | * that size, but rounding down to the usual big powers of 2. And keep | ||
487 | * to sensible bounds. | ||
488 | */ | ||
489 | |||
490 | int size_mb = flash_size / 1024 / 1024; | ||
491 | int hashsize = (size_mb * 2) & ~0x3f; | ||
492 | |||
493 | if (hashsize < INOCACHE_HASHSIZE_MIN) | ||
494 | return INOCACHE_HASHSIZE_MIN; | ||
495 | if (hashsize > INOCACHE_HASHSIZE_MAX) | ||
496 | return INOCACHE_HASHSIZE_MAX; | ||
497 | |||
498 | return hashsize; | ||
499 | } | ||
481 | 500 | ||
482 | int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) | 501 | int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) |
483 | { | 502 | { |
@@ -524,7 +543,8 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) | |||
524 | if (ret) | 543 | if (ret) |
525 | return ret; | 544 | return ret; |
526 | 545 | ||
527 | c->inocache_list = kcalloc(INOCACHE_HASHSIZE, sizeof(struct jffs2_inode_cache *), GFP_KERNEL); | 546 | c->inocache_hashsize = calculate_inocache_hashsize(c->flash_size); |
547 | c->inocache_list = kcalloc(c->inocache_hashsize, sizeof(struct jffs2_inode_cache *), GFP_KERNEL); | ||
528 | if (!c->inocache_list) { | 548 | if (!c->inocache_list) { |
529 | ret = -ENOMEM; | 549 | ret = -ENOMEM; |
530 | goto out_wbuf; | 550 | goto out_wbuf; |