Question about power fail during file upgrade
Hi,
I need some help to understand how the JFFS2 works. If I have a version 1 of software component A on JFFS2, what happen if power failed while I am in the middle of upgrading the component A to version 2 ? The question is do I have version 1 intact or a combination of version 1 and 2 ?
Does the JFFS2 filesystem only set the inodes of a file to be valid only after a complete file is written to the flash ? Does the old file will only be deleted only after the new file is verified to be valid ?
Thanks in advanced.
regards
choo
__________________________________________________________________
The NEW Netscape 7.0 browser is now available. Upgrade now! http://channels.netscape.com/ns/browsers/download.jsp
Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/
Quoted 9 lines · [email protected] said:
I need some help to understand how the JFFS2 works. If I have a
version 1 of software component A on JFFS2, what happen if power failed while I am in the middle of upgrading the component A to version 2 ? The question is do I have version 1 intact or a combination of version 1 and 2 ?Does the JFFS2 filesystem only set the inodes of a file to be valid only after a complete file is written to the flash ? Does the old file will only be deleted only after the new file is verified to be valid ?
JFFS2 knows nothing of 'complete files'. You are guaranteed atomicity of individual file system operations only, according to POSIX.
As with other file systems, you can write the new version of the file, then rename it over the top of the original. That will be atomic.
There's been talk about extending JFFS2 to allow userspace 'transactions' but it's not been done.
--
dwmw2
Quoted 12 lines · David Woodhouse
Quoted 9 lines · [email protected] said:
I need some help to understand how the JFFS2 works. If I have a
version 1 of software component A on JFFS2, what happen if power failed while I am in the middle of upgrading the component A to version 2 ? The question is do I have version 1 intact or a combination of version 1 and 2 ?Does the JFFS2 filesystem only set the inodes of a file to be valid only after a complete file is written to the flash ? Does the old file will only be deleted only after the new file is verified to be valid ?
Quoted 8 lines
JFFS2 knows nothing of 'complete files'. You are guaranteed atomicity of individual file system operations only, according to POSIX.
As with other file systems, you can write the new version of the file, then rename it over the top of the original. That will be atomic.
There's been talk about extending JFFS2 to allow userspace 'transactions' but it's not been done.
so the only atomic change, that is guaranteed to work is renaming new.file -> old.file?
if I need to make upgrade which depends on 10 files what should I do? how about put all filesystem in one .tar and put it in ramdisk at system startup, then make upgrade of .tar file, which is on JFFS2 DOC and reboot? will it work?
Signature · 1 line
Piotr Trojanek
Quoted 16 lines · [email protected] said:
Quoted 15 lines · David Woodhouse
Quoted 10 lines · [email protected] said:
I need some help to understand how the JFFS2 works. If I have a
version 1 of software component A on JFFS2, what happen if power failed while I am in the middle of upgrading the component A to version 2 ? The question is do I have version 1 intact or a combination of version 1 and 2 ?Does the JFFS2 filesystem only set the inodes of a file to be valid only after a complete file is written to the flash ? Does the old file will only be deleted only after the new file is verified to be valid ?
JFFS2 knows nothing of 'complete files'. You are guaranteed atomicity of individual file system operations only, according to POSIX.
Quoted 8 lines
Quoted 5 lines
As with other file systems, you can write the new version of the file, then rename it over the top of the original. That will be atomic.
There's been talk about extending JFFS2 to allow userspace 'transactions' but it's not been done.
so the only atomic change, that is guaranteed to work is renaming new.file -> old.file?
At the filesystem level, yes.
Quoted 4 lines
if I need to make upgrade which depends on 10 files what should I do? how about put all filesystem in one .tar and put it in ramdisk at system startup, then make upgrade of .tar file, which is on JFFS2 DOC and reboot? will it work?
There are plenty of options, one of which is to implement transation support in the file system so that your application can ensure that either all 10 of your renames happen or none of them.
I'm assuming you only really care about atomicity w.r.t power failure, and a moment where the files are absent is acceptable as long as they can be trivially recovered at boot time? You could unpack all the files into a directory -- '/usr/mypackage-v2', then make a symlink from /usr/mypackage to whichever version is current. If you boot and find no symlink, you check which is the most recent _intact_ version and symlink to that. Many variations on the theme are possible.
trivially be re
--
dwmw2