Skip to contentSkip to conversation

dm-flakey NOT to return -EIO on READ?

DISCUSSION Akira Hayakawa 3 participants 12 messages Jul 6, 2016 – Jul 30, 2016 Device mapper

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw

Hi,
Yes this part is wrong and reads are not dropped.
I have a patch ready, just have to send it out.

Lukas

Quoted 73 lines · Akira Hayakawa

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

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

Signature · 5 lines
Lukas Herbolt
RHCE, RH436, BSc, SSc
Senior Technical Support Engineer
Global Support Services (GSS)
Email:    [email protected]
#2 lore raw

Thanks,

I want the patch in the main-tree quickly.
Because without it, my tests will not be green.
This is really annoying.

I made a quick reproducer of this problem.
If you are looking for one, this will help.
(You need to install sbt first)

https://github.com/akiradeveloper/writeboost-test-suite

  test("flakey (read)") {
    Memory(Sector.M(16)) { a =>
      Flakey.Table(a, 0, 1).create { b =>
        intercept[Exception] {
          Shell(s"dd status=none if=${b.bdev.path} iflag=direct of=/dev/null")
        }
      }
    }
  }
$ sudo sbt "testOnly dmtest.FlakeyTest"
12:44:00.643 [pool-2-thread-3-ScalaTest-running-FlakeyTest] INFO dmtest - [TEST] flakey (read)
12:44:00.752 [pool-2-thread-3-ScalaTest-running-FlakeyTest] DEBUG dmtest - reload: table=0 32768 flakey /dev/loop0 0 0 1
[info] FlakeyTest:
[info] - flakey (read) *** FAILED ***
[info]   Expected exception java.lang.Exception to be thrown, but no exception was thrown. (FlakeyTest.scala:9)
[info] Run completed in 2 seconds, 781 milliseconds.
[info] Total number of tests run: 1
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 0, failed 1, canceled 0, ignored 0, pending 0

- Akira

Quoted 84 lines · Lukas Herbolt

Hi,
Yes this part is wrong and reads are not dropped.
I have a patch ready, just have to send it out.

Lukas

Quoted 73 lines · Akira Hayakawa

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

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#3 lore raw
Quoted 4 lines · Lukas Herbolt
Quoted 3 lines

Hi,
Yes this part is wrong and reads are not dropped.
I have a patch ready, just have to send it out.

btw, is this fix going to be included in the next release?

Quoted 120 lines · Akira Hayakawa

Thanks,

I want the patch in the main-tree quickly.
Because without it, my tests will not be green.
This is really annoying.

I made a quick reproducer of this problem.
If you are looking for one, this will help.
(You need to install sbt first)

https://github.com/akiradeveloper/writeboost-test-suite

  test("flakey (read)") {
    Memory(Sector.M(16)) { a =>
      Flakey.Table(a, 0, 1).create { b =>
        intercept[Exception] {
          Shell(s"dd status=none if=${b.bdev.path} iflag=direct of=/dev/null")
        }
      }
    }
  }
$ sudo sbt "testOnly dmtest.FlakeyTest"
12:44:00.643 [pool-2-thread-3-ScalaTest-running-FlakeyTest] INFO dmtest - [TEST] flakey (read)
12:44:00.752 [pool-2-thread-3-ScalaTest-running-FlakeyTest] DEBUG dmtest - reload: table=0 32768 flakey /dev/loop0 0 0 1
[info] FlakeyTest:
[info] - flakey (read) *** FAILED ***
[info]   Expected exception java.lang.Exception to be thrown, but no exception was thrown. (FlakeyTest.scala:9)
[info] Run completed in 2 seconds, 781 milliseconds.
[info] Total number of tests run: 1
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 0, failed 1, canceled 0, ignored 0, pending 0

- Akira

Quoted 84 lines · Lukas Herbolt

Hi,
Yes this part is wrong and reads are not dropped.
I have a patch ready, just have to send it out.

Lukas

