Re: [Yaffs] 2 chunks getting written for object header on cr…

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Charles Manning
Date:  
To: yaffs
CC: sandeep dhoot
Subject: Re: [Yaffs] 2 chunks getting written for object header on creating a file
On Tuesday 23 November 2010 13:06:13 sandeep dhoot wrote:
> Hi all,
>
> I am studying and characterizing yaffs2 as part of my grad project.
> Well I see that on creating a file 2 chunks get written one after other and
> when the second is written the first is invalidated. The first gets written
> due to call to UpdateObjectHeader from yaffs_MknodObject while the second
> is written due to call to UpdateObjectHeader from yaffs_setattr. So why do
> we write object header again to flash on setattr and not just call
> inode_setattr and return? Is there any specific reason for writing a chunk
> on setattr? This always wastes one chunk on file creation.


This is due to the way yaffs treats individual operations as atomic.

When yaffs creates a file, it has no way of knowing that this will be followed
by a setattr.

Consider what would happen if we did not write the header for mknod and the
setattr did not get called. We could end up with a sequence like this:

* create file [obj header write ignored]
* start writing data chunks to file.
* power failure.
On the next boot we'd end up with some data chunks with no object. That would
end up creating an object in lost+found.

There is a potential to cache these writes to an extent and save some of these
redundant object header writes. There are more valuable opportunities to be
chasing, but this might happen in time.

Charles