diff options
author | Joel Becker <joel.becker@oracle.com> | 2008-08-20 20:09:42 -0400 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2008-10-13 19:57:04 -0400 |
commit | 1c25d93a4a27c90c3ae33f9e724f7b67783d68d1 (patch) | |
tree | d62c9b19fae527770939748566ce3a31ce0bce53 /fs/ocfs2/alloc.c | |
parent | 0ce1010f1a4319e02574b856d50dfdc0ed855f40 (diff) |
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: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/alloc.c')
-rw-r--r-- | fs/ocfs2/alloc.c | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index fe2ddbb81f74..d1aa7249deb2 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -618,34 +618,13 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb, | |||
618 | struct ocfs2_extent_block *eb; | 618 | struct ocfs2_extent_block *eb; |
619 | struct buffer_head *eb_bh = NULL; | 619 | struct buffer_head *eb_bh = NULL; |
620 | u64 last_eb_blk = 0; | 620 | u64 last_eb_blk = 0; |
621 | struct ocfs2_extent_tree et; | ||
621 | 622 | ||
622 | mlog_entry_void(); | 623 | mlog_entry_void(); |
623 | 624 | ||
624 | if (type == OCFS2_DINODE_EXTENT) { | 625 | ocfs2_get_extent_tree(&et, inode, root_bh, type, obj); |
625 | struct ocfs2_dinode *fe = | 626 | el = et.et_root_el; |
626 | (struct ocfs2_dinode *)root_bh->b_data; | 627 | last_eb_blk = ocfs2_et_get_last_eb_blk(&et); |
627 | if (!OCFS2_IS_VALID_DINODE(fe)) { | ||
628 | OCFS2_RO_ON_INVALID_DINODE(inode->i_sb, fe); | ||
629 | retval = -EIO; | ||
630 | goto bail; | ||
631 | } | ||
632 | |||
633 | if (fe->i_last_eb_blk) | ||
634 | last_eb_blk = le64_to_cpu(fe->i_last_eb_blk); | ||
635 | el = &fe->id2.i_list; | ||
636 | } else if (type == OCFS2_XATTR_VALUE_EXTENT) { | ||
637 | struct ocfs2_xattr_value_root *xv = | ||
638 | (struct ocfs2_xattr_value_root *) obj; | ||
639 | |||
640 | last_eb_blk = le64_to_cpu(xv->xr_last_eb_blk); | ||
641 | el = &xv->xr_list; | ||
642 | } else if (type == OCFS2_XATTR_TREE_EXTENT) { | ||
643 | struct ocfs2_xattr_block *xb = | ||
644 | (struct ocfs2_xattr_block *)root_bh->b_data; | ||
645 | |||
646 | last_eb_blk = le64_to_cpu(xb->xb_attrs.xb_root.xt_last_eb_blk); | ||
647 | el = &xb->xb_attrs.xb_root.xt_list; | ||
648 | } | ||
649 | 628 | ||
650 | if (last_eb_blk) { | 629 | if (last_eb_blk) { |
651 | retval = ocfs2_read_block(osb, last_eb_blk, | 630 | retval = ocfs2_read_block(osb, last_eb_blk, |
@@ -665,6 +644,7 @@ bail: | |||
665 | if (eb_bh) | 644 | if (eb_bh) |
666 | brelse(eb_bh); | 645 | brelse(eb_bh); |
667 | 646 | ||
647 | ocfs2_put_extent_tree(&et); | ||
668 | mlog_exit(retval); | 648 | mlog_exit(retval); |
669 | return retval; | 649 | return retval; |
670 | } | 650 | } |