Yaffs: Change cache policy When the cache is full and a new cache entry is needed, then space has to be made. This is sometimes termed push out. Until now, the push out involved finding the least recently used cache entry then pushing out all entries in the same file. This had the unintended consequence of making "bursty" writes and forcing extra reads under some conditions. Since the same code path was being used for fsync() and flushing, this also meant that flushing a file caused the file to be thrown out of the cache. That is not a very useful thing to do. These changes are twofold: 1. Only push out the LRU cache entry, rather than the whole file. This makes for a "smoother" push out. It also saves some reads. 2. Flushing a file no longer invalidates the file in cache, it just writes dirty cache entries. This makes better use of the cache. Signed-off-by: Charles Manning <cdhmanning@gmail.com>
yaffs direct: Expose background garbage collection Expose background garbage collection and add a demo pthread implementation of background gc. Signed-off-by: Charles Manning <cdhmanning@gmail.com>
yaffs: Clean up bitfield types It happens that the C spec says compilers can choose whether to treat int bitfields as signed or unsigned. In some cases, int was being used and signed was expected. The IAR ARM compiler in particular treats int bitfields as unsigned. Clean up these plus a few other bitfield usages to make the size and type explicit. Thanks to ChungKang Hu for identifying this issue. Signed-off-by: Charles Manning <cdhmanning@gmail.com>
yaffs-direct: Add reldir and reldev interfaces These interfaces allow far more flexibility in the way Yaffs Direct is hooked up to an RTOS VFS. The "normal" interface requires a fully, qualified path, which is a pain to achieve in some RTOSs. The new interfaces allow calls to be done with paths relative to a directory or to a device. This tends to make some RTOS integration cleaner. Example yaffs_open("/mountpoint-name/dir/file",...); now has two alternatives: yaffs_open_reldir(root_dir,"dir/file",...); or yaffs_open_reldev(dev, "dir/file",...); Signed-off-by: Charles Manning <cdhmanning@gmail.com>
yaffs-direct: Fix object leak caused by defered free The change to dtest.c adds a test case that was leaking objects. The change to yaffsfs.c fixes this. This leak was triggered by sequences of the following form: yaffs_open(file_name, ...); /* create obj */ ... yaffs_unlink(file_name); yaffs_close(file_name); When the file was closed, obj->my_inode was not NULL when yaffs_del_obj() is called, therefore the object was not released properly. The fix "unstitches" the object before the call to yaffs_del_obj(), so that obj->my_inode is NULL and the object freeing is done correctly. Signed-off-by: Charles Manning <cdhmanning@gmail.com>
Remove block number check from summary verification The summary already has other verification. This one is not needed. The check caused summaries to be ignored if they were not on the numbered block. This caused problems when a summary was embedded in an image and the image is written to a flash with bad blocks. Signed-off-by: Charles Manning <cdhmanning@gmail.com>