Commit 1c25d93a authored by Joel Becker's avatar Joel Becker Committed by Mark Fasheh

ocfs2: Use struct ocfs2_extent_tree in ocfs2_num_free_extents().

ocfs2_num_free_extents() re-implements the logic of
ocfs2_get_extent_tree().  Now that ocfs2_get_extent_tree() does not
allocate, let's use it in ocfs2_num_free_extents() to simplify the code.

The inode validation code in ocfs2_num_free_extents() is not needed.
All callers are passing in pre-validated inodes.
Signed-off-by: default avatarJoel Becker <joel.becker@oracle.com>
Signed-off-by: default avatarMark Fasheh <mfasheh@suse.com>
parent 0ce1010f
...@@ -618,34 +618,13 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb, ...@@ -618,34 +618,13 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb,
struct ocfs2_extent_block *eb; struct ocfs2_extent_block *eb;
struct buffer_head *eb_bh = NULL; struct buffer_head *eb_bh = NULL;
u64 last_eb_blk = 0; u64 last_eb_blk = 0;
struct ocfs2_extent_tree et;
mlog_entry_void(); mlog_entry_void();
if (type == OCFS2_DINODE_EXTENT) { ocfs2_get_extent_tree(&et, inode, root_bh, type, obj);
struct ocfs2_dinode *fe = el = et.et_root_el;
(struct ocfs2_dinode *)root_bh->b_data; last_eb_blk = ocfs2_et_get_last_eb_blk(&et);
if (!OCFS2_IS_VALID_DINODE(fe)) {
OCFS2_RO_ON_INVALID_DINODE(inode->i_sb, fe);
retval = -EIO;
goto bail;
}
if (fe->i_last_eb_blk)
last_eb_blk = le64_to_cpu(fe->i_last_eb_blk);
el = &fe->id2.i_list;
} else if (type == OCFS2_XATTR_VALUE_EXTENT) {
struct ocfs2_xattr_value_root *xv =
(struct ocfs2_xattr_value_root *) obj;
last_eb_blk = le64_to_cpu(xv->xr_last_eb_blk);
el = &xv->xr_list;
} else if (type == OCFS2_XATTR_TREE_EXTENT) {
struct ocfs2_xattr_block *xb =
(struct ocfs2_xattr_block *)root_bh->b_data;
last_eb_blk = le64_to_cpu(xb->xb_attrs.xb_root.xt_last_eb_blk);
el = &xb->xb_attrs.xb_root.xt_list;
}
if (last_eb_blk) { if (last_eb_blk) {
retval = ocfs2_read_block(osb, last_eb_blk, retval = ocfs2_read_block(osb, last_eb_blk,
...@@ -665,6 +644,7 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb, ...@@ -665,6 +644,7 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb,
if (eb_bh) if (eb_bh)
brelse(eb_bh); brelse(eb_bh);
ocfs2_put_extent_tree(&et);
mlog_exit(retval); mlog_exit(retval);
return retval; return retval;
} }
......
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