Re: [PATCH 1/2] md/raid1: fix the comparing region of interval tree
Xiao Ni <[email protected]>
| Newsgroups | gmane.linux.raid |
|---|---|
| Message-ID | <CALTww2_tgyMw71Vscg-xWe952zjHWv16pF8-f2osmSpk5GKoeQ@mail.gmail.com> |
On Wed, Feb 11, 2026 at 10:19 AM Yu Kuai <[email protected]> wrote: > > Hi, > > 在 2026/2/6 13:38, Xiao Ni 写道: > > 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. > > > > Signed-off-by: Xiao Ni <[email protected]> > > --- > > drivers/md/raid1.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > Perhaps also add a fix tag, with this: Thanks for the suggestion. I'll add it and send V2 > > Reviewed-by: Yu Kuai <[email protected]> > > > > > diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c > > index 867db18bc3ba..a41b1ec3d695 100644 > > --- a/drivers/md/raid1.c > > +++ b/drivers/md/raid1.c > > @@ -62,7 +62,7 @@ static int check_and_add_serial(struct md_rdev *rdev, struct r1bio *r1_bio, > > unsigned long flags; > > int ret = 0; > > sector_t lo = r1_bio->sector; > > - sector_t hi = lo + r1_bio->sectors; > > + sector_t hi = lo + r1_bio->sectors - 1; > > struct serial_in_rdev *serial = &rdev->serial[idx]; > > > > spin_lock_irqsave(&serial->serial_lock, flags); > > @@ -453,7 +453,7 @@ static void raid1_end_write_request(struct bio *bio) > > int mirror = find_bio_disk(r1_bio, bio); > > struct md_rdev *rdev = conf->mirrors[mirror].rdev; > > sector_t lo = r1_bio->sector; > > - sector_t hi = r1_bio->sector + r1_bio->sectors; > > + sector_t hi = r1_bio->sector + r1_bio->sectors - 1; > > bool ignore_error = !raid1_should_handle_error(bio) || > > (bio->bi_status && bio_op(bio) == REQ_OP_DISCARD); > > > > -- > Thansk, > Kuai >