Commit 2cd3e43e8db9d0ae1af443418547f65ee1efa280

Authored by Namhyung Kim
Committed by Greg Kroah-Hartman
1 parent fbfa65f9e3

md/raid5: fix FUA request handling in ops_run_io()

commit b062962edb086011e94ec4d9eb3f6a6d814f2a8f upstream.

Commit e9c7469bb4f5 ("md: implment REQ_FLUSH/FUA support")
introduced R5_WantFUA flag and set rw to WRITE_FUA in that case.
However remaining code still checks whether rw is exactly same
as WRITE or not, so FUAed-write ends up with being treated as
READ. Fix it.

This bug has been present since 2.6.37 and the fix is suitable for any
-stable kernel since then.  It is not clear why this has not caused
more problems.

Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Showing 1 changed file with 3 additions and 3 deletions Side-by-side Diff

... ... @@ -514,7 +514,7 @@
514 514 bi = &sh->dev[i].req;
515 515  
516 516 bi->bi_rw = rw;
517   - if (rw == WRITE)
  517 + if (rw & WRITE)
518 518 bi->bi_end_io = raid5_end_write_request;
519 519 else
520 520 bi->bi_end_io = raid5_end_read_request;
521 521  
... ... @@ -548,13 +548,13 @@
548 548 bi->bi_io_vec[0].bv_offset = 0;
549 549 bi->bi_size = STRIPE_SIZE;
550 550 bi->bi_next = NULL;
551   - if (rw == WRITE &&
  551 + if ((rw & WRITE) &&
552 552 test_bit(R5_ReWrite, &sh->dev[i].flags))
553 553 atomic_add(STRIPE_SECTORS,
554 554 &rdev->corrected_errors);
555 555 generic_make_request(bi);
556 556 } else {
557   - if (rw == WRITE)
  557 + if (rw & WRITE)
558 558 set_bit(STRIPE_DEGRADED, &sh->state);
559 559 pr_debug("skip op %ld on disc %d for sector %llu\n",
560 560 bi->bi_rw, i, (unsigned long long)sh->sector);