Commit d8558a29 authored by Theodore Ts'o's avatar Theodore Ts'o

ext4: clean up error handling in swap_inode_boot_loader()

Tighten up the code to make the code easier to read and maintain.
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent e67bc2b3
...@@ -104,21 +104,15 @@ static long swap_inode_boot_loader(struct super_block *sb, ...@@ -104,21 +104,15 @@ static long swap_inode_boot_loader(struct super_block *sb,
struct ext4_inode_info *ei_bl; struct ext4_inode_info *ei_bl;
struct ext4_sb_info *sbi = EXT4_SB(sb); struct ext4_sb_info *sbi = EXT4_SB(sb);
if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode)) { if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode))
err = -EINVAL; return -EINVAL;
goto swap_boot_out;
}
if (!inode_owner_or_capable(inode) || !capable(CAP_SYS_ADMIN)) { if (!inode_owner_or_capable(inode) || !capable(CAP_SYS_ADMIN))
err = -EPERM; return -EPERM;
goto swap_boot_out;
}
inode_bl = ext4_iget(sb, EXT4_BOOT_LOADER_INO); inode_bl = ext4_iget(sb, EXT4_BOOT_LOADER_INO);
if (IS_ERR(inode_bl)) { if (IS_ERR(inode_bl))
err = PTR_ERR(inode_bl); return PTR_ERR(inode_bl);
goto swap_boot_out;
}
ei_bl = EXT4_I(inode_bl); ei_bl = EXT4_I(inode_bl);
filemap_flush(inode->i_mapping); filemap_flush(inode->i_mapping);
...@@ -193,20 +187,14 @@ static long swap_inode_boot_loader(struct super_block *sb, ...@@ -193,20 +187,14 @@ static long swap_inode_boot_loader(struct super_block *sb,
ext4_mark_inode_dirty(handle, inode); ext4_mark_inode_dirty(handle, inode);
} }
} }
ext4_journal_stop(handle); ext4_journal_stop(handle);
ext4_double_up_write_data_sem(inode, inode_bl); ext4_double_up_write_data_sem(inode, inode_bl);
journal_err_out: journal_err_out:
ext4_inode_resume_unlocked_dio(inode); ext4_inode_resume_unlocked_dio(inode);
ext4_inode_resume_unlocked_dio(inode_bl); ext4_inode_resume_unlocked_dio(inode_bl);
unlock_two_nondirectories(inode, inode_bl); unlock_two_nondirectories(inode, inode_bl);
iput(inode_bl); iput(inode_bl);
swap_boot_out:
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment