mtd/fs/jffs2 gc.c,1.92,1.93
David Woodhouse
dwmw2 at infradead.org
Fri Jan 17 11:30:10 EST 2003
Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv28198
Modified Files:
gc.c
Log Message:
Move GC of live node to a separate function
Index: gc.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/gc.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -r1.92 -r1.93
--- gc.c 17 Jan 2003 16:04:16 -0000 1.92
+++ gc.c 17 Jan 2003 16:30:07 -0000 1.93
@@ -36,6 +36,8 @@
static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
struct jffs2_inode_info *f, struct jffs2_full_dnode *fn,
uint32_t start, uint32_t end);
+static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
+ struct jffs2_raw_node_ref *raw, int inum);
/* Called with erase_completion_lock held */
static struct jffs2_eraseblock *jffs2_find_gc_block(struct jffs2_sb_info *c)
@@ -113,14 +115,8 @@
{
struct jffs2_inode_cache *ic;
struct jffs2_eraseblock *jeb;
- struct jffs2_inode_info *f;
struct jffs2_raw_node_ref *raw;
- struct jffs2_node_frag *frag;
- struct jffs2_full_dnode *fn = NULL;
- struct jffs2_full_dirent *fd;
- uint32_t start = 0, end = 0, nrfrags = 0;
uint32_t inum;
- struct inode *inode;
int ret = 0;
if (down_interruptible(&c->alloc_sem))
@@ -305,14 +301,47 @@
if (ic->state == INO_STATE_GC) {
ret = jffs2_garbage_collect_pristine(c, ic, raw);
- if (ret != -EBADFD) {
- up(&c->alloc_sem);
- goto eraseit_lock;
- }
+ if (ret != -EBADFD)
+ goto release_sem;
+
/* Fall through if it wanted us to */
jffs2_set_inocache_state(c, ic, INO_STATE_CHECKEDABSENT);
}
+ ret = jffs2_garbage_collect_live(c, jeb, raw, inum);
+
+ release_sem:
+ up(&c->alloc_sem);
+
+ eraseit_lock:
+ /* If we've finished this block, start it erasing */
+ spin_lock(&c->erase_completion_lock);
+
+ eraseit:
+ if (c->gcblock && !c->gcblock->used_size) {
+ D1(printk(KERN_DEBUG "Block at 0x%08x completely obsoleted by GC. Moving to erase_pending_list\n", c->gcblock->offset));
+ /* We're GC'ing an empty block? */
+ list_add_tail(&c->gcblock->list, &c->erase_pending_list);
+ c->gcblock = NULL;
+ c->nr_erasing_blocks++;
+ jffs2_erase_pending_trigger(c);
+ }
+ spin_unlock(&c->erase_completion_lock);
+
+ return ret;
+}
+
+
+static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
+ struct jffs2_raw_node_ref *raw, int inum)
+{
+ struct jffs2_inode_info *f;
+ struct jffs2_node_frag *frag;
+ struct jffs2_full_dnode *fn = NULL;
+ struct jffs2_full_dirent *fd;
+ uint32_t start = 0, end = 0, nrfrags = 0;
+ struct inode *inode;
+ int ret = 0;
inode = iget(OFNI_BS_2SFFJ(c), inum);
if (is_bad_inode(inode)) {
@@ -399,26 +428,11 @@
}
upnout:
up(&f->sem);
- up(&c->alloc_sem);
iput(inode);
- eraseit_lock:
- /* If we've finished this block, start it erasing */
- spin_lock(&c->erase_completion_lock);
-
- eraseit:
- if (c->gcblock && !c->gcblock->used_size) {
- D1(printk(KERN_DEBUG "Block at 0x%08x completely obsoleted by GC. Moving to erase_pending_list\n", c->gcblock->offset));
- /* We're GC'ing an empty block? */
- list_add_tail(&c->gcblock->list, &c->erase_pending_list);
- c->gcblock = NULL;
- c->nr_erasing_blocks++;
- jffs2_erase_pending_trigger(c);
- }
- spin_unlock(&c->erase_completion_lock);
-
return ret;
}
+
static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
struct jffs2_inode_cache *ic,
struct jffs2_raw_node_ref *raw)
More information about the linux-mtd-cvs
mailing list