1 From: Joel Becker <joel.becker@oracle.com>
2 Subject: ocfs2: Use struct ocfs2_extent_tree in ocfs2_num_free_extents().
3 Patch-mainline: 2.6.28?
6 ocfs2_num_free_extents() re-implements the logic of
7 ocfs2_get_extent_tree(). Now that ocfs2_get_extent_tree() does not
8 allocate, let's use it in ocfs2_num_free_extents() to simplify the code.
10 The inode validation code in ocfs2_num_free_extents() is not needed.
11 All callers are passing in pre-validated inodes.
13 Signed-off-by: Joel Becker <joel.becker@oracle.com>
14 Acked-by: Mark Fasheh <mark.fasheh@suse.com>
16 fs/ocfs2/alloc.c | 30 +++++-------------------------
17 1 files changed, 5 insertions(+), 25 deletions(-)
19 diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
20 index fb6ae67..0b900f6 100644
21 --- a/fs/ocfs2/alloc.c
22 +++ b/fs/ocfs2/alloc.c
23 @@ -618,34 +618,13 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb,
24 struct ocfs2_extent_block *eb;
25 struct buffer_head *eb_bh = NULL;
27 + struct ocfs2_extent_tree et;
31 - if (type == OCFS2_DINODE_EXTENT) {
32 - struct ocfs2_dinode *fe =
33 - (struct ocfs2_dinode *)root_bh->b_data;
34 - if (!OCFS2_IS_VALID_DINODE(fe)) {
35 - OCFS2_RO_ON_INVALID_DINODE(inode->i_sb, fe);
40 - if (fe->i_last_eb_blk)
41 - last_eb_blk = le64_to_cpu(fe->i_last_eb_blk);
42 - el = &fe->id2.i_list;
43 - } else if (type == OCFS2_XATTR_VALUE_EXTENT) {
44 - struct ocfs2_xattr_value_root *xv =
45 - (struct ocfs2_xattr_value_root *) obj;
47 - last_eb_blk = le64_to_cpu(xv->xr_last_eb_blk);
49 - } else if (type == OCFS2_XATTR_TREE_EXTENT) {
50 - struct ocfs2_xattr_block *xb =
51 - (struct ocfs2_xattr_block *)root_bh->b_data;
53 - last_eb_blk = le64_to_cpu(xb->xb_attrs.xb_root.xt_last_eb_blk);
54 - el = &xb->xb_attrs.xb_root.xt_list;
56 + ocfs2_get_extent_tree(&et, inode, root_bh, type, obj);
58 + last_eb_blk = ocfs2_et_get_last_eb_blk(&et);
61 retval = ocfs2_read_block(osb, last_eb_blk,
62 @@ -665,6 +644,7 @@ bail:
66 + ocfs2_put_extent_tree(&et);