ext4_xattr: allow more entries to be inserted when space is small
authorngkaho1234 <ngkaho1234@gmail.com>
Mon, 16 May 2016 10:19:41 +0000 (10:19 +0000)
committerngkaho1234 <ngkaho1234@gmail.com>
Mon, 16 May 2016 13:50:59 +0000 (13:50 +0000)
src/ext4_xattr.c

index c5894e6a26093c97997d1c9353ffd2658f64b8f1..f86863183a081f5ed87b35a7a78601d39abd82c7 100644 (file)
@@ -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,