From patchwork Fri Oct 13 23:35:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Lyle X-Patchwork-Id: 10006129 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 B372060230 for ; Fri, 13 Oct 2017 23:36:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A465F29009 for ; Fri, 13 Oct 2017 23:36:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98FDE2918E; Fri, 13 Oct 2017 23:36: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=-6.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 4289D29009 for ; Fri, 13 Oct 2017 23:36:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753252AbdJMXgK (ORCPT ); Fri, 13 Oct 2017 19:36:10 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:48980 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752945AbdJMXgH (ORCPT ); Fri, 13 Oct 2017 19:36:07 -0400 Received: by mail-pf0-f194.google.com with SMTP id b79so11515420pfk.5 for ; Fri, 13 Oct 2017 16:36:07 -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=Im4NRbMC/eEB02E7pH9vWuRRvc8voT81WEqhBUysv94=; b=cRVeMlLQJfk/USsw5IDrtfMMGV1C6/alccUhecwU4t2n5xvYpc27IVJVvXnIRCPFB8 wMSxnl2upm55QKanro8N7juX1sHHWLGRZY1g7mq1ehpQLYYGyrYw1nQdqGgaau43auAE SCYlLBpfCZkal4iGJ7aVigSFHIgN3czrN+UIqdEIjKUl/f9JxU+Ulf20P/TRnC2w/jGd +pyk+WuFqdS/i0Ed8Kvx3u5GpOS/WRt4gnSJIgocGh0ke6+WCgbhr4lX6EJYq5zjV6RI Fwaqlr5/LeObR70LHjGNZ/QyyQyJV88BX4ChMAHwbabsCh5hN7aKEnmVXatwe0CVDhRH Wljw== 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=Im4NRbMC/eEB02E7pH9vWuRRvc8voT81WEqhBUysv94=; b=kFjdIn74MVvXeq1XGaBGz4LwyhwavamZsPGe6QDmUGP+1XL7qU8MtaOEWCy00IG5TG cMd+GnEga+z4pl/onSp7Bzzk3xAUFFOSveaV4G24FM5KGAPjPN83GYhJu/+HHHRlCiPJ 1oH07qQisig9DFgD0xkaxahkTQwltBGZ0I1DhLJ/W54wc1myjXicg1+8JT8VJiEZyjcD dOFKm3eGY2OwpwtWzzAowWyHwAxVGd7j8YXIMj8Nadjh5Ccd93tmFBlgaxSRBT0DniMJ LMpIUd3YKuGOieD4dmOQkQAk8lVHho0HPFCGAOztiOV72JPNa7KX9bi7OzwiXpvKXNau F4Nw== X-Gm-Message-State: AMCzsaXO3xtO6jCD251wl/+csWagY+WEWRoiCnLILQFoesol9bp7NraF Wg+UTat1YWlXqXWR+hJrqlpm1w== X-Google-Smtp-Source: AOwi7QCI/LQXTfjsDh1Tgju91Tg77Bf46hyWSm9AuSmXZ4vPZ7j82coOLeUYBF7wH9bKqSKYB2BvAA== X-Received: by 10.84.244.140 with SMTP id h12mr2745200pll.110.1507937767219; Fri, 13 Oct 2017 16:36:07 -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 74sm4950718pft.184.2017.10.13.16.36.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 16:36:06 -0700 (PDT) From: Michael Lyle To: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org Cc: axboe@fb.com, Michael Lyle Subject: [PATCH 08/15] bcache: don't write back data if reading it failed Date: Fri, 13 Oct 2017 16:35:35 -0700 Message-Id: <20171013233542.20938-9-mlyle@lyle.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171013233542.20938-1-mlyle@lyle.org> References: <20171013233542.20938-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 If an IO operation fails, and we didn't successfully read data from the cache, don't writeback invalid/partial data to the backing disk. Signed-off-by: Michael Lyle Reviewed-by: Coly Li --- drivers/md/bcache/writeback.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c index e663ca082183..5e65a392287d 100644 --- a/drivers/md/bcache/writeback.c +++ b/drivers/md/bcache/writeback.c @@ -179,13 +179,21 @@ static void write_dirty(struct closure *cl) struct dirty_io *io = container_of(cl, struct dirty_io, cl); struct keybuf_key *w = io->bio.bi_private; - dirty_init(w); - bio_set_op_attrs(&io->bio, REQ_OP_WRITE, 0); - io->bio.bi_iter.bi_sector = KEY_START(&w->key); - bio_set_dev(&io->bio, io->dc->bdev); - io->bio.bi_end_io = dirty_endio; + /* + * IO errors are signalled using the dirty bit on the key. + * If we failed to read, we should not attempt to write to the + * backing device. Instead, immediately go to write_dirty_finish + * to clean up. + */ + if (KEY_DIRTY(&w->key)) { + dirty_init(w); + bio_set_op_attrs(&io->bio, REQ_OP_WRITE, 0); + io->bio.bi_iter.bi_sector = KEY_START(&w->key); + bio_set_dev(&io->bio, io->dc->bdev); + io->bio.bi_end_io = dirty_endio; - closure_bio_submit(&io->bio, cl); + closure_bio_submit(&io->bio, cl); + } continue_at(cl, write_dirty_finish, io->dc->writeback_write_wq); }