Coly Li 351840
From b40503ea4f5c134b16ef405cab6c08f9343a0d06 Mon Sep 17 00:00:00 2001
Coly Li 351840
From: Zhai Zhaoxuan <kxuanobj@gmail.com>
Coly Li 351840
Date: Mon, 8 Jan 2018 12:21:27 -0800
Coly Li 351840
Subject: [PATCH] bcache: fix unmatched generic_end_io_acct() &
Coly Li 351840
 generic_start_io_acct()
Coly Li 351840
Git-commit: b40503ea4f5c134b16ef405cab6c08f9343a0d06
Coly Li 351840
Patch-mainline: v4.16-rc1
Coly Li 351840
References: bsc#1093023
Coly Li 351840
Coly Li 351840
The function cached_dev_make_request() and flash_dev_make_request() call
Coly Li 351840
generic_start_io_acct() with (struct bcache_device)->disk when they start a
Coly Li 351840
closure. Then the function bio_complete() calls generic_end_io_acct() with
Coly Li 351840
(struct search)->orig_bio->bi_disk when the closure has done.
Coly Li 351840
Since the `bi_disk` is not the bcache device, the generic_end_io_acct() is
Coly Li 351840
called with a wrong device queue.
Coly Li 351840
Coly Li 351840
It causes the "inflight" (in struct hd_struct) counter keep increasing
Coly Li 351840
without decreasing.
Coly Li 351840
Coly Li 351840
This patch fix the problem by calling generic_end_io_acct() with
Coly Li 351840
(struct bcache_device)->disk.
Coly Li 351840
Coly Li 351840
Signed-off-by: Zhai Zhaoxuan <kxuanobj@gmail.com>
Coly Li 351840
Reviewed-by: Michael Lyle <mlyle@lyle.org>
Coly Li 351840
Reviewed-by: Coly Li <colyli@suse.de>
Coly Li 351840
Reviewed-by: Tang Junhui <tang.junhui@zte.com.cn>
Coly Li 351840
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Coly Li 351840
Signed-off-by: Coly Li <colyli@suse.de>
Coly Li 351840
Coly Li 351840
---
Coly Li 351840
 drivers/md/bcache/request.c | 4 ++--
Coly Li 351840
 1 file changed, 2 insertions(+), 2 deletions(-)
Coly Li 351840
Coly Li 351840
diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
Coly Li 351840
index ddd941056f3c..1a46b41dac70 100644
Coly Li 351840
--- a/drivers/md/bcache/request.c
Coly Li 351840
+++ b/drivers/md/bcache/request.c
Coly Li 351840
@@ -633,8 +633,8 @@ static void request_endio(struct bio *bio)
Coly Li 351840
 static void bio_complete(struct search *s)
Coly Li 351840
 {
Coly Li 351840
 	if (s->orig_bio) {
Coly Li 351840
-		struct request_queue *q = s->orig_bio->bi_disk->queue;
Coly Li 351840
-		generic_end_io_acct(q, bio_data_dir(s->orig_bio),
Coly Li 351840
+		generic_end_io_acct(s->d->disk->queue,
Coly Li 351840
+				    bio_data_dir(s->orig_bio),
Coly Li 351840
 				    &s->d->disk->part0, s->start_time);
Coly Li 351840
 
Coly Li 351840
 		trace_bcache_request_end(s->d, s->orig_bio);
Coly Li 351840
-- 
Coly Li 351840
2.16.3
Coly Li 351840