dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* dm-flakey NOT to return -EIO on READ?
@ 2016-07-06  6:33 Akira Hayakawa
  2016-07-06  9:52 ` Lukas Herbolt
  0 siblings, 1 reply; 12+ messages in thread
From: Akira Hayakawa @ 2016-07-06  6:33 UTC (permalink / raw)
  To: device-mapper development

Hi,

I am using dm-flakey to emulate a broken device that should return -EIO on both read and write.
I use the parameter up_interval=0 and down_interval=1.

But when I am dd-ing the flakey device, while write fails, read succeeds.
This isn't the behavior I expect.

Then I looked into the code.

326 static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error)
327 {
328         struct flakey_c *fc = ti->private;
329         struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data));
330 
331         /*
332          * Corrupt successful READs while in down state.
333          * If flags were specified, only corrupt those that match.
334          */
335         if (fc->corrupt_bio_byte && !error && pb->bio_submitted &&
336             (bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) &&
337             all_corrupt_bio_flags_match(bio, fc))
338                 corrupt_bio_data(bio, fc);
339 
340         return error;
341 }

When the bio direction is READ and currupt_bio_bytes isn't specified
the READ bio is handled normally right?

I think READ requests should return -EIO if

1. corrupt_bio_bytes isn't specified
2. but the requested is handled during down interval.

as well as WRITE requests:

305                 /*
306                  * Corrupt matching writes.
307                  */
308                 if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == WRITE)) {
309                         if (all_corrupt_bio_flags_match(bio, fc))
310                                 corrupt_bio_data(bio, fc);
311                         goto map_bio;
312                 }
313 
314                 /*
315                  * By default, error all I/O.
316                  */
317                 return -EIO;
318         }

This code is similar to what we see in the end_io.

If my understanding is correct, I would like to modify dm-flakey to return -EIO in the end_io.

I would like to request for comments.

Thanks,

- Akira

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-07-30  0:26 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2016-07-29 18:00                 ` Lukas Herbolt
2016-07-29 22:55                 ` Akira Hayakawa
2016-07-30  0:26                 ` Akira Hayakawa

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).