add jbd2 speedup patches
[ext4-patch-queue.git] / cleanup-error-handling-in-swap_inode_boot_loader
blobb78915fa194492f743ed47789171d755d99470dd
1 ext4: clean up error handling in swap_inode_boot_loader()
3 Tighten up the code to make the code easier to read and maintain.
5 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
6 ---
7  fs/ext4/ioctl.c | 24 ++++++------------------
8  1 file changed, 6 insertions(+), 18 deletions(-)
10 diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
11 index a2a837f..0f2252e 100644
12 --- a/fs/ext4/ioctl.c
13 +++ b/fs/ext4/ioctl.c
14 @@ -104,21 +104,15 @@ static long swap_inode_boot_loader(struct super_block *sb,
15         struct ext4_inode_info *ei_bl;
16         struct ext4_sb_info *sbi = EXT4_SB(sb);
18 -       if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode)) {
19 -               err = -EINVAL;
20 -               goto swap_boot_out;
21 -       }
22 +       if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode))
23 +               return -EINVAL;
25 -       if (!inode_owner_or_capable(inode) || !capable(CAP_SYS_ADMIN)) {
26 -               err = -EPERM;
27 -               goto swap_boot_out;
28 -       }
29 +       if (!inode_owner_or_capable(inode) || !capable(CAP_SYS_ADMIN))
30 +               return -EPERM;
32         inode_bl = ext4_iget(sb, EXT4_BOOT_LOADER_INO);
33 -       if (IS_ERR(inode_bl)) {
34 -               err = PTR_ERR(inode_bl);
35 -               goto swap_boot_out;
36 -       }
37 +       if (IS_ERR(inode_bl))
38 +               return PTR_ERR(inode_bl);
39         ei_bl = EXT4_I(inode_bl);
41         filemap_flush(inode->i_mapping);
42 @@ -193,20 +187,14 @@ static long swap_inode_boot_loader(struct super_block *sb,
43                         ext4_mark_inode_dirty(handle, inode);
44                 }
45         }
47         ext4_journal_stop(handle);
49         ext4_double_up_write_data_sem(inode, inode_bl);
51  journal_err_out:
52         ext4_inode_resume_unlocked_dio(inode);
53         ext4_inode_resume_unlocked_dio(inode_bl);
55         unlock_two_nondirectories(inode, inode_bl);
57         iput(inode_bl);
59 -swap_boot_out:
60         return err;
61  }