Commit 68270995 authored by David Woodhouse's avatar David Woodhouse

[JFFS2] Introduce jffs2_scan_dirty_space() function.

To eliminate the __totlen field from struct jffs2_raw_node_ref, we need
to allocate nodes for dirty space instead of just tweaking the accounting
data. Introduce jffs2_scan_dirty_space() in preparation for that.
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent 7807ef7b
...@@ -1080,3 +1080,14 @@ void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, ...@@ -1080,3 +1080,14 @@ void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
ref->__totlen = len; ref->__totlen = len;
ref->next_phys = NULL; ref->next_phys = NULL;
} }
int jffs2_scan_dirty_space(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
uint32_t size)
{
c->dirty_size += size;
c->free_size -= size;
jeb->dirty_size += size;
jeb->free_size -= size;
return 0;
}
...@@ -430,6 +430,7 @@ int jffs2_fill_scan_buf(struct jffs2_sb_info *c, void *buf, ...@@ -430,6 +430,7 @@ int jffs2_fill_scan_buf(struct jffs2_sb_info *c, void *buf,
uint32_t ofs, uint32_t len); uint32_t ofs, uint32_t len);
struct jffs2_inode_cache *jffs2_scan_make_ino_cache(struct jffs2_sb_info *c, uint32_t ino); struct jffs2_inode_cache *jffs2_scan_make_ino_cache(struct jffs2_sb_info *c, uint32_t ino);
int jffs2_scan_classify_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); int jffs2_scan_classify_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb);
int jffs2_scan_dirty_space(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, uint32_t size);
/* build.c */ /* build.c */
int jffs2_do_mount_fs(struct jffs2_sb_info *c); int jffs2_do_mount_fs(struct jffs2_sb_info *c);
......
This diff is collapsed.
...@@ -380,6 +380,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras ...@@ -380,6 +380,7 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
struct jffs2_full_dirent *fd; struct jffs2_full_dirent *fd;
void *sp; void *sp;
int i, ino; int i, ino;
int err;
sp = summary->sum; sp = summary->sum;
...@@ -494,7 +495,8 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras ...@@ -494,7 +495,8 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
jffs2_free_raw_node_ref(raw); jffs2_free_raw_node_ref(raw);
if (PTR_ERR(xd) == -EEXIST) { if (PTR_ERR(xd) == -EEXIST) {
/* a newer version of xd exists */ /* a newer version of xd exists */
DIRTY_SPACE(je32_to_cpu(spx->totlen)); if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(spx->totlen))))
return err;
sp += JFFS2_SUMMARY_XATTR_SIZE; sp += JFFS2_SUMMARY_XATTR_SIZE;
break; break;
} }
...@@ -585,6 +587,7 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb ...@@ -585,6 +587,7 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
struct jffs2_raw_node_ref *cache_ref; struct jffs2_raw_node_ref *cache_ref;
int ret, ofs; int ret, ofs;
uint32_t crc; uint32_t crc;
int err;
ofs = jeb->offset + c->sector_size - sumsize; ofs = jeb->offset + c->sector_size - sumsize;
...@@ -629,11 +632,13 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb ...@@ -629,11 +632,13 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
if (je32_to_cpu(summary->cln_mkr) != c->cleanmarker_size) { if (je32_to_cpu(summary->cln_mkr) != c->cleanmarker_size) {
dbg_summary("CLEANMARKER node has totlen 0x%x != normal 0x%x\n", dbg_summary("CLEANMARKER node has totlen 0x%x != normal 0x%x\n",
je32_to_cpu(summary->cln_mkr), c->cleanmarker_size); je32_to_cpu(summary->cln_mkr), c->cleanmarker_size);
DIRTY_SPACE(PAD(je32_to_cpu(summary->cln_mkr))); if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(summary->cln_mkr)))))
return err;
} else if (jeb->first_node) { } else if (jeb->first_node) {
dbg_summary("CLEANMARKER node not first node in block " dbg_summary("CLEANMARKER node not first node in block "
"(0x%08x)\n", jeb->offset); "(0x%08x)\n", jeb->offset);
DIRTY_SPACE(PAD(je32_to_cpu(summary->cln_mkr))); if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(summary->cln_mkr)))))
return err;
} else { } else {
struct jffs2_raw_node_ref *marker_ref = jffs2_alloc_raw_node_ref(); struct jffs2_raw_node_ref *marker_ref = jffs2_alloc_raw_node_ref();
...@@ -650,7 +655,8 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb ...@@ -650,7 +655,8 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
} }
if (je32_to_cpu(summary->padded)) { if (je32_to_cpu(summary->padded)) {
DIRTY_SPACE(je32_to_cpu(summary->padded)); if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(summary->padded))))
return err;
} }
ret = jffs2_sum_process_sum_data(c, jeb, summary, pseudo_random); ret = jffs2_sum_process_sum_data(c, jeb, summary, pseudo_random);
...@@ -823,7 +829,7 @@ static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock ...@@ -823,7 +829,7 @@ static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock
infosize, jeb->offset + c->sector_size - jeb->free_size, ret, retlen); infosize, jeb->offset + c->sector_size - jeb->free_size, ret, retlen);
c->summary->sum_size = JFFS2_SUMMARY_NOSUM_SIZE; c->summary->sum_size = JFFS2_SUMMARY_NOSUM_SIZE;
DIRTY_SPACE(infosize); jffs2_scan_dirty_space(c, jeb, infosize);
return 1; return 1;
} }
......
...@@ -18,23 +18,6 @@ ...@@ -18,23 +18,6 @@
#include <linux/uio.h> #include <linux/uio.h>
#include <linux/jffs2.h> #include <linux/jffs2.h>
#define DIRTY_SPACE(x) do { typeof(x) _x = (x); \
c->free_size -= _x; c->dirty_size += _x; \
jeb->free_size -= _x ; jeb->dirty_size += _x; \
}while(0)
#define USED_SPACE(x) do { typeof(x) _x = (x); \
c->free_size -= _x; c->used_size += _x; \
jeb->free_size -= _x ; jeb->used_size += _x; \
}while(0)
#define WASTED_SPACE(x) do { typeof(x) _x = (x); \
c->free_size -= _x; c->wasted_size += _x; \
jeb->free_size -= _x ; jeb->wasted_size += _x; \
}while(0)
#define UNCHECKED_SPACE(x) do { typeof(x) _x = (x); \
c->free_size -= _x; c->unchecked_size += _x; \
jeb->free_size -= _x ; jeb->unchecked_size += _x; \
}while(0)
#define BLK_STATE_ALLFF 0 #define BLK_STATE_ALLFF 0
#define BLK_STATE_CLEAN 1 #define BLK_STATE_CLEAN 1
#define BLK_STATE_PARTDIRTY 2 #define BLK_STATE_PARTDIRTY 2
......
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