From patchwork Mon Aug 22 15:07:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 9293669 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 BA6DF607FF for ; Mon, 22 Aug 2016 15:07:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD35D28435 for ; Mon, 22 Aug 2016 15:07:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A207D28A0B; Mon, 22 Aug 2016 15:07:06 +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,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 3043328435 for ; Mon, 22 Aug 2016 15:07:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755188AbcHVPHC (ORCPT ); Mon, 22 Aug 2016 11:07:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39058 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755284AbcHVPHB (ORCPT ); Mon, 22 Aug 2016 11:07:01 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 190C981249; Mon, 22 Aug 2016 15:07:01 +0000 (UTC) Received: from localhost (dhcp-25-100.bos.redhat.com [10.18.25.100]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7MF70OC022720 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 22 Aug 2016 11:07:00 -0400 Date: Mon, 22 Aug 2016 11:07:21 -0400 From: Mike Snitzer To: Lukas Herbolt Cc: Qu Wenruo , device-mapper development , btrfs Subject: Re: [Regression/Behavior change]dm-flakey corrupt read bio, even the feature is drop_writes Message-ID: <20160822150720.GA29950@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 22 Aug 2016 15:07:01 +0000 (UTC) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Aug 22 2016 at 4:05am -0400, Lukas Herbolt wrote: > Hello, > > There is patch from Mike. It's part of current pull request to 4.8-rc1 > For more details check: > - https://www.redhat.com/archives/dm-devel/2016-July/msg00561.html > - https://www.redhat.com/archives/dm-devel/2016-August/msg00109.html > > Lukas > > On Mon, Aug 22, 2016 at 9:31 AM, Qu Wenruo wrote: > > Hi, Mike and btrfs and dm guys > > > > When doing regression test on v4.8-rc1, we found that fstests/btrfs/056 > > always fails. With the following dmesg: > > --- > > Buffer I/O error on dev dm-0, logical block 1310704, async page read > > Buffer I/O error on dev dm-0, logical block 16, async page read > > Buffer I/O error on dev dm-0, logical block 16, async page read > > --- > > > > And bisect leads to the following commits: > > --- > > commit 99f3c90d0d85708e7401a81ce3314e50bf7f2819 > > Author: Mike Snitzer > > Date: Fri Jul 29 13:19:55 2016 -0400 > > > > dm flakey: error READ bios during the down_interval > > --- > > > > While according to the document of dm-flakey, it says that when using > > drop_writes feature, read bios are not affected: > > --- > > drop_writes: > > All write I/O is silently ignored. > > Read I/O is handled correctly. I went back to the dm-flakey.c code at the time that the 'drop_writes' feature was added via commit b26f5e3d. It does confirm your understanding of how reads should be handled if drop_writes is enabled. Not sure why I thought differently. Please try the following patch. Tested-by: Qu Wenruo --- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c index 97e446d..6a2e8dd 100644 --- a/drivers/md/dm-flakey.c +++ b/drivers/md/dm-flakey.c @@ -289,15 +289,13 @@ static int flakey_map(struct dm_target *ti, struct bio *bio) pb->bio_submitted = true; /* - * Map reads as normal only if corrupt_bio_byte set. + * Error reads if neither corrupt_bio_byte or drop_writes are set. + * Otherwise, flakey_end_io() will decide if the reads should be modified. */ if (bio_data_dir(bio) == READ) { - /* If flags were specified, only corrupt those that match. */ - if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) && - all_corrupt_bio_flags_match(bio, fc)) - goto map_bio; - else + if (!fc->corrupt_bio_byte && !test_bit(DROP_WRITES, &fc->flags)) return -EIO; + goto map_bio; } /* @@ -334,14 +332,21 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error) struct flakey_c *fc = ti->private; struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data)); - /* - * Corrupt successful READs while in down state. - */ if (!error && pb->bio_submitted && (bio_data_dir(bio) == READ)) { - if (fc->corrupt_bio_byte) + if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) && + all_corrupt_bio_flags_match(bio, fc)) { + /* + * Corrupt successful matching READs while in down state. + */ corrupt_bio_data(bio, fc); - else + + } else if (!test_bit(DROP_WRITES, &fc->flags)) { + /* + * Error read during the down_interval if drop_writes + * wasn't configured. + */ return -EIO; + } } return error;