On Mon, Dec 23, 2019 at 1:49 AM <jgq516@xxxxxxxxx> wrote: > > From: Guoqing Jiang <guoqing.jiang@xxxxxxxxxxxxxxx> > > So far, IO serialization is used for two scenarios: > > 1. raid1 which enables write-behind mode, and there is rdev in the array > which is multi-queue device and flaged with writemostly. > 2. IO serialization is enabled or disabled by change serialize_policy. > > So introduce rdev_need_serial to check the first scenario. And for 1, IO > serialization is enabled automatically while 2 is controlled manually. > > And it is possible that both scenarios are true, so for create serial pool, > rdev/rdevs_init_serial should be separate from check if the pool existed or > not. Then for destroy pool, we need to check if the pool is needed by other > rdevs due to the first scenario. > > Signed-off-by: Guoqing Jiang <guoqing.jiang@xxxxxxxxxxxxxxx> > --- > drivers/md/md.c | 71 +++++++++++++++++++++++++++++-------------------- > 1 file changed, 42 insertions(+), 29 deletions(-) > > diff --git a/drivers/md/md.c b/drivers/md/md.c > index 796cf70e1c9f..788559f42d43 100644 > --- a/drivers/md/md.c > +++ b/drivers/md/md.c > @@ -147,28 +147,40 @@ static void rdevs_init_serial(struct mddev *mddev) > } > > /* > - * Create serial_info_pool for raid1 under conditions: > - * 1. rdev is the first multi-queue device flaged with writemostly, > - * also write-behind mode is enabled. > - * 2. rdev is NULL, means want to enable serialization for all rdevs. > + * rdev needs to enable serial stuffs if it meets the conditions: > + * 1. it is multi-queue device flaged with writemostly. > + * 2. the write-behind mode is enabled. > + */ > +static int rdev_need_serial(struct md_rdev *rdev) > +{ > + return (rdev && rdev->mddev->bitmap_info.max_write_behind > 0 && I guess there is not need to check rdev here? Thanks, Song