Re: [Yaffs] Re: power fail testing -->rename problem

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Charles Manning
Date:  
To: Sergei Sharonov, yaffs
Old-Topics: [Yaffs] Re: power fail testing
New-Topics: [Yaffs] Re: power fail testing -->rename problem
Subject: Re: [Yaffs] Re: power fail testing -->rename problem
I have investigated this and figured out a fix which I will code and test in
the next few days.

I considered a few approaches, but the mechanism I have settled on uses a
"shadowing" field.

The code went like this:

   if (newname exists)
   {
       unlink(newname);
   }
   rename(oldname,newname)


The problem Sergei discovered was that the power could be lost between the
unlink and the rename, causing the file system to end up with no file called
newname.

We cannot just reverse the order because that could leave us with two names
for different files -- bad!

The new code will go like this

   if (newname exists)
   {
       rename_with_shadow(oldname,newname);
        // Point A
       unlink(newname);
       // Point B
   }
   rename(oldname,newname)


A shadowing rename is like its non-shadowing brother except that it also
stores the object Id of the object that it "shadows". The semantics of
scanning a shadowing objectheader are different. If the shadowed object
exists (ie power lost at point A) then we unlink it.

Essentially the shadowing gives us a way of determining priority between two
like-named objects.

Why do we rename without the shadow afterwards? This is done so that we
remove the shadow after it is no longer needed. If this was not done we would
potentially have a shadow hanging around that would cause future files with
the same object Id to get deleted.

-- Charles




On Friday 29 April 2005 05:36, Sergei Sharonov wrote:
> Hi,
>
> > Rename() suppose to be atomic per
> > http://www.opengroup.org/onlinepubs/007908799/xsh/rename.html:
> > "If the link named by the new argument exists, it is removed and
> > old renamed to new. In this case, a link named new will remain
> > visible to other processes throughout the renaming operation and
> > will refer either to the file referred to by new or old before
> > the operation began."
>
> In yaffs_fs.c : yaffs_rename():
>  removed =
> yaffs_Unlink(yaffs_InodeToObject(new_dir),new_dentry->d_name.name); retVal
> = yaffs_RenameObject(yaffs_InodeToObject(old_dir),
>                             old_dentry->d_name.name,
> yaffs_InodeToObject(new_dir),
>                             new_dentry->d_name.name);

>
>
> Is sequencing a problem here?
>
> Sergei
>
>
>
> _______________________________________________
> yaffs mailing list
>
> http://stoneboat.aleph1.co.uk/cgi-bin/mailman/listinfo/yaffs