Commit 887ff81a authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Linus Torvalds

[PATCH] ext3/EA: In-inode extended attributes for ext3

This started of as a patch by Alex Tomas <alex@clusterfs.com> and got an
overhaul by me.  The on-disk structure used is the same as in Alex's
original patch.
Signed-off-by: default avatarAndreas Gruenbacher <agruen@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 7fada86f
......@@ -596,6 +596,9 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
spin_unlock(&sbi->s_next_gen_lock);
ei->i_state = EXT3_STATE_NEW;
ei->i_extra_isize =
(EXT3_INODE_SIZE(inode->i_sb) > EXT3_GOOD_OLD_INODE_SIZE) ?
sizeof(struct ext3_inode) - EXT3_GOOD_OLD_INODE_SIZE : 0;
ret = inode;
if(DQUOT_ALLOC_INODE(inode)) {
......
......@@ -2385,7 +2385,9 @@ static int __ext3_get_inode_loc(struct inode *inode,
int ext3_get_inode_loc(struct inode *inode, struct ext3_iloc *iloc)
{
return __ext3_get_inode_loc(inode, iloc, 1);
/* We have all inode data except xattrs in memory here. */
return __ext3_get_inode_loc(inode, iloc,
!(EXT3_I(inode)->i_state & EXT3_STATE_XATTR));
}
void ext3_set_inode_flags(struct inode *inode)
......@@ -2491,6 +2493,16 @@ void ext3_read_inode(struct inode * inode)
ei->i_data[block] = raw_inode->i_block[block];
INIT_LIST_HEAD(&ei->i_orphan);
ei->i_extra_isize =
(EXT3_INODE_SIZE(inode->i_sb) > EXT3_GOOD_OLD_INODE_SIZE) ?
le16_to_cpu(raw_inode->i_extra_isize) : 0;
if (ei->i_extra_isize) {
__le32 *magic = (void *)raw_inode + EXT3_GOOD_OLD_INODE_SIZE +
ei->i_extra_isize;
if (le32_to_cpu(*magic))
ei->i_state |= EXT3_STATE_XATTR;
}
if (S_ISREG(inode->i_mode)) {
inode->i_op = &ext3_file_inode_operations;
inode->i_fop = &ext3_file_operations;
......@@ -2626,6 +2638,9 @@ static int ext3_do_update_inode(handle_t *handle,
} else for (block = 0; block < EXT3_N_BLOCKS; block++)
raw_inode->i_block[block] = ei->i_data[block];
if (EXT3_INODE_SIZE(inode->i_sb) > EXT3_GOOD_OLD_INODE_SIZE)
raw_inode->i_extra_isize = cpu_to_le16(ei->i_extra_isize);
BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
rc = ext3_journal_dirty_metadata(handle, bh);
if (!err)
......
This diff is collapsed.
......@@ -31,6 +31,10 @@ struct ext3_xattr_header {
__u32 h_reserved[4]; /* zero right now */
};
struct ext3_xattr_ibody_header {
__le32 h_magic; /* magic number for identification */
};
struct ext3_xattr_entry {
__u8 e_name_len; /* length of name */
__u8 e_name_index; /* attribute name index */
......
......@@ -195,7 +195,7 @@ struct ext3_group_desc
*/
#define EXT3_STATE_JDATA 0x00000001 /* journaled data exists */
#define EXT3_STATE_NEW 0x00000002 /* inode is newly created */
#define EXT3_STATE_XATTR 0x00000004 /* has in-inode xattrs */
/* Used to pass group descriptor data when online resize is done */
struct ext3_new_group_input {
......@@ -293,6 +293,8 @@ struct ext3_inode {
__u32 m_i_reserved2[2];
} masix2;
} osd2; /* OS dependent 2 */
__le16 i_extra_isize;
__le16 i_pad1;
};
#define i_size_high i_dir_acl
......
......@@ -113,6 +113,9 @@ struct ext3_inode_info {
*/
loff_t i_disksize;
/* on-disk additional length */
__u16 i_extra_isize;
/*
* truncate_sem is for serialising ext3_truncate() against
* ext3_getblock(). In the 2.4 ext2 design, great chunks of inode's
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment