dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: Lukas Herbolt <lherbolt@redhat.com>
Cc: device-mapper development <dm-devel@redhat.com>,
	Akira Hayakawa <ruby.wktk@gmail.com>
Subject: Re: dm-flakey NOT to return -EIO on READ?
Date: Fri, 29 Jul 2016 13:30:12 -0400	[thread overview]
Message-ID: <20160729173012.GA88908@redhat.com> (raw)
In-Reply-To: <20160729143542.GA19246@redhat.com>

On Fri, Jul 29 2016 at 10:35am -0400,
Mike Snitzer <snitzer@redhat.com> wrote:

> On Fri, Jul 29 2016 at 10:31am -0400,
> Lukas Herbolt <lherbolt@redhat.com> wrote:
> 
> >  - http://people.redhat.com/~lherbolt/dm-flakey/v4.7-dm_flakey.tar.gz
> > 
> > Lukas
> 
> Please post an incremental patch relative to 4.7 or latest Linus
> kernel.  Don't make people suffer with tarballs of whatever you've
> packaged above.

I pulled out your incremental diff.  Your proposed fix isn't correct.  It
breaks the corrupt_bio_byte feature.  We cannot blindly drop reads early
in flakey_map(), like you've proposed, because the corrupt_bio_byte
feature relies on corrupt data being returned on read during the
down_interval.

The issue reported is: reads aren't dropped during the "down_interval".

I do agree that this needs fixing, and it was commit a3998799fb4df ("dm
flakey: add corrupt_bio_byte feature") that caused this regression.

But a fix must not break the corrupt_bio_byte feature.

This fix should resolve the problem, I'll be staging it to go upstream
during the 4.8-rc cycle (Akira, please test to verify your test fails as
expected now):

From: Mike Snitzer <snitzer@redhat.com>
Date: Fri, 29 Jul 2016 13:19:55 -0400
Subject: [PATCH] dm flakey: error READ bios during the down_interval

When the corrupt_bio_byte feature was introduced it caused READ bios to
no longer be errored with -EIO during the down_interval.  This had to do
with the complexity of needing to submit READs if the corrupt_bio_byte
feature was used.

Fix it so READ bios are properly errored with -EIO; doing so early in
flakey_map() as long as there isn't a match for the corrupt_bio_byte
feature.

Fixes: a3998799fb4df ("dm flakey: add corrupt_bio_byte feature")
Reported-by: Akira Hayakawa <ruby.wktk@gmail.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
---
 drivers/md/dm-flakey.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c
index 29b99fb..19db13e 100644
--- a/drivers/md/dm-flakey.c
+++ b/drivers/md/dm-flakey.c
@@ -289,10 +289,16 @@ static int flakey_map(struct dm_target *ti, struct bio *bio)
 		pb->bio_submitted = true;
 
 		/*
-		 * Map reads as normal.
+		 * Map reads as normal only if corrupt_bio_byte set.
 		 */
-		if (bio_data_dir(bio) == READ)
-			goto map_bio;
+		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
+				return -EIO;
+		}
 
 		/*
 		 * Drop writes?
@@ -330,12 +336,13 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error)
 
 	/*
 	 * Corrupt successful READs while in down state.
-	 * If flags were specified, only corrupt those that match.
 	 */
-	if (fc->corrupt_bio_byte && !error && pb->bio_submitted &&
-	    (bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) &&
-	    all_corrupt_bio_flags_match(bio, fc))
-		corrupt_bio_data(bio, fc);
+	if (!error && pb->bio_submitted && (bio_data_dir(bio) == READ)) {
+		if (fc->corrupt_bio_byte)
+			corrupt_bio_data(bio, fc);
+		else
+			return -EIO;
+	}
 
 	return error;
 }
-- 
2.7.4 (Apple Git-66)

  reply	other threads:[~2016-07-29 17:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-06  6:33 dm-flakey NOT to return -EIO on READ? Akira Hayakawa
2016-07-06  9:52 ` Lukas Herbolt
2016-07-06 12:54   ` Akira Hayakawa
2016-07-17  1:36     ` Akira Hayakawa
2016-07-29  6:25       ` Lukas Herbolt
2016-07-29  6:32         ` Akira Hayakawa
2016-07-29 14:31           ` Lukas Herbolt
2016-07-29 14:35             ` Mike Snitzer
2016-07-29 17:30               ` Mike Snitzer [this message]
2016-07-29 18:00                 ` Lukas Herbolt
2016-07-29 22:55                 ` Akira Hayakawa
2016-07-30  0:26                 ` Akira Hayakawa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160729173012.GA88908@redhat.com \
    --to=snitzer@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=lherbolt@redhat.com \
    --cc=ruby.wktk@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).