diff options
Diffstat (limited to 'fs/ocfs2/suballoc.c')
-rw-r--r-- | fs/ocfs2/suballoc.c | 107 |
1 files changed, 53 insertions, 54 deletions
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index 2d722f1fbaa0..94342bd9800d 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include "super.h" | 44 | #include "super.h" |
45 | #include "sysfile.h" | 45 | #include "sysfile.h" |
46 | #include "uptodate.h" | 46 | #include "uptodate.h" |
47 | #include "ocfs2_trace.h" | ||
47 | 48 | ||
48 | #include "buffer_head_io.h" | 49 | #include "buffer_head_io.h" |
49 | 50 | ||
@@ -308,8 +309,8 @@ static int ocfs2_validate_group_descriptor(struct super_block *sb, | |||
308 | int rc; | 309 | int rc; |
309 | struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data; | 310 | struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data; |
310 | 311 | ||
311 | mlog(0, "Validating group descriptor %llu\n", | 312 | trace_ocfs2_validate_group_descriptor( |
312 | (unsigned long long)bh->b_blocknr); | 313 | (unsigned long long)bh->b_blocknr); |
313 | 314 | ||
314 | BUG_ON(!buffer_uptodate(bh)); | 315 | BUG_ON(!buffer_uptodate(bh)); |
315 | 316 | ||
@@ -476,8 +477,8 @@ ocfs2_block_group_alloc_contig(struct ocfs2_super *osb, handle_t *handle, | |||
476 | 477 | ||
477 | /* setup the group */ | 478 | /* setup the group */ |
478 | bg_blkno = ocfs2_clusters_to_blocks(osb->sb, bit_off); | 479 | bg_blkno = ocfs2_clusters_to_blocks(osb->sb, bit_off); |
479 | mlog(0, "new descriptor, record %u, at block %llu\n", | 480 | trace_ocfs2_block_group_alloc_contig( |
480 | alloc_rec, (unsigned long long)bg_blkno); | 481 | (unsigned long long)bg_blkno, alloc_rec); |
481 | 482 | ||
482 | bg_bh = sb_getblk(osb->sb, bg_blkno); | 483 | bg_bh = sb_getblk(osb->sb, bg_blkno); |
483 | if (!bg_bh) { | 484 | if (!bg_bh) { |
@@ -656,8 +657,8 @@ ocfs2_block_group_alloc_discontig(handle_t *handle, | |||
656 | 657 | ||
657 | /* setup the group */ | 658 | /* setup the group */ |
658 | bg_blkno = ocfs2_clusters_to_blocks(osb->sb, bit_off); | 659 | bg_blkno = ocfs2_clusters_to_blocks(osb->sb, bit_off); |
659 | mlog(0, "new descriptor, record %u, at block %llu\n", | 660 | trace_ocfs2_block_group_alloc_discontig( |
660 | alloc_rec, (unsigned long long)bg_blkno); | 661 | (unsigned long long)bg_blkno, alloc_rec); |
661 | 662 | ||
662 | bg_bh = sb_getblk(osb->sb, bg_blkno); | 663 | bg_bh = sb_getblk(osb->sb, bg_blkno); |
663 | if (!bg_bh) { | 664 | if (!bg_bh) { |
@@ -727,8 +728,8 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb, | |||
727 | } | 728 | } |
728 | 729 | ||
729 | if (last_alloc_group && *last_alloc_group != 0) { | 730 | if (last_alloc_group && *last_alloc_group != 0) { |
730 | mlog(0, "use old allocation group %llu for block group alloc\n", | 731 | trace_ocfs2_block_group_alloc( |
731 | (unsigned long long)*last_alloc_group); | 732 | (unsigned long long)*last_alloc_group); |
732 | ac->ac_last_group = *last_alloc_group; | 733 | ac->ac_last_group = *last_alloc_group; |
733 | } | 734 | } |
734 | 735 | ||
@@ -851,16 +852,15 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb, | |||
851 | if (bits_wanted > free_bits) { | 852 | if (bits_wanted > free_bits) { |
852 | /* cluster bitmap never grows */ | 853 | /* cluster bitmap never grows */ |
853 | if (ocfs2_is_cluster_bitmap(alloc_inode)) { | 854 | if (ocfs2_is_cluster_bitmap(alloc_inode)) { |
854 | mlog(0, "Disk Full: wanted=%u, free_bits=%u\n", | 855 | trace_ocfs2_reserve_suballoc_bits_nospc(bits_wanted, |
855 | bits_wanted, free_bits); | 856 | free_bits); |
856 | status = -ENOSPC; | 857 | status = -ENOSPC; |
857 | goto bail; | 858 | goto bail; |
858 | } | 859 | } |
859 | 860 | ||
860 | if (!(flags & ALLOC_NEW_GROUP)) { | 861 | if (!(flags & ALLOC_NEW_GROUP)) { |
861 | mlog(0, "Alloc File %u Full: wanted=%u, free_bits=%u, " | 862 | trace_ocfs2_reserve_suballoc_bits_no_new_group( |
862 | "and we don't alloc a new group for it.\n", | 863 | slot, bits_wanted, free_bits); |
863 | slot, bits_wanted, free_bits); | ||
864 | status = -ENOSPC; | 864 | status = -ENOSPC; |
865 | goto bail; | 865 | goto bail; |
866 | } | 866 | } |
@@ -1117,8 +1117,8 @@ int ocfs2_reserve_new_inode(struct ocfs2_super *osb, | |||
1117 | spin_lock(&osb->osb_lock); | 1117 | spin_lock(&osb->osb_lock); |
1118 | osb->osb_inode_alloc_group = alloc_group; | 1118 | osb->osb_inode_alloc_group = alloc_group; |
1119 | spin_unlock(&osb->osb_lock); | 1119 | spin_unlock(&osb->osb_lock); |
1120 | mlog(0, "after reservation, new allocation group is " | 1120 | trace_ocfs2_reserve_new_inode_new_group( |
1121 | "%llu\n", (unsigned long long)alloc_group); | 1121 | (unsigned long long)alloc_group); |
1122 | 1122 | ||
1123 | /* | 1123 | /* |
1124 | * Some inodes must be freed by us, so try to allocate | 1124 | * Some inodes must be freed by us, so try to allocate |
@@ -1360,8 +1360,7 @@ static inline int ocfs2_block_group_set_bits(handle_t *handle, | |||
1360 | BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg)); | 1360 | BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg)); |
1361 | BUG_ON(le16_to_cpu(bg->bg_free_bits_count) < num_bits); | 1361 | BUG_ON(le16_to_cpu(bg->bg_free_bits_count) < num_bits); |
1362 | 1362 | ||
1363 | mlog(0, "block_group_set_bits: off = %u, num = %u\n", bit_off, | 1363 | trace_ocfs2_block_group_set_bits(bit_off, num_bits); |
1364 | num_bits); | ||
1365 | 1364 | ||
1366 | if (ocfs2_is_cluster_bitmap(alloc_inode)) | 1365 | if (ocfs2_is_cluster_bitmap(alloc_inode)) |
1367 | journal_type = OCFS2_JOURNAL_ACCESS_UNDO; | 1366 | journal_type = OCFS2_JOURNAL_ACCESS_UNDO; |
@@ -1434,10 +1433,10 @@ static int ocfs2_relink_block_group(handle_t *handle, | |||
1434 | BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg)); | 1433 | BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg)); |
1435 | BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(prev_bg)); | 1434 | BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(prev_bg)); |
1436 | 1435 | ||
1437 | mlog(0, "Suballoc %llu, chain %u, move group %llu to top, prev = %llu\n", | 1436 | trace_ocfs2_relink_block_group( |
1438 | (unsigned long long)le64_to_cpu(fe->i_blkno), chain, | 1437 | (unsigned long long)le64_to_cpu(fe->i_blkno), chain, |
1439 | (unsigned long long)le64_to_cpu(bg->bg_blkno), | 1438 | (unsigned long long)le64_to_cpu(bg->bg_blkno), |
1440 | (unsigned long long)le64_to_cpu(prev_bg->bg_blkno)); | 1439 | (unsigned long long)le64_to_cpu(prev_bg->bg_blkno)); |
1441 | 1440 | ||
1442 | fe_ptr = le64_to_cpu(fe->id2.i_chain.cl_recs[chain].c_blkno); | 1441 | fe_ptr = le64_to_cpu(fe->id2.i_chain.cl_recs[chain].c_blkno); |
1443 | bg_ptr = le64_to_cpu(bg->bg_next_group); | 1442 | bg_ptr = le64_to_cpu(bg->bg_next_group); |
@@ -1523,10 +1522,10 @@ static int ocfs2_cluster_group_search(struct inode *inode, | |||
1523 | if ((gd_cluster_off + max_bits) > | 1522 | if ((gd_cluster_off + max_bits) > |
1524 | OCFS2_I(inode)->ip_clusters) { | 1523 | OCFS2_I(inode)->ip_clusters) { |
1525 | max_bits = OCFS2_I(inode)->ip_clusters - gd_cluster_off; | 1524 | max_bits = OCFS2_I(inode)->ip_clusters - gd_cluster_off; |
1526 | mlog(0, "Desc %llu, bg_bits %u, clusters %u, use %u\n", | 1525 | trace_ocfs2_cluster_group_search_wrong_max_bits( |
1527 | (unsigned long long)le64_to_cpu(gd->bg_blkno), | 1526 | (unsigned long long)le64_to_cpu(gd->bg_blkno), |
1528 | le16_to_cpu(gd->bg_bits), | 1527 | le16_to_cpu(gd->bg_bits), |
1529 | OCFS2_I(inode)->ip_clusters, max_bits); | 1528 | OCFS2_I(inode)->ip_clusters, max_bits); |
1530 | } | 1529 | } |
1531 | 1530 | ||
1532 | ret = ocfs2_block_group_find_clear_bits(OCFS2_SB(inode->i_sb), | 1531 | ret = ocfs2_block_group_find_clear_bits(OCFS2_SB(inode->i_sb), |
@@ -1540,9 +1539,9 @@ static int ocfs2_cluster_group_search(struct inode *inode, | |||
1540 | gd_cluster_off + | 1539 | gd_cluster_off + |
1541 | res->sr_bit_offset + | 1540 | res->sr_bit_offset + |
1542 | res->sr_bits); | 1541 | res->sr_bits); |
1543 | mlog(0, "Checking %llu against %llu\n", | 1542 | trace_ocfs2_cluster_group_search_max_block( |
1544 | (unsigned long long)blkoff, | 1543 | (unsigned long long)blkoff, |
1545 | (unsigned long long)max_block); | 1544 | (unsigned long long)max_block); |
1546 | if (blkoff > max_block) | 1545 | if (blkoff > max_block) |
1547 | return -ENOSPC; | 1546 | return -ENOSPC; |
1548 | } | 1547 | } |
@@ -1586,9 +1585,9 @@ static int ocfs2_block_group_search(struct inode *inode, | |||
1586 | if (!ret && max_block) { | 1585 | if (!ret && max_block) { |
1587 | blkoff = le64_to_cpu(bg->bg_blkno) + | 1586 | blkoff = le64_to_cpu(bg->bg_blkno) + |
1588 | res->sr_bit_offset + res->sr_bits; | 1587 | res->sr_bit_offset + res->sr_bits; |
1589 | mlog(0, "Checking %llu against %llu\n", | 1588 | trace_ocfs2_block_group_search_max_block( |
1590 | (unsigned long long)blkoff, | 1589 | (unsigned long long)blkoff, |
1591 | (unsigned long long)max_block); | 1590 | (unsigned long long)max_block); |
1592 | if (blkoff > max_block) | 1591 | if (blkoff > max_block) |
1593 | ret = -ENOSPC; | 1592 | ret = -ENOSPC; |
1594 | } | 1593 | } |
@@ -1754,9 +1753,9 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, | |||
1754 | struct ocfs2_group_desc *bg; | 1753 | struct ocfs2_group_desc *bg; |
1755 | 1754 | ||
1756 | chain = ac->ac_chain; | 1755 | chain = ac->ac_chain; |
1757 | mlog(0, "trying to alloc %u bits from chain %u, inode %llu\n", | 1756 | trace_ocfs2_search_chain_begin( |
1758 | bits_wanted, chain, | 1757 | (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno, |
1759 | (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno); | 1758 | bits_wanted, chain); |
1760 | 1759 | ||
1761 | status = ocfs2_read_group_descriptor(alloc_inode, fe, | 1760 | status = ocfs2_read_group_descriptor(alloc_inode, fe, |
1762 | le64_to_cpu(cl->cl_recs[chain].c_blkno), | 1761 | le64_to_cpu(cl->cl_recs[chain].c_blkno), |
@@ -1797,8 +1796,8 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, | |||
1797 | goto bail; | 1796 | goto bail; |
1798 | } | 1797 | } |
1799 | 1798 | ||
1800 | mlog(0, "alloc succeeds: we give %u bits from block group %llu\n", | 1799 | trace_ocfs2_search_chain_succ( |
1801 | res->sr_bits, (unsigned long long)le64_to_cpu(bg->bg_blkno)); | 1800 | (unsigned long long)le64_to_cpu(bg->bg_blkno), res->sr_bits); |
1802 | 1801 | ||
1803 | res->sr_bg_blkno = le64_to_cpu(bg->bg_blkno); | 1802 | res->sr_bg_blkno = le64_to_cpu(bg->bg_blkno); |
1804 | 1803 | ||
@@ -1859,8 +1858,9 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, | |||
1859 | goto bail; | 1858 | goto bail; |
1860 | } | 1859 | } |
1861 | 1860 | ||
1862 | mlog(0, "Allocated %u bits from suballocator %llu\n", res->sr_bits, | 1861 | trace_ocfs2_search_chain_end( |
1863 | (unsigned long long)le64_to_cpu(fe->i_blkno)); | 1862 | (unsigned long long)le64_to_cpu(fe->i_blkno), |
1863 | res->sr_bits); | ||
1864 | 1864 | ||
1865 | out_loc_only: | 1865 | out_loc_only: |
1866 | *bits_left = le16_to_cpu(bg->bg_free_bits_count); | 1866 | *bits_left = le16_to_cpu(bg->bg_free_bits_count); |
@@ -1942,8 +1942,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac, | |||
1942 | goto bail; | 1942 | goto bail; |
1943 | } | 1943 | } |
1944 | 1944 | ||
1945 | mlog(0, "Search of victim chain %u came up with nothing, " | 1945 | trace_ocfs2_claim_suballoc_bits(victim); |
1946 | "trying all chains now.\n", victim); | ||
1947 | 1946 | ||
1948 | /* If we didn't pick a good victim, then just default to | 1947 | /* If we didn't pick a good victim, then just default to |
1949 | * searching each chain in order. Don't allow chain relinking | 1948 | * searching each chain in order. Don't allow chain relinking |
@@ -2171,8 +2170,8 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle, | |||
2171 | goto out; | 2170 | goto out; |
2172 | } | 2171 | } |
2173 | 2172 | ||
2174 | mlog(0, "Allocated %u bits from suballocator %llu\n", res->sr_bits, | 2173 | trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno, |
2175 | (unsigned long long)di_blkno); | 2174 | res->sr_bits); |
2176 | 2175 | ||
2177 | atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); | 2176 | atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); |
2178 | 2177 | ||
@@ -2393,7 +2392,7 @@ static int ocfs2_block_group_clear_bits(handle_t *handle, | |||
2393 | * ocfs2_read_group_descriptor(). Any corruption is a code bug. */ | 2392 | * ocfs2_read_group_descriptor(). Any corruption is a code bug. */ |
2394 | BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg)); | 2393 | BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg)); |
2395 | 2394 | ||
2396 | mlog(0, "off = %u, num = %u\n", bit_off, num_bits); | 2395 | trace_ocfs2_block_group_clear_bits(bit_off, num_bits); |
2397 | 2396 | ||
2398 | BUG_ON(undo_fn && !ocfs2_is_cluster_bitmap(alloc_inode)); | 2397 | BUG_ON(undo_fn && !ocfs2_is_cluster_bitmap(alloc_inode)); |
2399 | status = ocfs2_journal_access_gd(handle, INODE_CACHE(alloc_inode), | 2398 | status = ocfs2_journal_access_gd(handle, INODE_CACHE(alloc_inode), |
@@ -2466,9 +2465,10 @@ static int _ocfs2_free_suballoc_bits(handle_t *handle, | |||
2466 | BUG_ON(!OCFS2_IS_VALID_DINODE(fe)); | 2465 | BUG_ON(!OCFS2_IS_VALID_DINODE(fe)); |
2467 | BUG_ON((count + start_bit) > ocfs2_bits_per_group(cl)); | 2466 | BUG_ON((count + start_bit) > ocfs2_bits_per_group(cl)); |
2468 | 2467 | ||
2469 | mlog(0, "%llu: freeing %u bits from group %llu, starting at %u\n", | 2468 | trace_ocfs2_free_suballoc_bits( |
2470 | (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno, count, | 2469 | (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno, |
2471 | (unsigned long long)bg_blkno, start_bit); | 2470 | (unsigned long long)bg_blkno, |
2471 | start_bit, count); | ||
2472 | 2472 | ||
2473 | status = ocfs2_read_group_descriptor(alloc_inode, fe, bg_blkno, | 2473 | status = ocfs2_read_group_descriptor(alloc_inode, fe, bg_blkno, |
2474 | &group_bh); | 2474 | &group_bh); |
@@ -2560,10 +2560,9 @@ static int _ocfs2_free_clusters(handle_t *handle, | |||
2560 | ocfs2_block_to_cluster_group(bitmap_inode, start_blk, &bg_blkno, | 2560 | ocfs2_block_to_cluster_group(bitmap_inode, start_blk, &bg_blkno, |
2561 | &bg_start_bit); | 2561 | &bg_start_bit); |
2562 | 2562 | ||
2563 | mlog(0, "want to free %u clusters starting at block %llu\n", | 2563 | trace_ocfs2_free_clusters((unsigned long long)bg_blkno, |
2564 | num_clusters, (unsigned long long)start_blk); | 2564 | (unsigned long long)start_blk, |
2565 | mlog(0, "bg_blkno = %llu, bg_start_bit = %u\n", | 2565 | bg_start_bit, num_clusters); |
2566 | (unsigned long long)bg_blkno, bg_start_bit); | ||
2567 | 2566 | ||
2568 | status = _ocfs2_free_suballoc_bits(handle, bitmap_inode, bitmap_bh, | 2567 | status = _ocfs2_free_suballoc_bits(handle, bitmap_inode, bitmap_bh, |
2569 | bg_start_bit, bg_blkno, | 2568 | bg_start_bit, bg_blkno, |
@@ -2748,7 +2747,7 @@ static int ocfs2_get_suballoc_slot_bit(struct ocfs2_super *osb, u64 blkno, | |||
2748 | struct buffer_head *inode_bh = NULL; | 2747 | struct buffer_head *inode_bh = NULL; |
2749 | struct ocfs2_dinode *inode_fe; | 2748 | struct ocfs2_dinode *inode_fe; |
2750 | 2749 | ||
2751 | mlog(0, "blkno: %llu\n", (unsigned long long)blkno); | 2750 | trace_ocfs2_get_suballoc_slot_bit((unsigned long long)blkno); |
2752 | 2751 | ||
2753 | /* dirty read disk */ | 2752 | /* dirty read disk */ |
2754 | status = ocfs2_read_blocks_sync(osb, blkno, 1, &inode_bh); | 2753 | status = ocfs2_read_blocks_sync(osb, blkno, 1, &inode_bh); |
@@ -2809,8 +2808,8 @@ static int ocfs2_test_suballoc_bit(struct ocfs2_super *osb, | |||
2809 | u64 bg_blkno; | 2808 | u64 bg_blkno; |
2810 | int status; | 2809 | int status; |
2811 | 2810 | ||
2812 | mlog(0, "blkno: %llu bit: %u\n", (unsigned long long)blkno, | 2811 | trace_ocfs2_test_suballoc_bit((unsigned long long)blkno, |
2813 | (unsigned int)bit); | 2812 | (unsigned int)bit); |
2814 | 2813 | ||
2815 | alloc_di = (struct ocfs2_dinode *)alloc_bh->b_data; | 2814 | alloc_di = (struct ocfs2_dinode *)alloc_bh->b_data; |
2816 | if ((bit + 1) > ocfs2_bits_per_group(&alloc_di->id2.i_chain)) { | 2815 | if ((bit + 1) > ocfs2_bits_per_group(&alloc_di->id2.i_chain)) { |
@@ -2863,7 +2862,7 @@ int ocfs2_test_inode_bit(struct ocfs2_super *osb, u64 blkno, int *res) | |||
2863 | struct inode *inode_alloc_inode; | 2862 | struct inode *inode_alloc_inode; |
2864 | struct buffer_head *alloc_bh = NULL; | 2863 | struct buffer_head *alloc_bh = NULL; |
2865 | 2864 | ||
2866 | mlog(0, "blkno: %llu", (unsigned long long)blkno); | 2865 | trace_ocfs2_test_inode_bit((unsigned long long)blkno); |
2867 | 2866 | ||
2868 | status = ocfs2_get_suballoc_slot_bit(osb, blkno, &suballoc_slot, | 2867 | status = ocfs2_get_suballoc_slot_bit(osb, blkno, &suballoc_slot, |
2869 | &group_blkno, &suballoc_bit); | 2868 | &group_blkno, &suballoc_bit); |