diff options
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_alloc_btree.c | 33 | ||||
-rw-r--r-- | fs/xfs/xfs_btree.c | 52 | ||||
-rw-r--r-- | fs/xfs/xfs_btree.h | 14 | ||||
-rw-r--r-- | fs/xfs/xfs_ialloc_btree.c | 33 |
4 files changed, 44 insertions, 88 deletions
diff --git a/fs/xfs/xfs_alloc_btree.c b/fs/xfs/xfs_alloc_btree.c index 97f7328967fd..3916925e2584 100644 --- a/fs/xfs/xfs_alloc_btree.c +++ b/fs/xfs/xfs_alloc_btree.c | |||
@@ -280,38 +280,6 @@ xfs_allocbt_key_diff( | |||
280 | return (__int64_t)be32_to_cpu(kp->ar_startblock) - rec->ar_startblock; | 280 | return (__int64_t)be32_to_cpu(kp->ar_startblock) - rec->ar_startblock; |
281 | } | 281 | } |
282 | 282 | ||
283 | STATIC int | ||
284 | xfs_allocbt_kill_root( | ||
285 | struct xfs_btree_cur *cur, | ||
286 | struct xfs_buf *bp, | ||
287 | int level, | ||
288 | union xfs_btree_ptr *newroot) | ||
289 | { | ||
290 | int error; | ||
291 | |||
292 | XFS_BTREE_TRACE_CURSOR(cur, XBT_ENTRY); | ||
293 | XFS_BTREE_STATS_INC(cur, killroot); | ||
294 | |||
295 | /* | ||
296 | * Update the root pointer, decreasing the level by 1 and then | ||
297 | * free the old root. | ||
298 | */ | ||
299 | xfs_allocbt_set_root(cur, newroot, -1); | ||
300 | error = xfs_allocbt_free_block(cur, bp); | ||
301 | if (error) { | ||
302 | XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR); | ||
303 | return error; | ||
304 | } | ||
305 | |||
306 | XFS_BTREE_STATS_INC(cur, free); | ||
307 | |||
308 | xfs_btree_setbuf(cur, level, NULL); | ||
309 | cur->bc_nlevels--; | ||
310 | |||
311 | XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT); | ||
312 | return 0; | ||
313 | } | ||
314 | |||
315 | #ifdef DEBUG | 283 | #ifdef DEBUG |
316 | STATIC int | 284 | STATIC int |
317 | xfs_allocbt_keys_inorder( | 285 | xfs_allocbt_keys_inorder( |
@@ -423,7 +391,6 @@ static const struct xfs_btree_ops xfs_allocbt_ops = { | |||
423 | 391 | ||
424 | .dup_cursor = xfs_allocbt_dup_cursor, | 392 | .dup_cursor = xfs_allocbt_dup_cursor, |
425 | .set_root = xfs_allocbt_set_root, | 393 | .set_root = xfs_allocbt_set_root, |
426 | .kill_root = xfs_allocbt_kill_root, | ||
427 | .alloc_block = xfs_allocbt_alloc_block, | 394 | .alloc_block = xfs_allocbt_alloc_block, |
428 | .free_block = xfs_allocbt_free_block, | 395 | .free_block = xfs_allocbt_free_block, |
429 | .update_lastrec = xfs_allocbt_update_lastrec, | 396 | .update_lastrec = xfs_allocbt_update_lastrec, |
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c index 829af92f0fba..735dc2e671b1 100644 --- a/fs/xfs/xfs_btree.c +++ b/fs/xfs/xfs_btree.c | |||
@@ -217,7 +217,7 @@ xfs_btree_del_cursor( | |||
217 | */ | 217 | */ |
218 | for (i = 0; i < cur->bc_nlevels; i++) { | 218 | for (i = 0; i < cur->bc_nlevels; i++) { |
219 | if (cur->bc_bufs[i]) | 219 | if (cur->bc_bufs[i]) |
220 | xfs_btree_setbuf(cur, i, NULL); | 220 | xfs_trans_brelse(cur->bc_tp, cur->bc_bufs[i]); |
221 | else if (!error) | 221 | else if (!error) |
222 | break; | 222 | break; |
223 | } | 223 | } |
@@ -763,22 +763,19 @@ xfs_btree_readahead( | |||
763 | * Set the buffer for level "lev" in the cursor to bp, releasing | 763 | * Set the buffer for level "lev" in the cursor to bp, releasing |
764 | * any previous buffer. | 764 | * any previous buffer. |
765 | */ | 765 | */ |
766 | void | 766 | STATIC void |
767 | xfs_btree_setbuf( | 767 | xfs_btree_setbuf( |
768 | xfs_btree_cur_t *cur, /* btree cursor */ | 768 | xfs_btree_cur_t *cur, /* btree cursor */ |
769 | int lev, /* level in btree */ | 769 | int lev, /* level in btree */ |
770 | xfs_buf_t *bp) /* new buffer to set */ | 770 | xfs_buf_t *bp) /* new buffer to set */ |
771 | { | 771 | { |
772 | struct xfs_btree_block *b; /* btree block */ | 772 | struct xfs_btree_block *b; /* btree block */ |
773 | xfs_buf_t *obp; /* old buffer pointer */ | ||
774 | 773 | ||
775 | obp = cur->bc_bufs[lev]; | 774 | if (cur->bc_bufs[lev]) |
776 | if (obp) | 775 | xfs_trans_brelse(cur->bc_tp, cur->bc_bufs[lev]); |
777 | xfs_trans_brelse(cur->bc_tp, obp); | ||
778 | cur->bc_bufs[lev] = bp; | 776 | cur->bc_bufs[lev] = bp; |
779 | cur->bc_ra[lev] = 0; | 777 | cur->bc_ra[lev] = 0; |
780 | if (!bp) | 778 | |
781 | return; | ||
782 | b = XFS_BUF_TO_BLOCK(bp); | 779 | b = XFS_BUF_TO_BLOCK(bp); |
783 | if (cur->bc_flags & XFS_BTREE_LONG_PTRS) { | 780 | if (cur->bc_flags & XFS_BTREE_LONG_PTRS) { |
784 | if (be64_to_cpu(b->bb_u.l.bb_leftsib) == NULLDFSBNO) | 781 | if (be64_to_cpu(b->bb_u.l.bb_leftsib) == NULLDFSBNO) |
@@ -3011,6 +3008,43 @@ out0: | |||
3011 | return 0; | 3008 | return 0; |
3012 | } | 3009 | } |
3013 | 3010 | ||
3011 | /* | ||
3012 | * Kill the current root node, and replace it with it's only child node. | ||
3013 | */ | ||
3014 | STATIC int | ||
3015 | xfs_btree_kill_root( | ||
3016 | struct xfs_btree_cur *cur, | ||
3017 | struct xfs_buf *bp, | ||
3018 | int level, | ||
3019 | union xfs_btree_ptr *newroot) | ||
3020 | { | ||
3021 | int error; | ||
3022 | |||
3023 | XFS_BTREE_TRACE_CURSOR(cur, XBT_ENTRY); | ||
3024 | XFS_BTREE_STATS_INC(cur, killroot); | ||
3025 | |||
3026 | /* | ||
3027 | * Update the root pointer, decreasing the level by 1 and then | ||
3028 | * free the old root. | ||
3029 | */ | ||
3030 | cur->bc_ops->set_root(cur, newroot, -1); | ||
3031 | |||
3032 | error = cur->bc_ops->free_block(cur, bp); | ||
3033 | if (error) { | ||
3034 | XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR); | ||
3035 | return error; | ||
3036 | } | ||
3037 | |||
3038 | XFS_BTREE_STATS_INC(cur, free); | ||
3039 | |||
3040 | cur->bc_bufs[level] = NULL; | ||
3041 | cur->bc_ra[level] = 0; | ||
3042 | cur->bc_nlevels--; | ||
3043 | |||
3044 | XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT); | ||
3045 | return 0; | ||
3046 | } | ||
3047 | |||
3014 | STATIC int | 3048 | STATIC int |
3015 | xfs_btree_dec_cursor( | 3049 | xfs_btree_dec_cursor( |
3016 | struct xfs_btree_cur *cur, | 3050 | struct xfs_btree_cur *cur, |
@@ -3195,7 +3229,7 @@ xfs_btree_delrec( | |||
3195 | * Make it the new root of the btree. | 3229 | * Make it the new root of the btree. |
3196 | */ | 3230 | */ |
3197 | pp = xfs_btree_ptr_addr(cur, 1, block); | 3231 | pp = xfs_btree_ptr_addr(cur, 1, block); |
3198 | error = cur->bc_ops->kill_root(cur, bp, level, pp); | 3232 | error = xfs_btree_kill_root(cur, bp, level, pp); |
3199 | if (error) | 3233 | if (error) |
3200 | goto error0; | 3234 | goto error0; |
3201 | } else if (level > 0) { | 3235 | } else if (level > 0) { |
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h index 7fa07062bdda..82fafc66bd1f 100644 --- a/fs/xfs/xfs_btree.h +++ b/fs/xfs/xfs_btree.h | |||
@@ -152,9 +152,7 @@ struct xfs_btree_ops { | |||
152 | 152 | ||
153 | /* update btree root pointer */ | 153 | /* update btree root pointer */ |
154 | void (*set_root)(struct xfs_btree_cur *cur, | 154 | void (*set_root)(struct xfs_btree_cur *cur, |
155 | union xfs_btree_ptr *nptr, int level_change); | 155 | union xfs_btree_ptr *nptr, int level_change); |
156 | int (*kill_root)(struct xfs_btree_cur *cur, struct xfs_buf *bp, | ||
157 | int level, union xfs_btree_ptr *newroot); | ||
158 | 156 | ||
159 | /* block allocation / freeing */ | 157 | /* block allocation / freeing */ |
160 | int (*alloc_block)(struct xfs_btree_cur *cur, | 158 | int (*alloc_block)(struct xfs_btree_cur *cur, |
@@ -399,16 +397,6 @@ xfs_btree_reada_bufs( | |||
399 | xfs_agblock_t agbno, /* allocation group block number */ | 397 | xfs_agblock_t agbno, /* allocation group block number */ |
400 | xfs_extlen_t count); /* count of filesystem blocks */ | 398 | xfs_extlen_t count); /* count of filesystem blocks */ |
401 | 399 | ||
402 | /* | ||
403 | * Set the buffer for level "lev" in the cursor to bp, releasing | ||
404 | * any previous buffer. | ||
405 | */ | ||
406 | void | ||
407 | xfs_btree_setbuf( | ||
408 | xfs_btree_cur_t *cur, /* btree cursor */ | ||
409 | int lev, /* level in btree */ | ||
410 | struct xfs_buf *bp); /* new buffer to set */ | ||
411 | |||
412 | 400 | ||
413 | /* | 401 | /* |
414 | * Common btree core entry points. | 402 | * Common btree core entry points. |
diff --git a/fs/xfs/xfs_ialloc_btree.c b/fs/xfs/xfs_ialloc_btree.c index d352862cefa0..16921f55c542 100644 --- a/fs/xfs/xfs_ialloc_btree.c +++ b/fs/xfs/xfs_ialloc_btree.c | |||
@@ -183,38 +183,6 @@ xfs_inobt_key_diff( | |||
183 | cur->bc_rec.i.ir_startino; | 183 | cur->bc_rec.i.ir_startino; |
184 | } | 184 | } |
185 | 185 | ||
186 | STATIC int | ||
187 | xfs_inobt_kill_root( | ||
188 | struct xfs_btree_cur *cur, | ||
189 | struct xfs_buf *bp, | ||
190 | int level, | ||
191 | union xfs_btree_ptr *newroot) | ||
192 | { | ||
193 | int error; | ||
194 | |||
195 | XFS_BTREE_TRACE_CURSOR(cur, XBT_ENTRY); | ||
196 | XFS_BTREE_STATS_INC(cur, killroot); | ||
197 | |||
198 | /* | ||
199 | * Update the root pointer, decreasing the level by 1 and then | ||
200 | * free the old root. | ||
201 | */ | ||
202 | xfs_inobt_set_root(cur, newroot, -1); | ||
203 | error = xfs_inobt_free_block(cur, bp); | ||
204 | if (error) { | ||
205 | XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR); | ||
206 | return error; | ||
207 | } | ||
208 | |||
209 | XFS_BTREE_STATS_INC(cur, free); | ||
210 | |||
211 | cur->bc_bufs[level] = NULL; | ||
212 | cur->bc_nlevels--; | ||
213 | |||
214 | XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT); | ||
215 | return 0; | ||
216 | } | ||
217 | |||
218 | #ifdef DEBUG | 186 | #ifdef DEBUG |
219 | STATIC int | 187 | STATIC int |
220 | xfs_inobt_keys_inorder( | 188 | xfs_inobt_keys_inorder( |
@@ -309,7 +277,6 @@ static const struct xfs_btree_ops xfs_inobt_ops = { | |||
309 | 277 | ||
310 | .dup_cursor = xfs_inobt_dup_cursor, | 278 | .dup_cursor = xfs_inobt_dup_cursor, |
311 | .set_root = xfs_inobt_set_root, | 279 | .set_root = xfs_inobt_set_root, |
312 | .kill_root = xfs_inobt_kill_root, | ||
313 | .alloc_block = xfs_inobt_alloc_block, | 280 | .alloc_block = xfs_inobt_alloc_block, |
314 | .free_block = xfs_inobt_free_block, | 281 | .free_block = xfs_inobt_free_block, |
315 | .get_minrecs = xfs_inobt_get_minrecs, | 282 | .get_minrecs = xfs_inobt_get_minrecs, |