Whamcloud - gitweb
LU-13416 ldiskfs: don't corrupt data on journal replay
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ubuntu14+16 / ext4-large-eas.patch
1 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
2 index 10a2a86..217fdcc 100644
3 --- a/fs/ext4/ext4.h
4 +++ b/fs/ext4/ext4.h
5 @@ -1781,6 +1781,7 @@ EXT4_FEATURE_INCOMPAT_FUNCS(encrypt,              ENCRYPT)
6                                          EXT4_FEATURE_INCOMPAT_EXTENTS| \
7                                          EXT4_FEATURE_INCOMPAT_64BIT| \
8                                          EXT4_FEATURE_INCOMPAT_FLEX_BG| \
9 +                                        EXT4_FEATURE_INCOMPAT_EA_INODE| \
10                                          EXT4_FEATURE_INCOMPAT_MMP | \
11                                          EXT4_FEATURE_INCOMPAT_DIRDATA| \
12                                          EXT4_FEATURE_INCOMPAT_INLINE_DATA | \
13 @@ -2252,6 +2259,10 @@ struct mmpd_data {
14  # define ATTRIB_NORET  __attribute__((noreturn))
15  # define NORET_AND     noreturn,
16  
17 +struct ext4_xattr_ino_array {
18 +       unsigned int xia_count;         /* # of used item in the array */
19 +       unsigned int xia_inodes[0];
20 +};
21  /* bitmap.c */
22  extern unsigned int ext4_count_free(char *bitmap, unsigned numchars);
23  void ext4_inode_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
24 @@ -2582,6 +2593,7 @@ extern void ext4_set_inode_flags(struct inode *);
25  extern void ext4_get_inode_flags(struct ext4_inode_info *);
26  extern int ext4_alloc_da_blocks(struct inode *inode);
27  extern void ext4_set_aops(struct inode *inode);
28 +extern int ext4_meta_trans_blocks(struct inode *, int nrblocks, int chunk);
29  extern int ext4_writepage_trans_blocks(struct inode *);
30  extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks);
31  extern int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode,
32 Index: linux-stage/fs/ext4/extents.c
33 ===================================================================
34 --- linux-stage.orig/fs/ext4/extents.c
35 +++ linux-stage/fs/ext4/extents.c
36 @@ -2461,7 +2461,8 @@ int ext4_ext_index_trans_blocks(struct i
37  
38  static inline int get_default_free_blocks_flags(struct inode *inode)
39  {
40 -       if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
41 +       if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode) ||
42 +           (EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL))
43                 return EXT4_FREE_BLOCKS_METADATA | EXT4_FREE_BLOCKS_FORGET;
44         else if (ext4_should_journal_data(inode))
45                 return EXT4_FREE_BLOCKS_FORGET;
46 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
47 index 0cccda3..43ca376 100644
48 --- a/fs/ext4/ialloc.c
49 +++ b/fs/ext4/ialloc.c
50 @@ -293,7 +293,6 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
51          * as writing the quota to disk may need the lock as well.
52          */
53         dquot_initialize(inode);
54 -       ext4_xattr_delete_inode(handle, inode);
55         dquot_free_inode(inode);
56         dquot_drop(inode);
57  
58 Index: linux-stage/fs/ext4/indirect.c
59 ===================================================================
60 --- linux-stage.orig/fs/ext4/indirect.c
61 +++ linux-stage/fs/ext4/indirect.c
62 @@ -959,7 +959,8 @@ static int ext4_clear_blocks(handle_t *h
63         int     flags = EXT4_FREE_BLOCKS_VALIDATED;
64         int     err;
65  
66 -       if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
67 +       if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode) ||
68 +           (EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL))
69                 flags |= EXT4_FREE_BLOCKS_FORGET | EXT4_FREE_BLOCKS_METADATA;
70         else if (ext4_should_journal_data(inode))
71                 flags |= EXT4_FREE_BLOCKS_FORGET;
72 diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
73 index 53e8a88..5112c5a 100644
74 --- a/fs/ext4/inline.c
75 +++ b/fs/ext4/inline.c
76 @@ -61,7 +61,7 @@ static int get_max_inline_xattr_value_size(struct inode *inode,
77  
78         /* Compute min_offs. */
79         for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
80 -               if (!entry->e_value_block && entry->e_value_size) {
81 +               if (!entry->e_value_inum && entry->e_value_size) {
82                         size_t offs = le16_to_cpu(entry->e_value_offs);
83                         if (offs < min_offs)
84                                 min_offs = offs;
85 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
86 index 04c5f63..3034ceb 100644
87 --- a/fs/ext4/inode.c
88 +++ b/fs/ext4/inode.c
89 @@ -139,8 +139,6 @@ static void ext4_invalidatepage(struct page *page, unsigned int offset,
90                                 unsigned int length);
91  static int __ext4_journalled_writepage(struct page *page, unsigned int len);
92  static int ext4_bh_delay_or_unwritten(handle_t *handle, struct buffer_head *bh);
93 -static int ext4_meta_trans_blocks(struct inode *inode, int lblocks,
94 -                                 int pextents);
95  
96  /*
97   * Test whether an inode is a fast symlink.
98 @@ -189,6 +187,8 @@ void ext4_evict_inode(struct inode *inode)
99  {
100         handle_t *handle;
101         int err;
102 +       int extra_credits = 3;
103 +       struct ext4_xattr_ino_array *lea_ino_array = NULL;
104  
105         trace_ext4_evict_inode(inode);
106  
107 @@ -241,8 +241,8 @@ void ext4_evict_inode(struct inode *inode)
108          * protection against it
109          */
110         sb_start_intwrite(inode->i_sb);
111 -       handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE,
112 -                                   ext4_blocks_for_truncate(inode)+3);
113 +
114 +       handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, extra_credits);
115         if (IS_ERR(handle)) {
116                 ext4_std_error(inode->i_sb, PTR_ERR(handle));
117                 /*
118 @@ -254,9 +254,36 @@ void ext4_evict_inode(struct inode *inode)
119                 sb_end_intwrite(inode->i_sb);
120                 goto no_delete;
121         }
122 -
123         if (IS_SYNC(inode))
124                 ext4_handle_sync(handle);
125 +
126 +       /*
127 +        * Delete xattr inode before deleting the main inode.
128 +        */
129 +       err = ext4_xattr_delete_inode(handle, inode, &lea_ino_array);
130 +       if (err) {
131 +               ext4_warning(inode->i_sb,
132 +                            "couldn't delete inode's xattr (err %d)", err);
133 +               goto stop_handle;
134 +       }
135 +
136 +       if (!IS_NOQUOTA(inode))
137 +               extra_credits += 2 * EXT4_QUOTA_DEL_BLOCKS(inode->i_sb);
138 +
139 +       if (!ext4_handle_has_enough_credits(handle,
140 +                       ext4_blocks_for_truncate(inode) + extra_credits)) {
141 +               err = ext4_journal_extend(handle,
142 +                       ext4_blocks_for_truncate(inode) + extra_credits);
143 +               if (err > 0)
144 +                       err = ext4_journal_restart(handle,
145 +                       ext4_blocks_for_truncate(inode) + extra_credits);
146 +               if (err != 0) {
147 +                       ext4_warning(inode->i_sb,
148 +                                    "couldn't extend journal (err %d)", err);
149 +                       goto stop_handle;
150 +               }
151 +       }
152 +
153         inode->i_size = 0;
154         err = ext4_mark_inode_dirty(handle, inode);
155         if (err) {
156 @@ -273,10 +300,10 @@ void ext4_evict_inode(struct inode *inode)
157          * enough credits left in the handle to remove the inode from
158          * the orphan list and set the dtime field.
159          */
160 -       if (!ext4_handle_has_enough_credits(handle, 3)) {
161 -               err = ext4_journal_extend(handle, 3);
162 +       if (!ext4_handle_has_enough_credits(handle, extra_credits)) {
163 +               err = ext4_journal_extend(handle, extra_credits);
164                 if (err > 0)
165 -                       err = ext4_journal_restart(handle, 3);
166 +                       err = ext4_journal_restart(handle, extra_credits);
167                 if (err != 0) {
168                         ext4_warning(inode->i_sb,
169                                      "couldn't extend journal (err %d)", err);
170 @@ -311,8 +338,12 @@ void ext4_evict_inode(struct inode *inode)
171                 ext4_clear_inode(inode);
172         else
173                 ext4_free_inode(handle, inode);
174 +
175         ext4_journal_stop(handle);
176         sb_end_intwrite(inode->i_sb);
177 +
178 +       if (lea_ino_array != NULL)
179 +               ext4_xattr_inode_array_free(inode, lea_ino_array);
180         return;
181  no_delete:
182         ext4_clear_inode(inode);        /* We must guarantee clearing of inode... */
183 @@ -5008,7 +5039,7 @@ static int ext4_index_trans_blocks(struct inode *inode, int lblocks,
184   *
185   * Also account for superblock, inode, quota and xattr blocks
186   */
187 -static int ext4_meta_trans_blocks(struct inode *inode, int lblocks,
188 +int ext4_meta_trans_blocks(struct inode *inode, int lblocks,
189                                   int pextents)
190  {
191         ext4_group_t groups, ngroups = ext4_get_groups_count(inode->i_sb);
192 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
193 index 263002f..b69145b 100644
194 --- a/fs/ext4/xattr.c
195 +++ b/fs/ext4/xattr.c
196 @@ -202,6 +202,7 @@ ext4_xattr_check_names(struct ext4_xattr_entry *entry, void *end,
197  
198         while (!IS_LAST_ENTRY(entry)) {
199                 if (entry->e_value_size != 0 &&
200 +                   entry->e_value_inum == 0 &&
201                     (value_start + le16_to_cpu(entry->e_value_offs) <
202                      (void *)e + sizeof(__u32) ||
203                      value_start + le16_to_cpu(entry->e_value_offs) +
204 @@ -234,19 +235,26 @@ ext4_xattr_check_block(struct inode *inode, struct buffer_head *bh)
205  }
206  
207  static inline int
208 -ext4_xattr_check_entry(struct ext4_xattr_entry *entry, size_t size)
209 +ext4_xattr_check_entry(struct ext4_xattr_entry *entry, size_t size,
210 +                      struct inode *inode)
211  {
212         size_t value_size = le32_to_cpu(entry->e_value_size);
213  
214 -       if (entry->e_value_block != 0 || value_size > size ||
215 +       if (!entry->e_value_inum &&
216             le16_to_cpu(entry->e_value_offs) + value_size > size)
217                 return -EFSCORRUPTED;
218 +       if (entry->e_value_inum &&
219 +           (le32_to_cpu(entry->e_value_inum) < EXT4_FIRST_INO(inode->i_sb) ||
220 +            le32_to_cpu(entry->e_value_inum) >
221 +            le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_inodes_count)))
222 +               return -EFSCORRUPTED;
223         return 0;
224  }
225  
226  static int
227  ext4_xattr_find_entry(struct ext4_xattr_entry **pentry, int name_index,
228 -                     const char *name, size_t size, int sorted)
229 +                     const char *name, size_t size, int sorted,
230 +                     struct inode *inode)
231  {
232         struct ext4_xattr_entry *entry;
233         size_t name_len;
234 @@ -266,11 +274,104 @@ ext4_xattr_find_entry(struct ext4_xattr_entry **pentry, int name_index,
235                         break;
236         }
237         *pentry = entry;
238 -       if (!cmp && ext4_xattr_check_entry(entry, size))
239 +       if (!cmp && ext4_xattr_check_entry(entry, size, inode))
240                 return -EFSCORRUPTED;
241         return cmp ? -ENODATA : 0;
242  }
243  
244 +/*
245 + * Read the EA value from an inode.
246 + */
247 +static int
248 +ext4_xattr_inode_read(struct inode *ea_inode, void *buf, size_t *size)
249 +{
250 +       unsigned long block = 0;
251 +       struct buffer_head *bh = NULL;
252 +       int blocksize;
253 +       size_t csize, ret_size = 0;
254 +
255 +       if (*size == 0)
256 +               return 0;
257 +
258 +       blocksize = ea_inode->i_sb->s_blocksize;
259 +
260 +       while (ret_size < *size) {
261 +               csize = (*size - ret_size) > blocksize ? blocksize :
262 +                                                       *size - ret_size;
263 +               bh = ext4_bread(NULL, ea_inode, block, 0);
264 +               if (IS_ERR(bh)) {
265 +                       *size = ret_size;
266 +                       return PTR_ERR(bh);
267 +               }
268 +               memcpy(buf, bh->b_data, csize);
269 +               brelse(bh);
270 +
271 +               buf += csize;
272 +               block += 1;
273 +               ret_size += csize;
274 +       }
275 +
276 +       *size = ret_size;
277 +
278 +       return 0;
279 +}
280 +
281 +struct inode *ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino, int *err)
282 +{
283 +       struct inode *ea_inode = NULL;
284 +
285 +       ea_inode = ext4_iget(parent->i_sb, ea_ino);
286 +       if (IS_ERR(ea_inode) || is_bad_inode(ea_inode)) {
287 +               int rc = IS_ERR(ea_inode) ? PTR_ERR(ea_inode) : 0;
288 +               ext4_error(parent->i_sb, "error while reading EA inode %lu "
289 +                          "/ %d %d", ea_ino, rc, is_bad_inode(ea_inode));
290 +               *err = rc != 0 ? rc : -EIO;
291 +               return NULL;
292 +       }
293 +
294 +       if (EXT4_XATTR_INODE_GET_PARENT(ea_inode) != parent->i_ino ||
295 +           ea_inode->i_generation != parent->i_generation) {
296 +               ext4_error(parent->i_sb, "Backpointer from EA inode %lu "
297 +                          "to parent invalid.", ea_ino);
298 +               *err = -EINVAL;
299 +               goto error;
300 +       }
301 +
302 +       if (!(EXT4_I(ea_inode)->i_flags & EXT4_EA_INODE_FL)) {
303 +               ext4_error(parent->i_sb, "EA inode %lu does not have "
304 +                          "EXT4_EA_INODE_FL flag set.\n", ea_ino);
305 +               *err = -EINVAL;
306 +               goto error;
307 +       }
308 +
309 +       *err = 0;
310 +       return ea_inode;
311 +
312 +error:
313 +       iput(ea_inode);
314 +       return NULL;
315 +}
316 +
317 +/*
318 + * Read the value from the EA inode.
319 + */
320 +static int
321 +ext4_xattr_inode_get(struct inode *inode, unsigned long ea_ino, void *buffer,
322 +                    size_t *size)
323 +{
324 +       struct inode *ea_inode = NULL;
325 +       int err;
326 +
327 +       ea_inode = ext4_xattr_inode_iget(inode, ea_ino, &err);
328 +       if (err)
329 +               return err;
330 +
331 +       err = ext4_xattr_inode_read(ea_inode, buffer, size);
332 +       iput(ea_inode);
333 +
334 +       return err;
335 +}
336 +
337  static int
338  ext4_xattr_block_get(struct inode *inode, int name_index, const char *name,
339                      void *buffer, size_t buffer_size)
340 @@ -303,7 +404,8 @@ bad_block:
341         }
342         ext4_xattr_cache_insert(ext4_mb_cache, bh);
343         entry = BFIRST(bh);
344 -       error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1);
345 +       error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1,
346 +                                     inode);
347         if (error == -EFSCORRUPTED)
348                 goto bad_block;
349         if (error)
350 @@ -313,8 +415,16 @@ bad_block:
351                 error = -ERANGE;
352                 if (size > buffer_size)
353                         goto cleanup;
354 -               memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs),
355 -                      size);
356 +               if (entry->e_value_inum) {
357 +                       error = ext4_xattr_inode_get(inode,
358 +                                            le32_to_cpu(entry->e_value_inum),
359 +                                            buffer, &size);
360 +                       if (error)
361 +                               goto cleanup;
362 +               } else {
363 +                       memcpy(buffer, bh->b_data +
364 +                              le16_to_cpu(entry->e_value_offs), size);
365 +               }
366         }
367         error = size;
368  
369 @@ -348,7 +458,7 @@ ext4_xattr_ibody_get(struct inode *inode, int name_index, const char *name,
370         if (error)
371                 goto cleanup;
372         error = ext4_xattr_find_entry(&entry, name_index, name,
373 -                                     end - (void *)entry, 0);
374 +                                     end - (void *)entry, 0, inode);
375         if (error)
376                 goto cleanup;
377         size = le32_to_cpu(entry->e_value_size);
378 @@ -356,8 +466,16 @@ ext4_xattr_ibody_get(struct inode *inode, int name_index, const char *name,
379                 error = -ERANGE;
380                 if (size > buffer_size)
381                         goto cleanup;
382 -               memcpy(buffer, (void *)IFIRST(header) +
383 -                      le16_to_cpu(entry->e_value_offs), size);
384 +               if (entry->e_value_inum) {
385 +                       error = ext4_xattr_inode_get(inode,
386 +                                            le32_to_cpu(entry->e_value_inum),
387 +                                            buffer, &size);
388 +                       if (error)
389 +                               goto cleanup;
390 +               } else {
391 +                       memcpy(buffer, (void *)IFIRST(header) +
392 +                              le16_to_cpu(entry->e_value_offs), size);
393 +               }
394         }
395         error = size;
396  
397 @@ -603,7 +721,7 @@ static size_t ext4_xattr_free_space(struct ext4_xattr_entry *last,
398                                     size_t *min_offs, void *base, int *total)
399  {
400         for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
401 -               if (!last->e_value_block && last->e_value_size) {
402 +               if (!last->e_value_inum && last->e_value_size) {
403                         size_t offs = le16_to_cpu(last->e_value_offs);
404                         if (offs < *min_offs)
405                                 *min_offs = offs;
406 @@ -614,16 +732,176 @@ static size_t ext4_xattr_free_space(struct ext4_xattr_entry *last,
407         return (*min_offs - ((void *)last - base) - sizeof(__u32));
408  }
409  
410 +/*
411 + * Write the value of the EA in an inode.
412 + */
413  static int
414 -ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s)
415 +ext4_xattr_inode_write(handle_t *handle, struct inode *ea_inode,
416 +                      const void *buf, int bufsize)
417 +{
418 +       struct buffer_head *bh = NULL;
419 +       unsigned long block = 0;
420 +       unsigned blocksize = ea_inode->i_sb->s_blocksize;
421 +       unsigned max_blocks = (bufsize + blocksize - 1) >> ea_inode->i_blkbits;
422 +       int csize, wsize = 0;
423 +       int ret = 0;
424 +       int retries = 0;
425 +
426 +retry:
427 +       while (ret >= 0 && ret < max_blocks) {
428 +               struct ext4_map_blocks map;
429 +               map.m_lblk = block += ret;
430 +               map.m_len = max_blocks -= ret;
431 +
432 +               ret = ext4_map_blocks(handle, ea_inode, &map,
433 +                                     EXT4_GET_BLOCKS_CREATE);
434 +               if (ret <= 0) {
435 +                       ext4_mark_inode_dirty(handle, ea_inode);
436 +                       if (ret == -ENOSPC &&
437 +                           ext4_should_retry_alloc(ea_inode->i_sb, &retries)) {
438 +                               ret = 0;
439 +                               goto retry;
440 +                       }
441 +                       break;
442 +               }
443 +       }
444 +
445 +       if (ret < 0)
446 +               return ret;
447 +
448 +       block = 0;
449 +       while (wsize < bufsize) {
450 +               if (bh != NULL)
451 +                       brelse(bh);
452 +               csize = (bufsize - wsize) > blocksize ? blocksize :
453 +                                                               bufsize - wsize;
454 +               bh = ext4_getblk(handle, ea_inode, block, 0);
455 +               if (IS_ERR(bh)) {
456 +                       ret = PTR_ERR(bh);
457 +                       goto out;
458 +               }
459 +               ret = ext4_journal_get_write_access(handle, bh);
460 +               if (ret)
461 +                       goto out;
462 +
463 +               memcpy(bh->b_data, buf, csize);
464 +               set_buffer_uptodate(bh);
465 +               ext4_handle_dirty_metadata(handle, ea_inode, bh);
466 +
467 +               buf += csize;
468 +               wsize += csize;
469 +               block += 1;
470 +       }
471 +
472 +       mutex_lock(&ea_inode->i_mutex);
473 +       i_size_write(ea_inode, wsize);
474 +       ext4_update_i_disksize(ea_inode, wsize);
475 +       mutex_unlock(&ea_inode->i_mutex);
476 +
477 +       ext4_mark_inode_dirty(handle, ea_inode);
478 +
479 +out:
480 +       brelse(bh);
481 +
482 +       return ret;
483 +}
484 +
485 +/*
486 + * Create an inode to store the value of a large EA.
487 + */
488 +static struct inode *
489 +ext4_xattr_inode_create(handle_t *handle, struct inode *inode)
490 +{
491 +       struct inode *ea_inode = NULL;
492 +
493 +       /*
494 +        * Let the next inode be the goal, so we try and allocate the EA inode
495 +        * in the same group, or nearby one.
496 +        */
497 +       ea_inode = ext4_new_inode(handle, inode->i_sb->s_root->d_inode,
498 +                                 S_IFREG|0600, NULL, inode->i_ino + 1, NULL);
499 +
500 +       if (!IS_ERR(ea_inode)) {
501 +               ea_inode->i_op = &ext4_file_inode_operations;
502 +               ea_inode->i_fop = &ext4_file_operations;
503 +               ext4_set_aops(ea_inode);
504 +               ea_inode->i_generation = inode->i_generation;
505 +               EXT4_I(ea_inode)->i_flags |= EXT4_EA_INODE_FL;
506 +
507 +               /*
508 +                * A back-pointer from EA inode to parent inode will be useful
509 +                * for e2fsck.
510 +                */
511 +               EXT4_XATTR_INODE_SET_PARENT(ea_inode, inode->i_ino);
512 +               unlock_new_inode(ea_inode);
513 +       }
514 +
515 +       return ea_inode;
516 +}
517 +
518 +/*
519 + * Unlink the inode storing the value of the EA.
520 + */
521 +int
522 +ext4_xattr_inode_unlink(struct inode *inode, unsigned long ea_ino)
523 +{
524 +       struct inode *ea_inode = NULL;
525 +       int err;
526 +
527 +       ea_inode = ext4_xattr_inode_iget(inode, ea_ino, &err);
528 +       if (err)
529 +               return err;
530 +
531 +       clear_nlink(ea_inode);
532 +       iput(ea_inode);
533 +
534 +       return 0;
535 +}
536 +
537 +/*
538 + * Add value of the EA in an inode.
539 + */
540 +static int
541 +ext4_xattr_inode_set(handle_t *handle, struct inode *inode, unsigned long *ea_ino,
542 +                    const void *value, size_t value_len)
543 +{
544 +       struct inode *ea_inode = NULL;
545 +       int err;
546 +
547 +       /* Create an inode for the EA value */
548 +       ea_inode = ext4_xattr_inode_create(handle, inode);
549 +       if (IS_ERR(ea_inode))
550 +               return -1;
551 +
552 +       err = ext4_xattr_inode_write(handle, ea_inode, value, value_len);
553 +       if (err)
554 +               clear_nlink(ea_inode);
555 +       else
556 +               *ea_ino = ea_inode->i_ino;
557 +
558 +       iput(ea_inode);
559 +
560 +       return err;
561 +}
562 +
563 +static int
564 +ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s,
565 +                    handle_t *handle, struct inode *inode)
566  {
567         struct ext4_xattr_entry *last;
568         size_t free, min_offs = s->end - s->base, name_len = strlen(i->name);
569 +       int in_inode = i->in_inode;
570 +
571 +       if (EXT4_HAS_INCOMPAT_FEATURE(inode->i_sb,
572 +                EXT4_FEATURE_INCOMPAT_EA_INODE) &&
573 +           (EXT4_XATTR_SIZE(i->value_len) >
574 +            EXT4_XATTR_MIN_LARGE_EA_SIZE(inode->i_sb->s_blocksize)))
575 +               in_inode = 1;
576  
577         /* Compute min_offs and last. */
578         last = s->first;
579         for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
580 -               if (!last->e_value_block && last->e_value_size) {
581 +               if (!last->e_value_inum && last->e_value_size) {
582                         size_t offs = le16_to_cpu(last->e_value_offs);
583                         if (offs < min_offs)
584                                 min_offs = offs;
585 @@ -631,15 +909,20 @@ ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s)
586         }
587         free = min_offs - ((void *)last - s->base) - sizeof(__u32);
588         if (!s->not_found) {
589 -               if (!s->here->e_value_block && s->here->e_value_size) {
590 +               if (!in_inode &&
591 +                   !s->here->e_value_inum && s->here->e_value_size) {
592                         size_t size = le32_to_cpu(s->here->e_value_size);
593                         free += EXT4_XATTR_SIZE(size);
594                 }
595                 free += EXT4_XATTR_LEN(name_len);
596         }
597         if (i->value) {
598 -               if (free < EXT4_XATTR_LEN(name_len) +
599 -                          EXT4_XATTR_SIZE(i->value_len))
600 +               size_t value_len = EXT4_XATTR_SIZE(i->value_len);
601 +
602 +               if (in_inode)
603 +                       value_len = 0;
604 +
605 +               if (free < EXT4_XATTR_LEN(name_len) + value_len)
606                         return -ENOSPC;
607         }
608  
609 @@ -653,7 +936,8 @@ ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s)
610                 s->here->e_name_len = name_len;
611                 memcpy(s->here->e_name, i->name, name_len);
612         } else {
613 -               if (!s->here->e_value_block && s->here->e_value_size) {
614 +               if (!s->here->e_value_inum && s->here->e_value_size &&
615 +                   s->here->e_value_offs > 0) {
616                         void *first_val = s->base + min_offs;
617                         size_t offs = le16_to_cpu(s->here->e_value_offs);
618                         void *val = s->base + offs;
619 @@ -687,13 +971,18 @@ ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s)
620                         last = s->first;
621                         while (!IS_LAST_ENTRY(last)) {
622                                 size_t o = le16_to_cpu(last->e_value_offs);
623 -                               if (!last->e_value_block &&
624 +                               if (!last->e_value_inum &&
625                                     last->e_value_size && o < offs)
626                                         last->e_value_offs =
627                                                 cpu_to_le16(o + size);
628                                 last = EXT4_XATTR_NEXT(last);
629                         }
630                 }
631 +               if (s->here->e_value_inum) {
632 +                       ext4_xattr_inode_unlink(inode,
633 +                                       le32_to_cpu(s->here->e_value_inum));
634 +                       s->here->e_value_inum = 0;
635 +               }
636                 if (!i->value) {
637                         /* Remove the old name. */
638                         size_t size = EXT4_XATTR_LEN(name_len);
639 @@ -707,10 +996,17 @@ ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s)
640         if (i->value) {
641                 /* Insert the new value. */
642                 s->here->e_value_size = cpu_to_le32(i->value_len);
643 -               if (i->value_len) {
644 +               if (in_inode) {
645 +                       unsigned long ea_ino = le32_to_cpu(s->here->e_value_inum);
646 +                       ext4_xattr_inode_set(handle, inode, &ea_ino, i->value,
647 +                                            i->value_len);
648 +                       s->here->e_value_inum = cpu_to_le32(ea_ino);
649 +                       s->here->e_value_offs = 0;
650 +               } else if (i->value_len) {
651                         size_t size = EXT4_XATTR_SIZE(i->value_len);
652                         void *val = s->base + min_offs - size;
653                         s->here->e_value_offs = cpu_to_le16(min_offs - size);
654 +                       s->here->e_value_inum = 0;
655                         if (i->value == EXT4_ZERO_XATTR_VALUE) {
656                                 memset(val, 0, size);
657                         } else {
658 @@ -760,7 +1056,7 @@ ext4_xattr_block_find(struct inode *inode, struct ext4_xattr_info *i,
659                 bs->s.end = bs->bh->b_data + bs->bh->b_size;
660                 bs->s.here = bs->s.first;
661                 error = ext4_xattr_find_entry(&bs->s.here, i->name_index,
662 -                                             i->name, bs->bh->b_size, 1);
663 +                                            i->name, bs->bh->b_size, 1, inode);
664                 if (error && error != -ENODATA)
665                         goto cleanup;
666                 bs->s.not_found = error;
667 @@ -785,8 +1081,6 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
668  
669  #define header(x) ((struct ext4_xattr_header *)(x))
670  
671 -       if (i->value && i->value_len > sb->s_blocksize)
672 -               return -ENOSPC;
673         if (s->base) {
674                 ce = mb_cache_entry_get(ext4_mb_cache, bs->bh->b_bdev,
675                                         bs->bh->b_blocknr);
676 @@ -802,7 +1096,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
677                                 ce = NULL;
678                         }
679                         ea_bdebug(bs->bh, "modifying in-place");
680 -                       error = ext4_xattr_set_entry(i, s);
681 +                       error = ext4_xattr_set_entry(i, s, handle, inode);
682                         if (!error) {
683                                 if (!IS_LAST_ENTRY(s->first))
684                                         ext4_xattr_rehash(header(s->base),
685 @@ -854,7 +1148,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
686                 s->end = s->base + sb->s_blocksize;
687         }
688  
689 -       error = ext4_xattr_set_entry(i, s);
690 +       error = ext4_xattr_set_entry(i, s, handle, inode);
691         if (error == -EFSCORRUPTED)
692                 goto bad_block;
693         if (error)
694 @@ -998,7 +1292,7 @@ int ext4_xattr_ibody_find(struct inode *inode, struct ext4_xattr_info *i,
695                 /* Find the named attribute. */
696                 error = ext4_xattr_find_entry(&is->s.here, i->name_index,
697                                               i->name, is->s.end -
698 -                                             (void *)is->s.base, 0);
699 +                                             (void *)is->s.base, 0, inode);
700                 if (error && error != -ENODATA)
701                         return error;
702                 is->s.not_found = error;
703 @@ -1016,7 +1310,7 @@ int ext4_xattr_ibody_inline_set(handle_t *handle, struct inode *inode,
704  
705         if (EXT4_I(inode)->i_extra_isize == 0)
706                 return -ENOSPC;
707 -       error = ext4_xattr_set_entry(i, s);
708 +       error = ext4_xattr_set_entry(i, s, handle, inode);
709         if (error) {
710                 if (error == -ENOSPC &&
711                     ext4_has_inline_data(inode)) {
712 @@ -1028,7 +1322,7 @@ int ext4_xattr_ibody_inline_set(handle_t *handle, struct inode *inode,
713                         error = ext4_xattr_ibody_find(inode, i, is);
714                         if (error)
715                                 return error;
716 -                       error = ext4_xattr_set_entry(i, s);
717 +                       error = ext4_xattr_set_entry(i, s, handle, inode);
718                 }
719                 if (error)
720                         return error;
721 @@ -1054,7 +1348,7 @@ static int ext4_xattr_ibody_set(handle_t *handle, struct inode *inode,
722  
723         if (EXT4_I(inode)->i_extra_isize == 0)
724                 return -ENOSPC;
725 -       error = ext4_xattr_set_entry(i, s);
726 +       error = ext4_xattr_set_entry(i, s, handle, inode);
727         if (error)
728                 return error;
729         header = IHDR(inode, ext4_raw_inode(&is->iloc));
730 @@ -1090,7 +1384,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
731                 .name = name,
732                 .value = value,
733                 .value_len = value_len,
734 -
735 +               .in_inode = 0,
736         };
737         struct ext4_xattr_ibody_find is = {
738                 .s = { .not_found = -ENODATA, },
739 @@ -1155,6 +1449,15 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
740                                         goto cleanup;
741                         }
742                         error = ext4_xattr_block_set(handle, inode, &i, &bs);
743 +                       if (EXT4_HAS_INCOMPAT_FEATURE(inode->i_sb,
744 +                                       EXT4_FEATURE_INCOMPAT_EA_INODE) &&
745 +                           error == -ENOSPC) {
746 +                               /* xattr not fit to block, store at external
747 +                                * inode */
748 +                               i.in_inode = 1;
749 +                               error = ext4_xattr_ibody_set(handle, inode,
750 +                                                            &i, &is);
751 +                       }
752                         if (error)
753                                 goto cleanup;
754                         if (!is.s.not_found) {
755 @@ -1201,9 +1504,22 @@ ext4_xattr_set(struct inode *inode, int name_index, const char *name,
756                const void *value, size_t value_len, int flags)
757  {
758         handle_t *handle;
759 +       struct super_block *sb = inode->i_sb;
760         int error, retries = 0;
761         int credits = ext4_jbd2_credits_xattr(inode);
762  
763 +       if ((value_len >= EXT4_XATTR_MIN_LARGE_EA_SIZE(sb->s_blocksize)) &&
764 +           EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EA_INODE)) {
765 +               int nrblocks = (value_len + sb->s_blocksize - 1) >>
766 +                                       sb->s_blocksize_bits;
767 +
768 +               /* For new inode */
769 +               credits += EXT4_SINGLEDATA_TRANS_BLOCKS(sb) + 3;
770 +
771 +               /* For data blocks of EA inode */
772 +               credits += ext4_meta_trans_blocks(inode, nrblocks, 0);
773 +       }
774 +
775  retry:
776         handle = ext4_journal_start(inode, EXT4_HT_XATTR, credits);
777         if (IS_ERR(handle)) {
778 @@ -1215,7 +1531,7 @@ retry:
779                                               value, value_len, flags);
780                 error2 = ext4_journal_stop(handle);
781                 if (error == -ENOSPC &&
782 -                   ext4_should_retry_alloc(inode->i_sb, &retries))
783 +                   ext4_should_retry_alloc(sb, &retries))
784                         goto retry;
785                 if (error == 0)
786                         error = error2;
787 @@ -1237,7 +1553,7 @@ static void ext4_xattr_shift_entries(struct ext4_xattr_entry *entry,
788  
789         /* Adjust the value offsets of the entries */
790         for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
791 -               if (!last->e_value_block && last->e_value_size) {
792 +               if (!last->e_value_inum && last->e_value_size) {
793                         new_offs = le16_to_cpu(last->e_value_offs) +
794                                                         value_offs_shift;
795                         BUG_ON(new_offs + le32_to_cpu(last->e_value_size)
796 @@ -1484,21 +1800,135 @@ cleanup:
797  }
798  
799  
800 +#define EIA_INCR 16 /* must be 2^n */
801 +#define EIA_MASK (EIA_INCR - 1)
802 +/* Add the large xattr @ino into @lea_ino_array for later deletion.
803 + * If @lea_ino_array is new or full it will be grown and the old
804 + * contents copied over.
805 + */
806 +static int
807 +ext4_expand_ino_array(struct ext4_xattr_ino_array **lea_ino_array, __u32 ino)
808 +{
809 +       if (*lea_ino_array == NULL) {
810 +               /*
811 +                * Start with 15 inodes, so it fits into a power-of-two size.
812 +                * If *lea_ino_array is NULL, this is essentially offsetof()
813 +                */
814 +               (*lea_ino_array) =
815 +                       kmalloc(offsetof(struct ext4_xattr_ino_array,
816 +                                        xia_inodes[EIA_MASK]),
817 +                               GFP_NOFS);
818 +               if (*lea_ino_array == NULL)
819 +                       return -ENOMEM;
820 +               (*lea_ino_array)->xia_count = 0;
821 +       } else if (((*lea_ino_array)->xia_count & EIA_MASK) == EIA_MASK) {
822 +               /* expand the array once all 15 + n * 16 slots are full */
823 +               struct ext4_xattr_ino_array *new_array = NULL;
824 +               int count = (*lea_ino_array)->xia_count;
825 +
826 +               /* if new_array is NULL, this is essentially offsetof() */
827 +               new_array = kmalloc(
828 +                               offsetof(struct ext4_xattr_ino_array,
829 +                                        xia_inodes[count + EIA_INCR]),
830 +                               GFP_NOFS);
831 +               if (new_array == NULL)
832 +                       return -ENOMEM;
833 +               memcpy(new_array, *lea_ino_array,
834 +                      offsetof(struct ext4_xattr_ino_array,
835 +                               xia_inodes[count]));
836 +               kfree(*lea_ino_array);
837 +               *lea_ino_array = new_array;
838 +       }
839 +       (*lea_ino_array)->xia_inodes[(*lea_ino_array)->xia_count++] = ino;
840 +       return 0;
841 +}
842 +
843 +/**
844 + * Add xattr inode to orphan list
845 + */
846 +static int
847 +ext4_xattr_inode_orphan_add(handle_t *handle, struct inode *inode,
848 +                       int credits, struct ext4_xattr_ino_array *lea_ino_array)
849 +{
850 +       struct inode *ea_inode = NULL;
851 +       int idx = 0, error = 0;
852 +
853 +       if (lea_ino_array == NULL)
854 +               return 0;
855 +
856 +       for (; idx < lea_ino_array->xia_count; ++idx) {
857 +               if (!ext4_handle_has_enough_credits(handle, credits)) {
858 +                       error = ext4_journal_extend(handle, credits);
859 +                       if (error > 0)
860 +                               error = ext4_journal_restart(handle, credits);
861 +
862 +                       if (error != 0) {
863 +                               ext4_warning(inode->i_sb,
864 +                                       "couldn't extend journal "
865 +                                       "(err %d)", error);
866 +                               return error;
867 +                       }
868 +               }
869 +               ea_inode = ext4_xattr_inode_iget(inode,
870 +                               lea_ino_array->xia_inodes[idx], &error);
871 +               if (error)
872 +                       continue;
873 +               ext4_orphan_add(handle, ea_inode);
874 +               /* the inode's i_count will be released by caller */
875 +       }
876 +
877 +       return 0;
878 +}
879  
880  /*
881   * ext4_xattr_delete_inode()
882   *
883 - * Free extended attribute resources associated with this inode. This
884 + * Free extended attribute resources associated with this inode. Traverse
885 + * all entries and unlink any xattr inodes associated with this inode. This
886   * is called immediately before an inode is freed. We have exclusive
887 - * access to the inode.
888 + * access to the inode. If an orphan inode is deleted it will also delete any
889 + * xattr block and all xattr inodes. They are checked by ext4_xattr_inode_iget()
890 + * to ensure they belong to the parent inode and were not deleted already.
891   */
892 -void
893 -ext4_xattr_delete_inode(handle_t *handle, struct inode *inode)
894 +int
895 +ext4_xattr_delete_inode(handle_t *handle, struct inode *inode,
896 +                       struct ext4_xattr_ino_array **lea_ino_array)
897  {
898         struct buffer_head *bh = NULL;
899 +       struct ext4_xattr_ibody_header *header;
900 +       struct ext4_inode *raw_inode;
901 +       struct ext4_iloc iloc;
902 +       struct ext4_xattr_entry *entry;
903 +       int credits = 3, error = 0;
904  
905 -       if (!EXT4_I(inode)->i_file_acl)
906 +       if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR))
907 +               goto delete_external_ea;
908 +
909 +       error = ext4_get_inode_loc(inode, &iloc);
910 +       if (error)
911 +               goto cleanup;
912 +       raw_inode = ext4_raw_inode(&iloc);
913 +       header = IHDR(inode, raw_inode);
914 +       for (entry = IFIRST(header); !IS_LAST_ENTRY(entry);
915 +            entry = EXT4_XATTR_NEXT(entry)) {
916 +               if (!entry->e_value_inum)
917 +                       continue;
918 +               if (ext4_expand_ino_array(lea_ino_array,
919 +                                         entry->e_value_inum) != 0) {
920 +                       brelse(iloc.bh);
921 +                       goto cleanup;
922 +               }
923 +               entry->e_value_inum = 0;
924 +       }
925 +       brelse(iloc.bh);
926 +
927 +delete_external_ea:
928 +       if (!EXT4_I(inode)->i_file_acl) {
929 +               /* add xattr inode to orphan list */
930 +               ext4_xattr_inode_orphan_add(handle, inode, credits,
931 +                                               *lea_ino_array);
932                 goto cleanup;
933 +       }
934         bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
935         if (!bh) {
936                 EXT4_ERROR_INODE(inode, "block %llu read error",
937 @@ -1511,11 +1941,69 @@ ext4_xattr_delete_inode(handle_t *handle, struct inode *inode)
938                                  EXT4_I(inode)->i_file_acl);
939                 goto cleanup;
940         }
941 +
942 +       for (entry = BFIRST(bh); !IS_LAST_ENTRY(entry);
943 +            entry = EXT4_XATTR_NEXT(entry)) {
944 +               if (!entry->e_value_inum)
945 +                       continue;
946 +               if (ext4_expand_ino_array(lea_ino_array,
947 +                                         entry->e_value_inum) != 0)
948 +                       goto cleanup;
949 +               entry->e_value_inum = 0;
950 +       }
951 +
952 +       /* add xattr inode to orphan list */
953 +       error = ext4_xattr_inode_orphan_add(handle, inode, credits,
954 +                                       *lea_ino_array);
955 +       if (error != 0)
956 +               goto cleanup;
957 +
958 +       if (!IS_NOQUOTA(inode))
959 +               credits += 2 * EXT4_QUOTA_DEL_BLOCKS(inode->i_sb);
960 +
961 +       if (!ext4_handle_has_enough_credits(handle, credits)) {
962 +               error = ext4_journal_extend(handle, credits);
963 +               if (error > 0)
964 +                       error = ext4_journal_restart(handle, credits);
965 +               if (error != 0) {
966 +                       ext4_warning(inode->i_sb,
967 +                               "couldn't extend journal (err %d)", error);
968 +                       goto cleanup;
969 +               }
970 +       }
971 +
972         ext4_xattr_release_block(handle, inode, bh);
973         EXT4_I(inode)->i_file_acl = 0;
974  
975  cleanup:
976         brelse(bh);
977 +
978 +       return error;
979 +}
980 +
981 +void
982 +ext4_xattr_inode_array_free(struct inode *inode,
983 +                           struct ext4_xattr_ino_array *lea_ino_array)
984 +{
985 +       struct inode    *ea_inode = NULL;
986 +       int             idx = 0;
987 +       int             err;
988 +
989 +       if (lea_ino_array == NULL)
990 +               return;
991 +
992 +       for (; idx < lea_ino_array->xia_count; ++idx) {
993 +               ea_inode = ext4_xattr_inode_iget(inode,
994 +                               lea_ino_array->xia_inodes[idx], &err);
995 +               if (err)
996 +                       continue;
997 +               /* for inode's i_count get from ext4_xattr_delete_inode */
998 +               if (!list_empty(&EXT4_I(ea_inode)->i_orphan))
999 +                       iput(ea_inode);
1000 +               clear_nlink(ea_inode);
1001 +               iput(ea_inode);
1002 +       }
1003 +       kfree(lea_ino_array);
1004  }
1005  
1006  /*
1007 @@ -1585,10 +2073,9 @@ ext4_xattr_cmp(struct ext4_xattr_header *header1,
1008                     entry1->e_name_index != entry2->e_name_index ||
1009                     entry1->e_name_len != entry2->e_name_len ||
1010                     entry1->e_value_size != entry2->e_value_size ||
1011 +                   entry1->e_value_inum != entry2->e_value_inum ||
1012                     memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len))
1013                         return 1;
1014 -               if (entry1->e_value_block != 0 || entry2->e_value_block != 0)
1015 -                       return -EFSCORRUPTED;
1016                 if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs),
1017                            (char *)header2 + le16_to_cpu(entry2->e_value_offs),
1018                            le32_to_cpu(entry1->e_value_size)))
1019 @@ -1673,7 +2160,7 @@ static inline void ext4_xattr_hash_entry(struct ext4_xattr_header *header,
1020                        *name++;
1021         }
1022  
1023 -       if (entry->e_value_block == 0 && entry->e_value_size != 0) {
1024 +       if (!entry->e_value_inum && entry->e_value_size) {
1025                 __le32 *value = (__le32 *)((char *)header +
1026                         le16_to_cpu(entry->e_value_offs));
1027                 for (n = (le32_to_cpu(entry->e_value_size) +
1028 diff --git a/fs/ext4/xattr.h b/fs/ext4/xattr.h
1029 index ddc0957..57c7ad5 100644
1030 --- a/fs/ext4/xattr.h
1031 +++ b/fs/ext4/xattr.h
1032 @@ -43,7 +43,7 @@ struct ext4_xattr_entry {
1033         __u8    e_name_len;     /* length of name */
1034         __u8    e_name_index;   /* attribute name index */
1035         __le16  e_value_offs;   /* offset in disk block of value */
1036 -       __le32  e_value_block;  /* disk block attribute is stored on (n/i) */
1037 +       __le32  e_value_inum;   /* inode in which the value is stored */
1038         __le32  e_value_size;   /* size of attribute value */
1039         __le32  e_hash;         /* hash value of name and value */
1040         char    e_name[0];      /* attribute name */
1041 @@ -68,6 +68,26 @@ struct ext4_xattr_entry {
1042                 EXT4_I(inode)->i_extra_isize))
1043  #define IFIRST(hdr) ((struct ext4_xattr_entry *)((hdr)+1))
1044  
1045 +/*
1046 + * Link EA inode back to parent one using i_mtime field.
1047 + * Extra integer type conversion added to ignore higher
1048 + * bits in i_mtime.tv_sec which might be set by ext4_get()
1049 + */
1050 +#define EXT4_XATTR_INODE_SET_PARENT(inode, inum)      \
1051 +do {                                                  \
1052 +      (inode)->i_mtime.tv_sec = inum;                 \
1053 +} while(0)
1054 +
1055 +#define EXT4_XATTR_INODE_GET_PARENT(inode)            \
1056 +((__u32)(inode)->i_mtime.tv_sec)
1057 +
1058 +/*
1059 + * The minimum size of EA value when you start storing it in an external inode
1060 + * size of block - size of header - size of 1 entry - 4 null bytes
1061 +*/
1062 +#define EXT4_XATTR_MIN_LARGE_EA_SIZE(b)                                        \
1063 +       ((b) - EXT4_XATTR_LEN(3) - sizeof(struct ext4_xattr_header) - 4)
1064 +
1065  #define BHDR(bh) ((struct ext4_xattr_header *)((bh)->b_data))
1066  #define ENTRY(ptr) ((struct ext4_xattr_entry *)(ptr))
1067  #define BFIRST(bh) ENTRY(BHDR(bh)+1)
1068 @@ -76,10 +96,11 @@ struct ext4_xattr_entry {
1069  #define EXT4_ZERO_XATTR_VALUE ((void *)-1)
1070  
1071  struct ext4_xattr_info {
1072 -       int name_index;
1073         const char *name;
1074         const void *value;
1075         size_t value_len;
1076 +       int name_index;
1077 +       int in_inode;
1078  };
1079  
1080  struct ext4_xattr_search {
1081 @@ -107,7 +128,14 @@ extern int ext4_xattr_get(struct inode *, int, const char *, void *, size_t);
1082  extern int ext4_xattr_set(struct inode *, int, const char *, const void *, size_t, int);
1083  extern int ext4_xattr_set_handle(handle_t *, struct inode *, int, const char *, const void *, size_t, int);
1084  
1085 -extern void ext4_xattr_delete_inode(handle_t *, struct inode *);
1086 +extern struct inode *ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino,
1087 +                                          int *err);
1088 +extern int ext4_xattr_inode_unlink(struct inode *inode, unsigned long ea_ino);
1089 +extern int ext4_xattr_delete_inode(handle_t *handle, struct inode *inode,
1090 +                                  struct ext4_xattr_ino_array **array);
1091 +extern void ext4_xattr_inode_array_free(struct inode *inode,
1092 +                                       struct ext4_xattr_ino_array *array);
1093 +
1094  extern void ext4_xattr_put_super(struct super_block *);
1095  
1096  extern int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,