Skip to content

Commit a04733d

Browse files
committed
ocfs2: Remove mlog(0) from fs/ocfs2/localalloc.c
This is the 2nd step to remove the debug info of DISK_ALLOC. So this patch removes all mlog(0,...) from localalloc.c and adds the corresponding tracepoints. Different mlogs have different solutions. 1. Some are replaced with trace event directly. 2. Some are replaced while some new parameters are added. 3. Some are combined into one trace events. 4. Some redundant mlogs are removed. Signed-off-by: Tao Ma <boyu.mt@taobao.com>
1 parent a09d09b commit a04733d

2 files changed

Lines changed: 135 additions & 34 deletions

File tree

‎fs/ocfs2/localalloc.c‎

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "suballoc.h"
4444
#include "super.h"
4545
#include "sysfile.h"
46+
#include "ocfs2_trace.h"
4647

4748
#include "buffer_head_io.h"
4849

@@ -201,8 +202,7 @@ void ocfs2_la_set_sizes(struct ocfs2_super *osb, int requested_mb)
201202
la_max_mb = ocfs2_clusters_to_megabytes(sb,
202203
ocfs2_local_alloc_size(sb) * 8);
203204

204-
mlog(0, "requested: %dM, max: %uM, default: %uM\n",
205-
requested_mb, la_max_mb, la_default_mb);
205+
trace_ocfs2_la_set_sizes(requested_mb, la_max_mb, la_default_mb);
206206

207207
if (requested_mb == -1) {
208208
/* No user request - use defaults */
@@ -276,8 +276,8 @@ int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits)
276276

277277
ret = 1;
278278
bail:
279-
mlog(0, "state=%d, bits=%llu, la_bits=%d, ret=%d\n",
280-
osb->local_alloc_state, (unsigned long long)bits, la_bits, ret);
279+
trace_ocfs2_alloc_should_use_local(
280+
(unsigned long long)bits, osb->local_alloc_state, la_bits, ret);
281281
spin_unlock(&osb->osb_lock);
282282
return ret;
283283
}
@@ -362,7 +362,7 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
362362
if (inode)
363363
iput(inode);
364364

365-
mlog(0, "Local alloc window bits = %d\n", osb->local_alloc_bits);
365+
trace_ocfs2_load_local_alloc(osb->local_alloc_bits);
366366

367367
if (status)
368368
mlog_errno(status);
@@ -497,7 +497,7 @@ int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb,
497497
struct inode *inode = NULL;
498498
struct ocfs2_dinode *alloc;
499499

500-
mlog(0, "(slot_num = %d)\n", slot_num);
500+
trace_ocfs2_begin_local_alloc_recovery(slot_num);
501501

502502
*alloc_copy = NULL;
503503

@@ -705,10 +705,6 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
705705
goto bail;
706706
}
707707

708-
if (ac->ac_max_block)
709-
mlog(0, "Calling in_range for max block %llu\n",
710-
(unsigned long long)ac->ac_max_block);
711-
712708
ac->ac_inode = local_alloc_inode;
713709
/* We should never use localalloc from another slot */
714710
ac->ac_alloc_slot = osb->slot_num;
@@ -722,8 +718,9 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
722718
iput(local_alloc_inode);
723719
}
724720

725-
mlog(0, "bits=%d, slot=%d, ret=%d\n", bits_wanted, osb->slot_num,
726-
status);
721+
trace_ocfs2_reserve_local_alloc_bits(
722+
(unsigned long long)ac->ac_max_block,
723+
bits_wanted, osb->slot_num, status);
727724

728725
if (status)
729726
mlog_errno(status);
@@ -797,7 +794,7 @@ static u32 ocfs2_local_alloc_count_bits(struct ocfs2_dinode *alloc)
797794
for (i = 0; i < le16_to_cpu(la->la_size); i++)
798795
count += hweight8(buffer[i]);
799796

800-
mlog(0, "count %u\n", count);
797+
trace_ocfs2_local_alloc_count_bits(count);
801798
return count;
802799
}
803800

@@ -812,10 +809,7 @@ static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb,
812809
void *bitmap = NULL;
813810
struct ocfs2_reservation_map *resmap = &osb->osb_la_resmap;
814811

815-
mlog(0, "(numbits wanted = %u)\n", *numbits);
816-
817812
if (!alloc->id1.bitmap1.i_total) {
818-
mlog(0, "No bits in my window!\n");
819813
bitoff = -1;
820814
goto bail;
821815
}
@@ -875,8 +869,7 @@ static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb,
875869
}
876870
}
877871

878-
mlog(0, "Exiting loop, bitoff = %d, numfound = %d\n", bitoff,
879-
numfound);
872+
trace_ocfs2_local_alloc_find_clear_bits_search_bitmap(bitoff, numfound);
880873

