diff options
| author | ngkaho1234 <ngkaho1234@gmail.com> | 2016-05-16 10:19:41 +0000 |
|---|---|---|
| committer | ngkaho1234 <ngkaho1234@gmail.com> | 2016-05-16 13:50:59 +0000 |
| commit | 716af5fa6399c4a8be1a87331fc70b5d3cf537ae (patch) | |
| tree | a8511203c9a2bafb1feda8c5d034af7e7eec96c2 /src | |
| parent | 5372f03b3a0947f9c14a8bf015404f2fa0c71db2 (diff) | |
ext4_xattr: allow more entries to be inserted when space is small
Diffstat (limited to 'src')
| -rw-r--r-- | src/ext4_xattr.c | 41 |
1 files changed, 3 insertions, 38 deletions
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, |