Quoted 73 lines · Akira Hayakawa

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

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#4 lore raw

Hi Akira,
Sorry I was on holiday.
I have patch ready, would you be able to test it before posting it.

Let me know if I should build the kernel for you or just share the source with you.

Lukas

Quoted 138 lines · Akira Hayakawa
Quoted 4 lines · Lukas Herbolt
Quoted 3 lines

Hi,
Yes this part is wrong and reads are not dropped.
I have a patch ready, just have to send it out.

btw, is this fix going to be included in the next release?

Quoted 10 lines · Akira Hayakawa

Thanks,

I want the patch in the main-tree quickly. Because without it, my tests will not be green. This is really annoying.

I made a quick reproducer of this problem. If you are looking for one, this will help. (You need to install sbt first)

Quoted 7 lines

https://github.com/akiradeveloper/writeboost-test-suite

  test("flakey (read)") {
    Memory(Sector.M(16)) { a =>
      Flakey.Table(a, 0, 1).create { b =>
        intercept[Exception] {
          Shell(s"dd status=none if=${b.bdev.path} iflag=direct

of=/dev/null")

Quoted 7 lines
        }
      }
    }

}

$ sudo sbt "testOnly dmtest.FlakeyTest"
12:44:00.643 [pool-2-thread-3-ScalaTest-running-FlakeyTest] INFO dmtest

- [TEST] flakey (read)

Quoted 1 line

12:44:00.752 [pool-2-thread-3-ScalaTest-running-FlakeyTest] DEBUG dmtest

- reload: table=0 32768 flakey /dev/loop0 0 0 1

Quoted 3 lines

[info] FlakeyTest:
[info] - flakey (read) *** FAILED ***
[info] Expected exception java.lang.Exception to be thrown, but no

exception was thrown. (FlakeyTest.scala:9)

Quoted 15 lines

[info] Run completed in 2 seconds, 781 milliseconds. [info] Total number of tests run: 1
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 0, failed 1, canceled 0, ignored 0, pending 0

- Akira

Quoted 7 lines · Lukas Herbolt

Hi,
Yes this part is wrong and reads are not dropped.
I have a patch ready, just have to send it out.

Lukas

On Wed, Jul 6, 2016 at 8:33 AM, Akira Hayakawa <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi,

I am using dm-flakey to emulate a broken device that should return

-EIO on

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

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.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

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

Quoted 41 lines
Quoted 41 lines
Quoted 41 lines

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 }

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

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

Quoted 16 lines
Quoted 16 lines
Quoted 13 lines

-EIO in the end_io.

I would like to request for comments.

Thanks,

- Akira

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

Signature · 5 lines
Lukas Herbolt
RHCE, RH436, BSc, SSc
Senior Technical Support Engineer
Global Support Services (GSS)
Email:    [email protected]
#5 lore raw

Hi Lukas,

Quoted 4 lines

I have patch ready, would you be able to test it before posting it.

Let me know if I should build the kernel for you or just share the source with you.

OK.
Please share the git tree and specify the branch to test.

Akira

Quoted 152 lines · Lukas Herbolt

Hi Akira,
Sorry I was on holiday.
I have patch ready, would you be able to test it before posting it.

Let me know if I should build the kernel for you or just share the source with you.

Lukas

Quoted 138 lines · Akira Hayakawa
Quoted 4 lines · Lukas Herbolt
Quoted 3 lines

Hi,
Yes this part is wrong and reads are not dropped.
I have a patch ready, just have to send it out.

btw, is this fix going to be included in the next release?

Quoted 10 lines · Akira Hayakawa

Thanks,

I want the patch in the main-tree quickly. Because without it, my tests will not be green. This is really annoying.

I made a quick reproducer of this problem. If you are looking for one, this will help. (You need to install sbt first)

Quoted 7 lines

