diff options
Diffstat (limited to 'fs/ocfs2/localalloc.c')
-rw-r--r-- | fs/ocfs2/localalloc.c | 109 |
1 files changed, 43 insertions, 66 deletions
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index ec6adbf8f551..210c35237548 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/highmem.h> | 29 | #include <linux/highmem.h> |
30 | #include <linux/bitops.h> | 30 | #include <linux/bitops.h> |
31 | 31 | ||
32 | #define MLOG_MASK_PREFIX ML_DISK_ALLOC | ||
33 | #include <cluster/masklog.h> | 32 | #include <cluster/masklog.h> |
34 | 33 | ||
35 | #include "ocfs2.h" | 34 | #include "ocfs2.h" |
@@ -43,6 +42,7 @@ | |||
43 | #include "suballoc.h" | 42 | #include "suballoc.h" |
44 | #include "super.h" | 43 | #include "super.h" |
45 | #include "sysfile.h" | 44 | #include "sysfile.h" |
45 | #include "ocfs2_trace.h" | ||
46 | 46 | ||
47 | #include "buffer_head_io.h" | 47 | #include "buffer_head_io.h" |
48 | 48 | ||
@@ -201,8 +201,7 @@ void ocfs2_la_set_sizes(struct ocfs2_super *osb, int requested_mb) | |||
201 | la_max_mb = ocfs2_clusters_to_megabytes(sb, | 201 | la_max_mb = ocfs2_clusters_to_megabytes(sb, |
202 | ocfs2_local_alloc_size(sb) * 8); | 202 | ocfs2_local_alloc_size(sb) * 8); |
203 | 203 | ||
204 | mlog(0, "requested: %dM, max: %uM, default: %uM\n", | 204 | trace_ocfs2_la_set_sizes(requested_mb, la_max_mb, la_default_mb); |
205 | requested_mb, la_max_mb, la_default_mb); | ||
206 | 205 | ||
207 | if (requested_mb == -1) { | 206 | if (requested_mb == -1) { |
208 | /* No user request - use defaults */ | 207 | /* No user request - use defaults */ |
@@ -276,8 +275,8 @@ int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits) | |||
276 | 275 | ||
277 | ret = 1; | 276 | ret = 1; |
278 | bail: | 277 | bail: |
279 | mlog(0, "state=%d, bits=%llu, la_bits=%d, ret=%d\n", | 278 | trace_ocfs2_alloc_should_use_local( |
280 | osb->local_alloc_state, (unsigned long long)bits, la_bits, ret); | 279 | (unsigned long long)bits, osb->local_alloc_state, la_bits, ret); |
281 | spin_unlock(&osb->osb_lock); | 280 | spin_unlock(&osb->osb_lock); |
282 | return ret; | 281 | return ret; |
283 | } | 282 | } |
@@ -291,8 +290,6 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb) | |||
291 | struct inode *inode = NULL; | 290 | struct inode *inode = NULL; |
292 | struct ocfs2_local_alloc *la; | 291 | struct ocfs2_local_alloc *la; |
293 | 292 | ||
294 | mlog_entry_void(); | ||
295 | |||
296 | if (osb->local_alloc_bits == 0) | 293 | if (osb->local_alloc_bits == 0) |
297 | goto bail; | 294 | goto bail; |
298 | 295 | ||
@@ -364,9 +361,10 @@ bail: | |||
364 | if (inode) | 361 | if (inode) |
365 | iput(inode); | 362 | iput(inode); |
366 | 363 | ||
367 | mlog(0, "Local alloc window bits = %d\n", osb->local_alloc_bits); | 364 | trace_ocfs2_load_local_alloc(osb->local_alloc_bits); |
368 | 365 | ||
369 | mlog_exit(status); | 366 | if (status) |
367 | mlog_errno(status); | ||
370 | return status; | 368 | return status; |
371 | } | 369 | } |
372 | 370 | ||
@@ -388,8 +386,6 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) | |||
388 | struct ocfs2_dinode *alloc_copy = NULL; | 386 | struct ocfs2_dinode *alloc_copy = NULL; |
389 | struct ocfs2_dinode *alloc = NULL; | 387 | struct ocfs2_dinode *alloc = NULL; |
390 | 388 | ||
391 | mlog_entry_void(); | ||
392 | |||
393 | cancel_delayed_work(&osb->la_enable_wq); | 389 | cancel_delayed_work(&osb->la_enable_wq); |
394 | flush_workqueue(ocfs2_wq); | 390 | flush_workqueue(ocfs2_wq); |
395 | 391 | ||
@@ -482,8 +478,6 @@ out: | |||
482 | 478 | ||
483 | if (alloc_copy) | 479 | if (alloc_copy) |
484 | kfree(alloc_copy); | 480 | kfree(alloc_copy); |
485 | |||
486 | mlog_exit_void(); | ||
487 | } | 481 | } |
488 | 482 | ||
489 | /* | 483 | /* |
@@ -502,7 +496,7 @@ int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb, | |||
502 | struct inode *inode = NULL; | 496 | struct inode *inode = NULL; |
503 | struct ocfs2_dinode *alloc; | 497 | struct ocfs2_dinode *alloc; |
504 | 498 | ||
505 | mlog_entry("(slot_num = %d)\n", slot_num); | 499 | trace_ocfs2_begin_local_alloc_recovery(slot_num); |
506 | 500 | ||
507 | *alloc_copy = NULL; | 501 | *alloc_copy = NULL; |
508 | 502 | ||
@@ -552,7 +546,8 @@ bail: | |||
552 | iput(inode); | 546 | iput(inode); |
553 | } | 547 | } |
554 | 548 | ||
555 | mlog_exit(status); | 549 | if (status) |
550 | mlog_errno(status); | ||
556 | return status; | 551 | return status; |
557 | } | 552 | } |
558 | 553 | ||
@@ -570,8 +565,6 @@ int ocfs2_complete_local_alloc_recovery(struct ocfs2_super *osb, | |||
570 | struct buffer_head *main_bm_bh = NULL; | 565 | struct buffer_head *main_bm_bh = NULL; |
571 | struct inode *main_bm_inode; | 566 | struct inode *main_bm_inode; |
572 | 567 | ||
573 | mlog_entry_void(); | ||
574 | |||
575 | main_bm_inode = ocfs2_get_system_file_inode(osb, | 568 | main_bm_inode = ocfs2_get_system_file_inode(osb, |
576 | GLOBAL_BITMAP_SYSTEM_INODE, | 569 | GLOBAL_BITMAP_SYSTEM_INODE, |
577 | OCFS2_INVALID_SLOT); | 570 | OCFS2_INVALID_SLOT); |
@@ -620,7 +613,8 @@ out_mutex: | |||
620 | out: | 613 | out: |
621 | if (!status) | 614 | if (!status) |
622 | ocfs2_init_steal_slots(osb); | 615 | ocfs2_init_steal_slots(osb); |
623 | mlog_exit(status); | 616 | if (status) |
617 | mlog_errno(status); | ||
624 | return status; | 618 | return status; |
625 | } | 619 | } |
626 | 620 | ||
@@ -640,8 +634,6 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, | |||
640 | struct inode *local_alloc_inode; | 634 | struct inode *local_alloc_inode; |
641 | unsigned int free_bits; | 635 | unsigned int free_bits; |
642 | 636 | ||
643 | mlog_entry_void(); | ||
644 | |||
645 | BUG_ON(!ac); | 637 | BUG_ON(!ac); |
646 | 638 | ||
647 | local_alloc_inode = | 639 | local_alloc_inode = |
@@ -712,10 +704,6 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, | |||
712 | goto bail; | 704 | goto bail; |
713 | } | 705 | } |
714 | 706 | ||
715 | if (ac->ac_max_block) | ||
716 | mlog(0, "Calling in_range for max block %llu\n", | ||
717 | (unsigned long long)ac->ac_max_block); | ||
718 | |||
719 | ac->ac_inode = local_alloc_inode; | 707 | ac->ac_inode = local_alloc_inode; |
720 | /* We should never use localalloc from another slot */ | 708 | /* We should never use localalloc from another slot */ |
721 | ac->ac_alloc_slot = osb->slot_num; | 709 | ac->ac_alloc_slot = osb->slot_num; |
@@ -729,10 +717,12 @@ bail: | |||
729 | iput(local_alloc_inode); | 717 | iput(local_alloc_inode); |
730 | } | 718 | } |
731 | 719 | ||
732 | mlog(0, "bits=%d, slot=%d, ret=%d\n", bits_wanted, osb->slot_num, | 720 | trace_ocfs2_reserve_local_alloc_bits( |
733 | status); | 721 | (unsigned long long)ac->ac_max_block, |
722 | bits_wanted, osb->slot_num, status); | ||
734 | 723 | ||
735 | mlog_exit(status); | 724 | if (status) |
725 | mlog_errno(status); | ||
736 | return status; | 726 | return status; |
737 | } | 727 | } |
738 | 728 | ||
@@ -749,7 +739,6 @@ int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, | |||
749 | struct ocfs2_dinode *alloc; | 739 | struct ocfs2_dinode *alloc; |
750 | struct ocfs2_local_alloc *la; | 740 | struct ocfs2_local_alloc *la; |
751 | 741 | ||
752 | mlog_entry_void(); | ||
753 | BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL); | 742 | BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL); |
754 | 743 | ||
755 | local_alloc_inode = ac->ac_inode; | 744 | local_alloc_inode = ac->ac_inode; |
@@ -788,7 +777,8 @@ int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, | |||
788 | ocfs2_journal_dirty(handle, osb->local_alloc_bh); | 777 | ocfs2_journal_dirty(handle, osb->local_alloc_bh); |
789 | 778 | ||
790 | bail: | 779 | bail: |
791 | mlog_exit(status); | 780 | if (status) |
781 | mlog_errno(status); | ||
792 | return status; | 782 | return status; |
793 | } | 783 | } |
794 | 784 | ||
@@ -799,13 +789,11 @@ static u32 ocfs2_local_alloc_count_bits(struct ocfs2_dinode *alloc) | |||
799 | u32 count = 0; | 789 | u32 count = 0; |
800 | struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); | 790 | struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); |
801 | 791 | ||
802 | mlog_entry_void(); | ||
803 | |||
804 | buffer = la->la_bitmap; | 792 | buffer = la->la_bitmap; |
805 | for (i = 0; i < le16_to_cpu(la->la_size); i++) | 793 | for (i = 0; i < le16_to_cpu(la->la_size); i++) |
806 | count += hweight8(buffer[i]); | 794 | count += hweight8(buffer[i]); |
807 | 795 | ||
808 | mlog_exit(count); | 796 | trace_ocfs2_local_alloc_count_bits(count); |
809 | return count; | 797 | return count; |
810 | } | 798 | } |
811 | 799 | ||
@@ -820,10 +808,7 @@ static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb, | |||
820 | void *bitmap = NULL; | 808 | void *bitmap = NULL; |
821 | struct ocfs2_reservation_map *resmap = &osb->osb_la_resmap; | 809 | struct ocfs2_reservation_map *resmap = &osb->osb_la_resmap; |
822 | 810 | ||
823 | mlog_entry("(numbits wanted = %u)\n", *numbits); | ||
824 | |||
825 | if (!alloc->id1.bitmap1.i_total) { | 811 | if (!alloc->id1.bitmap1.i_total) { |
826 | mlog(0, "No bits in my window!\n"); | ||
827 | bitoff = -1; | 812 | bitoff = -1; |
828 | goto bail; | 813 | goto bail; |
829 | } | 814 | } |
@@ -883,8 +868,7 @@ static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb, | |||
883 | } | 868 | } |
884 | } | 869 | } |
885 | 870 | ||
886 | mlog(0, "Exiting loop, bitoff = %d, numfound = %d\n", bitoff, | 871 | trace_ocfs2_local_alloc_find_clear_bits_search_bitmap(bitoff, numfound); |
887 | numfound); | ||
888 | 872 | ||
889 | if (numfound == *numbits) | 873 | if (numfound == *numbits) |
890 | bitoff = startoff - numfound; | 874 | bitoff = startoff - numfound; |
@@ -895,7 +879,10 @@ bail: | |||
895 | if (local_resv) | 879 | if (local_resv) |
896 | ocfs2_resv_discard(resmap, resv); | 880 | ocfs2_resv_discard(resmap, resv); |
897 | 881 | ||
898 | mlog_exit(bitoff); | 882 | trace_ocfs2_local_alloc_find_clear_bits(*numbits, |
883 | le32_to_cpu(alloc->id1.bitmap1.i_total), | ||
884 | bitoff, numfound); | ||
885 | |||
899 | return bitoff; | 886 | return bitoff; |
900 | } | 887 | } |
901 | 888 | ||
@@ -903,15 +890,12 @@ static void ocfs2_clear_local_alloc(struct ocfs2_dinode *alloc) | |||
903 | { | 890 | { |
904 | struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); | 891 | struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); |
905 | int i; | 892 | int i; |
906 | mlog_entry_void(); | ||
907 | 893 | ||
908 | alloc->id1.bitmap1.i_total = 0; | 894 | alloc->id1.bitmap1.i_total = 0; |
909 | alloc->id1.bitmap1.i_used = 0; | 895 | alloc->id1.bitmap1.i_used = 0; |
910 | la->la_bm_off = 0; | 896 | la->la_bm_off = 0; |
911 | for(i = 0; i < le16_to_cpu(la->la_size); i++) | 897 | for(i = 0; i < le16_to_cpu(la->la_size); i++) |
912 | la->la_bitmap[i] = 0; | 898 | la->la_bitmap[i] = 0; |
913 | |||
914 | mlog_exit_void(); | ||
915 | } | 899 | } |
916 | 900 | ||
917 | #if 0 | 901 | #if 0 |
@@ -952,18 +936,16 @@ static int ocfs2_sync_local_to_main(struct ocfs2_super *osb, | |||
952 | void *bitmap; | 936 | void *bitmap; |
953 | struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); | 937 | struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); |
954 | 938 | ||
955 | mlog_entry("total = %u, used = %u\n", | 939 | trace_ocfs2_sync_local_to_main( |
956 | le32_to_cpu(alloc->id1.bitmap1.i_total), | 940 | le32_to_cpu(alloc->id1.bitmap1.i_total), |
957 | le32_to_cpu(alloc->id1.bitmap1.i_used)); | 941 | le32_to_cpu(alloc->id1.bitmap1.i_used)); |
958 | 942 | ||
959 | if (!alloc->id1.bitmap1.i_total) { | 943 | if (!alloc->id1.bitmap1.i_total) { |
960 | mlog(0, "nothing to sync!\n"); | ||
961 | goto bail; | 944 | goto bail; |
962 | } | 945 | } |
963 | 946 | ||
964 | if (le32_to_cpu(alloc->id1.bitmap1.i_used) == | 947 | if (le32_to_cpu(alloc->id1.bitmap1.i_used) == |
965 | le32_to_cpu(alloc->id1.bitmap1.i_total)) { | 948 | le32_to_cpu(alloc->id1.bitmap1.i_total)) { |
966 | mlog(0, "all bits were taken!\n"); | ||
967 | goto bail; | 949 | goto bail; |
968 | } | 950 | } |
969 | 951 | ||
@@ -985,8 +967,7 @@ static int ocfs2_sync_local_to_main(struct ocfs2_super *osb, | |||
985 | ocfs2_clusters_to_blocks(osb->sb, | 967 | ocfs2_clusters_to_blocks(osb->sb, |
986 | start - count); | 968 | start - count); |
987 | 969 | ||
988 | mlog(0, "freeing %u bits starting at local alloc bit " | 970 | trace_ocfs2_sync_local_to_main_free( |
989 | "%u (la_start_blk = %llu, blkno = %llu)\n", | ||
990 | count, start - count, | 971 | count, start - count, |
991 | (unsigned long long)la_start_blk, | 972 | (unsigned long long)la_start_blk, |
992 | (unsigned long long)blkno); | 973 | (unsigned long long)blkno); |
@@ -1007,7 +988,8 @@ static int ocfs2_sync_local_to_main(struct ocfs2_super *osb, | |||
1007 | } | 988 | } |
1008 | 989 | ||
1009 | bail: | 990 | bail: |
1010 | mlog_exit(status); | 991 | if (status) |
992 | mlog_errno(status); | ||
1011 | return status; | 993 | return status; |
1012 | } | 994 | } |
1013 | 995 | ||
@@ -1132,7 +1114,8 @@ bail: | |||
1132 | *ac = NULL; | 1114 | *ac = NULL; |
1133 | } | 1115 | } |
1134 | 1116 | ||
1135 | mlog_exit(status); | 1117 | if (status) |
1118 | mlog_errno(status); | ||
1136 | return status; | 1119 | return status; |
1137 | } | 1120 | } |
1138 | 1121 | ||
@@ -1148,17 +1131,12 @@ static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, | |||
1148 | struct ocfs2_dinode *alloc = NULL; | 1131 | struct ocfs2_dinode *alloc = NULL; |
1149 | struct ocfs2_local_alloc *la; | 1132 | struct ocfs2_local_alloc *la; |
1150 | 1133 | ||
1151 | mlog_entry_void(); | ||
1152 | |||
1153 | alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; | 1134 | alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; |
1154 | la = OCFS2_LOCAL_ALLOC(alloc); | 1135 | la = OCFS2_LOCAL_ALLOC(alloc); |
1155 | 1136 | ||
1156 | if (alloc->id1.bitmap1.i_total) | 1137 | trace_ocfs2_local_alloc_new_window( |
1157 | mlog(0, "asking me to alloc a new window over a non-empty " | 1138 | le32_to_cpu(alloc->id1.bitmap1.i_total), |
1158 | "one\n"); | 1139 | osb->local_alloc_bits); |
1159 | |||
1160 | mlog(0, "Allocating %u clusters for a new window.\n", | ||
1161 | osb->local_alloc_bits); | ||
1162 | 1140 | ||
1163 | /* Instruct the allocation code to try the most recently used | 1141 | /* Instruct the allocation code to try the most recently used |
1164 | * cluster group. We'll re-record the group used this pass | 1142 | * cluster group. We'll re-record the group used this pass |
@@ -1220,13 +1198,13 @@ retry_enospc: | |||
1220 | ocfs2_resmap_restart(&osb->osb_la_resmap, cluster_count, | 1198 | ocfs2_resmap_restart(&osb->osb_la_resmap, cluster_count, |
1221 | OCFS2_LOCAL_ALLOC(alloc)->la_bitmap); | 1199 | OCFS2_LOCAL_ALLOC(alloc)->la_bitmap); |
1222 | 1200 | ||
1223 | mlog(0, "New window allocated:\n"); | 1201 | trace_ocfs2_local_alloc_new_window_result( |
1224 | mlog(0, "window la_bm_off = %u\n", | 1202 | OCFS2_LOCAL_ALLOC(alloc)->la_bm_off, |
1225 | OCFS2_LOCAL_ALLOC(alloc)->la_bm_off); | 1203 | le32_to_cpu(alloc->id1.bitmap1.i_total)); |
1226 | mlog(0, "window bits = %u\n", le32_to_cpu(alloc->id1.bitmap1.i_total)); | ||
1227 | 1204 | ||
1228 | bail: | 1205 | bail: |
1229 | mlog_exit(status); | 1206 | if (status) |
1207 | mlog_errno(status); | ||
1230 | return status; | 1208 | return status; |
1231 | } | 1209 | } |
1232 | 1210 | ||
@@ -1243,8 +1221,6 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, | |||
1243 | struct ocfs2_dinode *alloc_copy = NULL; | 1221 | struct ocfs2_dinode *alloc_copy = NULL; |
1244 | struct ocfs2_alloc_context *ac = NULL; | 1222 | struct ocfs2_alloc_context *ac = NULL; |
1245 | 1223 | ||
1246 | mlog_entry_void(); | ||
1247 | |||
1248 | ocfs2_recalc_la_window(osb, OCFS2_LA_EVENT_SLIDE); | 1224 | ocfs2_recalc_la_window(osb, OCFS2_LA_EVENT_SLIDE); |
1249 | 1225 | ||
1250 | /* This will lock the main bitmap for us. */ | 1226 | /* This will lock the main bitmap for us. */ |
@@ -1324,7 +1300,8 @@ bail: | |||
1324 | if (ac) | 1300 | if (ac) |
1325 | ocfs2_free_alloc_context(ac); | 1301 | ocfs2_free_alloc_context(ac); |
1326 | 1302 | ||
1327 | mlog_exit(status); | 1303 | if (status) |
1304 | mlog_errno(status); | ||
1328 | return status; | 1305 | return status; |
1329 | } | 1306 | } |
1330 | 1307 | ||