From patchwork Wed Jan 3 04:39:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhai Zhaoxuan X-Patchwork-Id: 10141673 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 957226035E for ; Wed, 3 Jan 2018 04:40:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A20DB28EEE for ; Wed, 3 Jan 2018 04:40:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92E6328EF4; Wed, 3 Jan 2018 04:40:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F59D28EEE for ; Wed, 3 Jan 2018 04:40:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750989AbeACEjw (ORCPT ); Tue, 2 Jan 2018 23:39:52 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:43825 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750749AbeACEjv (ORCPT ); Tue, 2 Jan 2018 23:39:51 -0500 Received: by mail-pf0-f193.google.com with SMTP id e3so309602pfi.10; Tue, 02 Jan 2018 20:39:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=BO4vqkuhVu6NPU7CTazJDqP48GwmVJ3c2RKG8bXt0n4=; b=cXnt+9NmYJPSxUaXZ3XxBiz/yCMzcAULSN+zH/usm85CdOSA0FkE8eeYkqOcNsrsh2 xk6v18H8H76jry4jcBjHJZLsVIv50xA/Q2A2zR9EfUUxGRfV7Cbgkl0YYxa+Xfx6m6RK 6NoonaChclB1VsT/28XNLr+SPbR5VEjnrgxh1KdCNDS+XlgZS8Y4kwMppk2ADaw4M2Cs xv5rwCUFlStztCB+FQtCOboYkBpOagbic3WOoEp0plHDK8PRBVpnjHmNW/Dmagz0GxdY DwWPtArU49rLg2t0e2NKvZ+mc6j7ya0cc4YXPtT2zAFYE/AeC7gwiWpdDH96eik0XP40 0umg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BO4vqkuhVu6NPU7CTazJDqP48GwmVJ3c2RKG8bXt0n4=; b=AWh6xTsvnbC6Hk1H0aFHr1FuHFinzhlURBoG+/NS2zXYQ/uuPDT6Og3WrajYSdoEQ+ Zls9WNQR1UdccsRIeNxn3v2EG/Z36cCVP8hhSCX1yPloUPyleq7JXHELhB0DCb0BrJ08 IK0AWNJuJ+jAc+1/E1JkkW05QyZF+hA1JQ7wNIgC67LSrrg7l6hGzOa2fh3LfdUvbaN2 MEDMie6RfD/z2EEUmhpygEICGd5/fjLLO8+eiE+R4NVVwRVQ+eIURo1sGiTANhtwVHSp REQv3fGS7WCmqSPXM+07x7d93BVU4AXXQjADuePelSCM86NU67kmESODM+MxHy5xebia 4VTw== X-Gm-Message-State: AKGB3mKXdQect6zVCcCZlGJ6aYOi0P+XEABPx87EOJXjaXTEO/O/Xvfm P7uXNG6O5jObejoHsH5Isy26T6KA X-Google-Smtp-Source: ACJfBovH+jC0cd7E/jGJspPbg7YSTjjV45wS9DTUaukZkqLsjD57EpllI0NEL0O+z5akOpGVSHPHFA== X-Received: by 10.98.144.141 with SMTP id q13mr295111pfk.140.1514954390144; Tue, 02 Jan 2018 20:39:50 -0800 (PST) Received: from localhost.localdomain (outboundhk.mxmail.xiaomi.com. [207.226.244.124]) by smtp.gmail.com with ESMTPSA id e87sm422821pfd.165.2018.01.02.20.39.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jan 2018 20:39:48 -0800 (PST) From: Zhai Zhaoxuan To: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org Cc: tang.junhui@zte.com.cn, Michael Lyle , Zhai Zhaoxuan Subject: [PATCH] bcache: fix unmatched generic_end_io_acct() & generic_start_io_acct() Date: Wed, 3 Jan 2018 12:39:37 +0800 Message-Id: <20180103043937.28235-1-kxuanobj@gmail.com> X-Mailer: git-send-email 2.15.1 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The function cached_dev_make_request() and flash_dev_make_request() call generic_start_io_acct() with (struct bcache_device)->disk when they start a closure. Then the function bio_complete() calls generic_end_io_acct() with (struct search)->orig_bio->bi_disk when the closure has done. Since the `bi_disk` is not the bcache device, the generic_end_io_acct() is called with a wrong device queue. It causes the "inflight" (in struct hd_struct) counter keep increasing without decreasing. This patch fix the problem by calling generic_end_io_acct() with (struct bcache_device)->disk. Signed-off-by: Zhai Zhaoxuan Reviewed-by: Coly Li Reviewed-by: Michael Lyle --- drivers/md/bcache/request.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index 643c3021624f..83de85fe4542 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c @@ -611,8 +611,8 @@ static void request_endio(struct bio *bio) static void bio_complete(struct search *s) { if (s->orig_bio) { - struct request_queue *q = s->orig_bio->bi_disk->queue; - generic_end_io_acct(q, bio_data_dir(s->orig_bio), + generic_end_io_acct(s->d->disk->queue, + bio_data_dir(s->orig_bio), &s->d->disk->part0, s->start_time); trace_bcache_request_end(s->d, s->orig_bio);