Commit 0761f492 authored by Adrian Bunk's avatar Adrian Bunk Committed by Linus Torvalds

[PATCH] fs/jffs/: misc cleanups

This patch contains the following cleanups:
- make some needlessly global code static
- #if 0 the following unused functions:
  - intrep.c: jffs_print_file
  - jffs_fm.c: jffs_print_node_ref
Signed-off-by: default avatarAdrian Bunk <bunk@stusta.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent c4218843
...@@ -334,7 +334,7 @@ jffs_setattr(struct dentry *dentry, struct iattr *iattr) ...@@ -334,7 +334,7 @@ jffs_setattr(struct dentry *dentry, struct iattr *iattr)
} /* jffs_notify_change() */ } /* jffs_notify_change() */
struct inode * static struct inode *
jffs_new_inode(const struct inode * dir, struct jffs_raw_inode *raw_inode, jffs_new_inode(const struct inode * dir, struct jffs_raw_inode *raw_inode,
int * err) int * err)
{ {
...@@ -376,7 +376,7 @@ jffs_new_inode(const struct inode * dir, struct jffs_raw_inode *raw_inode, ...@@ -376,7 +376,7 @@ jffs_new_inode(const struct inode * dir, struct jffs_raw_inode *raw_inode,
} }
/* Get statistics of the file system. */ /* Get statistics of the file system. */
int static int
jffs_statfs(struct super_block *sb, struct kstatfs *buf) jffs_statfs(struct super_block *sb, struct kstatfs *buf)
{ {
struct jffs_control *c = (struct jffs_control *) sb->s_fs_info; struct jffs_control *c = (struct jffs_control *) sb->s_fs_info;
...@@ -410,7 +410,7 @@ jffs_statfs(struct super_block *sb, struct kstatfs *buf) ...@@ -410,7 +410,7 @@ jffs_statfs(struct super_block *sb, struct kstatfs *buf)
/* Rename a file. */ /* Rename a file. */
int static int
jffs_rename(struct inode *old_dir, struct dentry *old_dentry, jffs_rename(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry) struct inode *new_dir, struct dentry *new_dentry)
{ {
...@@ -1739,7 +1739,7 @@ jffs_read_inode(struct inode *inode) ...@@ -1739,7 +1739,7 @@ jffs_read_inode(struct inode *inode)
} }
void static void
jffs_delete_inode(struct inode *inode) jffs_delete_inode(struct inode *inode)
{ {
struct jffs_file *f; struct jffs_file *f;
...@@ -1762,7 +1762,7 @@ jffs_delete_inode(struct inode *inode) ...@@ -1762,7 +1762,7 @@ jffs_delete_inode(struct inode *inode)
} }
void static void
jffs_write_super(struct super_block *sb) jffs_write_super(struct super_block *sb)
{ {
struct jffs_control *c = (struct jffs_control *)sb->s_fs_info; struct jffs_control *c = (struct jffs_control *)sb->s_fs_info;
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
#include "jffs_fm.h" #include "jffs_fm.h"
long no_jffs_node = 0; long no_jffs_node = 0;
long no_jffs_file = 0; static long no_jffs_file = 0;
#if defined(JFFS_MEMORY_DEBUG) && JFFS_MEMORY_DEBUG #if defined(JFFS_MEMORY_DEBUG) && JFFS_MEMORY_DEBUG
long no_jffs_control = 0; long no_jffs_control = 0;
long no_jffs_raw_inode = 0; long no_jffs_raw_inode = 0;
...@@ -85,6 +85,32 @@ long no_name = 0; ...@@ -85,6 +85,32 @@ long no_name = 0;
static int jffs_scan_flash(struct jffs_control *c); static int jffs_scan_flash(struct jffs_control *c);
static int jffs_update_file(struct jffs_file *f, struct jffs_node *node); static int jffs_update_file(struct jffs_file *f, struct jffs_node *node);
static int jffs_build_file(struct jffs_file *f);
static int jffs_free_file(struct jffs_file *f);
static int jffs_free_node_list(struct jffs_file *f);
static int jffs_garbage_collect_now(struct jffs_control *c);
static int jffs_insert_file_into_hash(struct jffs_file *f);
static int jffs_remove_redundant_nodes(struct jffs_file *f);
/* Is there enough space on the flash? */
static inline int JFFS_ENOUGH_SPACE(struct jffs_control *c, __u32 space)
{
struct jffs_fmcontrol *fmc = c->fmc;
while (1) {
if ((fmc->flash_size - (fmc->used_size + fmc->dirty_size))
>= fmc->min_free_size + space) {
return 1;
}
if (fmc->dirty_size < fmc->sector_size)
return 0;
if (jffs_garbage_collect_now(c)) {
D1(printk("JFFS_ENOUGH_SPACE: jffs_garbage_collect_now() failed.\n"));
return 0;
}
}
}
#if CONFIG_JFFS_FS_VERBOSE > 0 #if CONFIG_JFFS_FS_VERBOSE > 0
static __u8 static __u8
...@@ -331,7 +357,7 @@ flash_erase_region(struct mtd_info *mtd, loff_t start, ...@@ -331,7 +357,7 @@ flash_erase_region(struct mtd_info *mtd, loff_t start,
} }
/* This routine calculates checksums in JFFS. */ /* This routine calculates checksums in JFFS. */
__u32 static __u32
jffs_checksum(const void *data, int size) jffs_checksum(const void *data, int size)
{ {
__u32 sum = 0; __u32 sum = 0;
...@@ -344,7 +370,7 @@ jffs_checksum(const void *data, int size) ...@@ -344,7 +370,7 @@ jffs_checksum(const void *data, int size)
} }
int static int
jffs_checksum_flash(struct mtd_info *mtd, loff_t start, int size, __u32 *result) jffs_checksum_flash(struct mtd_info *mtd, loff_t start, int size, __u32 *result)
{ {
__u32 sum = 0; __u32 sum = 0;
...@@ -646,7 +672,7 @@ jffs_build_fs(struct super_block *sb) ...@@ -646,7 +672,7 @@ jffs_build_fs(struct super_block *sb)
a (even) higher degree of confidence in your mount process. a (even) higher degree of confidence in your mount process.
A higher number would of course slow down your mount. A higher number would of course slow down your mount.
*/ */
int check_partly_erased_sectors(struct jffs_fmcontrol *fmc){ static int check_partly_erased_sectors(struct jffs_fmcontrol *fmc){
#define NUM_REREADS 4 /* see note above */ #define NUM_REREADS 4 /* see note above */
#define READ_AHEAD_BYTES 4096 /* must be a multiple of 4, #define READ_AHEAD_BYTES 4096 /* must be a multiple of 4,
...@@ -1478,7 +1504,7 @@ jffs_classify_node(struct jffs_node *node) ...@@ -1478,7 +1504,7 @@ jffs_classify_node(struct jffs_node *node)
/* Remove redundant nodes from a file. Mark the on-flash memory /* Remove redundant nodes from a file. Mark the on-flash memory
as dirty. */ as dirty. */
int static int
jffs_remove_redundant_nodes(struct jffs_file *f) jffs_remove_redundant_nodes(struct jffs_file *f)
{ {
struct jffs_node *newest_node; struct jffs_node *newest_node;
...@@ -1532,7 +1558,7 @@ jffs_remove_redundant_nodes(struct jffs_file *f) ...@@ -1532,7 +1558,7 @@ jffs_remove_redundant_nodes(struct jffs_file *f)
/* Insert a file into the hash table. */ /* Insert a file into the hash table. */
int static int
jffs_insert_file_into_hash(struct jffs_file *f) jffs_insert_file_into_hash(struct jffs_file *f)
{ {
int i = f->ino % f->c->hash_len; int i = f->ino % f->c->hash_len;
...@@ -1580,7 +1606,7 @@ jffs_insert_file_into_tree(struct jffs_file *f) ...@@ -1580,7 +1606,7 @@ jffs_insert_file_into_tree(struct jffs_file *f)
/* Remove a file from the hash table. */ /* Remove a file from the hash table. */
int static int
jffs_unlink_file_from_hash(struct jffs_file *f) jffs_unlink_file_from_hash(struct jffs_file *f)
{ {
D3(printk("jffs_unlink_file_from_hash(): f: 0x%p, " D3(printk("jffs_unlink_file_from_hash(): f: 0x%p, "
...@@ -2038,7 +2064,7 @@ jffs_foreach_file(struct jffs_control *c, int (*func)(struct jffs_file *)) ...@@ -2038,7 +2064,7 @@ jffs_foreach_file(struct jffs_control *c, int (*func)(struct jffs_file *))
/* Free all nodes associated with a file. */ /* Free all nodes associated with a file. */
int static int
jffs_free_node_list(struct jffs_file *f) jffs_free_node_list(struct jffs_file *f)
{ {
struct jffs_node *node; struct jffs_node *node;
...@@ -2058,7 +2084,7 @@ jffs_free_node_list(struct jffs_file *f) ...@@ -2058,7 +2084,7 @@ jffs_free_node_list(struct jffs_file *f)
/* Free a file and its name. */ /* Free a file and its name. */
int static int
jffs_free_file(struct jffs_file *f) jffs_free_file(struct jffs_file *f)
{ {
D3(printk("jffs_free_file: f #%u, \"%s\"\n", D3(printk("jffs_free_file: f #%u, \"%s\"\n",
...@@ -2073,7 +2099,7 @@ jffs_free_file(struct jffs_file *f) ...@@ -2073,7 +2099,7 @@ jffs_free_file(struct jffs_file *f)
return 0; return 0;
} }
long static long
jffs_get_file_count(void) jffs_get_file_count(void)
{ {
return no_jffs_file; return no_jffs_file;
...@@ -2127,7 +2153,7 @@ jffs_file_count(struct jffs_file *f) ...@@ -2127,7 +2153,7 @@ jffs_file_count(struct jffs_file *f)
/* Build up a file's range list from scratch by going through the /* Build up a file's range list from scratch by going through the
version list. */ version list. */
int static int
jffs_build_file(struct jffs_file *f) jffs_build_file(struct jffs_file *f)
{ {
struct jffs_node *n; struct jffs_node *n;
...@@ -2481,7 +2507,6 @@ jffs_update_file(struct jffs_file *f, struct jffs_node *node) ...@@ -2481,7 +2507,6 @@ jffs_update_file(struct jffs_file *f, struct jffs_node *node)
return 0; return 0;
} }
/* Print the contents of a node. */ /* Print the contents of a node. */
void void
jffs_print_node(struct jffs_node *n) jffs_print_node(struct jffs_node *n)
...@@ -2541,6 +2566,7 @@ jffs_print_raw_inode(struct jffs_raw_inode *raw_inode) ...@@ -2541,6 +2566,7 @@ jffs_print_raw_inode(struct jffs_raw_inode *raw_inode)
/* Print the contents of a file. */ /* Print the contents of a file. */
#if 0
int int
jffs_print_file(struct jffs_file *f) jffs_print_file(struct jffs_file *f)
{ {
...@@ -2580,7 +2606,7 @@ jffs_print_file(struct jffs_file *f) ...@@ -2580,7 +2606,7 @@ jffs_print_file(struct jffs_file *f)
D(printk("}\n")); D(printk("}\n"));
return 0; return 0;
} }
#endif /* 0 */
void void
jffs_print_hash_table(struct jffs_control *c) jffs_print_hash_table(struct jffs_control *c)
...@@ -2655,7 +2681,7 @@ jffs_print_memory_allocation_statistics(void) ...@@ -2655,7 +2681,7 @@ jffs_print_memory_allocation_statistics(void)
/* Rewrite `size' bytes, and begin at `node'. */ /* Rewrite `size' bytes, and begin at `node'. */
int static int
jffs_rewrite_data(struct jffs_file *f, struct jffs_node *node, __u32 size) jffs_rewrite_data(struct jffs_file *f, struct jffs_node *node, __u32 size)
{ {
struct jffs_control *c = f->c; struct jffs_control *c = f->c;
...@@ -2858,7 +2884,7 @@ jffs_rewrite_data(struct jffs_file *f, struct jffs_node *node, __u32 size) ...@@ -2858,7 +2884,7 @@ jffs_rewrite_data(struct jffs_file *f, struct jffs_node *node, __u32 size)
process and is often called multiple times at each occasion of a process and is often called multiple times at each occasion of a
garbage collect. */ garbage collect. */
int static int
jffs_garbage_collect_next(struct jffs_control *c) jffs_garbage_collect_next(struct jffs_control *c)
{ {
struct jffs_fmcontrol *fmc = c->fmc; struct jffs_fmcontrol *fmc = c->fmc;
...@@ -3097,7 +3123,7 @@ jffs_clear_end_of_node(struct jffs_control *c, __u32 erase_size) ...@@ -3097,7 +3123,7 @@ jffs_clear_end_of_node(struct jffs_control *c, __u32 erase_size)
} /* jffs_clear_end_of_node() */ } /* jffs_clear_end_of_node() */
/* Try to erase as much as possible of the dirt in the flash memory. */ /* Try to erase as much as possible of the dirt in the flash memory. */
long static long
jffs_try_to_erase(struct jffs_control *c) jffs_try_to_erase(struct jffs_control *c)
{ {
struct jffs_fmcontrol *fmc = c->fmc; struct jffs_fmcontrol *fmc = c->fmc;
...@@ -3198,7 +3224,7 @@ jffs_try_to_erase(struct jffs_control *c) ...@@ -3198,7 +3224,7 @@ jffs_try_to_erase(struct jffs_control *c)
collection can be. */ collection can be. */
int static int
jffs_garbage_collect_now(struct jffs_control *c) jffs_garbage_collect_now(struct jffs_control *c)
{ {
struct jffs_fmcontrol *fmc = c->fmc; struct jffs_fmcontrol *fmc = c->fmc;
......
...@@ -20,9 +20,6 @@ ...@@ -20,9 +20,6 @@
struct jffs_node *jffs_alloc_node(void); struct jffs_node *jffs_alloc_node(void);
void jffs_free_node(struct jffs_node *n); void jffs_free_node(struct jffs_node *n);
int jffs_get_node_inuse(void); int jffs_get_node_inuse(void);
long jffs_get_file_count(void);
__u32 jffs_checksum(const void *data, int size);
void jffs_cleanup_control(struct jffs_control *c); void jffs_cleanup_control(struct jffs_control *c);
int jffs_build_fs(struct super_block *sb); int jffs_build_fs(struct super_block *sb);
...@@ -36,15 +33,9 @@ struct jffs_file *jffs_find_child(struct jffs_file *dir, const char *name, int l ...@@ -36,15 +33,9 @@ struct jffs_file *jffs_find_child(struct jffs_file *dir, const char *name, int l
void jffs_free_node(struct jffs_node *node); void jffs_free_node(struct jffs_node *node);
int jffs_foreach_file(struct jffs_control *c, int (*func)(struct jffs_file *)); int jffs_foreach_file(struct jffs_control *c, int (*func)(struct jffs_file *));
int jffs_free_node_list(struct jffs_file *f);
int jffs_free_file(struct jffs_file *f);
int jffs_possibly_delete_file(struct jffs_file *f); int jffs_possibly_delete_file(struct jffs_file *f);
int jffs_build_file(struct jffs_file *f);
int jffs_insert_file_into_hash(struct jffs_file *f);
int jffs_insert_file_into_tree(struct jffs_file *f); int jffs_insert_file_into_tree(struct jffs_file *f);
int jffs_unlink_file_from_hash(struct jffs_file *f);
int jffs_unlink_file_from_tree(struct jffs_file *f); int jffs_unlink_file_from_tree(struct jffs_file *f);
int jffs_remove_redundant_nodes(struct jffs_file *f);
int jffs_file_count(struct jffs_file *f); int jffs_file_count(struct jffs_file *f);
int jffs_write_node(struct jffs_control *c, struct jffs_node *node, int jffs_write_node(struct jffs_control *c, struct jffs_node *node,
...@@ -56,32 +47,13 @@ int jffs_read_data(struct jffs_file *f, unsigned char *buf, __u32 read_offset, _ ...@@ -56,32 +47,13 @@ int jffs_read_data(struct jffs_file *f, unsigned char *buf, __u32 read_offset, _
/* Garbage collection stuff. */ /* Garbage collection stuff. */
int jffs_garbage_collect_thread(void *c); int jffs_garbage_collect_thread(void *c);
void jffs_garbage_collect_trigger(struct jffs_control *c); void jffs_garbage_collect_trigger(struct jffs_control *c);
int jffs_garbage_collect_now(struct jffs_control *c);
/* Is there enough space on the flash? */
static inline int JFFS_ENOUGH_SPACE(struct jffs_control *c, __u32 space)
{
struct jffs_fmcontrol *fmc = c->fmc;
while (1) {
if ((fmc->flash_size - (fmc->used_size + fmc->dirty_size))
>= fmc->min_free_size + space) {
return 1;
}
if (fmc->dirty_size < fmc->sector_size)
return 0;
if (jffs_garbage_collect_now(c)) {
D1(printk("JFFS_ENOUGH_SPACE: jffs_garbage_collect_now() failed.\n"));
return 0;
}
}
}
/* For debugging purposes. */ /* For debugging purposes. */
void jffs_print_node(struct jffs_node *n); void jffs_print_node(struct jffs_node *n);
void jffs_print_raw_inode(struct jffs_raw_inode *raw_inode); void jffs_print_raw_inode(struct jffs_raw_inode *raw_inode);
#if 0
int jffs_print_file(struct jffs_file *f); int jffs_print_file(struct jffs_file *f);
#endif /* 0 */
void jffs_print_hash_table(struct jffs_control *c); void jffs_print_hash_table(struct jffs_control *c);
void jffs_print_tree(struct jffs_file *first_file, int indent); void jffs_print_tree(struct jffs_file *first_file, int indent);
......
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
static int jffs_mark_obsolete(struct jffs_fmcontrol *fmc, __u32 fm_offset); static int jffs_mark_obsolete(struct jffs_fmcontrol *fmc, __u32 fm_offset);
#endif #endif
static struct jffs_fm *jffs_alloc_fm(void);
static void jffs_free_fm(struct jffs_fm *n);
extern kmem_cache_t *fm_cache; extern kmem_cache_t *fm_cache;
extern kmem_cache_t *node_cache; extern kmem_cache_t *node_cache;
...@@ -602,7 +605,7 @@ jffs_mark_obsolete(struct jffs_fmcontrol *fmc, __u32 fm_offset) ...@@ -602,7 +605,7 @@ jffs_mark_obsolete(struct jffs_fmcontrol *fmc, __u32 fm_offset)
/* check if it's possible to erase the wanted range, and if not, return /* check if it's possible to erase the wanted range, and if not, return
* the range that IS erasable, or a negative error code. * the range that IS erasable, or a negative error code.
*/ */
long static long
jffs_flash_erasable_size(struct mtd_info *mtd, __u32 offset, __u32 size) jffs_flash_erasable_size(struct mtd_info *mtd, __u32 offset, __u32 size)
{ {
u_long ssize; u_long ssize;
...@@ -700,7 +703,7 @@ jffs_erasable_size(struct jffs_fmcontrol *fmc) ...@@ -700,7 +703,7 @@ jffs_erasable_size(struct jffs_fmcontrol *fmc)
return (ret >= 0 ? ret : 0); return (ret >= 0 ? ret : 0);
} }
struct jffs_fm *jffs_alloc_fm(void) static struct jffs_fm *jffs_alloc_fm(void)
{ {
struct jffs_fm *fm; struct jffs_fm *fm;
...@@ -710,7 +713,7 @@ struct jffs_fm *jffs_alloc_fm(void) ...@@ -710,7 +713,7 @@ struct jffs_fm *jffs_alloc_fm(void)
return fm; return fm;
} }
void jffs_free_fm(struct jffs_fm *n) static void jffs_free_fm(struct jffs_fm *n)
{ {
kmem_cache_free(fm_cache,n); kmem_cache_free(fm_cache,n);
DJM(no_jffs_fm--); DJM(no_jffs_fm--);
...@@ -778,6 +781,7 @@ jffs_print_fm(struct jffs_fm *fm) ...@@ -778,6 +781,7 @@ jffs_print_fm(struct jffs_fm *fm)
D(printk("}\n")); D(printk("}\n"));
} }
#if 0
void void
jffs_print_node_ref(struct jffs_node_ref *ref) jffs_print_node_ref(struct jffs_node_ref *ref)
{ {
...@@ -787,3 +791,5 @@ jffs_print_node_ref(struct jffs_node_ref *ref) ...@@ -787,3 +791,5 @@ jffs_print_node_ref(struct jffs_node_ref *ref)
D(printk(" 0x%p, /* next */\n", ref->next)); D(printk(" 0x%p, /* next */\n", ref->next));
D(printk("}\n")); D(printk("}\n"));
} }
#endif /* 0 */
...@@ -64,10 +64,6 @@ ...@@ -64,10 +64,6 @@
void jffs_free_fm(struct jffs_fm *n);
struct jffs_fm *jffs_alloc_fm(void);
struct jffs_node_ref struct jffs_node_ref
{ {
struct jffs_node *node; struct jffs_node *node;
...@@ -145,6 +141,8 @@ void jffs_fmfree_partly(struct jffs_fmcontrol *fmc, struct jffs_fm *fm, ...@@ -145,6 +141,8 @@ void jffs_fmfree_partly(struct jffs_fmcontrol *fmc, struct jffs_fm *fm,
void jffs_print_fmcontrol(struct jffs_fmcontrol *fmc); void jffs_print_fmcontrol(struct jffs_fmcontrol *fmc);
void jffs_print_fm(struct jffs_fm *fm); void jffs_print_fm(struct jffs_fm *fm);
#if 0
void jffs_print_node_ref(struct jffs_node_ref *ref); void jffs_print_node_ref(struct jffs_node_ref *ref);
#endif /* 0 */
#endif /* __LINUX_JFFS_FM_H__ */ #endif /* __LINUX_JFFS_FM_H__ */
...@@ -208,7 +208,6 @@ struct jffs_flash_status ...@@ -208,7 +208,6 @@ struct jffs_flash_status
#define JFFS_MEMORY_DEBUG 0 #define JFFS_MEMORY_DEBUG 0
extern long no_jffs_node; extern long no_jffs_node;
extern long no_jffs_file;
#if defined(JFFS_MEMORY_DEBUG) && JFFS_MEMORY_DEBUG #if defined(JFFS_MEMORY_DEBUG) && JFFS_MEMORY_DEBUG
extern long no_jffs_control; extern long no_jffs_control;
extern long no_jffs_raw_inode; extern long no_jffs_raw_inode;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment