提交 ffdd7a54 编写于 作者: J Joel Becker 提交者: Mark Fasheh

ocfs2: Wrap up the common use cases of ocfs2_new_path().

The majority of ocfs2_new_path() calls are:

	ocfs2_new_path(path_root_bh(otherpath),
		       path_root_el(otherpath));

Let's call that ocfs2_new_path_from_path().  The rest do similar things
from struct ocfs2_extent_tree.  Let's call those
ocfs2_new_path_from_et().  This will make the next change easier.
Signed-off-by: NJoel Becker <joel.becker@oracle.com>
Signed-off-by: NMark Fasheh <mfasheh@suse.com>
上级 50655ae9
...@@ -532,6 +532,16 @@ static struct ocfs2_path *ocfs2_new_path(struct buffer_head *root_bh, ...@@ -532,6 +532,16 @@ static struct ocfs2_path *ocfs2_new_path(struct buffer_head *root_bh,
return path; return path;
} }
static struct ocfs2_path *ocfs2_new_path_from_path(struct ocfs2_path *path)
{
return ocfs2_new_path(path_root_bh(path), path_root_el(path));
}
static struct ocfs2_path *ocfs2_new_path_from_et(struct ocfs2_extent_tree *et)
{
return ocfs2_new_path(et->et_root_bh, et->et_root_el);
}
/* /*
* Convenience function to journal all components in a path. * Convenience function to journal all components in a path.
*/ */
...@@ -2150,8 +2160,7 @@ static int ocfs2_rotate_tree_right(struct inode *inode, ...@@ -2150,8 +2160,7 @@ static int ocfs2_rotate_tree_right(struct inode *inode,
*ret_left_path = NULL; *ret_left_path = NULL;
left_path = ocfs2_new_path(path_root_bh(right_path), left_path = ocfs2_new_path_from_path(right_path);
path_root_el(right_path));
if (!left_path) { if (!left_path) {
ret = -ENOMEM; ret = -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
...@@ -2692,8 +2701,7 @@ static int __ocfs2_rotate_tree_left(struct inode *inode, ...@@ -2692,8 +2701,7 @@ static int __ocfs2_rotate_tree_left(struct inode *inode,
goto out; goto out;
} }
left_path = ocfs2_new_path(path_root_bh(path), left_path = ocfs2_new_path_from_path(path);
path_root_el(path));
if (!left_path) { if (!left_path) {
ret = -ENOMEM; ret = -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
...@@ -2702,8 +2710,7 @@ static int __ocfs2_rotate_tree_left(struct inode *inode, ...@@ -2702,8 +2710,7 @@ static int __ocfs2_rotate_tree_left(struct inode *inode,
ocfs2_cp_path(left_path, path); ocfs2_cp_path(left_path, path);
right_path = ocfs2_new_path(path_root_bh(path), right_path = ocfs2_new_path_from_path(path);
path_root_el(path));
if (!right_path) { if (!right_path) {
ret = -ENOMEM; ret = -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
...@@ -2833,8 +2840,7 @@ static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle, ...@@ -2833,8 +2840,7 @@ static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle,
* We have a path to the left of this one - it needs * We have a path to the left of this one - it needs
* an update too. * an update too.
*/ */
left_path = ocfs2_new_path(path_root_bh(path), left_path = ocfs2_new_path_from_path(path);
path_root_el(path));
if (!left_path) { if (!left_path) {
ret = -ENOMEM; ret = -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
...@@ -3075,8 +3081,7 @@ static int ocfs2_get_right_path(struct inode *inode, ...@@ -3075,8 +3081,7 @@ static int ocfs2_get_right_path(struct inode *inode,
/* This function shouldn't be called for the rightmost leaf. */ /* This function shouldn't be called for the rightmost leaf. */
BUG_ON(right_cpos == 0); BUG_ON(right_cpos == 0);
right_path = ocfs2_new_path(path_root_bh(left_path), right_path = ocfs2_new_path_from_path(left_path);
path_root_el(left_path));
if (!right_path) { if (!right_path) {
ret = -ENOMEM; ret = -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
...@@ -3247,8 +3252,7 @@ static int ocfs2_get_left_path(struct inode *inode, ...@@ -3247,8 +3252,7 @@ static int ocfs2_get_left_path(struct inode *inode,
/* This function shouldn't be called for the leftmost leaf. */ /* This function shouldn't be called for the leftmost leaf. */
BUG_ON(left_cpos == 0); BUG_ON(left_cpos == 0);
left_path = ocfs2_new_path(path_root_bh(right_path), left_path = ocfs2_new_path_from_path(right_path);
path_root_el(right_path));
if (!left_path) { if (!left_path) {
ret = -ENOMEM; ret = -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
...@@ -3780,8 +3784,7 @@ static int ocfs2_append_rec_to_path(struct inode *inode, handle_t *handle, ...@@ -3780,8 +3784,7 @@ static int ocfs2_append_rec_to_path(struct inode *inode, handle_t *handle,
* leftmost leaf. * leftmost leaf.
*/ */
if (left_cpos) { if (left_cpos) {
left_path = ocfs2_new_path(path_root_bh(right_path), left_path = ocfs2_new_path_from_path(right_path);
path_root_el(right_path));
if (!left_path) { if (!left_path) {
ret = -ENOMEM; ret = -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
...@@ -4018,7 +4021,7 @@ static int ocfs2_do_insert_extent(struct inode *inode, ...@@ -4018,7 +4021,7 @@ static int ocfs2_do_insert_extent(struct inode *inode,
goto out_update_clusters; goto out_update_clusters;
} }
right_path = ocfs2_new_path(et->et_root_bh, et->et_root_el); right_path = ocfs2_new_path_from_et(et);
if (!right_path) { if (!right_path) {
ret = -ENOMEM; ret = -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
...@@ -4130,8 +4133,7 @@ ocfs2_figure_merge_contig_type(struct inode *inode, struct ocfs2_path *path, ...@@ -4130,8 +4133,7 @@ ocfs2_figure_merge_contig_type(struct inode *inode, struct ocfs2_path *path,
goto out; goto out;
if (left_cpos != 0) { if (left_cpos != 0) {
left_path = ocfs2_new_path(path_root_bh(path), left_path = ocfs2_new_path_from_path(path);
path_root_el(path));
if (!left_path) if (!left_path)
goto out; goto out;
...@@ -4187,8 +4189,7 @@ ocfs2_figure_merge_contig_type(struct inode *inode, struct ocfs2_path *path, ...@@ -4187,8 +4189,7 @@ ocfs2_figure_merge_contig_type(struct inode *inode, struct ocfs2_path *path,
if (right_cpos == 0) if (right_cpos == 0)
goto out; goto out;
right_path = ocfs2_new_path(path_root_bh(path), right_path = ocfs2_new_path_from_path(path);
path_root_el(path));
if (!right_path) if (!right_path)
goto out; goto out;
...@@ -4381,7 +4382,7 @@ static int ocfs2_figure_insert_type(struct inode *inode, ...@@ -4381,7 +4382,7 @@ static int ocfs2_figure_insert_type(struct inode *inode,
return 0; return 0;
} }
path = ocfs2_new_path(et->et_root_bh, et->et_root_el); path = ocfs2_new_path_from_et(et);
if (!path) { if (!path) {
ret = -ENOMEM; ret = -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
...@@ -4910,7 +4911,7 @@ int ocfs2_mark_extent_written(struct inode *inode, ...@@ -4910,7 +4911,7 @@ int ocfs2_mark_extent_written(struct inode *inode,
if (et->et_ops == &ocfs2_dinode_et_ops) if (et->et_ops == &ocfs2_dinode_et_ops)
ocfs2_extent_map_trunc(inode, 0); ocfs2_extent_map_trunc(inode, 0);
left_path = ocfs2_new_path(et->et_root_bh, et->et_root_el); left_path = ocfs2_new_path_from_et(et);
if (!left_path) { if (!left_path) {
ret = -ENOMEM; ret = -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
...@@ -5082,8 +5083,7 @@ static int ocfs2_truncate_rec(struct inode *inode, handle_t *handle, ...@@ -5082,8 +5083,7 @@ static int ocfs2_truncate_rec(struct inode *inode, handle_t *handle,
} }
if (left_cpos && le16_to_cpu(el->l_next_free_rec) > 1) { if (left_cpos && le16_to_cpu(el->l_next_free_rec) > 1) {
left_path = ocfs2_new_path(path_root_bh(path), left_path = ocfs2_new_path_from_path(path);
path_root_el(path));
if (!left_path) { if (!left_path) {
ret = -ENOMEM; ret = -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
...@@ -5192,7 +5192,7 @@ int ocfs2_remove_extent(struct inode *inode, ...@@ -5192,7 +5192,7 @@ int ocfs2_remove_extent(struct inode *inode,
ocfs2_extent_map_trunc(inode, 0); ocfs2_extent_map_trunc(inode, 0);
path = ocfs2_new_path(et->et_root_bh, et->et_root_el); path = ocfs2_new_path_from_et(et);
if (!path) { if (!path) {
ret = -ENOMEM; ret = -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册