]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
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? | |
4 | References: FATE302067 | |
5 | ||
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. | |
9 | ||
10 | The inode validation code in ocfs2_num_free_extents() is not needed. | |
11 | All callers are passing in pre-validated inodes. | |
12 | ||
13 | Signed-off-by: Joel Becker <joel.becker@oracle.com> | |
14 | Acked-by: Mark Fasheh <mark.fasheh@suse.com> | |
15 | --- | |
16 | fs/ocfs2/alloc.c | 30 +++++------------------------- | |
17 | 1 files changed, 5 insertions(+), 25 deletions(-) | |
18 | ||
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; | |
26 | u64 last_eb_blk = 0; | |
27 | + struct ocfs2_extent_tree et; | |
28 | ||
29 | mlog_entry_void(); | |
30 | ||
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); | |
36 | - retval = -EIO; | |
37 | - goto bail; | |
38 | - } | |
39 | - | |
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; | |
46 | - | |
47 | - last_eb_blk = le64_to_cpu(xv->xr_last_eb_blk); | |
48 | - el = &xv->xr_list; | |
49 | - } else if (type == OCFS2_XATTR_TREE_EXTENT) { | |
50 | - struct ocfs2_xattr_block *xb = | |
51 | - (struct ocfs2_xattr_block *)root_bh->b_data; | |
52 | - | |
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; | |
55 | - } | |
56 | + ocfs2_get_extent_tree(&et, inode, root_bh, type, obj); | |
57 | + el = et.et_root_el; | |
58 | + last_eb_blk = ocfs2_et_get_last_eb_blk(&et); | |
59 | ||
60 | if (last_eb_blk) { | |
61 | retval = ocfs2_read_block(osb, last_eb_blk, | |
62 | @@ -665,6 +644,7 @@ bail: | |
63 | if (eb_bh) | |
64 | brelse(eb_bh); | |
65 | ||
66 | + ocfs2_put_extent_tree(&et); | |
67 | mlog_exit(retval); | |
68 | return retval; | |
69 | } | |
70 | -- | |
71 | 1.5.4.5 | |
72 |