add patch create-function-to-read-journal-inode
[ext4-patch-queue.git] / remove-unused-variables-from-ext4_expand_isize_ea
blob0957fcc6d1740ed55fc40837954c7f0524cb66c8
1 ext4: remove (almost) unused variables from ext4_expand_extra_isize_ea()
3 From: Jan Kara <jack@suse.cz>
5 'start' variable is completely unused in ext4_expand_extra_isize_ea().
6 Variable 'first' is used only once in one place. So just remove them.
7 Variables 'entry' and 'last' are only really used later in the function
8 inside a loop. Move their declarations there.
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 | 20 ++++++++------------
14  1 file changed, 8 insertions(+), 12 deletions(-)
16 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
17 index 8f582ae1032d..2ef687620205 100644
18 --- a/fs/ext4/xattr.c
19 +++ b/fs/ext4/xattr.c
20 @@ -1425,12 +1425,11 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
21                                struct ext4_inode *raw_inode, handle_t *handle)
22  {
23         struct ext4_xattr_ibody_header *header;
24 -       struct ext4_xattr_entry *entry, *last, *first;
25         struct buffer_head *bh = NULL;
26         size_t min_offs;
27         size_t ifree, bfree;
28         int total_ino;
29 -       void *base, *start, *end;
30 +       void *base, *end;
31         int error = 0, tried_min_extra_isize = 0;
32         int s_min_extra_isize = le16_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_min_extra_isize);
33         int isize_diff; /* How much do we need to grow i_extra_isize */
34 @@ -1446,24 +1445,22 @@ retry:
35                 goto out;
37         header = IHDR(inode, raw_inode);
38 -       entry = IFIRST(header);
40         /*
41          * Check if enough free space is available in the inode to shift the
42          * entries ahead by new_extra_isize.
43          */
45 -       base = start = entry;
46 +       base = IFIRST(header);
47         end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size;
48         min_offs = end - base;
49 -       last = entry;
50         total_ino = sizeof(struct ext4_xattr_ibody_header);
52         error = xattr_check_inode(inode, header, end);
53         if (error)
54                 goto cleanup;
56 -       ifree = ext4_xattr_free_space(last, &min_offs, base, &total_ino);
57 +       ifree = ext4_xattr_free_space(base, &min_offs, base, &total_ino);
58         if (ifree >= isize_diff)
59                 goto shift;
61 @@ -1483,10 +1480,10 @@ retry:
62                         goto cleanup;
63                 }
64                 base = BHDR(bh);
65 -               first = BFIRST(bh);
66                 end = bh->b_data + bh->b_size;
67                 min_offs = end - base;
68 -               bfree = ext4_xattr_free_space(first, &min_offs, base, NULL);
69 +               bfree = ext4_xattr_free_space(BFIRST(bh), &min_offs, base,
70 +                                             NULL);
71                 if (bfree + ifree < isize_diff) {
72                         if (!tried_min_extra_isize && s_min_extra_isize) {
73                                 tried_min_extra_isize++;
74 @@ -1502,14 +1499,14 @@ retry:
75         }
77         while (isize_diff > ifree) {
78 -               struct ext4_xattr_entry *small_entry = NULL;
79 +               struct ext4_xattr_entry *small_entry = NULL, *entry = NULL;
80 +               struct ext4_xattr_entry *last;
81                 unsigned int entry_size;        /* EA entry size */
82                 unsigned int total_size;        /* EA entry size + value size */
83                 unsigned int min_total_size = ~0U;
85                 last = IFIRST(header);
86                 /* Find the entry best suited to be pushed into EA block */
87 -               entry = NULL;
88                 for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
89                         total_size =
90                         EXT4_XATTR_SIZE(le32_to_cpu(last->e_value_size)) +
91 @@ -1556,8 +1553,7 @@ retry:
93  shift:
94         /* Adjust the offsets and shift the remaining entries ahead */
95 -       entry = IFIRST(header);
96 -       ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize
97 +       ext4_xattr_shift_entries(IFIRST(header), EXT4_I(inode)->i_extra_isize
98                         - new_extra_isize, (void *)raw_inode +
99                         EXT4_GOOD_OLD_INODE_SIZE + new_extra_isize,
100                         (void *)header, total_ino);
101 -- 
102 2.6.6