lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Tue, 28 Jun 2011 17:55:22 +0900
From:	Namhyung Kim <namhyung@...il.com>
To:	Jens Axboe <axboe@...nel.dk>
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH/RFC] block: add blktrace complete tracepoint in bio_endio()

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@...il.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