diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2008-02-06 05:11:15 -0500 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2008-03-31 05:40:47 -0400 |
commit | b45e41d7d56dfef1ae9e02e6c59990066ba82e5c (patch) | |
tree | c139447fa57beb3886def4e17449cc34bf40cf3c /fs/gfs2/bmap.c | |
parent | 1639431a3f57b43da1e15e9268a1d691ac01ba26 (diff) |
[GFS2] Add extent allocation to block allocator
Rather than having to allocate a single block at a time, this patch
allows the block allocator to allocate an extent. Since there is
no difference (so far as the block allocator is concerned) between
data blocks and indirect blocks, it is posible to allocate a single
extent and for the caller to unrevoke just the blocks required
for indirect blocks.
Currently the only bit of GFS2 to make use of this feature is the
build height function. The intention is that gfs2_block_map will
be changed to make use of this feature in future patches.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/bmap.c')
-rw-r--r-- | fs/gfs2/bmap.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index e3a75a27cee7..1fda731c074b 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c | |||
@@ -136,8 +136,9 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page) | |||
136 | /* Get a free block, fill it with the stuffed data, | 136 | /* Get a free block, fill it with the stuffed data, |
137 | and write it out to disk */ | 137 | and write it out to disk */ |
138 | 138 | ||
139 | unsigned int n = 1; | ||
140 | block = gfs2_alloc_block(ip, &n); | ||
139 | if (isdir) { | 141 | if (isdir) { |
140 | block = gfs2_alloc_block(ip); | ||
141 | gfs2_trans_add_unrevoke(GFS2_SB(&ip->i_inode), block, 1); | 142 | gfs2_trans_add_unrevoke(GFS2_SB(&ip->i_inode), block, 1); |
142 | error = gfs2_dir_get_new_buffer(ip, block, &bh); | 143 | error = gfs2_dir_get_new_buffer(ip, block, &bh); |
143 | if (error) | 144 | if (error) |
@@ -146,8 +147,6 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page) | |||
146 | dibh, sizeof(struct gfs2_dinode)); | 147 | dibh, sizeof(struct gfs2_dinode)); |
147 | brelse(bh); | 148 | brelse(bh); |
148 | } else { | 149 | } else { |
149 | block = gfs2_alloc_block(ip); | ||
150 | |||
151 | error = gfs2_unstuffer_page(ip, dibh, block, page); | 150 | error = gfs2_unstuffer_page(ip, dibh, block, page); |
152 | if (error) | 151 | if (error) |
153 | goto out_brelse; | 152 | goto out_brelse; |
@@ -195,7 +194,7 @@ static int build_height(struct inode *inode, struct metapath *mp, unsigned heigh | |||
195 | int error; | 194 | int error; |
196 | __be64 *bp; | 195 | __be64 *bp; |
197 | u64 bn; | 196 | u64 bn; |
198 | unsigned n; | 197 | unsigned n, i = 0; |
199 | 198 | ||
200 | if (height <= ip->i_height) | 199 | if (height <= ip->i_height) |
201 | return 0; | 200 | return 0; |
@@ -204,12 +203,16 @@ static int build_height(struct inode *inode, struct metapath *mp, unsigned heigh | |||
204 | if (error) | 203 | if (error) |
205 | return error; | 204 | return error; |
206 | 205 | ||
207 | for(n = 0; n < new_height; n++) { | 206 | do { |
208 | bn = gfs2_alloc_block(ip); | 207 | n = new_height - i; |
209 | gfs2_trans_add_unrevoke(GFS2_SB(inode), bn, 1); | 208 | bn = gfs2_alloc_block(ip, &n); |
210 | mp->mp_bh[n] = gfs2_meta_new(ip->i_gl, bn); | 209 | gfs2_trans_add_unrevoke(GFS2_SB(inode), bn, n); |
211 | gfs2_trans_add_bh(ip->i_gl, mp->mp_bh[n], 1); | 210 | do { |
212 | } | 211 | mp->mp_bh[i] = gfs2_meta_new(ip->i_gl, bn++); |
212 | gfs2_trans_add_bh(ip->i_gl, mp->mp_bh[i], 1); | ||
213 | i++; | ||
214 | } while(i < n); | ||
215 | } while(i < new_height); | ||
213 | 216 | ||
214 | n = 0; | 217 | n = 0; |
215 | bn = mp->mp_bh[0]->b_blocknr; | 218 | bn = mp->mp_bh[0]->b_blocknr; |
@@ -358,6 +361,7 @@ static int lookup_block(struct gfs2_inode *ip, unsigned int height, | |||
358 | { | 361 | { |
359 | int boundary; | 362 | int boundary; |
360 | __be64 *ptr = metapointer(&boundary, height, mp); | 363 | __be64 *ptr = metapointer(&boundary, height, mp); |
364 | unsigned int n = 1; | ||
361 | 365 | ||
362 | if (*ptr) { | 366 | if (*ptr) { |
363 | *block = be64_to_cpu(*ptr); | 367 | *block = be64_to_cpu(*ptr); |
@@ -369,7 +373,7 @@ static int lookup_block(struct gfs2_inode *ip, unsigned int height, | |||
369 | if (!create) | 373 | if (!create) |
370 | return 0; | 374 | return 0; |
371 | 375 | ||
372 | *block = gfs2_alloc_block(ip); | 376 | *block = gfs2_alloc_block(ip, &n); |
373 | if (height != ip->i_height - 1 || gfs2_is_dir(ip)) | 377 | if (height != ip->i_height - 1 || gfs2_is_dir(ip)) |
374 | gfs2_trans_add_unrevoke(GFS2_SB(&ip->i_inode), *block, 1); | 378 | gfs2_trans_add_unrevoke(GFS2_SB(&ip->i_inode), *block, 1); |
375 | 379 | ||