===================================================================
--- linux-stage.orig/fs/ext4/ext4.h
+++ linux-stage/fs/ext4/ext4.h
-@@ -1579,6 +1579,7 @@ static inline void ext4_clear_state_flag
+@@ -1617,6 +1617,7 @@ static inline void ext4_clear_state_flag
EXT4_FEATURE_INCOMPAT_EXTENTS| \
EXT4_FEATURE_INCOMPAT_64BIT| \
EXT4_FEATURE_INCOMPAT_FLEX_BG| \
EXT4_FEATURE_INCOMPAT_MMP | \
EXT4_FEATURE_INCOMPAT_DIRDATA| \
EXT4_FEATURE_INCOMPAT_INLINE_DATA)
-@@ -1990,6 +1997,10 @@ struct mmpd_data {
+@@ -2028,6 +2029,10 @@ struct mmpd_data {
# define ATTRIB_NORET __attribute__((noreturn))
# define NORET_AND noreturn,
/* bitmap.c */
extern unsigned int ext4_count_free(char *bitmap, unsigned numchars);
void ext4_inode_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
-@@ -2194,6 +2205,7 @@ extern void ext4_set_inode_flags(struct
+@@ -2233,6 +2238,7 @@ extern void ext4_set_inode_flags(struct
extern void ext4_get_inode_flags(struct ext4_inode_info *);
extern int ext4_alloc_da_blocks(struct inode *inode);
extern void ext4_set_aops(struct inode *inode);
===================================================================
--- linux-stage.orig/fs/ext4/inode.c
+++ linux-stage/fs/ext4/inode.c
-@@ -134,8 +134,6 @@ static void ext4_invalidatepage(struct p
+@@ -136,8 +136,6 @@ static void ext4_invalidatepage(struct p
unsigned int length);
static int __ext4_journalled_writepage(struct page *page, unsigned int len);
static int ext4_bh_delay_or_unwritten(handle_t *handle, struct buffer_head *bh);
/*
* Test whether an inode is a fast symlink.
-@@ -184,6 +182,8 @@ void ext4_evict_inode(struct inode *inod
+@@ -186,6 +184,8 @@ void ext4_evict_inode(struct inode *inod
{
handle_t *handle;
int err;
trace_ext4_evict_inode(inode);
-@@ -236,8 +236,8 @@ void ext4_evict_inode(struct inode *inod
+@@ -235,8 +235,8 @@ void ext4_evict_inode(struct inode *inod
* protection against it
*/
sb_start_intwrite(inode->i_sb);
if (IS_ERR(handle)) {
ext4_std_error(inode->i_sb, PTR_ERR(handle));
/*
-@@ -252,6 +252,32 @@ void ext4_evict_inode(struct inode *inod
+@@ -251,6 +251,32 @@ void ext4_evict_inode(struct inode *inod
if (IS_SYNC(inode))
ext4_handle_sync(handle);
inode->i_size = 0;
err = ext4_mark_inode_dirty(handle, inode);
if (err) {
-@@ -269,10 +296,10 @@ void ext4_evict_inode(struct inode *inod
+@@ -267,10 +293,10 @@ void ext4_evict_inode(struct inode *inod
* enough credits left in the handle to remove the inode from
* the orphan list and set the dtime field.
*/
if (err != 0) {
ext4_warning(inode->i_sb,
"couldn't extend journal (err %d)", err);
-@@ -308,6 +335,9 @@ void ext4_evict_inode(struct inode *inod
+@@ -307,6 +333,9 @@ void ext4_evict_inode(struct inode *inod
ext4_free_inode(handle, inode);
ext4_journal_stop(handle);
sb_end_intwrite(inode->i_sb);
return;
no_delete:
ext4_clear_inode(inode); /* We must guarantee clearing of inode... */
-@@ -4681,7 +4711,7 @@ static int ext4_index_trans_blocks(struc
+@@ -5132,7 +5161,7 @@ static int ext4_index_trans_blocks(struc
*
* Also account for superblock, inode, quota and xattr blocks
*/
#define BHDR(bh) ((struct ext4_xattr_header *)((bh)->b_data))
#define ENTRY(ptr) ((struct ext4_xattr_entry *)(ptr))
#define BFIRST(bh) ENTRY(BHDR(bh)+1)
-@@ -75,10 +84,11 @@ struct ext4_xattr_entry {
+@@ -75,10 +95,11 @@ struct ext4_xattr_entry {
#define EXT4_ZERO_XATTR_VALUE ((void *)-1)
struct ext4_xattr_info {
};
struct ext4_xattr_search {
-@@ -106,7 +116,13 @@ extern int ext4_xattr_get(struct inode *
+@@ -106,7 +127,13 @@ extern int ext4_xattr_get(struct inode *
extern int ext4_xattr_set(struct inode *, int, const char *, const void *, size_t, int);
extern int ext4_xattr_set_handle(handle_t *, struct inode *, int, const char *, const void *, size_t, int);
===================================================================
--- linux-stage.orig/fs/ext4/ialloc.c
+++ linux-stage/fs/ext4/ialloc.c
-@@ -269,7 +269,6 @@ void ext4_free_inode(handle_t *handle, s
+@@ -247,7 +247,6 @@ void ext4_free_inode(handle_t *handle, s
* as writing the quota to disk may need the lock as well.
*/
dquot_initialize(inode);
size_t offs = le16_to_cpu(entry->e_value_offs);
if (offs < min_offs)
min_offs = offs;
+Index: linux-stage/fs/ext4/extents.c
+===================================================================
+--- linux-stage.orig/fs/ext4/extents.c
++++ linux-stage/fs/ext4/extents.c
+@@ -2461,7 +2461,8 @@ int ext4_ext_index_trans_blocks(struct i
+
+ static inline int get_default_free_blocks_flags(struct inode *inode)
+ {
+- if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
++ if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode) ||
++ ext4_test_inode_flag(inode, EXT4_INODE_EA_INODE))
+ return EXT4_FREE_BLOCKS_METADATA | EXT4_FREE_BLOCKS_FORGET;
+ else if (ext4_should_journal_data(inode))
+ return EXT4_FREE_BLOCKS_FORGET;
+Index: linux-stage/fs/ext4/indirect.c
+===================================================================
+--- linux-stage.orig/fs/ext4/indirect.c
++++ linux-stage/fs/ext4/indirect.c
+@@ -959,7 +959,8 @@ static int ext4_clear_blocks(handle_t *h
+ int flags = EXT4_FREE_BLOCKS_VALIDATED;
+ int err;
+
+- if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
++ if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode) ||
++ ext4_test_inode_flag(inode, EXT4_INODE_EA_INODE))
+ flags |= EXT4_FREE_BLOCKS_FORGET | EXT4_FREE_BLOCKS_METADATA;
+ else if (ext4_should_journal_data(inode))
+ flags |= EXT4_FREE_BLOCKS_FORGET;
===================================================================
--- linux-stage.orig/fs/ext4/ext4.h
+++ linux-stage/fs/ext4/ext4.h
-@@ -1579,6 +1579,7 @@ static inline void ext4_clear_state_flag
+@@ -1620,6 +1620,7 @@ static inline void ext4_clear_state_flag
EXT4_FEATURE_INCOMPAT_EXTENTS| \
EXT4_FEATURE_INCOMPAT_64BIT| \
EXT4_FEATURE_INCOMPAT_FLEX_BG| \
EXT4_FEATURE_INCOMPAT_MMP | \
EXT4_FEATURE_INCOMPAT_DIRDATA| \
EXT4_FEATURE_INCOMPAT_INLINE_DATA)
-@@ -1990,6 +1997,10 @@ struct mmpd_data {
+@@ -2033,6 +2034,10 @@ struct mmpd_data {
# define ATTRIB_NORET __attribute__((noreturn))
# define NORET_AND noreturn,
/* bitmap.c */
extern unsigned int ext4_count_free(char *bitmap, unsigned numchars);
void ext4_inode_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
-@@ -2194,6 +2205,7 @@ extern void ext4_set_inode_flags(struct
+@@ -2238,6 +2243,7 @@ extern void ext4_set_inode_flags(struct
extern void ext4_get_inode_flags(struct ext4_inode_info *);
extern int ext4_alloc_da_blocks(struct inode *inode);
extern void ext4_set_aops(struct inode *inode);
===================================================================
--- linux-stage.orig/fs/ext4/inode.c
+++ linux-stage/fs/ext4/inode.c
-@@ -134,8 +134,6 @@ static void ext4_invalidatepage(struct p
+@@ -136,8 +136,6 @@ static void ext4_invalidatepage(struct p
unsigned int length);
static int __ext4_journalled_writepage(struct page *page, unsigned int len);
static int ext4_bh_delay_or_unwritten(handle_t *handle, struct buffer_head *bh);
/*
* Test whether an inode is a fast symlink.
-@@ -184,6 +182,8 @@ void ext4_evict_inode(struct inode *inod
+@@ -186,6 +184,8 @@ void ext4_evict_inode(struct inode *inod
{
handle_t *handle;
int err;
trace_ext4_evict_inode(inode);
-@@ -236,8 +236,8 @@ void ext4_evict_inode(struct inode *inod
+@@ -235,8 +235,8 @@ void ext4_evict_inode(struct inode *inod
* protection against it
*/
sb_start_intwrite(inode->i_sb);
if (IS_ERR(handle)) {
ext4_std_error(inode->i_sb, PTR_ERR(handle));
/*
-@@ -252,6 +252,32 @@ void ext4_evict_inode(struct inode *inod
+@@ -251,6 +251,32 @@ void ext4_evict_inode(struct inode *inod
if (IS_SYNC(inode))
ext4_handle_sync(handle);
inode->i_size = 0;
err = ext4_mark_inode_dirty(handle, inode);
if (err) {
-@@ -269,10 +296,10 @@ void ext4_evict_inode(struct inode *inod
+@@ -267,10 +293,10 @@ void ext4_evict_inode(struct inode *inod
* enough credits left in the handle to remove the inode from
* the orphan list and set the dtime field.
*/
if (err != 0) {
ext4_warning(inode->i_sb,
"couldn't extend journal (err %d)", err);
-@@ -308,6 +335,9 @@ void ext4_evict_inode(struct inode *inod
+@@ -307,6 +333,9 @@ void ext4_evict_inode(struct inode *inod
ext4_free_inode(handle, inode);
ext4_journal_stop(handle);
sb_end_intwrite(inode->i_sb);
return;
no_delete:
ext4_clear_inode(inode); /* We must guarantee clearing of inode... */
-@@ -4681,7 +4711,7 @@ static int ext4_index_trans_blocks(struc
+@@ -5140,7 +5169,7 @@ static int ext4_index_trans_blocks(struc
*
* Also account for superblock, inode, quota and xattr blocks
*/
#define BHDR(bh) ((struct ext4_xattr_header *)((bh)->b_data))
#define ENTRY(ptr) ((struct ext4_xattr_entry *)(ptr))
#define BFIRST(bh) ENTRY(BHDR(bh)+1)
-@@ -75,10 +84,11 @@ struct ext4_xattr_entry {
+@@ -75,10 +95,11 @@ struct ext4_xattr_entry {
#define EXT4_ZERO_XATTR_VALUE ((void *)-1)
struct ext4_xattr_info {
};
struct ext4_xattr_search {
-@@ -106,7 +116,13 @@ extern int ext4_xattr_get(struct inode *
+@@ -106,7 +127,13 @@ extern int ext4_xattr_get(struct inode *
extern int ext4_xattr_set(struct inode *, int, const char *, const void *, size_t, int);
extern int ext4_xattr_set_handle(handle_t *, struct inode *, int, const char *, const void *, size_t, int);
===================================================================
--- linux-stage.orig/fs/ext4/ialloc.c
+++ linux-stage/fs/ext4/ialloc.c
-@@ -269,7 +269,6 @@ void ext4_free_inode(handle_t *handle, s
+@@ -247,7 +247,6 @@ void ext4_free_inode(handle_t *handle, s
* as writing the quota to disk may need the lock as well.
*/
dquot_initialize(inode);
size_t offs = le16_to_cpu(entry->e_value_offs);
if (offs < min_offs)
min_offs = offs;
+Index: linux-stage/fs/ext4/extents.c
+===================================================================
+--- linux-stage.orig/fs/ext4/extents.c
++++ linux-stage/fs/ext4/extents.c
+@@ -2474,7 +2474,8 @@ int ext4_ext_index_trans_blocks(struct i
+
+ static inline int get_default_free_blocks_flags(struct inode *inode)
+ {
+- if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
++ if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode) ||
++ ext4_test_inode_flag(inode, EXT4_INODE_EA_INODE))
+ return EXT4_FREE_BLOCKS_METADATA | EXT4_FREE_BLOCKS_FORGET;
+ else if (ext4_should_journal_data(inode))
+ return EXT4_FREE_BLOCKS_FORGET;
+Index: linux-stage/fs/ext4/indirect.c
+===================================================================
+--- linux-stage.orig/fs/ext4/indirect.c
++++ linux-stage/fs/ext4/indirect.c
+@@ -967,7 +967,8 @@ static int ext4_clear_blocks(handle_t *h
+ int flags = EXT4_FREE_BLOCKS_VALIDATED;
+ int err;
+
+- if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
++ if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode) ||
++ ext4_test_inode_flag(inode, EXT4_INODE_EA_INODE))
+ flags |= EXT4_FREE_BLOCKS_FORGET | EXT4_FREE_BLOCKS_METADATA;
+ else if (ext4_should_journal_data(inode))
+ flags |= EXT4_FREE_BLOCKS_FORGET;
fs/ext4/xattr.h | 33 ++-
6 files changed, 603 insertions(+), 55 deletions(-)
-diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
-index ca73d33..6796a8b 100644
---- a/fs/ext4/ext4.h
-+++ b/fs/ext4/ext4.h
-@@ -1811,6 +1811,7 @@ EXT4_FEATURE_INCOMPAT_FUNCS(encrypt, ENCRYPT)
+Index: linux-stage/fs/ext4/ext4.h
+===================================================================
+--- linux-stage.orig/fs/ext4/ext4.h
++++ linux-stage/fs/ext4/ext4.h
+@@ -1811,6 +1811,7 @@ EXT4_FEATURE_INCOMPAT_FUNCS(encrypt, EN
EXT4_FEATURE_INCOMPAT_EXTENTS| \
EXT4_FEATURE_INCOMPAT_64BIT| \
EXT4_FEATURE_INCOMPAT_FLEX_BG| \
EXT4_FEATURE_INCOMPAT_MMP | \
EXT4_FEATURE_INCOMPAT_DIRDATA| \
EXT4_FEATURE_INCOMPAT_INLINE_DATA | \
-@@ -2304,6 +2305,12 @@ struct mmpd_data {
- */
+@@ -2305,6 +2306,12 @@ struct mmpd_data {
#define EXT4_MMP_MAX_CHECK_INTERVAL 300UL
-+/*
+ /*
+ * Maximum size of xattr attributes for FEATURE_INCOMPAT_EA_INODE 1Mb
+ * This limit is arbitrary, but is reasonable for the xattr API.
+ */
+#define EXT4_XATTR_MAX_LARGE_EA_SIZE (1024 * 1024)
+
- /*
++/*
* Function prototypes
*/
+
@@ -2316,6 +2323,10 @@ struct mmpd_data {
# define ATTRIB_NORET __attribute__((noreturn))
# define NORET_AND noreturn,
/* bitmap.c */
extern unsigned int ext4_count_free(char *bitmap, unsigned numchars);
void ext4_inode_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
-@@ -2572,6 +2583,7 @@ extern int ext4_truncate_restart_trans(handle_t *, struct inode *, int nblocks);
+@@ -2572,6 +2583,7 @@ extern int ext4_truncate_restart_trans(h
extern void ext4_set_inode_flags(struct inode *);
extern int ext4_alloc_da_blocks(struct inode *inode);
extern void ext4_set_aops(struct inode *inode);
extern int ext4_writepage_trans_blocks(struct inode *);
extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks);
extern int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode,
-diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
-index 7f9b8a5..0f284fb 100644
---- a/fs/ext4/ialloc.c
-+++ b/fs/ext4/ialloc.c
-@@ -273,7 +273,6 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
+Index: linux-stage/fs/ext4/ialloc.c
+===================================================================
+--- linux-stage.orig/fs/ext4/ialloc.c
++++ linux-stage/fs/ext4/ialloc.c
+@@ -273,7 +273,6 @@ void ext4_free_inode(handle_t *handle, s
* as writing the quota to disk may need the lock as well.
*/
dquot_initialize(inode);
dquot_free_inode(inode);
dquot_drop(inode);
-diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
-index b27a736..69e46f9 100644
---- a/fs/ext4/inline.c
-+++ b/fs/ext4/inline.c
-@@ -62,7 +62,7 @@ static int get_max_inline_xattr_value_size(struct inode *inode,
+Index: linux-stage/fs/ext4/inline.c
+===================================================================
+--- linux-stage.orig/fs/ext4/inline.c
++++ linux-stage/fs/ext4/inline.c
+@@ -62,7 +62,7 @@ static int get_max_inline_xattr_value_si
/* Compute min_offs. */
for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
size_t offs = le16_to_cpu(entry->e_value_offs);
if (offs < min_offs)
min_offs = offs;
-diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
-index 19f38c4..c701c45 100644
---- a/fs/ext4/inode.c
-+++ b/fs/ext4/inode.c
-@@ -140,8 +140,6 @@ static void ext4_invalidatepage(struct page *page, unsigned int offset,
+Index: linux-stage/fs/ext4/inode.c
+===================================================================
+--- linux-stage.orig/fs/ext4/inode.c
++++ linux-stage/fs/ext4/inode.c
+@@ -140,8 +140,6 @@ static void ext4_invalidatepage(struct p
unsigned int length);
static int __ext4_journalled_writepage(struct page *page, unsigned int len);
static int ext4_bh_delay_or_unwritten(handle_t *handle, struct buffer_head *bh);
/*
* Test whether an inode is a fast symlink.
-@@ -190,6 +188,8 @@ void ext4_evict_inode(struct inode *inode)
+@@ -190,6 +188,8 @@ void ext4_evict_inode(struct inode *inod
{
handle_t *handle;
int err;
trace_ext4_evict_inode(inode);
-@@ -240,8 +240,8 @@ void ext4_evict_inode(struct inode *inode)
+@@ -240,8 +240,8 @@ void ext4_evict_inode(struct inode *inod
* protection against it
*/
sb_start_intwrite(inode->i_sb);
if (IS_ERR(handle)) {
ext4_std_error(inode->i_sb, PTR_ERR(handle));
/*
-@@ -253,9 +253,36 @@ void ext4_evict_inode(struct inode *inode)
+@@ -253,9 +253,36 @@ void ext4_evict_inode(struct inode *inod
sb_end_intwrite(inode->i_sb);
goto no_delete;
}
inode->i_size = 0;
err = ext4_mark_inode_dirty(handle, inode);
if (err) {
-@@ -279,10 +306,10 @@ void ext4_evict_inode(struct inode *inode)
+@@ -279,10 +306,10 @@ void ext4_evict_inode(struct inode *inod
* enough credits left in the handle to remove the inode from
* the orphan list and set the dtime field.
*/
if (err != 0) {
ext4_warning(inode->i_sb,
"couldn't extend journal (err %d)", err);
-@@ -317,8 +344,12 @@ void ext4_evict_inode(struct inode *inode)
+@@ -317,8 +344,12 @@ void ext4_evict_inode(struct inode *inod
ext4_clear_inode(inode);
else
ext4_free_inode(handle, inode);
return;
no_delete:
ext4_clear_inode(inode); /* We must guarantee clearing of inode... */
-@@ -5624,7 +5655,7 @@ static int ext4_index_trans_blocks(struct inode *inode, int lblocks,
+@@ -5627,7 +5658,7 @@ static int ext4_index_trans_blocks(struc
*
* Also account for superblock, inode, quota and xattr blocks
*/
int pextents)
{
ext4_group_t groups, ngroups = ext4_get_groups_count(inode->i_sb);
-diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
-index 45accaa..8f16071 100644
---- a/fs/ext4/xattr.c
-+++ b/fs/ext4/xattr.c
-@@ -180,9 +180,8 @@ ext4_xattr_check_entries(struct ext4_xattr_entry *entry, void *end,
+Index: linux-stage/fs/ext4/xattr.c
+===================================================================
+--- linux-stage.orig/fs/ext4/xattr.c
++++ linux-stage/fs/ext4/xattr.c
+@@ -180,9 +180,8 @@ ext4_xattr_check_entries(struct ext4_xat
/* Check the values */
while (!IS_LAST_ENTRY(entry)) {
u16 offs = le16_to_cpu(entry->e_value_offs);
u32 size = le32_to_cpu(entry->e_value_size);
void *value;
-@@ -287,6 +286,99 @@ xattr_find_entry(struct inode *inode, struct ext4_xattr_entry **pentry,
+@@ -287,6 +286,99 @@ xattr_find_entry(struct inode *inode, st
return cmp ? -ENODATA : 0;
}
static int
ext4_xattr_block_get(struct inode *inode, int name_index, const char *name,
void *buffer, size_t buffer_size)
-@@ -325,8 +417,16 @@ ext4_xattr_block_get(struct inode *inode, int name_index, const char *name,
+@@ -325,8 +417,16 @@ ext4_xattr_block_get(struct inode *inode
error = -ERANGE;
if (size > buffer_size)
goto cleanup;
}
error = size;
-@@ -367,8 +467,16 @@ ext4_xattr_ibody_get(struct inode *inode, int name_index, const char *name,
+@@ -367,8 +467,16 @@ ext4_xattr_ibody_get(struct inode *inode
error = -ERANGE;
if (size > buffer_size)
goto cleanup;
}
error = size;
-@@ -634,7 +742,7 @@ static size_t ext4_xattr_free_space(struct ext4_xattr_entry *last,
+@@ -634,7 +742,7 @@ static size_t ext4_xattr_free_space(stru
size_t *min_offs, void *base, int *total)
{
for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
size_t offs = le16_to_cpu(last->e_value_offs);
if (offs < *min_offs)
*min_offs = offs;
-@@ -645,11 +753,166 @@ static size_t ext4_xattr_free_space(struct ext4_xattr_entry *last,
+@@ -645,11 +753,166 @@ static size_t ext4_xattr_free_space(stru
return (*min_offs - ((void *)last - base) - sizeof(__u32));
}
/* Compute min_offs and last. */
last = s->first;
-@@ -657,7 +920,7 @@ ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s)
+@@ -657,7 +920,7 @@ ext4_xattr_set_entry(struct ext4_xattr_i
next = EXT4_XATTR_NEXT(last);
if ((void *)next >= s->end)
return -EFSCORRUPTED;
size_t offs = le16_to_cpu(last->e_value_offs);
if (offs < min_offs)
min_offs = offs;
-@@ -665,15 +928,20 @@ ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s)
+@@ -665,15 +928,20 @@ ext4_xattr_set_entry(struct ext4_xattr_i
}
free = min_offs - ((void *)last - s->base) - sizeof(__u32);
if (!s->not_found) {
return -ENOSPC;
}
-@@ -687,7 +955,8 @@ ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s)
+@@ -687,7 +955,8 @@ 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 {
void *first_val = s->base + min_offs;
size_t offs = le16_to_cpu(s->here->e_value_offs);
void *val = s->base + offs;
-@@ -721,12 +990,18 @@ ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s)
+@@ -721,12 +990,18 @@ ext4_xattr_set_entry(struct ext4_xattr_i
last = s->first;
while (!IS_LAST_ENTRY(last)) {
size_t o = le16_to_cpu(last->e_value_offs);
if (!i->value) {
/* Remove the old name. */
size_t size = EXT4_XATTR_LEN(name_len);
-@@ -739,11 +1014,20 @@ ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s)
+@@ -739,11 +1014,20 @@ ext4_xattr_set_entry(struct ext4_xattr_i
if (i->value) {
/* Insert the new value. */
if (i->value == EXT4_ZERO_XATTR_VALUE) {
memset(val, 0, size);
} else {
-@@ -753,8 +1037,11 @@ ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s)
+@@ -753,8 +1037,11 @@ ext4_xattr_set_entry(struct ext4_xattr_i
memcpy(val, i->value, i->value_len);
}
}
}
struct ext4_xattr_block_find {
-@@ -815,8 +1102,6 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
+@@ -815,8 +1102,6 @@ ext4_xattr_block_set(handle_t *handle, s
#define header(x) ((struct ext4_xattr_header *)(x))
if (s->base) {
BUFFER_TRACE(bs->bh, "get_write_access");
error = ext4_journal_get_write_access(handle, bs->bh);
-@@ -835,7 +1120,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
+@@ -835,7 +1120,7 @@ ext4_xattr_block_set(handle_t *handle, s
mb_cache_entry_delete_block(ext4_mb_cache, hash,
bs->bh->b_blocknr);
ea_bdebug(bs->bh, "modifying in-place");
if (!error) {
if (!IS_LAST_ENTRY(s->first))
ext4_xattr_rehash(header(s->base),
-@@ -884,7 +1169,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
+@@ -884,7 +1169,7 @@ ext4_xattr_block_set(handle_t *handle, s
s->end = s->base + sb->s_blocksize;
}
if (error == -EFSCORRUPTED)
goto bad_block;
if (error)
-@@ -1084,7 +1369,7 @@ int ext4_xattr_ibody_inline_set(handle_t *handle, struct inode *inode,
+@@ -1084,7 +1369,7 @@ int ext4_xattr_ibody_inline_set(handle_t
if (EXT4_I(inode)->i_extra_isize == 0)
return -ENOSPC;
if (error)
return error;
header = IHDR(inode, ext4_raw_inode(&is->iloc));
-@@ -1098,7 +1383,7 @@ int ext4_xattr_ibody_inline_set(handle_t *handle, struct inode *inode,
+@@ -1098,7 +1383,7 @@ int ext4_xattr_ibody_inline_set(handle_t
return 0;
}
struct ext4_xattr_info *i,
struct ext4_xattr_ibody_find *is)
{
-@@ -1108,7 +1393,7 @@ static int ext4_xattr_ibody_set(struct inode *inode,
+@@ -1108,7 +1393,7 @@ static int ext4_xattr_ibody_set(struct i
if (EXT4_I(inode)->i_extra_isize == 0)
return -ENOSPC;
if (error)
return error;
header = IHDR(inode, ext4_raw_inode(&is->iloc));
-@@ -1155,7 +1440,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
+@@ -1155,7 +1440,7 @@ ext4_xattr_set_handle(handle_t *handle,
.name = name,
.value = value,
.value_len = value_len,
};
struct ext4_xattr_ibody_find is = {
.s = { .not_found = -ENODATA, },
-@@ -1204,7 +1489,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
+@@ -1204,7 +1489,7 @@ ext4_xattr_set_handle(handle_t *handle,
}
if (!value) {
if (!is.s.not_found)
else if (!bs.s.not_found)
error = ext4_xattr_block_set(handle, inode, &i, &bs);
} else {
-@@ -1215,7 +1500,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
+@@ -1215,7 +1500,7 @@ ext4_xattr_set_handle(handle_t *handle,
if (!bs.s.not_found && ext4_xattr_value_same(&bs.s, &i))
goto cleanup;
if (!error && !bs.s.not_found) {
i.value = NULL;
error = ext4_xattr_block_set(handle, inode, &i, &bs);
-@@ -1228,11 +1513,20 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
+@@ -1228,11 +1513,20 @@ ext4_xattr_set_handle(handle_t *handle,
goto cleanup;
}
error = ext4_xattr_block_set(handle, inode, &i, &bs);
}
}
}
-@@ -1271,12 +1565,26 @@ ext4_xattr_set(struct inode *inode, int name_index, const char *name,
+@@ -1271,12 +1565,26 @@ ext4_xattr_set(struct inode *inode, int
const void *value, size_t value_len, int flags)
{
handle_t *handle;
goto retry;
if (error == 0)
error = error2;
-@@ -1313,7 +1621,7 @@ static void ext4_xattr_shift_entries(struct ext4_xattr_entry *entry,
+@@ -1313,7 +1621,7 @@ static void ext4_xattr_shift_entries(str
/* Adjust the value offsets of the entries */
for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
new_offs = le16_to_cpu(last->e_value_offs) +
value_offs_shift;
last->e_value_offs = cpu_to_le16(new_offs);
-@@ -1374,7 +1682,7 @@ static int ext4_xattr_move_to_block(handle_t *handle, struct inode *inode,
+@@ -1374,7 +1682,7 @@ static int ext4_xattr_move_to_block(hand
goto out;
/* Remove the chosen entry from the inode */
bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
if (!bh) {
EXT4_ERROR_INODE(inode, "block %llu read error",
-@@ -1605,11 +2027,69 @@ ext4_xattr_delete_inode(handle_t *handle, struct inode *inode)
+@@ -1605,11 +2027,69 @@ ext4_xattr_delete_inode(handle_t *handle
EXT4_I(inode)->i_file_acl);
goto cleanup;
}
}
/*
-@@ -1661,10 +2141,9 @@ ext4_xattr_cmp(struct ext4_xattr_header *header1,
+@@ -1661,10 +2141,9 @@ ext4_xattr_cmp(struct ext4_xattr_header
entry1->e_name_index != entry2->e_name_index ||
entry1->e_name_len != entry2->e_name_len ||
entry1->e_value_size != entry2->e_value_size ||
if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
(char *)header2 + le16_to_cpu(entry2->e_value_offs),
le32_to_cpu(entry1->e_value_size)))
-@@ -1736,7 +2215,7 @@ static inline void ext4_xattr_hash_entry(struct ext4_xattr_header *header,
+@@ -1736,7 +2215,7 @@ static inline void ext4_xattr_hash_entry
*name++;
}
__le32 *value = (__le32 *)((char *)header +
le16_to_cpu(entry->e_value_offs));
for (n = (le32_to_cpu(entry->e_value_size) +
-diff --git a/fs/ext4/xattr.h b/fs/ext4/xattr.h
-index 099c8b6..6e10ff9 100644
---- a/fs/ext4/xattr.h
-+++ b/fs/ext4/xattr.h
+Index: linux-stage/fs/ext4/xattr.h
+===================================================================
+--- linux-stage.orig/fs/ext4/xattr.h
++++ linux-stage/fs/ext4/xattr.h
@@ -44,7 +44,7 @@ struct ext4_xattr_entry {
__u8 e_name_len; /* length of name */
__u8 e_name_index; /* attribute name index */
};
struct ext4_xattr_search {
-@@ -140,7 +161,13 @@ extern int ext4_xattr_get(struct inode *, int, const char *, void *, size_t);
+@@ -140,7 +161,13 @@ extern int ext4_xattr_get(struct inode *
extern int ext4_xattr_set(struct inode *, int, const char *, const void *, size_t, int);
extern int ext4_xattr_set_handle(handle_t *, struct inode *, int, const char *, const void *, size_t, int);
extern int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
struct ext4_inode *raw_inode, handle_t *handle);
---
-2.20.1
-
+Index: linux-stage/fs/ext4/extents.c
+===================================================================
+--- linux-stage.orig/fs/ext4/extents.c
++++ linux-stage/fs/ext4/extents.c
+@@ -2494,7 +2494,8 @@ int ext4_ext_index_trans_blocks(struct i
+
+ static inline int get_default_free_blocks_flags(struct inode *inode)
+ {
+- if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
++ if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode) ||
++ ext4_test_inode_flag(inode, EXT4_INODE_EA_INODE))
+ return EXT4_FREE_BLOCKS_METADATA | EXT4_FREE_BLOCKS_FORGET;
+ else if (ext4_should_journal_data(inode))
+ return EXT4_FREE_BLOCKS_FORGET;
+Index: linux-stage/fs/ext4/indirect.c
+===================================================================
+--- linux-stage.orig/fs/ext4/indirect.c
++++ linux-stage/fs/ext4/indirect.c
+@@ -835,7 +835,8 @@ static int ext4_clear_blocks(handle_t *h
+ int flags = EXT4_FREE_BLOCKS_VALIDATED;
+ int err;
+
+- if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
++ if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode) ||
++ ext4_test_inode_flag(inode, EXT4_INODE_EA_INODE))
+ flags |= EXT4_FREE_BLOCKS_FORGET | EXT4_FREE_BLOCKS_METADATA;
+ else if (ext4_should_journal_data(inode))
+ flags |= EXT4_FREE_BLOCKS_FORGET;