From: Namhyung Kim <namhyung@gmail.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH/RFC] block: add blktrace complete tracepoint in bio_endio()
Date: Tue, 28 Jun 2011 17:55:22 +0900 [thread overview]
Message-ID: <1309251322-9821-1-git-send-email-namhyung@gmail.com> (raw)
Currently bio-based drivers lack blktrace's completion notification
because the notification will be sent only in request completion path
(blk_update_request) and they never use requests.
This patch adds bio completion tracepoint in bio_endio() so that bio-
based drivers can be tracked. Also introduce __bio_endio() which keeps
original behavior (w/o trace) to be called from the request completion
path and error path of generic_make_request(). It should not affect
normal request-based drivers.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
block/blk-core.c | 6 ++++--
fs/bio.c | 18 ++++++++++++++++++
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index d2f8f4049abd..69d66ea6f083 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -147,6 +147,8 @@ void blk_rq_init(struct request_queue *q, struct request *rq)
}
EXPORT_SYMBOL(blk_rq_init);
+extern void __bio_endio(struct bio *bio, int error);
+
static void req_bio_endio(struct request *rq, struct bio *bio,
unsigned int nbytes, int error)
{
@@ -172,7 +174,7 @@ static void req_bio_endio(struct request *rq, struct bio *bio,
/* don't actually finish bio if it's part of flush sequence */
if (bio->bi_size == 0 && !(rq->cmd_flags & REQ_FLUSH_SEQ))
- bio_endio(bio, error);
+ __bio_endio(bio, error);
}
void blk_dump_rq_flags(struct request *rq, char *msg)
@@ -1545,7 +1547,7 @@ static inline void __generic_make_request(struct bio *bio)
return;
end_io:
- bio_endio(bio, err);
+ __bio_endio(bio, err);
}
/*
diff --git a/fs/bio.c b/fs/bio.c
index 9bfade8a609b..6a0346f8bd69 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -1426,6 +1426,20 @@ void bio_flush_dcache_pages(struct bio *bi)
EXPORT_SYMBOL(bio_flush_dcache_pages);
#endif
+/*
+ * Same as bio_endio() below but no trace.
+ */
+void __bio_endio(struct bio *bio, int error)
+{
+ if (error)
+ clear_bit(BIO_UPTODATE, &bio->bi_flags);
+ else if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
+ error = -EIO;
+
+ if (bio->bi_end_io)
+ bio->bi_end_io(bio, error);
+}
+
/**
* bio_endio - end I/O on a bio
* @bio: bio
@@ -1442,11 +1456,15 @@ EXPORT_SYMBOL(bio_flush_dcache_pages);
**/
void bio_endio(struct bio *bio, int error)
{
+ struct request_queue *q = bdev_get_queue(bio->bi_bdev);
+
if (error)
clear_bit(BIO_UPTODATE, &bio->bi_flags);
else if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
error = -EIO;
+ trace_block_bio_complete(q, bio, error);
+
if (bio->bi_end_io)
bio->bi_end_io(bio, error);
}
--
1.7.6
reply other threads:[~2011-06-28 8:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1309251322-9821-1-git-send-email-namhyung@gmail.com \
--to=namhyung@gmail.com \
--cc=axboe@kernel.dk \
--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®