mirror of https://github.com/OpenIPC/firmware.git
69 lines
2.2 KiB
Diff
69 lines
2.2 KiB
Diff
diff -drupN a/fs/ext4/xattr.c b/fs/ext4/xattr.c
|
|
--- a/fs/ext4/xattr.c 2018-08-06 17:23:04.000000000 +0300
|
|
+++ b/fs/ext4/xattr.c 2022-06-12 05:28:14.000000000 +0300
|
|
@@ -207,14 +207,15 @@ ext4_xattr_check_block(struct inode *ino
|
|
{
|
|
int error;
|
|
|
|
- if (buffer_verified(bh))
|
|
- return 0;
|
|
-
|
|
if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) ||
|
|
BHDR(bh)->h_blocks != cpu_to_le32(1))
|
|
return -EFSCORRUPTED;
|
|
if (!ext4_xattr_block_csum_verify(inode, bh))
|
|
return -EFSBADCRC;
|
|
+
|
|
+ if (buffer_verified(bh))
|
|
+ return 0;
|
|
+
|
|
error = ext4_xattr_check_names(BFIRST(bh), bh->b_data + bh->b_size,
|
|
bh->b_data);
|
|
if (!error)
|
|
@@ -681,7 +682,7 @@ ext4_xattr_set_entry(struct ext4_xattr_i
|
|
s->here->e_name_len = name_len;
|
|
memcpy(s->here->e_name, i->name, name_len);
|
|
} else {
|
|
- if (s->here->e_value_size) {
|
|
+ if (!s->not_found && s->here->e_value_size && s->here->e_value_offs) {
|
|
void *first_val = s->base + min_offs;
|
|
size_t offs = le16_to_cpu(s->here->e_value_offs);
|
|
void *val = s->base + offs;
|
|
@@ -1078,22 +1079,8 @@ int ext4_xattr_ibody_inline_set(handle_t
|
|
if (EXT4_I(inode)->i_extra_isize == 0)
|
|
return -ENOSPC;
|
|
error = ext4_xattr_set_entry(i, s);
|
|
- if (error) {
|
|
- if (error == -ENOSPC &&
|
|
- ext4_has_inline_data(inode)) {
|
|
- error = ext4_try_to_evict_inline_data(handle, inode,
|
|
- EXT4_XATTR_LEN(strlen(i->name) +
|
|
- EXT4_XATTR_SIZE(i->value_len)));
|
|
- if (error)
|
|
- return error;
|
|
- error = ext4_xattr_ibody_find(inode, i, is);
|
|
- if (error)
|
|
- return error;
|
|
- error = ext4_xattr_set_entry(i, s);
|
|
- }
|
|
- if (error)
|
|
- return error;
|
|
- }
|
|
+ if (error)
|
|
+ return error;
|
|
header = IHDR(inode, ext4_raw_inode(&is->iloc));
|
|
if (!IS_LAST_ENTRY(s->first)) {
|
|
header->h_magic = cpu_to_le32(EXT4_XATTR_MAGIC);
|
|
@@ -1424,6 +1411,11 @@ static int ext4_xattr_make_inode_space(h
|
|
last = IFIRST(header);
|
|
/* Find the entry best suited to be pushed into EA block */
|
|
for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
|
|
+ /* never move system.data out of the inode */
|
|
+ if ((last->e_name_len == 4) &&
|
|
+ (last->e_name_index == EXT4_XATTR_INDEX_SYSTEM) &&
|
|
+ !memcmp(last->e_name, "data", 4))
|
|
+ continue;
|
|
total_size =
|
|
EXT4_XATTR_SIZE(le32_to_cpu(last->e_value_size)) +
|
|
EXT4_XATTR_LEN(last->e_name_len);
|