From patchwork Mon Oct 30 21:46:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Lyle X-Patchwork-Id: 10033309 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 E6C356039A for ; Mon, 30 Oct 2017 21:47:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8D7328945 for ; Mon, 30 Oct 2017 21:47:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDB7F28949; Mon, 30 Oct 2017 21:47:04 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 778E928945 for ; Mon, 30 Oct 2017 21:47:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932490AbdJ3VrC (ORCPT ); Mon, 30 Oct 2017 17:47:02 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:56723 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932274AbdJ3VrA (ORCPT ); Mon, 30 Oct 2017 17:47:00 -0400 Received: by mail-pg0-f67.google.com with SMTP id m18so12795258pgd.13 for ; Mon, 30 Oct 2017 14:47:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyle-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lScKMTu89bQA9B//1wQlFMi27Oxrn1k22cpqT8E2jBE=; b=V4l1xdxm5gcW1N9KPdJneWBnnDLW243kDO34IRoY8puALaPKtZqKrw/mgH3acQtJH9 KYWS+nF2VOVXyR/tfZoCZ6l+U2xGuainMz9GEOUMDtyP2CQCGacvP+bd9Pnc/1pN5/O7 r+NzWd8VrcUerBYdg3qRFtrxoF4sdb1g3qXW3wWSprkZuqe4VN1lLtnZ7DN/IwvgJ/hQ MgGbJxM41/0u169JHVRCkDgiI4kVexqGvivqHmQ230VYOFB87CzT0IfzEYSlhIXpfcFd 0FHZ/6QmrAOOb/HAe8Av1AlZ4ABbtebSDlTyeRUJXaoYLP/FIvbLucyFd2qWbTEZCH4e 2hMw== 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:in-reply-to :references; bh=lScKMTu89bQA9B//1wQlFMi27Oxrn1k22cpqT8E2jBE=; b=l1R0fgAy0Jupo4pZJzdIzPot04jLz8v9ZBLpni17HLeFb94/D9vGBUVeAnKIjL9x29 kpseuIrD+/sfoZxPBxyy57cMniNHxAfbDXl45g3OBXKiDHFUMep2LzD+ztspUZYFLrw9 0L8yUTm0TS66VbAU6bITDcPBLqWg4q9epEQHzfRHO6bRtAUipHx4MnJSHUDBROMEJCXO nnSCSszPKlFxruo+6126G9f/KvLDB/eMG91cFKgtdddo7owdQ8v2Zn65y+H8GL45VFhs xVvNkHWaVYSGYhAYnWDGb7YqwVb+M7W40tEJE7Iv8lwOnsNjItLb9xvoB4WO4WQDEmBn QNPg== X-Gm-Message-State: AMCzsaXpm0m2SwEtVKLrjRk+zVr3SoxaIoMG0PTuEqC0Y35ECegWC+Mu LheT52iuEmVF/X15OG32WjDR3Q== X-Google-Smtp-Source: ABhQp+T7Wq0dpYzoHJa5xkKHSKbCOAzH780sCr9Cq8u7n/6vhoCiDmcpyAM/bEzFWkInLbr5D5VIdQ== X-Received: by 10.84.244.6 with SMTP id g6mr8617793pll.148.1509400019819; Mon, 30 Oct 2017 14:46:59 -0700 (PDT) Received: from localhost.localdomain (68-189-67-104.dhcp.prtv.ca.charter.com. [68.189.67.104]) by smtp.gmail.com with ESMTPSA id t78sm23733329pgb.93.2017.10.30.14.46.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Oct 2017 14:46:59 -0700 (PDT) From: Michael Lyle To: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org Cc: axboe@fb.com, "tang.junhui" Subject: [PATCH 4/5] bcache: fix wrong cache_misses statistics Date: Mon, 30 Oct 2017 14:46:34 -0700 Message-Id: <20171030214635.29888-5-mlyle@lyle.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171030214635.29888-1-mlyle@lyle.org> References: <20171030214635.29888-1-mlyle@lyle.org> 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 From: "tang.junhui" Currently, Cache missed IOs are identified by s->cache_miss, but actually, there are many situations that missed IOs are not assigned a value for s->cache_miss in cached_dev_cache_miss(), for example, a bypassed IO (s->iop.bypass = 1), or the cache_bio allocate failed. In these situations, it will go to out_put or out_submit, and s->cache_miss is null, which leads bch_mark_cache_accounting() to treat this IO as a hit IO. [ML: applied by 3-way merge] Signed-off-by: tang.junhui Reviewed-by: Michael Lyle Reviewed-by: Coly Li --- drivers/md/bcache/request.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index 886e4b6643f1..597dd1e87bea 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c @@ -470,6 +470,7 @@ struct search { unsigned recoverable:1; unsigned write:1; unsigned read_dirty_data:1; + unsigned cache_missed:1; unsigned long start_time; @@ -656,6 +657,7 @@ static inline struct search *search_alloc(struct bio *bio, s->orig_bio = bio; s->cache_miss = NULL; + s->cache_missed = 0; s->d = d; s->recoverable = 1; s->write = op_is_write(bio_op(bio)); @@ -775,7 +777,7 @@ static void cached_dev_read_done_bh(struct closure *cl) struct cached_dev *dc = container_of(s->d, struct cached_dev, disk); bch_mark_cache_accounting(s->iop.c, s->d, - !s->cache_miss, s->iop.bypass); + !s->cache_missed, s->iop.bypass); trace_bcache_read(s->orig_bio, !s->cache_miss, s->iop.bypass); if (s->iop.status) @@ -794,6 +796,8 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s, struct cached_dev *dc = container_of(s->d, struct cached_dev, disk); struct bio *miss, *cache_bio; + s->cache_missed = 1; + if (s->cache_miss || s->iop.bypass) { miss = bio_next_split(bio, sectors, GFP_NOIO, s->d->bio_split); ret = miss == bio ? MAP_DONE : MAP_CONTINUE;