mirror of https://gitee.com/openkylin/linux.git
ext4: move_extent_per_page() cleanup
Integrate duplicate lines (acquire/release semaphore and invalidate extent cache in move_extent_per_page()) into mext_replace_branches(), to reduce source and object code size. Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This commit is contained in:
parent
446aaa6e7e
commit
ac48b0a1d0
|
@ -660,6 +660,9 @@ mext_replace_branches(handle_t *handle, struct inode *orig_inode,
|
||||||
int replaced_count = 0;
|
int replaced_count = 0;
|
||||||
int dext_alen;
|
int dext_alen;
|
||||||
|
|
||||||
|
/* Protect extent trees against block allocations via delalloc */
|
||||||
|
double_down_write_data_sem(orig_inode, donor_inode);
|
||||||
|
|
||||||
/* Get the original extent for the block "orig_off" */
|
/* Get the original extent for the block "orig_off" */
|
||||||
*err = get_ext_path(orig_inode, orig_off, &orig_path);
|
*err = get_ext_path(orig_inode, orig_off, &orig_path);
|
||||||
if (*err)
|
if (*err)
|
||||||
|
@ -755,6 +758,11 @@ mext_replace_branches(handle_t *handle, struct inode *orig_inode,
|
||||||
kfree(donor_path);
|
kfree(donor_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ext4_ext_invalidate_cache(orig_inode);
|
||||||
|
ext4_ext_invalidate_cache(donor_inode);
|
||||||
|
|
||||||
|
double_up_write_data_sem(orig_inode, donor_inode);
|
||||||
|
|
||||||
return replaced_count;
|
return replaced_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -820,19 +828,9 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode,
|
||||||
* Just swap data blocks between orig and donor.
|
* Just swap data blocks between orig and donor.
|
||||||
*/
|
*/
|
||||||
if (uninit) {
|
if (uninit) {
|
||||||
/*
|
|
||||||
* Protect extent trees against block allocations
|
|
||||||
* via delalloc
|
|
||||||
*/
|
|
||||||
double_down_write_data_sem(orig_inode, donor_inode);
|
|
||||||
replaced_count = mext_replace_branches(handle, orig_inode,
|
replaced_count = mext_replace_branches(handle, orig_inode,
|
||||||
donor_inode, orig_blk_offset,
|
donor_inode, orig_blk_offset,
|
||||||
block_len_in_page, err);
|
block_len_in_page, err);
|
||||||
|
|
||||||
/* Clear the inode cache not to refer to the old data */
|
|
||||||
ext4_ext_invalidate_cache(orig_inode);
|
|
||||||
ext4_ext_invalidate_cache(donor_inode);
|
|
||||||
double_up_write_data_sem(orig_inode, donor_inode);
|
|
||||||
goto out2;
|
goto out2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -880,8 +878,6 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode,
|
||||||
/* Release old bh and drop refs */
|
/* Release old bh and drop refs */
|
||||||
try_to_release_page(page, 0);
|
try_to_release_page(page, 0);
|
||||||
|
|
||||||
/* Protect extent trees against block allocations via delalloc */
|
|
||||||
double_down_write_data_sem(orig_inode, donor_inode);
|
|
||||||
replaced_count = mext_replace_branches(handle, orig_inode, donor_inode,
|
replaced_count = mext_replace_branches(handle, orig_inode, donor_inode,
|
||||||
orig_blk_offset, block_len_in_page,
|
orig_blk_offset, block_len_in_page,
|
||||||
&err2);
|
&err2);
|
||||||
|
@ -890,18 +886,10 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode,
|
||||||
block_len_in_page = replaced_count;
|
block_len_in_page = replaced_count;
|
||||||
replaced_size =
|
replaced_size =
|
||||||
block_len_in_page << orig_inode->i_blkbits;
|
block_len_in_page << orig_inode->i_blkbits;
|
||||||
} else {
|
} else
|
||||||
double_up_write_data_sem(orig_inode, donor_inode);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the inode cache not to refer to the old data */
|
|
||||||
ext4_ext_invalidate_cache(orig_inode);
|
|
||||||
ext4_ext_invalidate_cache(donor_inode);
|
|
||||||
|
|
||||||
double_up_write_data_sem(orig_inode, donor_inode);
|
|
||||||
|
|
||||||
if (!page_has_buffers(page))
|
if (!page_has_buffers(page))
|
||||||
create_empty_buffers(page, 1 << orig_inode->i_blkbits, 0);
|
create_empty_buffers(page, 1 << orig_inode->i_blkbits, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue