bcache: print number of keys in trace_bcache_journal_write
authorGuoju Fang <fangguoju@gmail.com>
Thu, 13 Dec 2018 14:53:57 +0000 (22:53 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 13 Dec 2018 15:15:54 +0000 (08:15 -0700)
Sometimes flush journal may be very frequent, so it's useful to dump
number of keys every time write journal.

Signed-off-by: Guoju Fang <fangguoju@gmail.com>
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/journal.c
include/trace/events/bcache.h

index 522c7426f3a05cee10df0e984521472849b9b707..b2fd412715b1f810a0e9dbb19e522884f9bd879e 100644 (file)
@@ -663,7 +663,7 @@ static void journal_write_unlocked(struct closure *cl)
                                 REQ_SYNC|REQ_META|REQ_PREFLUSH|REQ_FUA);
                bch_bio_map(bio, w->data);
 
-               trace_bcache_journal_write(bio);
+               trace_bcache_journal_write(bio, w->data->keys);
                bio_list_add(&list, bio);
 
                SET_PTR_OFFSET(k, i, PTR_OFFSET(k, i) + sectors);
index 2cbd6e42ad835ea22941963b1443a814dcac4d40..e4526f85c19d3689bb61066e865b9e9f209c8478 100644 (file)
@@ -221,9 +221,30 @@ DEFINE_EVENT(cache_set, bcache_journal_entry_full,
        TP_ARGS(c)
 );
 
-DEFINE_EVENT(bcache_bio, bcache_journal_write,
-       TP_PROTO(struct bio *bio),
-       TP_ARGS(bio)
+TRACE_EVENT(bcache_journal_write,
+       TP_PROTO(struct bio *bio, u32 keys),
+       TP_ARGS(bio, keys),
+
+       TP_STRUCT__entry(
+               __field(dev_t,          dev                     )
+               __field(sector_t,       sector                  )
+               __field(unsigned int,   nr_sector               )
+               __array(char,           rwbs,   6               )
+               __field(u32,            nr_keys                 )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = bio_dev(bio);
+               __entry->sector         = bio->bi_iter.bi_sector;
+               __entry->nr_sector      = bio->bi_iter.bi_size >> 9;
+               __entry->nr_keys        = keys;
+               blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size);
+       ),
+
+       TP_printk("%d,%d  %s %llu + %u keys %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
+                 (unsigned long long)__entry->sector, __entry->nr_sector,
+                 __entry->nr_keys)
 );
 
 /* Btree */