add patch create-function-to-read-journal-inode
[ext4-patch-queue.git] / replace-bogus-assertion-in-ext4_xattr_shift_entries
blob6694604569d18985821b3a4198eab94189f77a6b
1 ext4: replace bogus assertion in ext4_xattr_shift_entries()
3 From: Jan Kara <jack@suse.cz>
5 We were checking whether computed offsets do not exceed end of block in
6 ext4_xattr_shift_entries(). However this does not make sense since we
7 always only decrease offsets. So replace that assertion with a check
8 whether we really decrease xattrs value offsets.
10 Signed-off-by: Jan Kara <jack@suse.cz>
11 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 ---
13  fs/ext4/xattr.c | 9 +++++----
14  1 file changed, 5 insertions(+), 4 deletions(-)
16 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
17 index 1447860b61ec..82b025c977fc 100644
18 --- a/fs/ext4/xattr.c
19 +++ b/fs/ext4/xattr.c
20 @@ -1319,18 +1319,19 @@ retry:
21   */
22  static void ext4_xattr_shift_entries(struct ext4_xattr_entry *entry,
23                                      int value_offs_shift, void *to,
24 -                                    void *from, size_t n, int blocksize)
25 +                                    void *from, size_t n)
26  {
27         struct ext4_xattr_entry *last = entry;
28         int new_offs;
30 +       /* We always shift xattr headers further thus offsets get lower */
31 +       BUG_ON(value_offs_shift > 0);
33         /* Adjust the value offsets of the entries */
34         for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
35                 if (last->e_value_size) {
36                         new_offs = le16_to_cpu(last->e_value_offs) +
37                                                         value_offs_shift;
38 -                       BUG_ON(new_offs + le32_to_cpu(last->e_value_size)
39 -                                > blocksize);
40                         last->e_value_offs = cpu_to_le16(new_offs);
41                 }
42         }
43 @@ -1542,7 +1543,7 @@ shift:
44         ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize
45                         - new_extra_isize, (void *)raw_inode +
46                         EXT4_GOOD_OLD_INODE_SIZE + new_extra_isize,
47 -                       (void *)header, total_ino, inode->i_sb->s_blocksize);
48 +                       (void *)header, total_ino);
49         EXT4_I(inode)->i_extra_isize = new_extra_isize;
50         brelse(bh);
51  out:
52 -- 
53 2.6.6