mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@us.ibm.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	linux-ext4 <linux-ext4@vger.kernel.org>
Subject: [PATCH] block: Add a trace point whenever a barrier IO request is sent
Date: Wed, 21 Apr 2010 13:56:26 -0700	[thread overview]
Message-ID: <20100421205626.GA15607@tux1.beaverton.ibm.com> (raw)

Simple debugging patch used to watch for barrier requests.  I've been using
this to watch ext4's barrier=1 behavior.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---

 block/blk-core.c             |    4 ++++
 include/trace/events/block.h |   35 +++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 0 deletions(-)


diff --git a/block/blk-core.c b/block/blk-core.c
index 9fe174d..fe02ea7 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -36,6 +36,7 @@
 EXPORT_TRACEPOINT_SYMBOL_GPL(block_remap);
 EXPORT_TRACEPOINT_SYMBOL_GPL(block_rq_remap);
 EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_complete);
+EXPORT_TRACEPOINT_SYMBOL_GPL(block_barrier);
 
 static int __make_request(struct request_queue *q, struct bio *bio);
 
@@ -1135,6 +1136,9 @@ void init_request_from_bio(struct request *req, struct bio *bio)
 	if (bio_rw_flagged(bio, BIO_RW_NOIDLE))
 		req->cmd_flags |= REQ_NOIDLE;
 
+	if (req->cmd_flags & (REQ_HARDBARRIER | REQ_SOFTBARRIER))
+		trace_block_barrier(req, bio);
+
 	req->errors = 0;
 	req->__sector = bio->bi_sector;
 	req->ioprio = bio_prio(bio);
diff --git a/include/trace/events/block.h b/include/trace/events/block.h
index d870a91..ccf96c3 100644
--- a/include/trace/events/block.h
+++ b/include/trace/events/block.h
@@ -198,6 +198,41 @@ TRACE_EVENT(block_bio_bounce,
 );
 
 /**
+ * block_barrier - barrier operation requested
+ * @r: request that asked for the barrier
+ * @bio: block operation
+ *
+ * This tracepoint indicates that a barrier operation has been
+ * requested and a flush will be sent to the underlying block
+ * device.
+ */
+TRACE_EVENT(block_barrier,
+
+	TP_PROTO(struct request *r, struct bio *bio),
+
+	TP_ARGS(r, bio),
+
+	TP_STRUCT__entry(
+		__field( dev_t,		dev		)
+		__field( sector_t,	sector		)
+		__field( unsigned,	nr_sector	)
+		__field( unsigned,	cmd_flags	)
+	),
+
+	TP_fast_assign(
+		__entry->dev		= bio->bi_bdev->bd_dev;
+		__entry->sector		= bio->bi_sector;
+		__entry->nr_sector	= bio->bi_size >> 9;
+		__entry->cmd_flags	= r->cmd_flags;
+	),
+
+	TP_printk("%d:%d %llu + %u [0x%x]",
+		  MAJOR(__entry->dev), MINOR(__entry->dev),
+		  (unsigned long long)__entry->sector,
+		  __entry->nr_sector, __entry->cmd_flags)
+);
+
+/**
  * block_bio_complete - completed all work on the block operation
  * @q: queue holding the block operation
  * @bio: block operation completed

             reply	other threads:[~2010-04-21 20:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-21 20:56 Darrick J. Wong [this message]
2010-04-21 21:27 ` Jens Axboe
2010-04-23 19:41   ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100421205626.GA15607@tux1.beaverton.ibm.com \
    --to=djwong@us.ibm.com \
    --cc=axboe@kernel.dk \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®