[Tux3] [RFC] Refactor create_entry and find_entry to work with xattrs

OGAWA Hirofumi hirofumi at mail.parknet.co.jp
Fri Dec 12 01:56:12 PST 2008


Daniel Phillips <phillips at phunq.net> writes:

> We are likely to change this again after a while, but for now this
> will let us test xattr support in kernel and we can concentrate on
> more important issues.

Yes, this would be work. 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())

> @@ -139,7 +139,7 @@
>  	name_len = 0;
>  	rec_len = blocksize;
>  	*entry = (tux_dirent){ .rec_len = tux_rec_len_to_disk(blocksize) };
> -	dir->i_size += blocksize;
> +	*size += blocksize;
>  create:
>  	if (!is_deleted(entry)) {
>  		tux_dirent *newent = (tux_dirent *)((char *)entry + name_len);
> @@ -158,11 +158,11 @@

> diff -r ad6aff100867 user/kernel/tux3.h
> --- a/user/kernel/tux3.h	Thu Dec 11 19:32:14 2008 -0800
> +++ b/user/kernel/tux3.h	Thu Dec 11 23:29:04 2008 -0800
> @@ -280,7 +280,7 @@
>  	struct xcache *xcache;
>  	struct sb *i_sb;
>  	map_t *map;
> -	u64 i_size;
> +	loff_t i_size;
>  	unsigned i_version;
>  	struct timespec i_mtime, i_ctime, i_atime;
>  	unsigned i_mode, i_uid, i_gid, i_nlink;

-- 
OGAWA Hirofumi <hirofumi at mail.parknet.co.jp>

_______________________________________________
Tux3 mailing list
Tux3 at tux3.org
http://mailman.tux3.org/cgi-bin/mailman/listinfo/tux3



More information about the Tux3 mailing list