1 From: Tao Ma <tao.ma@oracle.com>
2 Subject: [PATCH 01/16] ocfs2: Modify ocfs2_num_free_extents for future xattr usage.
3 Patch-mainline: 2.6.28?
6 ocfs2_num_free_extents() is used to find the number of free extent records
7 in an inode btree. Hence, it takes an "ocfs2_dinode" parameter. We want to
8 use this for extended attribute trees in the future, so genericize the
9 interface the take a buffer head. A future patch will allow that buffer_head
10 to contain any structure rooting an ocfs2 btree.
12 Signed-off-by: Tao Ma <tao.ma@oracle.com>
13 Signed-off-by: Mark Fasheh <mfasheh@suse.com>
15 fs/ocfs2/alloc.c | 3 ++-
16 fs/ocfs2/alloc.h | 2 +-
17 fs/ocfs2/aops.c | 5 +++--
18 fs/ocfs2/dir.c | 3 ++-
19 fs/ocfs2/file.c | 11 ++++++-----
20 fs/ocfs2/file.h | 2 +-
21 6 files changed, 15 insertions(+), 11 deletions(-)
23 --- a/fs/ocfs2/alloc.c
24 +++ b/fs/ocfs2/alloc.c
25 @@ -368,12 +368,13 @@ struct ocfs2_merge_ctxt {
27 int ocfs2_num_free_extents(struct ocfs2_super *osb,
29 - struct ocfs2_dinode *fe)
30 + struct buffer_head *bh)
33 struct ocfs2_extent_list *el;
34 struct ocfs2_extent_block *eb;
35 struct buffer_head *eb_bh = NULL;
36 + struct ocfs2_dinode *fe = (struct ocfs2_dinode *)bh->b_data;
40 --- a/fs/ocfs2/alloc.h
41 +++ b/fs/ocfs2/alloc.h
42 @@ -47,7 +47,7 @@ int ocfs2_remove_extent(struct inode *in
43 struct ocfs2_cached_dealloc_ctxt *dealloc);
44 int ocfs2_num_free_extents(struct ocfs2_super *osb,
46 - struct ocfs2_dinode *fe);
47 + struct buffer_head *bh);
48 /* how many new metadata chunks would an allocation need at maximum? */
49 static inline int ocfs2_extend_meta_needed(struct ocfs2_dinode *fe)
53 @@ -1712,8 +1712,9 @@ int ocfs2_write_begin_nolock(struct addr
54 * ocfs2_lock_allocators(). It greatly over-estimates
55 * the work to be done.
57 - ret = ocfs2_lock_allocators(inode, di, clusters_to_alloc,
58 - extents_to_split, &data_ac, &meta_ac);
59 + ret = ocfs2_lock_allocators(inode, wc->w_di_bh,
60 + clusters_to_alloc, extents_to_split,
61 + &data_ac, &meta_ac);
67 @@ -1479,7 +1479,8 @@ static int ocfs2_extend_dir(struct ocfs2
68 spin_lock(&OCFS2_I(dir)->ip_lock);
69 if (dir_i_size == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)) {
70 spin_unlock(&OCFS2_I(dir)->ip_lock);
71 - num_free_extents = ocfs2_num_free_extents(osb, dir, fe);
72 + num_free_extents = ocfs2_num_free_extents(osb, dir,
74 if (num_free_extents < 0) {
75 status = num_free_extents;
79 @@ -521,7 +521,7 @@ int ocfs2_do_extend_allocation(struct oc
81 flags = OCFS2_EXT_UNWRITTEN;
83 - free_extents = ocfs2_num_free_extents(osb, inode, fe);
84 + free_extents = ocfs2_num_free_extents(osb, inode, fe_bh);
85 if (free_extents < 0) {
86 status = free_extents;
88 @@ -609,7 +609,7 @@ leave:
89 * File systems which don't support holes call this from
90 * ocfs2_extend_allocation().
92 -int ocfs2_lock_allocators(struct inode *inode, struct ocfs2_dinode *di,
93 +int ocfs2_lock_allocators(struct inode *inode, struct buffer_head *di_bh,
94 u32 clusters_to_add, u32 extents_to_split,
95 struct ocfs2_alloc_context **data_ac,
96 struct ocfs2_alloc_context **meta_ac)
97 @@ -617,6 +617,7 @@ int ocfs2_lock_allocators(struct inode *
98 int ret = 0, num_free_extents;
99 unsigned int max_recs_needed = clusters_to_add + 2 * extents_to_split;
100 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
101 + struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
105 @@ -629,7 +630,7 @@ int ocfs2_lock_allocators(struct inode *
106 (unsigned long long)OCFS2_I(inode)->ip_blkno, (long long)i_size_read(inode),
107 le32_to_cpu(di->i_clusters), clusters_to_add, extents_to_split);
109 - num_free_extents = ocfs2_num_free_extents(osb, inode, di);
110 + num_free_extents = ocfs2_num_free_extents(osb, inode, di_bh);
111 if (num_free_extents < 0) {
112 ret = num_free_extents;
114 @@ -724,7 +725,7 @@ static int __ocfs2_extend_allocation(str
116 BUG_ON(le32_to_cpu(fe->i_clusters) != OCFS2_I(inode)->ip_clusters);
118 - status = ocfs2_lock_allocators(inode, fe, clusters_to_add, 0, &data_ac,
119 + status = ocfs2_lock_allocators(inode, bh, clusters_to_add, 0, &data_ac,
123 @@ -1395,7 +1396,7 @@ static int __ocfs2_remove_inode_range(st
124 struct ocfs2_alloc_context *meta_ac = NULL;
125 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
127 - ret = ocfs2_lock_allocators(inode, di, 0, 1, NULL, &meta_ac);
128 + ret = ocfs2_lock_allocators(inode, di_bh, 0, 1, NULL, &meta_ac);
132 --- a/fs/ocfs2/file.h
133 +++ b/fs/ocfs2/file.h
134 @@ -55,7 +55,7 @@ int ocfs2_do_extend_allocation(struct oc
135 enum ocfs2_alloc_restarted *reason_ret);
136 int ocfs2_extend_no_holes(struct inode *inode, u64 new_i_size,
138 -int ocfs2_lock_allocators(struct inode *inode, struct ocfs2_dinode *di,
139 +int ocfs2_lock_allocators(struct inode *inode, struct buffer_head *fe,
140 u32 clusters_to_add, u32 extents_to_split,
141 struct ocfs2_alloc_context **data_ac,
142 struct ocfs2_alloc_context **meta_ac);