2011/7/2 Mulyadi Santosa <[email protected]>:
> Hi Joao! :)
>
> 2011/7/2 João Eduardo Luís <[email protected]>:
>> Hello.
>>
>> Nice post. I had never noticed that. And I am able to reproduce the ls-stat 
>> behavior on a debian box with ext4 fs and no SELinux, or any other ACL's 
>> whatsoever.
>
> OK, so far I can conclude it's not 100% reproducible on every
> case...and it looks it is indeed due to enabled ACL and/or
> SELinux...hmmmmmm
>
>
>> You state:
>>
>>> But my friend pointed that stat was accouting extra blocks that might (I 
>>> say "might" because my friend is not so sure) contain metadata such as 
>>> SELinux and ACL.

Hi,

After reading a bit of ext3 code, I'm now fairly sure the blocks
allocated for extended attributes are counted as i_blocks (which stat
returns) for an inode. Extented attributes for an inode can either
reside in the inode or can at max span 1 filesystem block{size.}.  The
extra allocated block number for the inode is stored in i_file_acl
field of the inode.

As an example, kernel has various code paths which given a symlink
tries to determine whether the symlink is a fast or a slow one. "fast"
means the path is less than 64 bytes long and resides in inode itself
while slow means the path exists in a block and the block needs to be
loaded to resolve the symlink. So for fast symlinks i_blocks should be
0 for an inode.

Now have a look at the code which determines whether the symlink is
fast or slow.

/*
 * Test whether an inode is a fast symlink.
 */
static int ext3_inode_is_fast_symlink(struct inode *inode)
{
        int ea_blocks = EXT3_I(inode)->i_file_acl ?
                (inode->i_sb->s_blocksize >> 9) : 0;

        return (S_ISLNK(inode->i_mode) && inode->i_blocks - ea_blocks == 0);
}


Further reading revealed that we do allocate a new block for inode
when we set xattrs.

static int ext3_xattr_block_set() {
..........
      ext3_new_block();
.....
}

So, I think if you have extended attributes which reside in an
external block, it will be counted in i_blocks.

-- 
Thanks -
Manish

_______________________________________________
Kernelnewbies mailing list
[email protected]
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Reply via email to