On Friday 12 December 2008 01:56, OGAWA Hirofumi wrote:
> ...Just FYI for people, probably you know though,
> inode->i_size has race on 32bit arch. It is 64bit value, so,
> 
>       *size += blocksize;
> 
> means something like the following. E.g.
> 
>       load 0x0(size), %reg1
>       load 0x4(size), %reg2
>         add blocksize, %reg1
>         add-carry %reg2
>       store %reg1, 0x0(size)
>                               <---- (W)
>       store %reg2, 0x4(size)
> 
> So, block I/O library like block_write_full_page() can read the size at
> (W) point. The result may be bogus size.
> 
> We have to fix this later, maybe change with phtree. (don't read i_size
> without lock, or use i_size_read()/i_size_write())

Ah, I thought about that when you mentioned it earlier and forgot to
take care of it in my patch.  Something like this:

loff_t tux_create_entry(struct inode *dir, const char *name, int len, inum_t 
inum, unsigned mode)
{
        loff_t size = i_size_read(dir);
        int err = _tux_create_entry(dir, name, len, inum, mode, &size);
        i_size_write(dir, size);
        return err;
}

Regards,

Daniel

_______________________________________________
Tux3 mailing list
[email protected]
http://mailman.tux3.org/cgi-bin/mailman/listinfo/tux3

Reply via email to