https://github.com/akiradeveloper/writeboost-test-suite

  test("flakey (read)") {
    Memory(Sector.M(16)) { a =>
      Flakey.Table(a, 0, 1).create { b =>
        intercept[Exception] {
          Shell(s"dd status=none if=${b.bdev.path} iflag=direct

of=/dev/null")

Quoted 7 lines
        }
      }
    }

}

$ sudo sbt "testOnly dmtest.FlakeyTest"
12:44:00.643 [pool-2-thread-3-ScalaTest-running-FlakeyTest] INFO dmtest

- [TEST] flakey (read)

Quoted 1 line

12:44:00.752 [pool-2-thread-3-ScalaTest-running-FlakeyTest] DEBUG dmtest

- reload: table=0 32768 flakey /dev/loop0 0 0 1

Quoted 3 lines

[info] FlakeyTest:
[info] - flakey (read) *** FAILED ***
[info] Expected exception java.lang.Exception to be thrown, but no

exception was thrown. (FlakeyTest.scala:9)

Quoted 15 lines

[info] Run completed in 2 seconds, 781 milliseconds. [info] Total number of tests run: 1
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 0, failed 1, canceled 0, ignored 0, pending 0

- Akira

Quoted 7 lines · Lukas Herbolt

Hi,
Yes this part is wrong and reads are not dropped.
I have a patch ready, just have to send it out.

Lukas

On Wed, Jul 6, 2016 at 8:33 AM, Akira Hayakawa <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi,

I am using dm-flakey to emulate a broken device that should return

-EIO on

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

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.

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

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

Quoted 41 lines
Quoted 41 lines
Quoted 41 lines

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 }

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

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

Quoted 16 lines
Quoted 16 lines
Quoted 13 lines

-EIO in the end_io.

I would like to request for comments.

Thanks,

- Akira

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#6 lore raw

- http://people.redhat.com/~lherbolt/dm-flakey/v4.7-dm_flakey.tar.gz

Lukas

Quoted 172 lines · Akira Hayakawa

Hi Lukas,

Quoted 4 lines

I have patch ready, would you be able to test it before posting it.

Let me know if I should build the kernel for you or just share the source with you.

OK.
Please share the git tree and specify the branch to test.

Akira

Quoted 10 lines · Lukas Herbolt

Hi Akira,
Sorry I was on holiday.
I have patch ready, would you be able to test it before posting it.

Let me know if I should build the kernel for you or just share the source with you.

Lukas

On Sun, Jul 17, 2016 at 3:36 AM, Akira Hayakawa <[email protected]>

Quoted 32 lines · wrote:
Quoted 32 lines
Quoted 5 lines · Lukas Herbolt
Quoted 3 lines

Hi,
Yes this part is wrong and reads are not dropped.
I have a patch ready, just have to send it out.

btw, is this fix going to be included in the next release?

Quoted 10 lines · Akira Hayakawa

Thanks,

I want the patch in the main-tree quickly. Because without it, my tests will not be green. This is really annoying.

I made a quick reproducer of this problem. If you are looking for one, this will help. (You need to install sbt first)

Quoted 7 lines

