diff options
Diffstat (limited to 'fs/ext4/ioctl.c')
| -rw-r--r-- | fs/ext4/ioctl.c | 37 | 
1 files changed, 11 insertions, 26 deletions
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index a569d335f80..0f2252ec274 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -101,28 +101,18 @@ static long swap_inode_boot_loader(struct super_block *sb,  	handle_t *handle;  	int err;  	struct inode *inode_bl; -	struct ext4_inode_info *ei;  	struct ext4_inode_info *ei_bl; -	struct ext4_sb_info *sbi; +	struct ext4_sb_info *sbi = EXT4_SB(sb); -	if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode)) { -		err = -EINVAL; -		goto swap_boot_out; -	} - -	if (!inode_owner_or_capable(inode) || !capable(CAP_SYS_ADMIN)) { -		err = -EPERM; -		goto swap_boot_out; -	} +	if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode)) +		return -EINVAL; -	sbi = EXT4_SB(sb); -	ei = EXT4_I(inode); +	if (!inode_owner_or_capable(inode) || !capable(CAP_SYS_ADMIN)) +		return -EPERM;  	inode_bl = ext4_iget(sb, EXT4_BOOT_LOADER_INO); -	if (IS_ERR(inode_bl)) { -		err = PTR_ERR(inode_bl); -		goto swap_boot_out; -	} +	if (IS_ERR(inode_bl)) +		return PTR_ERR(inode_bl);  	ei_bl = EXT4_I(inode_bl);  	filemap_flush(inode->i_mapping); @@ -130,7 +120,7 @@ static long swap_inode_boot_loader(struct super_block *sb,  	/* Protect orig inodes against a truncate and make sure,  	 * that only 1 swap_inode_boot_loader is running. */ -	ext4_inode_double_lock(inode, inode_bl); +	lock_two_nondirectories(inode, inode_bl);  	truncate_inode_pages(&inode->i_data, 0);  	truncate_inode_pages(&inode_bl->i_data, 0); @@ -144,7 +134,7 @@ static long swap_inode_boot_loader(struct super_block *sb,  	handle = ext4_journal_start(inode_bl, EXT4_HT_MOVE_EXTENTS, 2);  	if (IS_ERR(handle)) {  		err = -EINVAL; -		goto swap_boot_out; +		goto journal_err_out;  	}  	/* Protect extent tree against block allocations via delalloc */ @@ -197,19 +187,14 @@ static long swap_inode_boot_loader(struct super_block *sb,  			ext4_mark_inode_dirty(handle, inode);  		}  	} -  	ext4_journal_stop(handle); -  	ext4_double_up_write_data_sem(inode, inode_bl); +journal_err_out:  	ext4_inode_resume_unlocked_dio(inode);  	ext4_inode_resume_unlocked_dio(inode_bl); - -	ext4_inode_double_unlock(inode, inode_bl); - +	unlock_two_nondirectories(inode, inode_bl);  	iput(inode_bl); - -swap_boot_out:  	return err;  }  | 
