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