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