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

Re: Major JFFS2 bug (?)

Under what conditions could the 3rd step fail? Failure to allocate space
for the new copy of the directory? Wouldn't the removal of foo then also

The program should be aware that both foo and foo.new might already
exist and handle that case. Perhaps a delay, then delete foo.new then
create the new one and mv it to foo? The safe bet is to just error out
with a message that foo.new already exists. That's was some passwd bins

The other cases look fine. Expected behavior. as long as steps one and
two are atomic "everything will be all right" (tm).

David Woodhouse wrote:
> 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

Tim Riker - http://rikers.org/ - short SIGs! <g>
All I need to know I could have learned in Kindergarten
... if I'd just been paying attention.

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