[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Major JFFS2 bug (?)




Tim@xxxxxxx.org said:
>  The mv should be atomic on JFFS2. It would be useful for someone to
> build a test script to insure that this is the case. Ie: after a power
> cycle you either have all of foo.new in foo or the old foo. There
> should never be a mix according to dwmw2's comments as to how this is
> implemented.

To clarify - there are three operations to do, all three of which should 
happen in a single transaction upon 'mv foo.new foo':

 - Remove old dirent 'foo' if it existed, i_nlink--;
 - Create new dirent 'foo' pointing to the old 'foo.new' inode.
 - Remove old dirent 'foo.new'

JFFS2 currently does the first two atomically in a single transaction, then 
attempts the third.

So you'll always end up with either _all_ of the original 'foo' or _all_ of
'foo.new' in what's now known as 'foo'. They're entirely different inodes,
and all that rename() changes is directory entries. If the final operation
goes wrong, you might actually end up with a hard link though.

In fact, jffs2_rename() will attempt to remove the newly-created 'foo' 
dirent if the third operation (removing 'foo.new') fails, to prevent the 
creation of a hard link. In the case where an old 'foo' didn't exist, that 
makes sense. In the case where and old 'foo' _did_ exist, however, that is 
entirely the wrong thing to do, and will leave _no_ dirent for 'foo' on the 
medium. I'll fix that.

--
dwmw2



To unsubscribe from this list: send the line "unsubscribe jffs-dev" in
the body of a message to majordomo@xxxxxxx.com