mtd/fs/jffs2 TODO,1.10,1.11 file.c,1.87,1.88 os-linux.h,1.29,1.30
super-v24.c,1.68,1.69 super.c,1.83,1.84 wbuf.c,1.35,1.36
David Woodhouse
dwmw2 at infradead.org
Sun Aug 24 16:34:56 EDT 2003
Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv21935/fs/jffs2
Modified Files:
TODO file.c os-linux.h super-v24.c super.c wbuf.c
Log Message:
Clean up flush_wbuf functions
Index: TODO
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/TODO,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- TODO 9 Sep 2002 16:31:21 -0000 1.10
+++ TODO 24 Aug 2003 20:34:52 -0000 1.11
@@ -11,14 +11,10 @@
- test, test, test
- NAND flash support:
- - flush_wbuf using GC to fill it, don't just pad.
- Deal with write errors. Data don't get lost - we just have to write
the affected node(s) out again somewhere else.
- make fsync flush only if actually required
- - make sys_sync() work.
- reboot notifier
- - timed flush of old wbuf
- - fix magical second arg of jffs2_flush_wbuf(). Split into two or more functions instead.
- Optimisations:
Index: file.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/file.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -r1.87 -r1.88
--- file.c 24 Aug 2003 10:29:09 -0000 1.87
+++ file.c 24 Aug 2003 20:34:52 -0000 1.88
@@ -28,25 +28,12 @@
int jffs2_fsync(struct file *filp, struct dentry *dentry, int datasync)
{
struct inode *inode = dentry->d_inode;
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
- if (!jffs2_wbuf_dirty(c))
- return 0;
-
- /* flush write buffer and update c->nextblock */
-
- /* FIXME NAND */
- /* At the moment we flush the buffer, to make sure
- * that every thing is on the flash.
- * maybe we have to think about it to find a smarter
- * solution.
- */
- down(&c->alloc_sem);
- down(&f->sem);
+ /* Trigger GC to flush the pending writes.
+ FIXME: We should do this only if our particular inode has
+ writes pending in the wbuf */
jffs2_flush_wbuf_gc(c);
- up(&f->sem);
- up(&c->alloc_sem);
return 0;
}
Index: os-linux.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/os-linux.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- os-linux.h 24 Aug 2003 10:29:09 -0000 1.29
+++ os-linux.h 24 Aug 2003 20:34:52 -0000 1.30
@@ -111,8 +111,8 @@
#define jffs2_flash_write(c, ofs, len, retlen, buf) ((c)->mtd->write((c)->mtd, ofs, len, retlen, buf))
#define jffs2_flash_read(c, ofs, len, retlen, buf) ((c)->mtd->read((c)->mtd, ofs, len, retlen, buf))
-#define jffs2_flush_wbuf_pad(c, flag) do { ; } while(0)
-#define jffs2_flush_wbuf_gc(c, flag) do { ; } while(0)
+#define jffs2_flush_wbuf_pad(c) ({ (void)(c), 0; })
+#define jffs2_flush_wbuf_gc(c) ({ (void)(c), 0; })
#define jffs2_nand_read_failcnt(c,jeb) do { ; } while(0)
#define jffs2_write_nand_badblock(c,jeb) do { ; } while(0)
#define jffs2_nand_flash_setup(c) (0)
Index: super-v24.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/super-v24.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- super-v24.c 24 Aug 2003 11:14:21 -0000 1.68
+++ super-v24.c 24 Aug 2003 20:34:53 -0000 1.69
@@ -103,19 +103,11 @@
static int jffs2_sync_fs(struct super_block *sb)
{
struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
- int ret;
-
- if (!jffs2_wbuf_dirty(c))
- return 0;
/* Flush with GC is OK -- it leaves a partially-written node
but only a GC node, so no data are lost if it's not
complete and we immediately power off */
- down(&c->alloc_sem);
- ret = jffs2_flush_wbuf_gc(c);
- up(&c->alloc_sem);
-
- return ret;
+ return jffs2_flush_wbuf_gc(c);
}
static DECLARE_FSTYPE_DEV(jffs2_fs_type, "jffs2", jffs2_read_super);
Index: super.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/super.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -r1.83 -r1.84
--- super.c 24 Aug 2003 11:14:21 -0000 1.83
+++ super.c 24 Aug 2003 20:34:53 -0000 1.84
@@ -275,19 +275,14 @@
static int jffs2_sync_fs(struct super_block *sb, int wait)
{
struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
- int ret;
- if (!wait || !jffs2_wbuf_dirty(c))
- return 0;
+ if (wait)
+ /* Flush with GC is OK -- it leaves a partially-written node
+ but only a GC node, so no data are lost if it's not
+ complete and we immediately power off */
+ return jffs2_flush_wbuf_gc(c);
- /* Flush with GC is OK -- it leaves a partially-written node
- but only a GC node, so no data are lost if it's not
- complete and we immediately power off */
- down(&c->alloc_sem);
- ret = jffs2_flush_wbuf_gc(c);
- up(&c->alloc_sem);
-
- return ret;
+ return 0;
}
static void jffs2_kill_sb(struct super_block *sb)
Index: wbuf.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/wbuf.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- wbuf.c 24 Aug 2003 10:29:09 -0000 1.35
+++ wbuf.c 24 Aug 2003 20:34:53 -0000 1.36
@@ -105,13 +105,10 @@
return;
}
-
+ up(&c->alloc_sem);
/* if !c->nextblock then the tail will have got flushed from
jffs2_do_reserve_space() anyway. */
- if(c->nextblock)
- jffs2_flush_wbuf_gc(c);
-
- up(&c->alloc_sem);
+ jffs2_flush_wbuf_gc(c);
}
@@ -217,21 +214,49 @@
memset(c->wbuf,0xff,c->wbuf_pagesize);
/* adjust write buffer offset, else we get a non contiguous write bug */
- c->wbuf_ofs+= c->wbuf_pagesize;
+ c->wbuf_ofs += c->wbuf_pagesize;
+ c->wbuf_partnode_ofs = c->wbuf_ofs;
c->wbuf_len = 0;
return 0;
}
+/* Trigger garbage collection to flush the write-buffer. */
int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c)
{
- return __jffs2_flush_wbuf(c, 2);
+ uint32_t old_wbuf_ofs;
+ uint32_t old_wbuf_len;
+ int ret = 0;
+
+ down(&c->alloc_sem);
+ old_wbuf_ofs = c->wbuf_ofs;
+ old_wbuf_len = c->wbuf_len;
+
+ while (old_wbuf_len &&
+ old_wbuf_ofs == c->wbuf_ofs) {
+
+ up(&c->alloc_sem);
+
+ ret = jffs2_garbage_collect_pass(c);
+ if (ret) {
+ /* GC failed. Flush it with padding instead */
+ down(&c->alloc_sem);
+ ret = __jffs2_flush_wbuf(c, 2);
+ break;
+ }
+ down(&c->alloc_sem);
+ }
+
+ up(&c->alloc_sem);
+ return ret;
}
+/* Pad write-buffer to end and write it, wasting space. */
int jffs2_flush_wbuf_pad(struct jffs2_sb_info *c)
{
return __jffs2_flush_wbuf(c, 1);
}
+
#define PAGE_DIV(x) ( (x) & (~(c->wbuf_pagesize - 1)) )
#define PAGE_MOD(x) ( (x) & (c->wbuf_pagesize - 1) )
int jffs2_flash_writev(struct jffs2_sb_info *c, const struct iovec *invecs, unsigned long count, loff_t to, size_t *retlen)
@@ -343,7 +368,8 @@
}
outvec_to += donelen;
c->wbuf_ofs = outvec_to;
-
+ c->wbuf_partnode_ofs = to;
+
/* All invecs done ? */
if (invec == count)
goto alldone;
@@ -400,6 +426,7 @@
donelen += wbuf_retlen;
c->wbuf_ofs = PAGE_DIV(outvec_to) + PAGE_DIV(totlen);
+ c->wbuf_partnode_ofs = to;
if (remainder) {
outvecs[splitvec].iov_base += split_ofs;
@@ -782,6 +809,7 @@
/* Initialise write buffer */
c->wbuf_pagesize = c->mtd->oobblock;
c->wbuf_ofs = 0xFFFFFFFF;
+ c->wbuf_partnode_ofs = c->wbuf_ofs;
/* Initialise process for timed wbuf flush */
INIT_WORK(&c->wbuf_task,(void*) jffs2_wbuf_process, (void *)c);
More information about the linux-mtd-cvs
mailing list