On Mon, Aug 24, 2020 at 10:43 PM Xiao Ni <xni@xxxxxxxxxx> wrote: > > For far layout, the discard region is not continuous on disks. So it needs > far copies r10bio to cover all regions. It needs a way to know all r10bios > have finish or not. Similar with raid10_sync_request, only the first r10bio > master_bio records the discard bio. Other r10bios master_bio record the > first r10bio. The first r10bio can finish after other r10bios finish and > then return the discard bio. > > Signed-off-by: Xiao Ni <xni@xxxxxxxxxx> > --- > drivers/md/raid10.c | 87 +++++++++++++++++++++++++++++++++++++++-------------- > drivers/md/raid10.h | 1 + > 2 files changed, 65 insertions(+), 23 deletions(-) > > diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c > index 257791e..f6518ea 100644 > --- a/drivers/md/raid10.c > +++ b/drivers/md/raid10.c > @@ -1534,6 +1534,29 @@ static struct bio *raid10_split_bio(struct r10conf *conf, > return bio; > } > > +static void raid_end_discard_bio(struct r10bio *r10bio) Let's name this raid10_* > +{ > + struct r10conf *conf = r10bio->mddev->private; > + struct r10bio *first_r10bio; > + > + while (atomic_dec_and_test(&r10bio->remaining)) { Should this be "if (atomic_*"? Thanks, Song [...]