https://github.com/akiradeveloper/writeboost-test-suite

  test("flakey (read)") {
    Memory(Sector.M(16)) { a =>
      Flakey.Table(a, 0, 1).create { b =>
        intercept[Exception] {
          Shell(s"dd status=none if=${b.bdev.path} iflag=direct

of=/dev/null")

Quoted 5 lines
        }
      }
    }

}

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
$ sudo sbt "testOnly dmtest.FlakeyTest"
12:44:00.643 [pool-2-thread-3-ScalaTest-running-FlakeyTest] INFO dmtest

- [TEST] flakey (read)

Quoted 1 line

12:44:00.752 [pool-2-thread-3-ScalaTest-running-FlakeyTest] DEBUG

dmtest

Quoted 29 lines
Quoted 29 lines

- reload: table=0 32768 flakey /dev/loop0 0 0 1

Quoted 3 lines

[info] FlakeyTest:
[info] - flakey (read) *** FAILED ***
[info] Expected exception java.lang.Exception to be thrown, but no

exception was thrown. (FlakeyTest.scala:9)

Quoted 15 lines

[info] Run completed in 2 seconds, 781 milliseconds. [info] Total number of tests run: 1
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 0, failed 1, canceled 0, ignored 0, pending 0

- Akira

Quoted 7 lines · Lukas Herbolt

Hi,
Yes this part is wrong and reads are not dropped.
I have a patch ready, just have to send it out.

Lukas

On Wed, Jul 6, 2016 at 8:33 AM, Akira Hayakawa <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines

Hi,

I am using dm-flakey to emulate a broken device that should return

-EIO on

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

both read and write.
I use the parameter up_interval=0 and down_interval=1.

Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

But when I am dd-ing the flakey device, while write fails, read

succeeds.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

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

Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

error)
327 {
328 struct flakey_c *fc = ti->private;
329 struct per_bio_data *pb = dm_per_bio_data(bio,

sizeof(struct

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

per_bio_data));
330
331 /*
332 * Corrupt successful READs while in down state.
333 * If flags were specified, only corrupt those that

match.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

334 */
335 if (fc->corrupt_bio_byte && !error && pb->bio_submitted

&&

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

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.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

as well as WRITE requests:

305 /*
306 * Corrupt matching writes.
307 */
308 if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw

==

Quoted 36 lines
Quoted 33 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

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 }

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

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

Quoted 16 lines
Quoted 16 lines
Quoted 13 lines

-EIO in the end_io.

I would like to request for comments.

Thanks,

- Akira

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

Signature · 5 lines
Lukas Herbolt
RHCE, RH436, BSc, SSc
Senior Technical Support Engineer
Global Support Services (GSS)
Email:    [email protected]
#8 lore raw
Quoted 10 lines · Mike Snitzer
Quoted 3 lines · Lukas Herbolt

- 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 <[email protected]>
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")
---
 drivers/md/dm-flakey.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/md/dm-flakey.c +15 -8
index 29b99fb..19db13e 100644
@@ -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;
 }
Signature · 1 line
2.7.4 (Apple Git-66)
#9 lore raw

Thanks Mike for fixing.
This was my first attempt to fix something in kernel so I wasn't sure about the patch itself.
- Lukas

Quoted 103 lines · Mike Snitzer
Quoted 10 lines · Mike Snitzer
Quoted 3 lines · Lukas Herbolt

- 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 <[email protected]>
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")
---
 drivers/md/dm-flakey.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/md/dm-flakey.c +3 -3
index 29b99fb..19db13e 100644
@@ -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) &&

drivers/md/dm-flakey.c +11 -5
+                           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)

Signature · 5 lines
Lukas Herbolt
RHCE, RH436, BSc, SSc
Senior Technical Support Engineer
Global Support Services (GSS)
Email:    [email protected]
#10 lore raw
In reply to Mike Snitzer

I just looked at the patch. (not tested yet)

I think the else part in the endio isn't necessary.

Review

Quoted 2 lines
(quoted diff) +2 -0
+		else
+			return -EIO;

Akira

Quoted 96 lines · Mike Snitzer
Quoted 10 lines · Mike Snitzer
Quoted 3 lines · Lukas Herbolt

- 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 <[email protected]>
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")
---
 drivers/md/dm-flakey.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/md/dm-flakey.c +15 -8
index 29b99fb..19db13e 100644
@@ -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;
 }
#11 lore raw
In reply to Mike Snitzer

Mike,

Quoted 3 lines

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

I tested with the patch and it's now ok.

Akira

Quoted 96 lines · Mike Snitzer
Quoted 10 lines · Mike Snitzer
Quoted 3 lines · Lukas Herbolt

- 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 <[email protected]>
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")
---
 drivers/md/dm-flakey.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/md/dm-flakey.c +15 -8
index 29b99fb..19db13e 100644
@@ -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;
 }