diff options
author | Dave Chinner <david@fromorbit.com> | 2014-05-14 19:37:44 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2014-05-14 19:37:44 -0400 |
commit | b76769294ba400415fc44038c21cc2df86f9a28b (patch) | |
tree | a1ca6152391c86ae024e09d69e7b0ad75a5c61d5 /fs/xfs/xfs_ialloc_btree.c | |
parent | 232c2f5c65dd80055e7163a5c82e3816119330e6 (diff) | |
parent | 53801fd97ae000793f51187b122b9475102199a8 (diff) |
Merge branch 'xfs-free-inode-btree' into for-next
Diffstat (limited to 'fs/xfs/xfs_ialloc_btree.c')
-rw-r--r-- | fs/xfs/xfs_ialloc_btree.c | 68 |
1 files changed, 63 insertions, 5 deletions
diff --git a/fs/xfs/xfs_ialloc_btree.c b/fs/xfs/xfs_ialloc_btree.c index f1630ff619dd..726f83a681a5 100644 --- a/fs/xfs/xfs_ialloc_btree.c +++ b/fs/xfs/xfs_ialloc_btree.c | |||
@@ -49,7 +49,8 @@ xfs_inobt_dup_cursor( | |||
49 | struct xfs_btree_cur *cur) | 49 | struct xfs_btree_cur *cur) |
50 | { | 50 | { |
51 | return xfs_inobt_init_cursor(cur->bc_mp, cur->bc_tp, | 51 | return xfs_inobt_init_cursor(cur->bc_mp, cur->bc_tp, |
52 | cur->bc_private.a.agbp, cur->bc_private.a.agno); | 52 | cur->bc_private.a.agbp, cur->bc_private.a.agno, |
53 | cur->bc_btnum); | ||
53 | } | 54 | } |
54 | 55 | ||
55 | STATIC void | 56 | STATIC void |
@@ -66,6 +67,21 @@ xfs_inobt_set_root( | |||
66 | xfs_ialloc_log_agi(cur->bc_tp, agbp, XFS_AGI_ROOT | XFS_AGI_LEVEL); | 67 | xfs_ialloc_log_agi(cur->bc_tp, agbp, XFS_AGI_ROOT | XFS_AGI_LEVEL); |
67 | } | 68 | } |
68 | 69 | ||
70 | STATIC void | ||
71 | xfs_finobt_set_root( | ||
72 | struct xfs_btree_cur *cur, | ||
73 | union xfs_btree_ptr *nptr, | ||
74 | int inc) /* level change */ | ||
75 | { | ||
76 | struct xfs_buf *agbp = cur->bc_private.a.agbp; | ||
77 | struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp); | ||
78 | |||
79 | agi->agi_free_root = nptr->s; | ||
80 | be32_add_cpu(&agi->agi_free_level, inc); | ||
81 | xfs_ialloc_log_agi(cur->bc_tp, agbp, | ||
82 | XFS_AGI_FREE_ROOT | XFS_AGI_FREE_LEVEL); | ||
83 | } | ||
84 | |||
69 | STATIC int | 85 | STATIC int |
70 | xfs_inobt_alloc_block( | 86 | xfs_inobt_alloc_block( |
71 | struct xfs_btree_cur *cur, | 87 | struct xfs_btree_cur *cur, |
@@ -172,6 +188,17 @@ xfs_inobt_init_ptr_from_cur( | |||
172 | ptr->s = agi->agi_root; | 188 | ptr->s = agi->agi_root; |
173 | } | 189 | } |
174 | 190 | ||
191 | STATIC void | ||
192 | xfs_finobt_init_ptr_from_cur( | ||
193 | struct xfs_btree_cur *cur, | ||
194 | union xfs_btree_ptr *ptr) | ||
195 | { | ||
196 | struct xfs_agi *agi = XFS_BUF_TO_AGI(cur->bc_private.a.agbp); | ||
197 | |||
198 | ASSERT(cur->bc_private.a.agno == be32_to_cpu(agi->agi_seqno)); | ||
199 | ptr->s = agi->agi_free_root; | ||
200 | } | ||
201 | |||
175 | STATIC __int64_t | 202 | STATIC __int64_t |
176 | xfs_inobt_key_diff( | 203 | xfs_inobt_key_diff( |
177 | struct xfs_btree_cur *cur, | 204 | struct xfs_btree_cur *cur, |
@@ -202,6 +229,7 @@ xfs_inobt_verify( | |||
202 | */ | 229 | */ |
203 | switch (block->bb_magic) { | 230 | switch (block->bb_magic) { |
204 | case cpu_to_be32(XFS_IBT_CRC_MAGIC): | 231 | case cpu_to_be32(XFS_IBT_CRC_MAGIC): |
232 | case cpu_to_be32(XFS_FIBT_CRC_MAGIC): | ||
205 | if (!xfs_sb_version_hascrc(&mp->m_sb)) | 233 | if (!xfs_sb_version_hascrc(&mp->m_sb)) |
206 | return false; | 234 | return false; |
207 | if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_uuid)) | 235 | if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_uuid)) |
@@ -213,6 +241,7 @@ xfs_inobt_verify( | |||
213 | return false; | 241 | return false; |
214 | /* fall through */ | 242 | /* fall through */ |
215 | case cpu_to_be32(XFS_IBT_MAGIC): | 243 | case cpu_to_be32(XFS_IBT_MAGIC): |
244 | case cpu_to_be32(XFS_FIBT_MAGIC): | ||
216 | break; | 245 | break; |
217 | default: | 246 | default: |
218 | return 0; | 247 | return 0; |
@@ -316,6 +345,28 @@ static const struct xfs_btree_ops xfs_inobt_ops = { | |||
316 | #endif | 345 | #endif |
317 | }; | 346 | }; |
318 | 347 | ||
348 | static const struct xfs_btree_ops xfs_finobt_ops = { | ||
349 | .rec_len = sizeof(xfs_inobt_rec_t), | ||
350 | .key_len = sizeof(xfs_inobt_key_t), | ||
351 | |||
352 | .dup_cursor = xfs_inobt_dup_cursor, | ||
353 | .set_root = xfs_finobt_set_root, | ||
354 | .alloc_block = xfs_inobt_alloc_block, | ||
355 | .free_block = xfs_inobt_free_block, | ||
356 | .get_minrecs = xfs_inobt_get_minrecs, | ||
357 | .get_maxrecs = xfs_inobt_get_maxrecs, | ||
358 | .init_key_from_rec = xfs_inobt_init_key_from_rec, | ||
359 | .init_rec_from_key = xfs_inobt_init_rec_from_key, | ||
360 | .init_rec_from_cur = xfs_inobt_init_rec_from_cur, | ||
361 | .init_ptr_from_cur = xfs_finobt_init_ptr_from_cur, | ||
362 | .key_diff = xfs_inobt_key_diff, | ||
363 | .buf_ops = &xfs_inobt_buf_ops, | ||
364 | #if defined(DEBUG) || defined(XFS_WARN) | ||
365 | .keys_inorder = xfs_inobt_keys_inorder, | ||
366 | .recs_inorder = xfs_inobt_recs_inorder, | ||
367 | #endif | ||
368 | }; | ||
369 | |||
319 | /* | 370 | /* |
320 | * Allocate a new inode btree cursor. | 371 | * Allocate a new inode btree cursor. |
321 | */ | 372 | */ |
@@ -324,7 +375,8 @@ xfs_inobt_init_cursor( | |||
324 | struct xfs_mount *mp, /* file system mount point */ | 375 | struct xfs_mount *mp, /* file system mount point */ |
325 | struct xfs_trans *tp, /* transaction pointer */ | 376 | struct xfs_trans *tp, /* transaction pointer */ |
326 | struct xfs_buf *agbp, /* buffer for agi structure */ | 377 | struct xfs_buf *agbp, /* buffer for agi structure */ |
327 | xfs_agnumber_t agno) /* allocation group number */ | 378 | xfs_agnumber_t agno, /* allocation group number */ |
379 | xfs_btnum_t btnum) /* ialloc or free ino btree */ | ||
328 | { | 380 | { |
329 | struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp); | 381 | struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp); |
330 | struct xfs_btree_cur *cur; | 382 | struct xfs_btree_cur *cur; |
@@ -333,11 +385,17 @@ xfs_inobt_init_cursor( | |||
333 | 385 | ||
334 | cur->bc_tp = tp; | 386 | cur->bc_tp = tp; |
335 | cur->bc_mp = mp; | 387 | cur->bc_mp = mp; |
336 | cur->bc_nlevels = be32_to_cpu(agi->agi_level); | 388 | cur->bc_btnum = btnum; |
337 | cur->bc_btnum = XFS_BTNUM_INO; | 389 | if (btnum == XFS_BTNUM_INO) { |
390 | cur->bc_nlevels = be32_to_cpu(agi->agi_level); | ||
391 | cur->bc_ops = &xfs_inobt_ops; | ||
392 | } else { | ||
393 | cur->bc_nlevels = be32_to_cpu(agi->agi_free_level); | ||
394 | cur->bc_ops = &xfs_finobt_ops; | ||
395 | } | ||
396 | |||
338 | cur->bc_blocklog = mp->m_sb.sb_blocklog; | 397 | cur->bc_blocklog = mp->m_sb.sb_blocklog; |
339 | 398 | ||
340 | cur->bc_ops = &xfs_inobt_ops; | ||
341 | if (xfs_sb_version_hascrc(&mp->m_sb)) | 399 | if (xfs_sb_version_hascrc(&mp->m_sb)) |
342 | cur->bc_flags |= XFS_BTREE_CRC_BLOCKS; | 400 | cur->bc_flags |= XFS_BTREE_CRC_BLOCKS; |
343 | 401 | ||