ext4: inplace xattr block update fails to deduplicate blocks
[sfrench/cifs-2.6.git] / fs / ext4 / xattr.c
index cff4f41ced612d9b0f344be66a17e434981f8861..4025666c59912661a2cf9f799bf4cce9bb6a411d 100644 (file)
@@ -451,6 +451,7 @@ ext4_xattr_inode_get(struct inode *inode, struct ext4_xattr_entry *entry,
                }
                /* Do not add ea_inode to the cache. */
                ea_inode_cache = NULL;
+               err = 0;
        } else if (err)
                goto out;
 
@@ -1815,9 +1816,6 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
                        ea_bdebug(bs->bh, "modifying in-place");
                        error = ext4_xattr_set_entry(i, s, handle, inode,
                                                     true /* is_block */);
-                       if (!error)
-                               ext4_xattr_block_cache_insert(ea_block_cache,
-                                                             bs->bh);
                        ext4_xattr_block_csum_set(inode, bs->bh);
                        unlock_buffer(bs->bh);
                        if (error == -EFSCORRUPTED)
@@ -1973,6 +1971,7 @@ inserted:
                } else if (bs->bh && s->base == bs->bh->b_data) {
                        /* We were modifying this block in-place. */
                        ea_bdebug(bs->bh, "keeping this block");
+                       ext4_xattr_block_cache_insert(ea_block_cache, bs->bh);
                        new_bh = bs->bh;
                        get_bh(new_bh);
                } else {