Skip to content

Commit aff8da0

Browse files
committed
md/raid1: handle flush request correctly
I got a warning triggered in align_to_barrier_unit_end. It's a flush request so sectors == 0. The flush request happens to work well without the new barrier patch, but we'd better handle it explictly. Cc: NeilBrown <[email protected]> Acked-by: Coly Li <[email protected]> Signed-off-by: Shaohua Li <[email protected]>
1 parent d939cdf commit aff8da0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/md/raid1.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,8 +1282,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio)
12821282
unsigned long flags;
12831283
const int op = bio_op(bio);
12841284
const unsigned long do_sync = (bio->bi_opf & REQ_SYNC);
1285-
const unsigned long do_flush_fua = (bio->bi_opf &
1286-
(REQ_PREFLUSH | REQ_FUA));
1285+
const unsigned long do_fua = (bio->bi_opf & REQ_FUA);
12871286
struct md_rdev *blocked_rdev;
12881287
struct blk_plug_cb *cb;
12891288
struct raid1_plug_cb *plug = NULL;
@@ -1509,7 +1508,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio)
15091508
conf->mirrors[i].rdev->data_offset);
15101509
mbio->bi_bdev = conf->mirrors[i].rdev->bdev;
15111510
mbio->bi_end_io = raid1_end_write_request;
1512-
bio_set_op_attrs(mbio, op, do_flush_fua | do_sync);
1511+
bio_set_op_attrs(mbio, op, do_fua | do_sync);
15131512
if (test_bit(FailFast, &conf->mirrors[i].rdev->flags) &&
15141513
!test_bit(WriteMostly, &conf->mirrors[i].rdev->flags) &&
15151514
conf->raid_disks - mddev->degraded > 1)
@@ -1565,6 +1564,11 @@ static void raid1_make_request(struct mddev *mddev, struct bio *bio)
15651564
struct bio *split;
15661565
sector_t sectors;
15671566

1567+
if (unlikely(bio->bi_opf & REQ_PREFLUSH)) {
1568+
md_flush_request(mddev, bio);
1569+
return;
1570+
}
1571+
15681572
/* if bio exceeds barrier unit boundary, split it */
15691573
do {
15701574
sectors = align_to_barrier_unit_end(

0 commit comments

Comments
 (0)