Skip to content

Commit de3544d

Browse files
XiaoNi87hailan94
authored andcommitted
md/raid1: fix the comparing region of interval tree
Interval tree uses [start, end] as a region which stores in the tree. In raid1, it uses the wrong end value. For example: bio(A,B) is too big and needs to be split to bio1(A,C-1), bio2(C,B). The region of bio1 is [A,C] and the region of bio2 is [C,B]. So bio1 and bio2 overlap which is not right. Fix this problem by using right end value of the region. Fixes: d0d2d8b ("md/raid1: introduce wait_for_serialization") Signed-off-by: Xiao Ni <xni@redhat.com> Link: https://lore.kernel.org/linux-raid/20260305011839.5118-2-xni@redhat.com/ Signed-off-by: Yu Kuai <yukuai3@huawei.com>
1 parent 52e4324 commit de3544d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/md/raid1.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static int check_and_add_serial(struct md_rdev *rdev, struct r1bio *r1_bio,
6262
unsigned long flags;
6363
int ret = 0;
6464
sector_t lo = r1_bio->sector;
65-
sector_t hi = lo + r1_bio->sectors;
65+
sector_t hi = lo + r1_bio->sectors - 1;
6666
struct serial_in_rdev *serial = &rdev->serial[idx];
6767

6868
spin_lock_irqsave(&serial->serial_lock, flags);
@@ -452,7 +452,7 @@ static void raid1_end_write_request(struct bio *bio)
452452
int mirror = find_bio_disk(r1_bio, bio);
453453
struct md_rdev *rdev = conf->mirrors[mirror].rdev;
454454
sector_t lo = r1_bio->sector;
455-
sector_t hi = r1_bio->sector + r1_bio->sectors;
455+
sector_t hi = r1_bio->sector + r1_bio->sectors - 1;
456456
bool ignore_error = !raid1_should_handle_error(bio) ||
457457
(bio->bi_status && bio_op(bio) == REQ_OP_DISCARD);
458458

0 commit comments

Comments
 (0)