Allow the disabling of tags ECC
[yaffs2.git] / yaffs_fs.c
index e4ed3bc7bf0c2ea7a7725c1f98c3fe0020bb2ed9..a51dc20de633f900f25cf4ba5c8d993142956012 100644 (file)
@@ -32,7 +32,7 @@
  */
 
 const char *yaffs_fs_c_version =
-    "$Id: yaffs_fs.c,v 1.81 2009-05-26 01:22:44 charles Exp $";
+    "$Id: yaffs_fs.c,v 1.84 2009-10-14 00:01:56 charles Exp $";
 extern const char *yaffs_guts_c_version;
 
 #include <linux/version.h>
@@ -589,7 +589,7 @@ static int yaffs_file_flush(struct file *file)
 
        yaffs_GrossLock(dev);
 
-       yaffs_FlushFile(obj, 1);
+       yaffs_FlushFile(obj, 1,0);
 
        yaffs_GrossUnlock(dev);
 
@@ -751,7 +751,7 @@ static int yaffs_write_begin(struct file *filp, struct address_space *mapping,
 
        T(YAFFS_TRACE_OS, ("start yaffs_write_begin\n"));
        /* Get a page */
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 28)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
        pg = grab_cache_page_write_begin(mapping, index, flags);
 #else
        pg = __grab_cache_page(mapping, index);
@@ -1438,7 +1438,7 @@ static int yaffs_sync_object(struct file *file, struct dentry *dentry,
 
        T(YAFFS_TRACE_OS, ("yaffs_sync_object\n"));
        yaffs_GrossLock(dev);
-       yaffs_FlushFile(obj, 1);
+       yaffs_FlushFile(obj, 1, datasync);
        yaffs_GrossUnlock(dev);
        return 0;
 }
@@ -1596,6 +1596,21 @@ static int yaffs_statfs(struct super_block *sb, struct statfs *buf)
 }
 
 
+
+static void yaffs_flush_sb_inodes(struct super_block *sb)
+{
+       struct inode *iptr;
+       yaffs_Object *obj;
+       
+       list_for_each_entry(iptr,&sb->s_inodes, i_sb_list){
+               obj = yaffs_InodeToObject(iptr);
+               if(obj){
+                       T(YAFFS_TRACE_OS, ("flushing obj %d\n",obj->objectId));
+                       yaffs_FlushFile(obj,1,0);
+               }
+       }
+}
+
 static int yaffs_do_sync_fs(struct super_block *sb)
 {
 
@@ -1607,6 +1622,7 @@ static int yaffs_do_sync_fs(struct super_block *sb)
 
                if (dev) {
                        yaffs_FlushEntireDeviceCache(dev);
+                       yaffs_flush_sb_inodes(sb);
                        yaffs_CheckpointSave(dev);
                }
 
@@ -1796,6 +1812,8 @@ typedef struct {
        int skip_checkpoint_read;
        int skip_checkpoint_write;
        int no_cache;
+       int tags_ecc_on;
+       int tags_ecc_overridden;
 } yaffs_options;
 
 #define MAX_OPT_LEN 20
@@ -1811,6 +1829,9 @@ static int yaffs_parse_options(yaffs_options *options, const char *options_str)
                memset(cur_opt, 0, MAX_OPT_LEN + 1);
                p = 0;
 
+               while(*options_str == ',')
+                       options_str++;
+
                while (*options_str && *options_str != ',') {
                        if (p < MAX_OPT_LEN) {
                                cur_opt[p] = *options_str;
@@ -1821,7 +1842,13 @@ static int yaffs_parse_options(yaffs_options *options, const char *options_str)
 
                if (!strcmp(cur_opt, "inband-tags"))
                        options->inband_tags = 1;
-               else if (!strcmp(cur_opt, "no-cache"))
+               else if (!strcmp(cur_opt, "tags-ecc-off")){
+                       options->tags_ecc_on = 0;
+                       options->tags_ecc_overridden=1;
+               } else if (!strcmp(cur_opt, "tags-ecc-on")){
+                       options->tags_ecc_on = 1;
+                       options->tags_ecc_overridden = 1;
+               } else if (!strcmp(cur_opt, "no-cache"))
                        options->no_cache = 1;
                else if (!strcmp(cur_opt, "no-checkpoint-read"))
                        options->skip_checkpoint_read = 1;
@@ -2037,6 +2064,12 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
        dev->nShortOpCaches = (options.no_cache) ? 0 : 10;
        dev->inbandTags = options.inband_tags;
 
+#ifdef CONFIG_YAFFS_DISABLE_TAGS_ECC
+       dev->noTagsECC = 1;
+#endif
+       if(options.tags_ecc_overridden)
+               dev->noTagsECC = !options.tags_ecc_on;
+
        /* ... and the functions. */
        if (yaffsVersion == 2) {
                dev->writeChunkWithTagsToNAND =
@@ -2273,6 +2306,7 @@ static char *yaffs_dump_dev(char *buf, yaffs_Device * dev)
        buf +=
            sprintf(buf, "nBackgroudDeletions %d\n", dev->nBackgroundDeletions);
        buf += sprintf(buf, "useNANDECC......... %d\n", dev->useNANDECC);
+       buf += sprintf(buf, "noTagsECC.......... %d\n", dev->noTagsECC);
        buf += sprintf(buf, "isYaffs2........... %d\n", dev->isYaffs2);
        buf += sprintf(buf, "inbandTags......... %d\n", dev->inbandTags);