aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTahsin Erdogan <tahsin@google.com>2017-06-21 22:05:44 -0400
committerTheodore Ts'o <tytso@mit.edu>2017-06-21 22:05:44 -0400
commit9bb21cedda7cd69789e1f93d7d918f5ca48ba165 (patch)
tree8b5023991731f6c1014543093a3dc7a983affd59
parent0bd454c04f02e7bb101d8ff510b54826eda4a5f0 (diff)
ext4: fix ext4_xattr_make_inode_space() value size calculation
ext4_xattr_make_inode_space() is interested in calculating the inline space used in an inode. When a xattr entry refers to an external inode the value size indicates the external inode size, not the value size in the inline area. Change the function to take this into account. Signed-off-by: Tahsin Erdogan <tahsin@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--fs/ext4/xattr.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 13b7fa4cbf16..2be891ffeda1 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1745,9 +1745,10 @@ static int ext4_xattr_make_inode_space(handle_t *handle, struct inode *inode,
1745 last = IFIRST(header); 1745 last = IFIRST(header);
1746 /* Find the entry best suited to be pushed into EA block */ 1746 /* Find the entry best suited to be pushed into EA block */
1747 for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) { 1747 for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
1748 total_size = 1748 total_size = EXT4_XATTR_LEN(last->e_name_len);
1749 EXT4_XATTR_SIZE(le32_to_cpu(last->e_value_size)) + 1749 if (!last->e_value_inum)
1750 EXT4_XATTR_LEN(last->e_name_len); 1750 total_size += EXT4_XATTR_SIZE(
1751 le32_to_cpu(last->e_value_size));
1751 if (total_size <= bfree && 1752 if (total_size <= bfree &&
1752 total_size < min_total_size) { 1753 total_size < min_total_size) {
1753 if (total_size + ifree < isize_diff) { 1754 if (total_size + ifree < isize_diff) {
@@ -1766,8 +1767,10 @@ static int ext4_xattr_make_inode_space(handle_t *handle, struct inode *inode,
1766 } 1767 }
1767 1768
1768 entry_size = EXT4_XATTR_LEN(entry->e_name_len); 1769 entry_size = EXT4_XATTR_LEN(entry->e_name_len);
1769 total_size = entry_size + 1770 total_size = entry_size;
1770 EXT4_XATTR_SIZE(le32_to_cpu(entry->e_value_size)); 1771 if (!entry->e_value_inum)
1772 total_size += EXT4_XATTR_SIZE(
1773 le32_to_cpu(entry->e_value_size));
1771 error = ext4_xattr_move_to_block(handle, inode, raw_inode, 1774 error = ext4_xattr_move_to_block(handle, inode, raw_inode,
1772 entry); 1775 entry);
1773 if (error) 1776 if (error)