@@ -27,6 +27,47 @@ static const char * const bch2_journal_errors[] = {
27
27
NULL
28
28
};
29
29
30
+ static void bch2_journal_buf_to_text (struct printbuf * out , struct journal * j , u64 seq )
31
+ {
32
+ union journal_res_state s = READ_ONCE (j -> reservations );
33
+ unsigned i = seq & JOURNAL_BUF_MASK ;
34
+ struct journal_buf * buf = j -> buf + i ;
35
+
36
+ prt_printf (out , "seq:" );
37
+ prt_tab (out );
38
+ prt_printf (out , "%llu" , seq );
39
+ prt_newline (out );
40
+ printbuf_indent_add (out , 2 );
41
+
42
+ prt_printf (out , "refcount:" );
43
+ prt_tab (out );
44
+ prt_printf (out , "%u" , journal_state_count (s , i ));
45
+ prt_newline (out );
46
+
47
+ prt_printf (out , "size:" );
48
+ prt_tab (out );
49
+ prt_human_readable_u64 (out , vstruct_bytes (buf -> data ));
50
+ prt_newline (out );
51
+
52
+ prt_printf (out , "expires" );
53
+ prt_tab (out );
54
+ prt_printf (out , "%li jiffies" , buf -> expires - jiffies );
55
+ prt_newline (out );
56
+
57
+ printbuf_indent_sub (out , 2 );
58
+ }
59
+
60
+ static void bch2_journal_bufs_to_text (struct printbuf * out , struct journal * j )
61
+ {
62
+ if (!out -> nr_tabstops )
63
+ printbuf_tabstop_push (out , 24 );
64
+
65
+ for (u64 seq = journal_last_unwritten_seq (j );
66
+ seq <= journal_cur_seq (j );
67
+ seq ++ )
68
+ bch2_journal_buf_to_text (out , j , seq );
69
+ }
70
+
30
71
static inline bool journal_seq_unwritten (struct journal * j , u64 seq )
31
72
{
32
73
return seq > j -> seq_ondisk ;
@@ -156,7 +197,7 @@ void bch2_journal_buf_put_final(struct journal *j, u64 seq, bool write)
156
197
* We don't close a journal_buf until the next journal_buf is finished writing,
157
198
* and can be opened again - this also initializes the next journal_buf:
158
199
*/
159
- static void __journal_entry_close (struct journal * j , unsigned closed_val )
200
+ static void __journal_entry_close (struct journal * j , unsigned closed_val , bool trace )
160
201
{
161
202
struct bch_fs * c = container_of (j , struct bch_fs , journal );
162
203
struct journal_buf * buf = journal_cur_buf (j );
@@ -185,7 +226,17 @@ static void __journal_entry_close(struct journal *j, unsigned closed_val)
185
226
/* Close out old buffer: */
186
227
buf -> data -> u64s = cpu_to_le32 (old .cur_entry_offset );
187
228
188
- trace_journal_entry_close (c , vstruct_bytes (buf -> data ));
229
+ if (trace_journal_entry_close_enabled () && trace ) {
230
+ struct printbuf pbuf = PRINTBUF ;
231
+ pbuf .atomic ++ ;
232
+
233
+ prt_str (& pbuf , "entry size: " );
234
+ prt_human_readable_u64 (& pbuf , vstruct_bytes (buf -> data ));
235
+ prt_newline (& pbuf );
236
+ bch2_prt_task_backtrace (& pbuf , current , 1 );
237
+ trace_journal_entry_close (c , pbuf .buf );
238
+ printbuf_exit (& pbuf );
239
+ }
189
240
190
241
sectors = vstruct_blocks_plus (buf -> data , c -> block_bits ,
191
242
buf -> u64s_reserved ) << c -> block_bits ;
@@ -225,7 +276,7 @@ static void __journal_entry_close(struct journal *j, unsigned closed_val)
225
276
void bch2_journal_halt (struct journal * j )
226
277
{
227
278
spin_lock (& j -> lock );
228
- __journal_entry_close (j , JOURNAL_ENTRY_ERROR_VAL );
279
+ __journal_entry_close (j , JOURNAL_ENTRY_ERROR_VAL , true );
229
280
if (!j -> err_seq )
230
281
j -> err_seq = journal_cur_seq (j );
231
282
journal_wake (j );
@@ -239,7 +290,7 @@ static bool journal_entry_want_write(struct journal *j)
239
290
240
291
/* Don't close it yet if we already have a write in flight: */
241
292
if (ret )
242
- __journal_entry_close (j , JOURNAL_ENTRY_CLOSED_VAL );
293
+ __journal_entry_close (j , JOURNAL_ENTRY_CLOSED_VAL , true );
243
294
else if (nr_unwritten_journal_entries (j )) {
244
295
struct journal_buf * buf = journal_cur_buf (j );
245
296
@@ -406,7 +457,7 @@ static void journal_write_work(struct work_struct *work)
406
457
if (delta > 0 )
407
458
mod_delayed_work (c -> io_complete_wq , & j -> write_work , delta );
408
459
else
409
- __journal_entry_close (j , JOURNAL_ENTRY_CLOSED_VAL );
460
+ __journal_entry_close (j , JOURNAL_ENTRY_CLOSED_VAL , true );
410
461
unlock :
411
462
spin_unlock (& j -> lock );
412
463
}
@@ -463,13 +514,21 @@ static int __journal_res_get(struct journal *j, struct journal_res *res,
463
514
buf -> buf_size < JOURNAL_ENTRY_SIZE_MAX )
464
515
j -> buf_size_want = max (j -> buf_size_want , buf -> buf_size << 1 );
465
516
466
- __journal_entry_close (j , JOURNAL_ENTRY_CLOSED_VAL );
517
+ __journal_entry_close (j , JOURNAL_ENTRY_CLOSED_VAL , false );
467
518
ret = journal_entry_open (j );
468
519
469
520
if (ret == JOURNAL_ERR_max_in_flight ) {
470
521
track_event_change (& c -> times [BCH_TIME_blocked_journal_max_in_flight ],
471
522
& j -> max_in_flight_start , true);
472
- trace_and_count (c , journal_entry_full , c );
523
+ if (trace_journal_entry_full_enabled ()) {
524
+ struct printbuf buf = PRINTBUF ;
525
+ buf .atomic ++ ;
526
+
527
+ bch2_journal_bufs_to_text (& buf , j );
528
+ trace_journal_entry_full (c , buf .buf );
529
+ printbuf_exit (& buf );
530
+ }
531
+ count_event (c , journal_entry_full );
473
532
}
474
533
unlock :
475
534
can_discard = j -> can_discard ;
@@ -549,7 +608,7 @@ void bch2_journal_entry_res_resize(struct journal *j,
549
608
/*
550
609
* Not enough room in current journal entry, have to flush it:
551
610
*/
552
- __journal_entry_close (j , JOURNAL_ENTRY_CLOSED_VAL );
611
+ __journal_entry_close (j , JOURNAL_ENTRY_CLOSED_VAL , true );
553
612
} else {
554
613
journal_cur_buf (j )-> u64s_reserved += d ;
555
614
}
@@ -606,7 +665,7 @@ int bch2_journal_flush_seq_async(struct journal *j, u64 seq,
606
665
struct journal_res res = { 0 };
607
666
608
667
if (journal_entry_is_open (j ))
609
- __journal_entry_close (j , JOURNAL_ENTRY_CLOSED_VAL );
668
+ __journal_entry_close (j , JOURNAL_ENTRY_CLOSED_VAL , true );
610
669
611
670
spin_unlock (& j -> lock );
612
671
@@ -786,7 +845,7 @@ static struct journal_buf *__bch2_next_write_buffer_flush_journal_buf(struct jou
786
845
787
846
if (buf -> need_flush_to_write_buffer ) {
788
847
if (seq == journal_cur_seq (j ))
789
- __journal_entry_close (j , JOURNAL_ENTRY_CLOSED_VAL );
848
+ __journal_entry_close (j , JOURNAL_ENTRY_CLOSED_VAL , true );
790
849
791
850
union journal_res_state s ;
792
851
s .v = atomic64_read_acquire (& j -> reservations .counter );
@@ -1339,35 +1398,9 @@ void __bch2_journal_debug_to_text(struct printbuf *out, struct journal *j)
1339
1398
}
1340
1399
1341
1400
prt_newline (out );
1342
-
1343
- for (u64 seq = journal_cur_seq (j );
1344
- seq >= journal_last_unwritten_seq (j );
1345
- -- seq ) {
1346
- unsigned i = seq & JOURNAL_BUF_MASK ;
1347
-
1348
- prt_printf (out , "unwritten entry:" );
1349
- prt_tab (out );
1350
- prt_printf (out , "%llu" , seq );
1351
- prt_newline (out );
1352
- printbuf_indent_add (out , 2 );
1353
-
1354
- prt_printf (out , "refcount:" );
1355
- prt_tab (out );
1356
- prt_printf (out , "%u" , journal_state_count (s , i ));
1357
- prt_newline (out );
1358
-
1359
- prt_printf (out , "sectors:" );
1360
- prt_tab (out );
1361
- prt_printf (out , "%u" , j -> buf [i ].sectors );
1362
- prt_newline (out );
1363
-
1364
- prt_printf (out , "expires" );
1365
- prt_tab (out );
1366
- prt_printf (out , "%li jiffies" , j -> buf [i ].expires - jiffies );
1367
- prt_newline (out );
1368
-
1369
- printbuf_indent_sub (out , 2 );
1370
- }
1401
+ prt_printf (out , "unwritten entries:" );
1402
+ prt_newline (out );
1403
+ bch2_journal_bufs_to_text (out , j );
1371
1404
1372
1405
prt_printf (out ,
1373
1406
"replay done:\t\t%i\n" ,
0 commit comments