MTD CVS update: 'mtd/fs/jffs intrep.c'
finn at infradead.org
finn at infradead.org
Mon Jul 17 09:49:20 EDT 2000
Update of /home/cvs/mtd/fs/jffs
In directory infradead.org:/tmp/cvs-serv26701
Modified Files:
intrep.c
Log Message:
With this patch, I address the operation of renaming one file to a name that
already exists to be totally atomic. Thus the file system should now be
totally consistent even if the system is power-cycled in any moment during
this kind of rename operation. This is a very ordinary file system operation
but it haven't been completely safe (until now I hope). Anyway, no one have
complained yet...
So, if we initially have two files A and B, for example, and we rename A to B,
e.g. `mv A B', the old file B should disappear, be deleted, and the old file
A should now be named B.
Two write operations to the flash device is necessary: First, write a new raw
inode with the ordinary rename information plus the rename flag lit and plus
the inode number of the other file that is to be overridden. The inode number
is stored in the, otherwise empty, data section. The second write operation is
the one that simply removes the other file.
If the power is lost during the writing of the first raw inode, the erroneous
checksum will discard this raw inode during the scanning of the flash device
at the next boot and nothing will happen. If the first node gets written but
not the next one due to power loss, it, at least before, resulted in an
inconsistent file system. Now however, at boot time, the information stored in
the first raw inode is used to remove the other file. The inode number stored
in the first raw inode is inserted in a list that is immediately processed
after the scanning of the flash device.
Hence, if only the first raw inode gets written to the flash device, the
information stored in it is processed at the next boot and thus will make the
file system consistent again.
* jffs_cleanup_control: Free everything in the delete_list if something is
stored there. Also call jffs_free_file for every file.
* jffs_build_fs: After the scan of the flash device, process the delete_list
by marking the files as deleted. These files will be removed later during
the calls to jffs_possibly_delete_file.
* jffs_scan_flash: Added code to detect and store rename information.
Also notice that the node's data_size is set to zero if the processed raw
inode was a special rename inode. The reason for that is that the data
stored in the data section is not part of the file in this case and should
not be inserted in the file in jffs_update_file.
* jffs_free_file: New function.
* Removed TODO comment.
To unsubscribe, send "unsubscribe mtd-cvs" to majordomo at infradead.org
More information about the linux-mtd-cvs
mailing list