On Wed, Jan 8, 2025 at 5:56 PM Yu Kuai <yukuai1@xxxxxxxxxxxxxxx> wrote: > > From: Yu Kuai <yukuai3@xxxxxxxxxx> > > Bitmap is used for the whole array for raid1/raid10, hence IO for the > array can be used directly for bitmap. However, bitmap is used for > underlying disks for raid5, hence IO for the array can't be used > directly for bitmap. > > Implement pers->bitmap_sector() for raid5 to convert IO ranges from the > array to the underlying disks. > > Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx> > --- > drivers/md/raid5.c | 145 ++++++++++++++++++++++++++++++--------------- > 1 file changed, 98 insertions(+), 47 deletions(-) > > diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c > index a5a619400d8f..5377f4c3fffc 100644 > --- a/drivers/md/raid5.c > +++ b/drivers/md/raid5.c > @@ -63,6 +63,13 @@ > > #define RAID5_MAX_REQ_STRIPES 256 > > +enum reshape_loc { > + LOC_NO_RESHAPE, > + LOC_AHEAD_OF_RESHAPE, > + LOC_INSIDE_RESHAPE, > + LOC_BEHIND_RESHAPE, > +}; > + It is unnecessary to move this enum definition and some functions. I moved them back. Thanks, Song > static bool devices_handle_discard_safely = false; > module_param(devices_handle_discard_safely, bool, 0644); > MODULE_PARM_DESC(devices_handle_discard_safely, > @@ -2947,6 +2954,94 @@ static void raid5_error(struct mddev *mddev, struct md_rdev *rdev) > r5c_update_on_rdev_error(mddev, rdev); > } > > +static bool ahead_of_reshape(struct mddev *mddev, sector_t sector, > + sector_t reshape_sector) > +{ > + return mddev->reshape_backwards ? sector < reshape_sector : > + sector >= reshape_sector; > +} > + > +static bool range_ahead_of_reshape(struct mddev *mddev, sector_t min, > + sector_t max, sector_t reshape_sector) > +{ > + return mddev->reshape_backwards ? max < reshape_sector : > + min >= reshape_sector; > +} > + [...] > +static enum reshape_loc get_reshape_loc(struct mddev *mddev, > + struct r5conf *conf, sector_t logical_sector) > +{ > + sector_t reshape_progress, reshape_safe; > + /*