From 716af5fa6399c4a8be1a87331fc70b5d3cf537ae Mon Sep 17 00:00:00 2001 From: ngkaho1234 Date: Mon, 16 May 2016 10:19:41 +0000 Subject: ext4_xattr: allow more entries to be inserted when space is small --- src/ext4_xattr.c | 41 +++-------------------------------------- 1 file changed, 3 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/ext4_xattr.c b/src/ext4_xattr.c index c5894e6..f868631 100644 --- a/src/ext4_xattr.c +++ b/src/ext4_xattr.c @@ -458,23 +458,6 @@ ext4_xattr_insert_item(struct ext4_xattr_ref *xattr_ref, uint8_t name_index, return NULL; } - if ((xattr_ref->ea_size + EXT4_XATTR_SIZE(data_size) + - EXT4_XATTR_LEN(item->name_len) - > - ext4_xattr_inode_space(xattr_ref) - - sizeof(struct ext4_xattr_ibody_header)) - && - (xattr_ref->ea_size + EXT4_XATTR_SIZE(data_size) + - EXT4_XATTR_LEN(item->name_len) > - ext4_xattr_block_space(xattr_ref) - - sizeof(struct ext4_xattr_header))) { - ext4_xattr_item_free(item); - - if (err) - *err = ENOSPC; - - return NULL; - } item->in_inode = true; if (xattr_ref->inode_size_rem < EXT4_XATTR_SIZE(data_size) + @@ -562,24 +545,8 @@ static int ext4_xattr_resize_item(struct ext4_xattr_ref *xattr_ref, /* * Check if we can hold this entry in both in-inode and - * on-block form - */ - if ((xattr_ref->ea_size - EXT4_XATTR_SIZE(old_data_size) + - EXT4_XATTR_SIZE(new_data_size) - > - ext4_xattr_inode_space(xattr_ref) - - sizeof(struct ext4_xattr_ibody_header)) - && - (xattr_ref->ea_size - EXT4_XATTR_SIZE(old_data_size) + - EXT4_XATTR_SIZE(new_data_size) - > - ext4_xattr_block_space(xattr_ref) - - sizeof(struct ext4_xattr_header))) { - - return ENOSPC; - } - - /* + * on-block form. + * * More complicated case: we do not allow entries stucking in * the middle between in-inode space and on-block space, so * the entry has to stay in either inode space or block space. @@ -836,9 +803,7 @@ static int ext4_xattr_write_to_disk(struct ext4_xattr_ref *xattr_ref) } RB_FOREACH_SAFE(item, ext4_xattr_tree, &xattr_ref->root, save_item) { - if (EXT4_XATTR_SIZE(item->data_size) + - EXT4_XATTR_LEN(item->name_len) <= - inode_size_rem) { + if (item->in_inode) { ibody_data = (char *)ibody_data - EXT4_XATTR_SIZE(item->data_size); ext4_xattr_set_inode_entry(item, ibody_header, entry, -- cgit v1.2.3