Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@xxxxxxx> --- kernel/trace/blktrace.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 81d2a3ee5a92..a46688289987 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -1316,8 +1316,25 @@ static void blk_add_trace_bio_bounce(void *ignore, static void blk_add_trace_bio_complete(void *ignore, struct request_queue *q, struct bio *bio) { - blk_add_trace_bio(q, bio, BLK_TA_COMPLETE, - blk_status_to_errno(bio->bi_status)); + u64 ta = 0; + struct blk_trace *bt; + struct blk_trace_ext *bte; + + rcu_read_lock(); + bt = rcu_dereference(q->blk_trace); + bte = rcu_dereference(q->blk_trace_ext); + if (likely(!bt) && likely(!bte)) { + rcu_read_unlock(); + return; + } + + if (bt) { + ta = BLK_TA_COMPLETE; + } else if (bte) { + ta = BLK_TA_COMPLETE_EXT; + } + rcu_read_unlock(); + blk_add_trace_bio(q, bio, ta, blk_status_to_errno(bio->bi_status)); } static void blk_add_trace_bio_backmerge(void *ignore, -- 2.22.1