881874
if (numfound == *numbits)
882875
bitoff = startoff - numfound;
@@ -887,7 +880,10 @@ static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb,
887880
if (local_resv)
888881
ocfs2_resv_discard(resmap, resv);
889882

890-
mlog(0, "bitoff %d\n", bitoff);
883+
trace_ocfs2_local_alloc_find_clear_bits(*numbits,
884+
le32_to_cpu(alloc->id1.bitmap1.i_total),
885+
bitoff, numfound);
886+
891887
return bitoff;
892888
}
893889

@@ -941,18 +937,16 @@ static int ocfs2_sync_local_to_main(struct ocfs2_super *osb,
941937
void *bitmap;
942938
struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc);
943939

944-
mlog(0, "total = %u, used = %u\n",
940+
trace_ocfs2_sync_local_to_main(
945941
le32_to_cpu(alloc->id1.bitmap1.i_total),
946942
le32_to_cpu(alloc->id1.bitmap1.i_used));
947943

948944
if (!alloc->id1.bitmap1.i_total) {
949-
mlog(0, "nothing to sync!\n");
950945
goto bail;
951946
}
952947

953948
if (le32_to_cpu(alloc->id1.bitmap1.i_used) ==
954949
le32_to_cpu(alloc->id1.bitmap1.i_total)) {
955-
mlog(0, "all bits were taken!\n");
956950
goto bail;
957951
}
958952

@@ -974,8 +968,7 @@ static int ocfs2_sync_local_to_main(struct ocfs2_super *osb,
974968
ocfs2_clusters_to_blocks(osb->sb,
975969
start - count);
976970

977-
mlog(0, "freeing %u bits starting at local alloc bit "
978-
"%u (la_start_blk = %llu, blkno = %llu)\n",
971+
trace_ocfs2_sync_local_to_main_free(
979972
count, start - count,
980973
(unsigned long long)la_start_blk,
981974
(unsigned long long)blkno);
@@ -1142,12 +1135,9 @@ static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb,
11421135
alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data;
11431136
la = OCFS2_LOCAL_ALLOC(alloc);
11441137

1145-
if (alloc->id1.bitmap1.i_total)
1146-
mlog(0, "asking me to alloc a new window over a non-empty "
1147-
"one\n");
1148-
1149-
mlog(0, "Allocating %u clusters for a new window.\n",
1150-
osb->local_alloc_bits);
1138+
trace_ocfs2_local_alloc_new_window(
1139+
le32_to_cpu(alloc->id1.bitmap1.i_total),
1140+
osb->local_alloc_bits);
11511141

11521142
/* Instruct the allocation code to try the most recently used
11531143
* cluster group. We'll re-record the group used this pass
@@ -1209,10 +1199,9 @@ static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb,
12091199
ocfs2_resmap_restart(&osb->osb_la_resmap, cluster_count,
12101200
OCFS2_LOCAL_ALLOC(alloc)->la_bitmap);
12111201

1212-
mlog(0, "New window allocated:\n");
1213-
mlog(0, "window la_bm_off = %u\n",
1214-
OCFS2_LOCAL_ALLOC(alloc)->la_bm_off);
1215-
mlog(0, "window bits = %u\n", le32_to_cpu(alloc->id1.bitmap1.i_total));
1202+
trace_ocfs2_local_alloc_new_window_result(
1203+
OCFS2_LOCAL_ALLOC(alloc)->la_bm_off,
1204+
le32_to_cpu(alloc->id1.bitmap1.i_total));
12161205

12171206
bail:
12181207
if (status)

‎fs/ocfs2/ocfs2_trace.h‎

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,23 @@ DEFINE_EVENT(ocfs2__int, name, \
2323
TP_PROTO(int num), \
2424
TP_ARGS(num))
2525

26+
DECLARE_EVENT_CLASS(ocfs2__uint,
27+
TP_PROTO(unsigned int num),
28+
TP_ARGS(num),
29+
TP_STRUCT__entry(
30+
__field( unsigned int, num )
31+
),
32+
TP_fast_assign(
33+
__entry->num = num;
34+
),
35+
TP_printk("%u", __entry->num)
36+
);
37+
38+
#define DEFINE_OCFS2_UINT_EVENT(name) \
39+
DEFINE_EVENT(ocfs2__uint, name, \
40+
TP_PROTO(unsigned int num), \
41+
TP_ARGS(num))
42+
2643
DECLARE_EVENT_CLASS(ocfs2__int_int,
2744
TP_PROTO(int value1, int value2),
2845
TP_ARGS(value1, value2),
@@ -61,6 +78,55 @@ DEFINE_EVENT(ocfs2__ull_uint, name, \
6178
TP_PROTO(unsigned long long val1, unsigned int val2), \
6279
TP_ARGS(val1, val2))
6380

81+
DECLARE_EVENT_CLASS(ocfs2__uint_uint_uint,
82+
TP_PROTO(unsigned int value1, unsigned int value2,
83+
unsigned int value3),
84+
TP_ARGS(value1, value2, value3),
85+
TP_STRUCT__entry(
86+
__field( unsigned int, value1 )
87+
__field( unsigned int, value2 )
88+
__field( unsigned int, value3 )
89+
),
90+
TP_fast_assign(
91+
__entry->value1 = value1;
92+
__entry->value2 = value2;
93+
__entry->value3 = value3;
94+
),
95+
TP_printk("%u %u %u", __entry->value1, __entry->value2, __entry->value3)
96+
);
97+
98+
#define DEFINE_OCFS2_UINT_UINT_UINT_EVENT(name) \
99+
DEFINE_EVENT(ocfs2__uint_uint_uint, name, \
100+
TP_PROTO(unsigned int value1, unsigned int value2, \
101+
unsigned int value3), \
102+
TP_ARGS(value1, value2, value3))
103+
104+
DECLARE_EVENT_CLASS(ocfs2__ull_int_int_int,
105+
TP_PROTO(unsigned long long ull, int value1, int value2, int value3),
106+
TP_ARGS(ull, value1, value2, value3),
107+
TP_STRUCT__entry(
108+
__field( unsigned long long, ull )
109+
__field( int, value1 )
110+
__field( int, value2 )
111+
__field( int, value3 )
112+
),
113+
TP_fast_assign(
114+
__entry->ull = ull;
115+
__entry->value1 = value1;
116+
__entry->value2 = value2;
117+
__entry->value3 = value3;
118+
),
119+
TP_printk("%llu %d %d %d",
120+
__entry->ull, __entry->value1,
121+
__entry->value2, __entry->value3)
122+
);
123+
124+
#define DEFINE_OCFS2_ULL_INT_INT_INT_EVENT(name) \
125+
DEFINE_EVENT(ocfs2__ull_int_int_int, name, \
126+
TP_PROTO(unsigned long long ull, int value1, \
127+
int value2, int value3), \
128+
TP_ARGS(ull, value1, value2, value3))
129+
64130
/* Trace events for fs/ocfs2/alloc.c. */
65131
DECLARE_EVENT_CLASS(ocfs2__btree_ops,
66132
TP_PROTO(unsigned long long owner,\
@@ -371,6 +437,52 @@ TRACE_EVENT(ocfs2_cache_block_dealloc,
371437

372438
/* End of trace events for fs/ocfs2/alloc.c. */
373439

440+
/* Trace events for fs/ocfs2/localalloc.c. */
441+
442+
DEFINE_OCFS2_UINT_UINT_UINT_EVENT(ocfs2_la_set_sizes);
443+
444+
DEFINE_OCFS2_ULL_INT_INT_INT_EVENT(ocfs2_alloc_should_use_local);
445+
446+
DEFINE_OCFS2_INT_EVENT(ocfs2_load_local_alloc);
447+
448+
DEFINE_OCFS2_INT_EVENT(ocfs2_begin_local_alloc_recovery);
449+
450+
DEFINE_OCFS2_ULL_INT_INT_INT_EVENT(ocfs2_reserve_local_alloc_bits);
451+
452+
DEFINE_OCFS2_UINT_EVENT(ocfs2_local_alloc_count_bits);
453+
454+
DEFINE_OCFS2_INT_INT_EVENT(ocfs2_local_alloc_find_clear_bits_search_bitmap);
455+
456+
DEFINE_OCFS2_ULL_INT_INT_INT_EVENT(ocfs2_local_alloc_find_clear_bits);
457+
458+
DEFINE_OCFS2_INT_INT_EVENT(ocfs2_sync_local_to_main);
459+
460+
TRACE_EVENT(ocfs2_sync_local_to_main_free,
461+
TP_PROTO(int count, int bit, unsigned long long start_blk,
462+
unsigned long long blkno),
463+
TP_ARGS(count, bit, start_blk, blkno),
464+
TP_STRUCT__entry(
465+
__field(int, count)
466+
__field(int, bit)
467+
__field(unsigned long long, start_blk)
468+
__field(unsigned long long, blkno)
469+
),
470+
TP_fast_assign(
471+
__entry->count = count;
472+
__entry->bit = bit;
473+
__entry->start_blk = start_blk;
474+
__entry->blkno = blkno;
475+
),
476+
TP_printk("%d %d %llu %llu",
477+
__entry->count, __entry->bit, __entry->start_blk,
478+
__entry->blkno)
479+
);
480+
481+
DEFINE_OCFS2_INT_INT_EVENT(ocfs2_local_alloc_new_window);
482+
483+
DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_local_alloc_new_window_result);
484+
485+
/* End of trace events for fs/ocfs2/localalloc.c. */
374486
#endif /* _TRACE_OCFS2_H */
375487

376488
/* This part must be outside protection */

0 commit comments

Comments
 (0)