On Saturday 03 April 2010 04:12:39 Jean-Loup Sabatier wrote:
> Good morning Josh, Good morning all,
>
> We use to force a YAFFS2 checkpoint (in a Linux root filesystem) after a
> modification and when we're not going to change it anymore for some time.
> For that we're remounting the partition in read only (it's a fake "remount"
> in "read-only", i.e. we could still write in the file system, but it just
> forces the check point).
>
Jean-Loup
Does this do anything more than sync() with yaffs_auto_checkpoint set
correctly?
One limitation I see with the current sync() method is that it always does
what is in yaffs_auto_checkpoint. If the mount is not dirtied then changing
the yaffs_auto_checkpoint and re-syncing will not result in a checkpoint.
eg.
echo 0 > /sys/modules/yaffs2/parameters/yaffs2_auto_checkpoint
sync
echo 2 > /sys/modules/yaffs2/parameters/yaffs2_auto_checkpoint
sync
will not write a checkpoint since the superblock is not dirty in the second
sync
Perhaps the following is a good idea:
--- a/yaffs_fs.c
+++ b/yaffs_fs.c
@@ -1935,20 +1935,28 @@ static void yaffs_FlushSuperBlock(struct super_block
*sb, int do_check
static int yaffs_do_sync_fs(struct super_block *sb, int do_checkpoint)
{
-
yaffs_Device *dev = yaffs_SuperToDevice(sb);
+ unsigned int current_auto;
+
+ /* Todo race conditions? */
+ current_auto=yaffs_auto_checkpoint;
+
T(YAFFS_TRACE_OS | YAFFS_TRACE_SYNC,
("yaffs_do_sync_fs: %s %s\n",
sb->s_dirt ? "dirty" : "clean",
do_checkpoint ? "with checkpoint" : "no checkpoint"));
- if (sb->s_dirt) {
+ if (sb->s_dirt || (current_auto & 4)) {
yaffs_GrossLock(dev);
yaffs_FlushSuperBlock(sb,do_checkpoint);
yaffs_GrossUnlock(dev);
sb->s_dirt = 0;
}
+
+ if(current_auto & 4)
+ yaffs_auto_checkpoint &= 3;
+
return 0;
}
Now a checkpoint can be forced by the following:
echo 0 > /sys/modules/yaffs2/parameters/yaffs2_auto_checkpoint
sync
echo 4 > /sys/modules/yaffs2/parameters/yaffs2_auto_checkpoint
sync
The above allows the sync to force a checkpoint by writing a value with bit
0x04 set. This will be cleared as soon as the checkpoint has been written
which makes the forcing a "one-shot".
-- Charles