Improvements to DOSFS
Thomas Doerfler
Thomas.Doerfler at imd-systems.de
Wed Jul 30 19:54:18 UTC 2003
Hello,
today I have added three PRs (439-441) to RTEMS gnatsweb.
These PR have patches for the following issues:
1. Adding rename functionality to DOSFS
2. Improvment of data write speed
3. Flush of temporary data buffer when closing a file to make
removing of media or poweroff of system without "unmount" more
reliable
Here are the details:
1. Rename functionality
=======================
The newlib "rename" function first tries to add a hard link
from the "new" filename to the original file, then it removes
the original filename. Since DOSFS does not support hard
links, rename does not work under DOSFS.
I have nevertheless added a "pseudo" link functionality to the
RTEMS DOSFS implementation. The added link functionality
creates a new directory entry with the new filename, then it
disconnects the actual file from the old filename entry and
connects the file to the new entry.
In this situation, the new entry already points to the file
data, the old entry is modified, so it looks like an "empty"
file. This is not exactly how "link" should work, because it
actually modifies the source node, but it is as close as
possible to the functionality required. I have ensured that
the file system is still in a valid state when a link has been
established.
When newlibs "rename" function finally deletes the old
filename, this "empty" entry is removed.
2. Improvement of write data speed
==================================
During file write operation, DOSFS needs more FAT clusters
from time to time. The current implementation of FAT12/FAT16
always searches the FAT from the beginning for free clusters,
while FAT32 already searches from the last position where it
had found a free cluster.
For FAT12/FAT16 devices, you can see that the write data rate
is reduced, when the device contains more data, because the
search for new clusters takes a big amount of time (cluster
search sometimes requires reading different FAT sectors from
disk).
Our patch (developed by Peter Rasmussen) uses the more
intelligent FAT32 mechanism also for FAT12/FAT16.
3. Flush of temporary data buffer when closing a file
=====================================================
Appart from the bdbuf sector cache, each filesystem also
contains a one sector buffer in the "fs_info" structure.
Unlike the bdbuf disk cache, which is swapped back to disk
after some time by the "swapout" task, this buffer is not
flushed after a timeout, but only when requested (e.g. by
unmount) or when it is needed for a different sector.
This patch ensures, that this buffer will be flushed back to
the bdbuf layer during a "fat_file_close" operation.
After this modification, I have no longer experienced
inconsistent FAT disks, when I have ensured that the system
was running for at least some seconds after the last file
written has been closed, even when I did not call unmount.
Any comments welcome,
Thomas Doerfler.
--------------------------------------------
IMD Ingenieurbuero fuer Microcomputertechnik
Thomas Doerfler Herbststrasse 8
D-82178 Puchheim Germany
email: Thomas.Doerfler at imd-systems.de
PGP public key available at: http://www.imd-
systems.de/pgp_keys.htm
More information about the users
mailing list